Interface Controller

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
ControllerImpl

public interface Controller extends AutoCloseable
Service that allows one Drillbit to communicate with another. Internally manages whether each particular bit is a server or a client depending on who initially made the connection. If no connection exists, the Controller is responsible for making a connection. TODO: Controller should automatically straight route local BitCommunication rather than connecting to its self.
  • Method Details

    • getTunnel

      Get a Bit to Bit communication tunnel. If the BitCom doesn't have a tunnel attached to the node already, it will start creating one. This create the connection asynchronously.
      Parameters:
      node -
      Returns:
    • start

      Throws:
      DrillbitStartupException
    • registerCustomHandler

      <REQUEST extends com.google.protobuf.MessageLite, RESPONSE extends com.google.protobuf.MessageLite> void registerCustomHandler(int messageTypeId, Controller.CustomMessageHandler<REQUEST,RESPONSE> handler, com.google.protobuf.Parser<REQUEST> parser)
      Register a new handler for custom message types. Should be done before any messages. This is threadsafe as this method manages locking internally.
      Parameters:
      messageTypeId - The type of message id to handle. This corresponds to the CustomMessage.type field. Note that only a single handler for a particular type of message can be registered within a particular Drillbit.
      handler - The handler that should be used to handle this type of message.
      parser - The parser used to handle the types of messages the handler above handles.
    • registerCustomHandler

      <REQUEST, RESPONSE> void registerCustomHandler(int messageTypeId, Controller.CustomMessageHandler<REQUEST,RESPONSE> handler, Controller.CustomSerDe<REQUEST> requestSerde, Controller.CustomSerDe<RESPONSE> responseSerde)
      Register a new handler for custom message types. Should be done before any messages. This is threadsafe as this method manages locking internally.
      Parameters:
      messageTypeId - The type of message id to handle. This corresponds to the CustomMessage.type field. Note that only a single handler for a particular type of message can be registered within a particular Drillbit.
      handler - The handler that should be used to handle this type of message.
      requestSerde - CustomSerDe for incoming requests.
      responseSerde - CustomSerDe for serializing responses.