org.sandev.basics.MessageDriver
Class MessageDriverNode
java.lang.Object
org.sandev.basics.MessageDriver.MessageDriverNodeDecl
org.sandev.basics.MessageDriver.MessageDriverNodeBase
org.sandev.basics.MessageDriver.MessageDriverNode
- All Implemented Interfaces:
- Controllable, Loggable, Messageable, AuthUserLookup, IDLookup
public class MessageDriverNode
- extends MessageDriverNodeBase
- implements AuthUserLookup, IDLookup
MessageDriverNode implementation.
|
Field Summary |
protected InstanceClassEnumerator |
instClassEnum
The InstanceClassEnumerator we use for translating VerbInstance
messages back into SandVerbMessages for use. |
protected TestScript |
script
The TestScript we are currently working from. |
protected int |
status
The status result of running the given test. |
protected StatusOutput |
statusWriter
Testing status output mechanism. |
protected int |
stepIndex
The index of the test step we are currently on. |
protected long |
timeOffset
The time offset from actual system time, calculated from the
configured startupTime parameter. |
protected UniqueIDManager |
uniqueIDManager
The ID counter and remapper we use for default processing of
incoming AggregateUpdate messages. |
| Fields inherited from class org.sandev.basics.MessageDriver.MessageDriverNodeBase |
ctrlwrappers, helperNodes, incomingAsyncDefaultAsyncSource, incomingSyncSandMessage, LOGDEBUG, LOGERROR, LOGFATAL, logger, LOGINFO, logLevel, LOGLEVEL_DEBUG, LOGLEVEL_ERROR, LOGLEVEL_FATAL, LOGLEVEL_INFO, LOGLEVEL_WARN, LOGWARN, messager, nodeInstance, outgoingAsyncSandMessage, outgoingSyncDefaultSyncDestination, parent, sandNodeErrorMessage, sandNodeState, SANDNODESTATE_FAILED, SANDNODESTATE_FAILING, SANDNODESTATE_RESUMING, SANDNODESTATE_RUNNING, SANDNODESTATE_STARTING, SANDNODESTATE_STOPPED, SANDNODESTATE_STOPPING, SANDNODESTATE_SUSPENDED, SANDNODESTATE_SUSPENDING, SANDNODESTATE_UNDEFINED, sandRoot |
| Fields inherited from interface org.sandev.basics.nodecommon.Controllable |
OPERATION_FAIL, OPERATION_RESUME, OPERATION_SHUTDOWN, OPERATION_STARTUP, OPERATION_STR_FAIL, OPERATION_STR_RESUME, OPERATION_STR_SHUTDOWN, OPERATION_STR_STARTUP, OPERATION_STR_SUSPEND, OPERATION_STR_UNDEFINED, OPERATION_STRINGS, OPERATION_SUSPEND, OPERATION_UNDEFINED, SHUTDOWN_ERROR_RESTART_GLOBAL, SHUTDOWN_ERROR_RESTART_LOCAL, SHUTDOWN_ERROR_TERMINATE, SHUTDOWN_NORMAL, STATE_FAILED, STATE_FAILING, STATE_RESUMING, STATE_RUNNING, STATE_STARTING, STATE_STOPPED, STATE_STOPPING, STATE_STR_FAILED, STATE_STR_FAILING, STATE_STR_RESUMING, STATE_STR_RUNNING, STATE_STR_STARTING, STATE_STR_STOPPED, STATE_STR_STOPPING, STATE_STR_SUSPENDED, STATE_STR_SUSPENDING, STATE_STR_UNDEFINED, STATE_STRINGS, STATE_SUSPENDED, STATE_SUSPENDING, STATE_UNDEFINED |
|
Method Summary |
protected SandCollectionMessage |
cacheQuery(SandQueryMessage sqm)
Run the given query against all cached entries and return a
collection of everything that matches. |
protected void |
changeDriverParam(TestNodeParamChange tnpc)
Dynamically change the given parameter value within this driver
node. |
protected void |
changeTargetNodeParam(TestNodeParamChange tnpc,
java.lang.String overrideNode)
Change the value of the param in the specified node. |
protected boolean |
classnameMatch(java.lang.String spec,
java.lang.String name)
Return true if the specification matches the name, either directly
or as a super interface. |
protected boolean |
compareConditions(SandAttrVal[] conds1,
SandAttrVal[] conds2)
Compare the conditions the two condition arrays and return
true if they are the equivalent, false otherwise. |
protected boolean |
compareMatch(SandAttrVal[] conditions,
SandStructMessage ssm)
Compare the conditions to the given message and return true
if they are a match, false otherwise. |
protected boolean |
conditionMatch(SandMessage msg,
int commType)
Return true if the given message matches the condition specified
in our current test step, false otherwise. |
protected AggregateUpdate |
doAggregateUpdate(AggregateUpdate au)
Create new IDs for anything being added, then put all the updated
data into our cache for reference. |
protected SandTransmitMessage |
executeAction(TestAction action)
Execute the given action, if any. |
protected SandTransmitMessage |
getDefaultResult(SandMessage msg)
Return an appropriate default message based on what was sent and
the data we have. |
SandPersistMessage |
getInstance(java.lang.String classname,
long id,
AuthUser user)
Lookup the specified class instance. |
InstanceClassEnumerator |
getInstClassEnum()
accessor for instClassEnum |
TestScript |
getScript()
accessor for script |
int |
getStatus()
accessor for status |
StatusOutput |
getStatusWriter()
accessor for statusWriter |
int |
getStepIndex()
accessor for stepIndex |
long |
getTimeOffset()
accessor for timeOffset |
UniqueIDManager |
getUniqueIDManager()
accessor for uniqueIDManager |
AuthUser |
getUserForID(long authID)
Return the AuthUser for the specified ID. |
AuthUser |
getUserFromLogin(java.lang.String username,
java.lang.String password)
Lookup the AuthUser matching the given username and password. |
protected TestRunStatus |
handleTestRunStatus(TestRunStatus trs)
Check if we are done and return the result. |
void |
incrementStepIndex()
incrementor for stepIndex |
protected InstanceClassEnumerator |
loadInstClassEnum()
Load our InstanceClassEnumerator for use. |
protected UniqueIDManager |
loadUniqueIDMgr()
Load our UniqueIDManager for use. |
protected void |
onDelivery(SandMessage msg)
Log what we got, then process it by comparing it against our
current location in the test script. |
protected SandMessage |
onReceive(SandMessage msg)
Log what we got, then handle the incoming message by comparing it
against our current location in the test script. |
protected void |
onStartup()
Load our TestScript and set up to run it. |
protected void |
sendUpdatesToListeners(AggregateUpdate au)
Broadcast the updates contained within the given AggregateUpdate
in case anyone is monitoring for these. |
void |
setInstClassEnum(InstanceClassEnumerator val)
mutator for instClassEnum |
void |
setScript(TestScript val)
mutator for script |
void |
setStatus(int val)
mutator for status |
void |
setStatusWriter(StatusOutput val)
mutator for statusWriter |
void |
setStepIndex(int val)
mutator for stepIndex |
protected void |
setTimeOffset()
If the startup time is set to something other than the default,
then compute the time offset we should be using for default
message handling. |
void |
setTimeOffset(long val)
mutator for timeOffset |
void |
setUniqueIDManager(UniqueIDManager val)
mutator for uniqueIDManager |
protected void |
statout(java.lang.String text)
Test status output method if statusWriter set. |
| Methods inherited from class org.sandev.basics.MessageDriver.MessageDriverNodeBase |
addWrapper, callDefaultSyncDestination, callQuery, deliver, deliverDefaultAsyncSource, fieldHasFlag, getDeploymentPrefix, getHelperNodes, getIDCache, getIncomingAsyncDefaultAsyncSource, getIncomingAsyncDefaultAsyncSourceDefaultValue, getIncomingAsyncDefaultAsyncSourceFieldPrintValue, getIncomingAsyncDefaultAsyncSourceFlag, getIncomingAsyncDefaultAsyncSourceInvalidValue, getIncomingAsyncDefaultAsyncSourceMetatype, getIncomingAsyncDefaultAsyncSourcePrintValue, getIncomingAsyncDefaultAsyncSourceRange, getIncomingAsyncDefaultAsyncSourceValidityCheck, getIncomingSyncSandMessage, getIncomingSyncSandMessageDefaultValue, getIncomingSyncSandMessageFieldPrintValue, getIncomingSyncSandMessageFlag, getIncomingSyncSandMessageInvalidValue, getIncomingSyncSandMessageMetatype, getIncomingSyncSandMessagePrintValue, getIncomingSyncSandMessageRange, getIncomingSyncSandMessageValidityCheck, getInstClassEnumName, getInstClassEnumNameDefaultValue, getInstClassEnumNameFieldPrintValue, getInstClassEnumNameFlag, getInstClassEnumNameInvalidValue, getInstClassEnumNameLengthMax, getInstClassEnumNameLengthNorm, getInstClassEnumNameMetatype, getInstClassEnumNamePrintValue, getInstClassEnumNameRange, getInstClassEnumNameValidityCheck, getLogger, getLoggerDefaultValue, getLoggerFieldPrintValue, getLoggerFlag, getLoggerInvalidValue, getLoggerMetatype, getLoggerPrintValue, getLoggerRange, getLoggerValidityCheck, getLogLevel, getLogLevelActualVals, getLogLevelDefaultValue, getLogLevelEnumSummary, getLogLevelFieldPrintValue, getLogLevelFlag, getLogLevelInvalidValue, getLogLevelKeyVals, getLogLevelMetatype, getLogLevelPrintVals, getLogLevelPrintValue, getLogLevelRange, getLogLevelValidityCheck, getMaxTestWaitSeconds, getMaxTestWaitSecondsDefaultValue, getMaxTestWaitSecondsFieldPrintValue, getMaxTestWaitSecondsFlag, getMaxTestWaitSecondsInvalidValue, getMaxTestWaitSecondsMetatype, getMaxTestWaitSecondsPrintValue, getMaxTestWaitSecondsRange, getMaxTestWaitSecondsValidityCheck, getMessager, getMessagerDefaultValue, getMessagerFieldPrintValue, getMessagerFlag, getMessagerInvalidValue, getMessagerMetatype, getMessagerPrintValue, getMessagerRange, getMessagerValidityCheck, getNodeInstance, getNodeInstanceDefaultValue, getNodeInstanceFieldPrintValue, getNodeInstanceFlag, getNodeInstanceInvalidValue, getNodeInstanceMetatype, getNodeInstanceName, getNodeInstancePrintValue, getNodeInstanceRange, getNodeInstanceValidityCheck, getOutgoingAsyncSandMessage, getOutgoingAsyncSandMessageDefaultValue, getOutgoingAsyncSandMessageFieldPrintValue, getOutgoingAsyncSandMessageFlag, getOutgoingAsyncSandMessageInvalidValue, getOutgoingAsyncSandMessageMetatype, getOutgoingAsyncSandMessagePrintValue, getOutgoingAsyncSandMessageRange, getOutgoingAsyncSandMessageValidityCheck, getOutgoingSyncDefaultSyncDestination, getOutgoingSyncDefaultSyncDestinationDefaultValue, getOutgoingSyncDefaultSyncDestinationFieldPrintValue, getOutgoingSyncDefaultSyncDestinationFlag, getOutgoingSyncDefaultSyncDestinationInvalidValue, getOutgoingSyncDefaultSyncDestinationMetatype, getOutgoingSyncDefaultSyncDestinationPrintValue, getOutgoingSyncDefaultSyncDestinationRange, getOutgoingSyncDefaultSyncDestinationValidityCheck, getParent, getPollingIntervalSeconds, getPollingIntervalSecondsDefaultValue, getPollingIntervalSecondsFieldPrintValue, getPollingIntervalSecondsFlag, getPollingIntervalSecondsInvalidValue, getPollingIntervalSecondsMetatype, getPollingIntervalSecondsPrintValue, getPollingIntervalSecondsRange, getPollingIntervalSecondsValidityCheck, getSandNodeErrorMessage, getSandNodeErrorMessageDefaultValue, getSandNodeErrorMessageFieldPrintValue, getSandNodeErrorMessageFlag, getSandNodeErrorMessageInvalidValue, getSandNodeErrorMessageLengthMax, getSandNodeErrorMessageLengthNorm, getSandNodeErrorMessageMetatype, getSandNodeErrorMessagePrintValue, getSandNodeErrorMessageRange, getSandNodeErrorMessageValidityCheck, getSandNodeState, getSandNodeStateActualVals, getSandNodeStateDefaultValue, getSandNodeStateEnumSummary, getSandNodeStateFieldPrintValue, getSandNodeStateFlag, getSandNodeStateInvalidValue, getSandNodeStateKeyVals, getSandNodeStateMetatype, getSandNodeStatePrintVals, getSandNodeStatePrintValue, getSandNodeStateRange, getSandNodeStateValidityCheck, getSandRoot, getServername, getStartupTime, getStartupTimeDefaultValue, getStartupTimeFieldPrintValue, getStartupTimeFlag, getStartupTimeInvalidValue, getStartupTimeMetatype, getStartupTimePrintValue, getStartupTimeRange, getStartupTimeValidityCheck, getStartupTimeWithOffset, getTestScriptFilename, getTestScriptFilenameDefaultValue, getTestScriptFilenameFieldPrintValue, getTestScriptFilenameFlag, getTestScriptFilenameInvalidValue, getTestScriptFilenameLengthMax, getTestScriptFilenameLengthNorm, getTestScriptFilenameMetatype, getTestScriptFilenamePrintValue, getTestScriptFilenameRange, getTestScriptFilenameValidityCheck, getUniqueIDMgrName, getUniqueIDMgrNameDefaultValue, getUniqueIDMgrNameFieldPrintValue, getUniqueIDMgrNameFlag, getUniqueIDMgrNameInvalidValue, getUniqueIDMgrNameLengthMax, getUniqueIDMgrNameLengthNorm, getUniqueIDMgrNameMetatype, getUniqueIDMgrNamePrintValue, getUniqueIDMgrNameRange, getUniqueIDMgrNameValidityCheck, init, log, log, logLevelActual2Print, logLevelLabelToValue, logLevelLabelToValueStatic, logLevelPrint2Actual, logLevelPrint2Key, logLevelValueToLabel, logLevelValueToLabelStatic, notifyStateChange, onFailure, onRestart, onResume, onShutdown, onSuspend, processMessage, readConfigParamsFromNodeInstance, receive, restart, resume, sandNodeStateActual2Print, sandNodeStateLabelToValue, sandNodeStateLabelToValueStatic, sandNodeStatePrint2Actual, sandNodeStatePrint2Key, sandNodeStateValueToLabel, sandNodeStateValueToLabelStatic, send, setHelperNodes, setIncomingAsyncDefaultAsyncSource, setIncomingAsyncDefaultAsyncSource, setIncomingSyncSandMessage, setIncomingSyncSandMessage, setInstClassEnumName, setInstClassEnumName, setLogger, setLogger, setLogLevel, setMaxTestWaitSeconds, setMessager, setMessager, setNodeInstance, setNodeInstance, setOutgoingAsyncSandMessage, setOutgoingAsyncSandMessage, setOutgoingSyncDefaultSyncDestination, setOutgoingSyncDefaultSyncDestination, setParent, setPollingIntervalSeconds, setSandNodeErrorMessage, setSandNodeErrorMessage, setSandNodeState, setSandRoot, setStartupTime, setStartupTime, setStartupTimeWithOffset, setTestScriptFilename, setTestScriptFilename, setUniqueIDMgrName, setUniqueIDMgrName, setupSecureReceive, setupSubscriptions, shutdown, startup, suspend, systemwideShutdown, validTransition |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
script
protected TestScript script
- The TestScript we are currently working from.
instClassEnum
protected InstanceClassEnumerator instClassEnum
- The InstanceClassEnumerator we use for translating VerbInstance
messages back into SandVerbMessages for use. Instantiated by
name from the instClassEnumName config param.
stepIndex
protected int stepIndex
- The index of the test step we are currently on. This is
incremented when the current condition is matched, so subsequent
steps can handle additional message traffic arising from the
action being taken. For example when we call with an update,
we might respond to several queries as part of the processing,
which are handled by the following steps.
status
protected int status
- The status result of running the given test. Defaults to TIMEOUT.
If all the steps are completed, then the result is set to SUCCESS.
If there is an error during processing of one of the steps, then
this is set to FAILED.
uniqueIDManager
protected UniqueIDManager uniqueIDManager
- The ID counter and remapper we use for default processing of
incoming AggregateUpdate messages. Note that since we are running
without a DataManager in most cases, we do not call the init
method, so whatever implementation is used here needs to be able
to work without initialization.
timeOffset
protected long timeOffset
- The time offset from actual system time, calculated from the
configured startupTime parameter. This is used for things like
setting the lastModifiedTime in default messaging handling.
statusWriter
protected StatusOutput statusWriter
- Testing status output mechanism.
MessageDriverNode
public MessageDriverNode()
getScript
public TestScript getScript()
- accessor for script
setScript
public void setScript(TestScript val)
- mutator for script
getInstClassEnum
public InstanceClassEnumerator getInstClassEnum()
- accessor for instClassEnum
setInstClassEnum
public void setInstClassEnum(InstanceClassEnumerator val)
- mutator for instClassEnum
getStepIndex
public int getStepIndex()
- accessor for stepIndex
setStepIndex
public void setStepIndex(int val)
- mutator for stepIndex
incrementStepIndex
public void incrementStepIndex()
- incrementor for stepIndex
getStatus
public int getStatus()
- accessor for status
setStatus
public void setStatus(int val)
- mutator for status
getUniqueIDManager
public UniqueIDManager getUniqueIDManager()
- accessor for uniqueIDManager
setUniqueIDManager
public void setUniqueIDManager(UniqueIDManager val)
- mutator for uniqueIDManager
getTimeOffset
public long getTimeOffset()
- accessor for timeOffset
setTimeOffset
public void setTimeOffset(long val)
- mutator for timeOffset
getStatusWriter
public StatusOutput getStatusWriter()
- accessor for statusWriter
setStatusWriter
public void setStatusWriter(StatusOutput val)
- mutator for statusWriter
statout
protected void statout(java.lang.String text)
- Test status output method if statusWriter set.
onStartup
protected void onStartup()
throws SandException
- Load our TestScript and set up to run it.
- Overrides:
onStartup in class MessageDriverNodeBase
- Throws:
SandException
onReceive
protected SandMessage onReceive(SandMessage msg)
throws SandException
- Log what we got, then handle the incoming message by comparing it
against our current location in the test script. If this is
something we were expecting, then take the specified action,
otherwise return our best guess to allow things to continue.
The message definition given in the action definition will
normally be a VerbInstance, since that is what the editor supports
working with. We call our InstanceClassEnumerator to translate
these into the actual messages to send.
- Overrides:
onReceive in class MessageDriverNodeBase
- Throws:
SandException
onDelivery
protected void onDelivery(SandMessage msg)
throws SandException
- Log what we got, then process it by comparing it against our
current location in the test script. If this is something we
were expecting, then take the specified action, otherwise do
- Overrides:
onDelivery in class MessageDriverNodeBase
- Throws:
SandException
getUserForID
public AuthUser getUserForID(long authID)
throws SandException
- Return the AuthUser for the specified ID.
- Specified by:
getUserForID in interface AuthUserLookup
- Throws:
SandException
getUserFromLogin
public AuthUser getUserFromLogin(java.lang.String username,
java.lang.String password)
throws SandException
- Lookup the AuthUser matching the given username and password.
- Specified by:
getUserFromLogin in interface AuthUserLookup
- Throws:
SandException
getInstance
public SandPersistMessage getInstance(java.lang.String classname,
long id,
AuthUser user)
- Lookup the specified class instance. Returns the instance from
cache if found, so classname and user params are ignored.
- Specified by:
getInstance in interface IDLookup
handleTestRunStatus
protected TestRunStatus handleTestRunStatus(TestRunStatus trs)
throws SandException
- Check if we are done and return the result. If we are not done,
and the current step does not have a condition associated with it,
then kick off a runner thread to do the test steps.
If the first step in a test has a condition, then the assumption
is that a worker thread from the node(s) being tested will be
kicking off the messaging flow. In either case, the steps are
being executed by a separate thread so all we need to do here
is wait for completion or timeout, whichever comes first.
- Throws:
SandException
executeAction
protected SandTransmitMessage executeAction(TestAction action)
throws SandException
- Execute the given action, if any. At the time of this call, the
stepIndex will have already been incremented so that any calls
back to us that occur during processing can be matched against
the next step.
- Throws:
SandException
loadInstClassEnum
protected InstanceClassEnumerator loadInstClassEnum()
throws SandException
- Load our InstanceClassEnumerator for use.
- Throws:
SandException
loadUniqueIDMgr
protected UniqueIDManager loadUniqueIDMgr()
throws SandException
- Load our UniqueIDManager for use.
- Throws:
SandException
conditionMatch
protected boolean conditionMatch(SandMessage msg,
int commType)
- Return true if the given message matches the condition specified
in our current test step, false otherwise. If the condition for
the current step is undefined, then this method returns false.
Unconditional steps are not taken in response to synchronous or
asynchronous messaging, they are taken as part of test processing.
Otherwise test control flow falls apart.
classnameMatch
protected boolean classnameMatch(java.lang.String spec,
java.lang.String name)
- Return true if the specification matches the name, either directly
or as a super interface.
compareConditions
protected boolean compareConditions(SandAttrVal[] conds1,
SandAttrVal[] conds2)
- Compare the conditions the two condition arrays and return
true if they are the equivalent, false otherwise.
compareMatch
protected boolean compareMatch(SandAttrVal[] conditions,
SandStructMessage ssm)
- Compare the conditions to the given message and return true
if they are a match, false otherwise.
getDefaultResult
protected SandTransmitMessage getDefaultResult(SandMessage msg)
throws SandException
- Return an appropriate default message based on what was sent and
the data we have.
Default processing:
- SandQueryMessage: query against our initialData
- AggregateUpdate: Fix the IDs using the IDCache counter, cache
the entries and return the result.
- All other messages: just return the same message
- Throws:
SandException
cacheQuery
protected SandCollectionMessage cacheQuery(SandQueryMessage sqm)
- Run the given query against all cached entries and return a
collection of everything that matches.
doAggregateUpdate
protected AggregateUpdate doAggregateUpdate(AggregateUpdate au)
throws SandException
- Create new IDs for anything being added, then put all the updated
data into our cache for reference. Return the fixed message.
The updates are broadcast as a side effect in case anyone is
listening for specific changes.
- Throws:
SandException
sendUpdatesToListeners
protected void sendUpdatesToListeners(AggregateUpdate au)
throws SandException
- Broadcast the updates contained within the given AggregateUpdate
in case anyone is monitoring for these.
- Throws:
SandException
changeTargetNodeParam
protected void changeTargetNodeParam(TestNodeParamChange tnpc,
java.lang.String overrideNode)
throws SandException
- Change the value of the param in the specified node. This works
by changing the given node instance and restarting the node so it
reads the new values. Leaving this separate from the MBean
infrastructure for now so testing can run without an MBeanServer.
Param changes for "this" (specified as the overrideNode) are
done dynamically without restarting the node.
- Throws:
SandException
changeDriverParam
protected void changeDriverParam(TestNodeParamChange tnpc)
throws SandException
- Dynamically change the given parameter value within this driver
node.
- Throws:
SandException
setTimeOffset
protected void setTimeOffset()
- If the startup time is set to something other than the default,
then compute the time offset we should be using for default
message handling.