public class SoloWorker extends java.lang.Object implements DebugListener
SoloWorker solo = new SoloWorker(); solo.setLogsInterface(alog); solo.initialize(); (use the API) solo.shutdown();
Solo
Modifier and Type | Field and Description |
---|---|
protected java.util.Properties |
_props |
static java.lang.String |
CAUSE_SEP
": "
|
protected SoloRemoteControl |
control |
static int |
default_connect_stimeout
How long to wait for a remote connection before issuing timeout.
|
static int |
default_ready_stimeout
How long to wait for a READY signal before issuing timeout.
|
static int |
default_result_stimeout
How long to wait for a RESULT signal after dispatch before issuing timeout.
|
static int |
default_running_stimeout
How long to wait for a RUNNING signal after dispatch before issuing timeout.
|
static int |
default_shutdown_stimeout
How long to wait for remote shutdown confirmation after dispatch before aborting the wait.
|
boolean |
doProcessFailure
Set this value to false to bypass or ignore default failure processing.
|
boolean |
doProcessSuccess
Set this value to false to bypass or ignore default success processing.
|
static java.io.PrintStream |
err
Initializes to System.err
|
static java.lang.String |
FAIL_SUFFIX
"FAILED"
|
static java.lang.String |
listenername |
protected LogsInterface |
log |
static java.io.PrintStream |
out
Initializes to System.out
|
static java.lang.String |
PASS_SUFFIX
" OK "
|
java.lang.String |
TAG |
static int |
tcp_delay
Average Network TCP transaction latency allowance for sockets communications.
|
Constructor and Description |
---|
SoloWorker() |
Modifier and Type | Method and Description |
---|---|
protected SoloRemoteControl |
createRemoteControl()
Called internally by the initialize() routine to get the desired instance/subclass of
SoloRemoteControl.
|
protected void |
debug(java.lang.String message)
Output debug messages to our LogsInterface, or to our out PrintStream if the LogsInterface is not set.
|
java.lang.String |
getListenerName()
Unique name to identify the listener.
|
SoloRemoteControl |
getRemoteControl() |
void |
initialize()
Called to initialize RemoteControl communications with a remote client and get it to the Ready state.
|
void |
onReceiveDebug(java.lang.String message)
A remote client has sent a Debug message to be logged by the listener.
|
protected java.util.Properties |
prepInstrumentDispatch(java.lang.String command)
Prepare a dispatchProps object targeting a remote "instrument" command instead of a remote "solo" command.
|
protected java.util.Properties |
prepSoloDispatch(java.lang.String command)
Prepare a dispatchProps object targeting a remote "solo" command instead of a remote "instrument" command.
|
void |
processFailure(java.lang.String action,
java.lang.String message)
Handle the reporting or logging of action or test failures.
|
void |
processSuccess(java.lang.String action,
java.lang.String message)
Handle the reporting or logging of action or test success.
|
void |
setControllerPort(int controllerPort)
Set the controller port where we will connect for messenger service.
|
void |
setLogsInterface(LogsInterface ilog)
Set the LogsInterface to be used by the class instance.
|
void |
setPortForwarding(boolean portForwarding)
Set if we will forward 'controller port' to remote messenger service's port.
|
SoloRemoteControl |
setRemoteControl(SoloRemoteControl controller,
boolean force)
Set the SoloRemoteControl instance to be used by this worker.
|
void |
shutdown()
Initial default implementation performs:
|
boolean |
shutdownRemote()
Initial default implementation performs:
|
void |
turnProtocolDebug(boolean enableDebug)
|
void |
turnRunnerDebug(boolean enableDebug)
|
public final java.lang.String TAG
public static int default_connect_stimeout
public static int default_ready_stimeout
public static int default_running_stimeout
public static int default_result_stimeout
public static int default_shutdown_stimeout
public static int tcp_delay
public static java.lang.String listenername
public static java.io.PrintStream out
public static java.io.PrintStream err
protected LogsInterface log
protected SoloRemoteControl control
public static java.lang.String CAUSE_SEP
public static java.lang.String PASS_SUFFIX
public static java.lang.String FAIL_SUFFIX
public boolean doProcessFailure
processFailure(String, String)
public boolean doProcessSuccess
processSuccess(String, String)
protected java.util.Properties _props
public void setLogsInterface(LogsInterface ilog)
ilog
- LogsInterface
public java.lang.String getListenerName()
NamedListener
getListenerName
in interface NamedListener
DebugListener
public void onReceiveDebug(java.lang.String message)
DebugListener
onReceiveDebug
in interface DebugListener
DebugListener
protected void debug(java.lang.String message)
message
- out
protected SoloRemoteControl createRemoteControl()
public SoloRemoteControl getRemoteControl()
public SoloRemoteControl setRemoteControl(SoloRemoteControl controller, boolean force)
controller
- force
- true to overwrite an existing controller with a different one, or null.getRemoteControl()
public void initialize() throws RemoteException, java.util.concurrent.TimeoutException, ShutdownInvocationException
control = createRemoteControll(); control.addListener(this); control.setLogsInterface(log); control.start(); control.waitForRemoteConnected(default_connect_stimeout); control.waitForRemoteReady(default_ready_stimeout);
RemoteException
- -- if there is a problem with RemoteControl initialization.java.util.concurrent.TimeoutException
- -- if the initialization and remote connection does not complete in timeout period.ShutdownInvocationException
- -- if the remote client unexpectedly performs a shutdown.setRemoteControl(SoloRemoteControl, boolean)
,
SoloRemoteControl.waitForRemoteReady(int)
,
SoloRemoteControl.setLogsInterface(LogsInterface)
public void setControllerPort(int controllerPort)
controllerPort
- public void setPortForwarding(boolean portForwarding)
portForwarding
- public void turnRunnerDebug(boolean enableDebug)
enableDebug
- public void turnProtocolDebug(boolean enableDebug)
enableDebug
- public void processFailure(java.lang.String action, java.lang.String message)
This is enabled by default. Callers can override default failure processing by setting doProcessFailure = false.
This implementation uses the LogsInterface that should be provided at or immediately following the creation of the Class instance. Subclasses may wish to use true jUnit reporting or other mechanisms.
If the LogsInterface call throws an Exception for any reason--including a NullPointerException because it was never provided or initialized--the implementation will log to our err PrintStream with the following format: cause +": "+ message
cause
- -- Normally, the action or id of the call that generated the failure.message
- -- The failure message provided for that action or id. If the message
is null the implementation will use FAIL_SUFFIX.LogsInterface.fail(String, String)
,
FAIL_SUFFIX
public void processSuccess(java.lang.String action, java.lang.String message)
This is enabled by default. A truer jUnit experience can be achieved by setting doHandleSuccess = false.
This implementation uses the LogsInterface that should be provided at or immediately following the creation of the Class instance. Subclasses may wish to use true jUnit reporting or other mechanisms.
If the LogsInterface call throws an Exception for any reason--including a NullPointerException because it was never provided or initialized--the implementation will log to our out PrintStream with the following format: cause +": "+ message
cause
- -- Normally, the action or id of the call that generated the success.message
- -- The success message provided for that action or id, if any. This can be
null. If the message is null this implementation will use PASS_SUFFIX.#doHandleSuccess
,
LogsInterface.pass(String, String)
,
PASS_SUFFIX
public void shutdown()
control.shutdown();
This will stop the SoloRemoteControlRunner
on the computer side.
Note: If you want to stop the remote service on the device side, shutdownRemote()
, and you MUST call it before shutdown()
method.SoloRemoteControl.shutdown()
,
shutdownRemote()
public boolean shutdownRemote()
control.performRemoteShutdown(int,int,int);Note: This method will stop the remote service on the device side,
shutdown()
method.protected java.util.Properties prepInstrumentDispatch(java.lang.String command)
command
- protected java.util.Properties prepSoloDispatch(java.lang.String command)
command
- Copyright © SAS Institute. All Rights Reserved.