Class ProtocolHandler
- java.lang.Object
-
- org.hansken.plugin.extraction.runtime.grpc.client.ProtocolHandler
-
- All Implemented Interfaces:
io.grpc.stub.StreamObserver<com.google.protobuf.Any>
public class ProtocolHandler extends Object implements io.grpc.stub.StreamObserver<com.google.protobuf.Any>
Handler for orchestrating the processing of atraceover gRPC, which itself is an observer for a stream in order to receive messages from the server.
-
-
Constructor Summary
Constructors Constructor Description ProtocolHandler(ReplyStream replyStream, ExtractionPluginGrpcAdapter adapter)Initialize a handler for processing atraceover gRPC.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidawait()Blocks and waits for the processing of thetraceto be finished, whether or not due to an error.voidonCompleted()voidonError(Throwable t)Callable that processes errors.voidonNext(com.google.protobuf.Any message)voidstart(Trace trace, DataContext context)Sends the START message sent over the communication streams.
-
-
-
Constructor Detail
-
ProtocolHandler
public ProtocolHandler(ReplyStream replyStream, ExtractionPluginGrpcAdapter adapter)
Initialize a handler for processing atraceover gRPC.- Parameters:
replyStream- the outbound message streamadapter- the adapter which can execute the received messages
-
-
Method Detail
-
start
public void start(Trace trace, DataContext context)
Sends the START message sent over the communication streams. This message is defined in the gRPC protocol. When the ExtractionPlugin receives this message it actually starts the process method.- Parameters:
trace- the trace to processcontext- the context to process
-
await
public void await()
Blocks and waits for the processing of thetraceto be finished, whether or not due to an error.- Throws:
RuntimeException- any exception that occured during remote processing
-
onNext
public void onNext(com.google.protobuf.Any message)
- Specified by:
onNextin interfaceio.grpc.stub.StreamObserver<com.google.protobuf.Any>
-
onError
public void onError(Throwable t)
Callable that processes errors. This method will _not_ signal the remote server that there was an exception, and thus this method will not disconnect from the server. Please use setErrorFromInternal() if the error cause was from an internal routine and a disconnect should be triggered. Since we are in error state, no new incoming messages are expected. Therefore onError() lowers a latch so that await() finishes. The throwable passed to this method will bubble back to the caller of await().- Specified by:
onErrorin interfaceio.grpc.stub.StreamObserver<com.google.protobuf.Any>- Parameters:
t- error that occured.
-
onCompleted
public void onCompleted()
- Specified by:
onCompletedin interfaceio.grpc.stub.StreamObserver<com.google.protobuf.Any>
-
-