Interface Controller
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
ControllerImpl
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.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Defines how the Controller should handle custom messages.static interface
A simple interface that describes the nature of the response to the custom incoming message.static interface
Interface for defining how to serialize and deserialize custom message for consumer who want to use something other than Protobuf messages. -
Method Summary
Modifier and TypeMethodDescriptionGet a Bit to Bit communication tunnel.<REQUEST extends com.google.protobuf.MessageLite,
RESPONSE extends com.google.protobuf.MessageLite>
voidregisterCustomHandler
(int messageTypeId, Controller.CustomMessageHandler<REQUEST, RESPONSE> handler, com.google.protobuf.Parser<REQUEST> parser) Register a new handler for custom message types.<REQUEST,
RESPONSE>
voidregisterCustomHandler
(int messageTypeId, Controller.CustomMessageHandler<REQUEST, RESPONSE> handler, Controller.CustomSerDe<REQUEST> requestSerde, Controller.CustomSerDe<RESPONSE> responseSerde) Register a new handler for custom message types.start
(CoordinationProtos.DrillbitEndpoint partialEndpoint, boolean allowPortHunting) Methods inherited from interface java.lang.AutoCloseable
close
-
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
CoordinationProtos.DrillbitEndpoint start(CoordinationProtos.DrillbitEndpoint partialEndpoint, boolean allowPortHunting) throws DrillbitStartupException - 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.
-