Class JeroMQControlClient
java.lang.Object
dev.getelements.elements.rt.remote.jeromq.JeroMQControlClient
- All Implemented Interfaces:
ControlClient,AutoCloseable
Implements the control protocol for interfacing with the
JeroMQInstanceConnectionService. This client
is responsible for performing control operations such as registering a node, deregistering a node, and querying
available nodes.
This class is designed to be used by a single thread and destroyed.-
Nested Class Summary
Nested classes/interfaces inherited from interface dev.getelements.elements.rt.remote.ControlClient
ControlClient.Factory -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionJeroMQControlClient(org.zeromq.ZContext zContext, String instanceConnectAddress, JeroMQSecurity securityChain) JeroMQControlClient(org.zeromq.ZContext zContext, String instanceConnectAddress, JeroMQSecurity jeroMQSecurity, long timeout, TimeUnit timeUnit) Creates aJeroMQControlClientconnecting to the remote instance to perform basic discover and control operations. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this instance ofControlClientvoidcloseBinding(NodeId nodeId) Issues the command to close a binding.voidcloseRoutesViaInstance(InstanceId instanceId, String instanceConnectAddress) Close the routes via theInstanceId.Gets theInstanceIdfor the remote instance.Gets the routing status for the system.static org.zeromq.ZMQ.Socketopen(JeroMQSecurity securityChain, org.zeromq.ZContext zContext) Opens and configures theZMQ.Sockettype used to connect to the remoteJeroMQCommandServer.openBinding(NodeId nodeId) Opens anInstanceConnectionService.InstanceBindingprovided theNodeIdand returns theInstanceConnectionService.InstanceBinding.openRouteToNode(NodeId nodeId, String instanceInvokerAddress) Issues the command to open up a route to the node.static org.zeromq.ZMsgrecv(org.zeromq.ZMQ.Socket socket) Receives a message from the suppliedZMQ.Socketinstance.static booleansend(org.zeromq.ZMsg zMsg, org.zeromq.ZMQ.Socket socket) Sends the suppliedZMsgon the suppliedZMQ.Socket, adding header and delimiter information as necessaryvoidsetReceiveTimeout(long timeout, TimeUnit timeUnit) Allows for the adjustment of thisControlClient's receive timeout.static voidtrace(org.zeromq.ZMsg zMsg, StackTraceElement[] trace) Embeds the supplied stack trace in the suppliedZMsg.
-
Field Details
-
DEFAULT_TIMEOUT
public static final long DEFAULT_TIMEOUT- See Also:
-
DEFAULT_TIMEOUT_UNITS
-
-
Constructor Details
-
JeroMQControlClient
public JeroMQControlClient(org.zeromq.ZContext zContext, String instanceConnectAddress, JeroMQSecurity securityChain) -
JeroMQControlClient
public JeroMQControlClient(org.zeromq.ZContext zContext, String instanceConnectAddress, JeroMQSecurity jeroMQSecurity, long timeout, TimeUnit timeUnit) Creates aJeroMQControlClientconnecting to the remote instance to perform basic discover and control operations. This usesZContext.shadow(ZContext)to make a shadow copy of theZContextand then closes it later.- Parameters:
zContext- theZContextused to communicateinstanceConnectAddress-
-
-
Method Details
-
open
public static org.zeromq.ZMQ.Socket open(JeroMQSecurity securityChain, org.zeromq.ZContext zContext) Opens and configures theZMQ.Sockettype used to connect to the remoteJeroMQCommandServer.- Parameters:
zContext- the context which to use when creating the socket- Returns:
- the
ZMQ.Sockettype
-
getRoutingStatus
Description copied from interface:ControlClientGets the routing status for the system.- Specified by:
getRoutingStatusin interfaceControlClient- Returns:
- the routing status.
-
getInstanceStatus
Description copied from interface:ControlClientGets theInstanceIdfor the remote instance.- Specified by:
getInstanceStatusin interfaceControlClient- Returns:
- the
InstanceStatus
-
openRouteToNode
Description copied from interface:ControlClientIssues the command to open up a route to the node.- Specified by:
openRouteToNodein interfaceControlClient- Parameters:
nodeId- theNodeIdinstanceInvokerAddress-- Returns:
- the connect address for the node
-
closeRoutesViaInstance
Description copied from interface:ControlClientClose the routes via theInstanceId. If no routes are known, then nothing happens.- Specified by:
closeRoutesViaInstancein interfaceControlClient- Parameters:
instanceId- theInstanceId
-
openBinding
Description copied from interface:ControlClientOpens anInstanceConnectionService.InstanceBindingprovided theNodeIdand returns theInstanceConnectionService.InstanceBinding.- Specified by:
openBindingin interfaceControlClient- Parameters:
nodeId- theNodeId- Returns:
- the
InstanceConnectionService.InstanceBinding
-
closeBinding
Description copied from interface:ControlClientIssues the command to close a binding. This will invalidate allInstanceConnectionService.InstanceBindings to thatNodeId.- Specified by:
closeBindingin interfaceControlClient- Parameters:
nodeId-
-
setReceiveTimeout
Description copied from interface:ControlClientAllows for the adjustment of thisControlClient's receive timeout.- Specified by:
setReceiveTimeoutin interfaceControlClient- Parameters:
timeout- the timeouttimeUnit- theTimeUnit
-
send
public static boolean send(org.zeromq.ZMsg zMsg, org.zeromq.ZMQ.Socket socket) Sends the suppliedZMsgon the suppliedZMQ.Socket, adding header and delimiter information as necessary- Parameters:
zMsg- theZMsgto sendsocket- theZMQ.Socketto use to send the request
-
trace
Embeds the supplied stack trace in the suppliedZMsg. The remote end will ignore the trace, however it will be visible in the debugger so it is possible to know where in the client code the message originated.- Parameters:
zMsg- the messagetrace- the trace
-
recv
public static org.zeromq.ZMsg recv(org.zeromq.ZMQ.Socket socket) Receives a message from the suppliedZMQ.Socketinstance.- Parameters:
socket- the socket on which to receive the incoming message.- Returns:
- the
ZMsginstance
-
close
public void close()Description copied from interface:ControlClientCloses this instance ofControlClient- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceControlClient
-