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 a trace over gRPC, which itself is an observer for a stream in order to receive messages from the server.
  • Constructor Details

    • ProtocolHandler

      public ProtocolHandler(ReplyStream replyStream, ExtractionPluginGrpcAdapter adapter)
      Initialize a handler for processing a trace over gRPC.
      Parameters:
      replyStream - the outbound message stream
      adapter - the adapter which can execute the received messages
  • Method Details

    • 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 process
      context - the context to process
    • await

      public void await()
      Blocks and waits for the processing of the trace to 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:
      onNext in interface io.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:
      onError in interface io.grpc.stub.StreamObserver<com.google.protobuf.Any>
      Parameters:
      t - error that occured.
    • onCompleted

      public void onCompleted()
      Specified by:
      onCompleted in interface io.grpc.stub.StreamObserver<com.google.protobuf.Any>