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 aJeroMQControlClient
connecting to the remote instance to perform basic discover and control operations. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes this instance ofControlClient
void
closeBinding
(NodeId nodeId) Issues the command to close a binding.void
closeRoutesViaInstance
(InstanceId instanceId, String instanceConnectAddress) Close the routes via theInstanceId
.Gets theInstanceId
for the remote instance.Gets the routing status for the system.static org.zeromq.ZMQ.Socket
open
(JeroMQSecurity securityChain, org.zeromq.ZContext zContext) Opens and configures theZMQ.Socket
type used to connect to the remoteJeroMQCommandServer
.openBinding
(NodeId nodeId) Opens anInstanceConnectionService.InstanceBinding
provided theNodeId
and returns theInstanceConnectionService.InstanceBinding
.openRouteToNode
(NodeId nodeId, String instanceInvokerAddress) Issues the command to open up a route to the node.static org.zeromq.ZMsg
recv
(org.zeromq.ZMQ.Socket socket) Receives a message from the suppliedZMQ.Socket
instance.static boolean
send
(org.zeromq.ZMsg zMsg, org.zeromq.ZMQ.Socket socket) Sends the suppliedZMsg
on the suppliedZMQ.Socket
, adding header and delimiter information as necessaryvoid
setReceiveTimeout
(long timeout, TimeUnit timeUnit) Allows for the adjustment of thisControlClient
's receive timeout.static void
trace
(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 aJeroMQControlClient
connecting to the remote instance to perform basic discover and control operations. This usesZContext.shadow(ZContext)
to make a shadow copy of theZContext
and then closes it later.- Parameters:
zContext
- theZContext
used to communicateinstanceConnectAddress
-
-
-
Method Details
-
open
public static org.zeromq.ZMQ.Socket open(JeroMQSecurity securityChain, org.zeromq.ZContext zContext) Opens and configures theZMQ.Socket
type used to connect to the remoteJeroMQCommandServer
.- Parameters:
zContext
- the context which to use when creating the socket- Returns:
- the
ZMQ.Socket
type
-
getRoutingStatus
Description copied from interface:ControlClient
Gets the routing status for the system.- Specified by:
getRoutingStatus
in interfaceControlClient
- Returns:
- the routing status.
-
getInstanceStatus
Description copied from interface:ControlClient
Gets theInstanceId
for the remote instance.- Specified by:
getInstanceStatus
in interfaceControlClient
- Returns:
- the
InstanceStatus
-
openRouteToNode
Description copied from interface:ControlClient
Issues the command to open up a route to the node.- Specified by:
openRouteToNode
in interfaceControlClient
- Parameters:
nodeId
- theNodeId
instanceInvokerAddress
-- Returns:
- the connect address for the node
-
closeRoutesViaInstance
Description copied from interface:ControlClient
Close the routes via theInstanceId
. If no routes are known, then nothing happens.- Specified by:
closeRoutesViaInstance
in interfaceControlClient
- Parameters:
instanceId
- theInstanceId
-
openBinding
Description copied from interface:ControlClient
Opens anInstanceConnectionService.InstanceBinding
provided theNodeId
and returns theInstanceConnectionService.InstanceBinding
.- Specified by:
openBinding
in interfaceControlClient
- Parameters:
nodeId
- theNodeId
- Returns:
- the
InstanceConnectionService.InstanceBinding
-
closeBinding
Description copied from interface:ControlClient
Issues the command to close a binding. This will invalidate allInstanceConnectionService.InstanceBinding
s to thatNodeId
.- Specified by:
closeBinding
in interfaceControlClient
- Parameters:
nodeId
-
-
setReceiveTimeout
Description copied from interface:ControlClient
Allows for the adjustment of thisControlClient
's receive timeout.- Specified by:
setReceiveTimeout
in interfaceControlClient
- Parameters:
timeout
- the timeouttimeUnit
- theTimeUnit
-
send
public static boolean send(org.zeromq.ZMsg zMsg, org.zeromq.ZMQ.Socket socket) Sends the suppliedZMsg
on the suppliedZMQ.Socket
, adding header and delimiter information as necessary- Parameters:
zMsg
- theZMsg
to sendsocket
- theZMQ.Socket
to 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.Socket
instance.- Parameters:
socket
- the socket on which to receive the incoming message.- Returns:
- the
ZMsg
instance
-
close
public void close()Description copied from interface:ControlClient
Closes this instance ofControlClient
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceControlClient
-