handle err
This commit is contained in:
parent
4283748b71
commit
21082796ac
2
pom.xml
2
pom.xml
|
@ -52,7 +52,7 @@
|
|||
<dependency>
|
||||
<groupId>com.loafle.overflow</groupId>
|
||||
<artifactId>crawler_sql</artifactId>
|
||||
<version>1.0.1-SNAPSHOT</version>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.loafle.overflow;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import com.loafle.overflow.crawler.Crawler;
|
||||
import com.loafle.overflow.crawler.jmx.JmxCrawler;
|
||||
import com.loafle.overflow.crawler.mongo.MongoCrawler;
|
||||
import com.loafle.overflow.crawler.redis.RedisCralwer;
|
||||
|
@ -10,10 +11,11 @@ import com.loafle.overflow.crawler.wmi.WMICrawler;
|
|||
import com.loafle.overflow.rpc.*;
|
||||
import io.grpc.ServerBuilder;
|
||||
import io.grpc.stub.StreamObserver;
|
||||
import com.loafle.overflow.crawler.Crawler;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.Boolean;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectOutput;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -102,6 +104,7 @@ public class Server {
|
|||
responseObserver.onCompleted();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
responseObserver.onError(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -116,18 +119,16 @@ public class Server {
|
|||
if(crawler != null) {
|
||||
try {
|
||||
Object obj = crawler.get(req.getId());
|
||||
|
||||
|
||||
|
||||
Output reply = Output.newBuilder()
|
||||
.setData(ByteString.copyFrom((byte[])obj))
|
||||
.setStartDate(333)
|
||||
.setEndDate(333)
|
||||
.setStartDate(0)
|
||||
.setEndDate(0)
|
||||
.build();
|
||||
responseObserver.onNext(reply);
|
||||
responseObserver.onCompleted();
|
||||
}catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
responseObserver.onError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -162,6 +163,7 @@ public class Server {
|
|||
responseObserver.onCompleted();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
responseObserver.onError(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -180,6 +182,7 @@ public class Server {
|
|||
responseObserver.onCompleted();
|
||||
}catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
responseObserver.onError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -199,6 +202,7 @@ public class Server {
|
|||
responseObserver.onCompleted();
|
||||
}catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
responseObserver.onError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user