XPRD
- java.lang.Object
-
- com.dashoptimization.XPRD
-
public class XPRD extends java.lang.ObjectMain public class for remote Mosel management
-
-
Field Summary
Modifier and Type Field and Description intfsrvIterationNumber of iterations performed byfindXsrvs.intfsrvMaxWaitMaximum amount of time (in milliseconds) the functionfindXsrvswaits for replies.intfsrvPortUDP port number used byfindXsrvsfor its broadcast messages.java.util.Map<java.lang.String,java.lang.String>rcmdEnvEnvironment variables to be defined when starting Mosel via 'rcmd'.
-
Constructor Summary
Constructor and Description XPRD()Generate an XPRD object for remote Mosel instance management.
-
Method Summary
Modifier and Type Method and Description XPRDMoselconnect(java.lang.String cnstr)Create a new instance by opening a connection.XPRDMoselconnect(java.lang.String cnstr, XPRDFileManager fmgr)Create a new instance using a user defined file manager by opening a connection.intdisconnect(XPRDMosel inst)Disconnect the specified instance.voiddropNextEvent()Drop the next event in the queue.intfindXsrvs(int group, int maxIps, java.util.Set<java.lang.String> addrs)Search xprmsrv servers on the local network.XPRDEventgetNextEvent()Get the next event in the queue.booleanisQueueEmpty()Check whether the event queue is empty.static booleansetKeepAlive(long maxfail, long interval)Change the keepalive timer settings.static voidshutdown()Shut down the dispatcher.static voidstart()Start the dispatcher.voidwaitForEvent()Wait until an event is available.voidwaitForEvent(long timeout)Wait until an event is available with a time limit.
-
-
-
Field Detail
-
fsrvPort
public int fsrvPort
UDP port number used byfindXsrvsfor its broadcast messages. Default value: 2514
-
fsrvIteration
public int fsrvIteration
Number of iterations performed byfindXsrvs. Default value: 1
-
fsrvMaxWait
public int fsrvMaxWait
Maximum amount of time (in milliseconds) the functionfindXsrvswaits for replies. Default value: 1000
-
rcmdEnv
public java.util.Map<java.lang.String,java.lang.String> rcmdEnv
Environment variables to be defined when starting Mosel via 'rcmd'. A variable can be removed from the target environment by associating anullvalue to this variable. Default value: null
-
-
Method Detail
-
findXsrvs
public int findXsrvs(int group, int maxIps, java.util.Set<java.lang.String> addrs)Search xprmsrv servers on the local network. This function sends a broadcast message over the local network and waits for replies from running xprmsrv servers. A given server will reply only to selected group numbers: thegroupargument specifies this property. The IP addresses of the hosts having replied to the request are returned via the last argument of the function in the form of strings. The maximum size of this set is fixed bymaxIps. Note that the provided set is not cleared: if it already containsmaxIpselements the routine returns immediately.- Parameters:
-
group- group number of the request -
maxIps- maximum number of addresses to collect -
addrs- set to return addresses as strings - Returns:
-
the size of
addrsor-1if the socket cannot be created - See Also:
-
fsrvPort,fsrvIteration,fsrvMaxWait
-
start
public static void start()
Start the dispatcher. Each dispatcher started with this method must be terminated by a call toshutdown()
-
shutdown
public static void shutdown()
Shut down the dispatcher. This method must be used in pair withstart()
-
setKeepAlive
public static boolean setKeepAlive(long maxfail, long interval)Change the keepalive timer settings. The server sends to its client a keepalive message at fixedinterval. A connection is considered broken if more thanmaxfail*intervalseconds have elapsed since the last message received. Setting 0 formaxfaildisables this mechanism.- Parameters:
-
maxfail- number of time intervals before the connection is considered broken (use 0 to disable; default value:2) -
interval- number of seconds between 2 keepalive messages (default value:60) - Returns:
-
trueif the operation is successful. This function can be used only if no node is connected
-
connect
public XPRDMosel connect(java.lang.String cnstr, XPRDFileManager fmgr) throws java.io.IOException
Create a new instance using a user defined file manager by opening a connection.- Parameters:
-
cnstr- connection string. An empty string is equivalent to"rcmd:mosel -r" -
fmgr- optional file manager (may benull). - Returns:
- the newly connected instance
- Throws:
-
java.io.IOException- If the connection fails.
-
connect
public XPRDMosel connect(java.lang.String cnstr) throws java.io.IOException
Create a new instance by opening a connection.- Parameters:
-
cnstr- connection string. An empty string is equivalent to"rcmd:mosel -r" - Returns:
- the newly connected instance
- Throws:
-
java.io.IOException- If the connection fails. - See Also:
-
connect(cnstr,null)
-
disconnect
public int disconnect(XPRDMosel inst)
Disconnect the specified instance.- Parameters:
-
inst- instance to disconnect - Returns:
- exit status of the instance
- Throws:
-
java.util.NoSuchElementException- If the instance is not connected through this XPRD
-
isQueueEmpty
public boolean isQueueEmpty()
Check whether the event queue is empty.- Returns:
-
trueif the queue of events is empty
-
getNextEvent
public XPRDEvent getNextEvent()
Get the next event in the queue.- Returns:
-
next available event or
nullif the queue is empty
-
dropNextEvent
public void dropNextEvent()
Drop the next event in the queue. Nothing is done if the queue is empty
-
waitForEvent
public void waitForEvent()
Wait until an event is available.
-
waitForEvent
public void waitForEvent(long timeout)
Wait until an event is available with a time limit.- Parameters:
-
timeout- time limit in seconds
-
-
