org.sandev.TaskHeap.PlanCalculator
Class PlanCalculatorNode

java.lang.Object
  extended byorg.sandev.TaskHeap.PlanCalculator.PlanCalculatorNodeDecl
      extended byorg.sandev.TaskHeap.PlanCalculator.PlanCalculatorNodeBase
          extended byorg.sandev.TaskHeap.PlanCalculator.PlanCalculatorNode
All Implemented Interfaces:
org.sandev.basics.nodecommon.Controllable, org.sandev.basics.nodecommon.Loggable, org.sandev.basics.nodecommon.Messageable

public class PlanCalculatorNode
extends PlanCalculatorNodeBase

Implementation of the PlanCalculator node.


Field Summary
protected  org.sandev.basics.util.IDLookup idLookup
          Our IDLookup instance used for retrieving plan component information not passed in with the PlanRecalc message.
 
Fields inherited from class org.sandev.TaskHeap.PlanCalculator.PlanCalculatorNodeBase
ctrlwrappers, helperNodes, incomingSyncPlanRecalc, LOGDEBUG, LOGERROR, LOGFATAL, logger, LOGINFO, logLevel, LOGLEVEL_DEBUG, LOGLEVEL_ERROR, LOGLEVEL_FATAL, LOGLEVEL_INFO, LOGLEVEL_WARN, LOGWARN, messager, nodeInstance, outgoingAsyncPlan, outgoingSyncExternalPlanQuery, outgoingSyncPlanQuery, outgoingSyncTaskQuery, outgoingSyncUpdaterNode, parent, RECURSIONLEVEL_FULL, RECURSIONLEVEL_OWNER, 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 class org.sandev.TaskHeap.PlanCalculator.PlanCalculatorNodeDecl
iDLookupInstanceName, recursionLevel
 
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
 
Constructor Summary
PlanCalculatorNode()
           
 
Method Summary
protected  org.sandev.basics.structs.SandPersistMessage findIDInUpdates(long id, org.sandev.basics.structs.SandUpdateMessage[] sums)
          Find the specified id in the given updates and return it.
 org.sandev.basics.util.IDLookup getIDLookup()
          initializing accessor for idLookup.
protected  long getTimeEstimateForID(long id, org.sandev.basics.util.AuthUser user, PlanRecalc pr, org.sandev.basics.util.UserWorkLog uwl)
          Given the ID of a PlanComponent, return the timeEstimate for it.
 org.sandev.basics.util.AuthUser getUserForID(long id)
          Given a userID, return the AuthUser for it.
 PlanRecalc onReceive(PlanRecalc planRecalc)
          Walk the PlanComponents.
protected  void onStartup()
          When we startup, we ping the node we use for updates to make sure our support infrastructure is up.
protected  long recalculatePlan(Plan plan, org.sandev.basics.util.AuthUser user, PlanRecalc pr, org.sandev.basics.util.UserWorkLog uwl)
          Calculate the timeEstimate of the given plan, appending an update to the PlanRecalc if the estimate has changed.
 void setIDLookup(org.sandev.basics.util.IDLookup val)
          mutator for idLookup
 
Methods inherited from class org.sandev.TaskHeap.PlanCalculator.PlanCalculatorNodeBase
addWrapper, callExternalPlanQuery, callPlanQuery, callTaskQuery, callUpdaterNode, deliver, fieldHasFlag, getHelperNodes, getIDCache, getIDLookupInstanceName, getIDLookupInstanceNameDefaultValue, getIDLookupInstanceNameFieldPrintValue, getIDLookupInstanceNameFlag, getIDLookupInstanceNameInvalidValue, getIDLookupInstanceNameLengthMax, getIDLookupInstanceNameLengthNorm, getIDLookupInstanceNameMetatype, getIDLookupInstanceNamePrintValue, getIDLookupInstanceNameRange, getIDLookupInstanceNameValidityCheck, getIncomingSyncPlanRecalc, getIncomingSyncPlanRecalcDefaultValue, getIncomingSyncPlanRecalcFieldPrintValue, getIncomingSyncPlanRecalcFlag, getIncomingSyncPlanRecalcInvalidValue, getIncomingSyncPlanRecalcMetatype, getIncomingSyncPlanRecalcPrintValue, getIncomingSyncPlanRecalcRange, getIncomingSyncPlanRecalcValidityCheck, getLogger, getLoggerDefaultValue, getLoggerFieldPrintValue, getLoggerFlag, getLoggerInvalidValue, getLoggerMetatype, getLoggerPrintValue, getLoggerRange, getLoggerValidityCheck, getLogLevel, getLogLevelActualVals, getLogLevelDefaultValue, getLogLevelEnumSummary, getLogLevelFieldPrintValue, getLogLevelFlag, getLogLevelInvalidValue, getLogLevelKeyVals, getLogLevelMetatype, getLogLevelPrintVals, getLogLevelPrintValue, getLogLevelRange, getLogLevelValidityCheck, getMessager, getMessagerDefaultValue, getMessagerFieldPrintValue, getMessagerFlag, getMessagerInvalidValue, getMessagerMetatype, getMessagerPrintValue, getMessagerRange, getMessagerValidityCheck, getNodeInstance, getNodeInstanceDefaultValue, getNodeInstanceFieldPrintValue, getNodeInstanceFlag, getNodeInstanceInvalidValue, getNodeInstanceMetatype, getNodeInstanceName, getNodeInstancePrintValue, getNodeInstanceRange, getNodeInstanceValidityCheck, getOutgoingAsyncPlan, getOutgoingAsyncPlanDefaultValue, getOutgoingAsyncPlanFieldPrintValue, getOutgoingAsyncPlanFlag, getOutgoingAsyncPlanInvalidValue, getOutgoingAsyncPlanMetatype, getOutgoingAsyncPlanPrintValue, getOutgoingAsyncPlanRange, getOutgoingAsyncPlanValidityCheck, getOutgoingSyncExternalPlanQuery, getOutgoingSyncExternalPlanQueryDefaultValue, getOutgoingSyncExternalPlanQueryFieldPrintValue, getOutgoingSyncExternalPlanQueryFlag, getOutgoingSyncExternalPlanQueryInvalidValue, getOutgoingSyncExternalPlanQueryMetatype, getOutgoingSyncExternalPlanQueryPrintValue, getOutgoingSyncExternalPlanQueryRange, getOutgoingSyncExternalPlanQueryValidityCheck, getOutgoingSyncPlanQuery, getOutgoingSyncPlanQueryDefaultValue, getOutgoingSyncPlanQueryFieldPrintValue, getOutgoingSyncPlanQueryFlag, getOutgoingSyncPlanQueryInvalidValue, getOutgoingSyncPlanQueryMetatype, getOutgoingSyncPlanQueryPrintValue, getOutgoingSyncPlanQueryRange, getOutgoingSyncPlanQueryValidityCheck, getOutgoingSyncTaskQuery, getOutgoingSyncTaskQueryDefaultValue, getOutgoingSyncTaskQueryFieldPrintValue, getOutgoingSyncTaskQueryFlag, getOutgoingSyncTaskQueryInvalidValue, getOutgoingSyncTaskQueryMetatype, getOutgoingSyncTaskQueryPrintValue, getOutgoingSyncTaskQueryRange, getOutgoingSyncTaskQueryValidityCheck, getOutgoingSyncUpdaterNode, getOutgoingSyncUpdaterNodeDefaultValue, getOutgoingSyncUpdaterNodeFieldPrintValue, getOutgoingSyncUpdaterNodeFlag, getOutgoingSyncUpdaterNodeInvalidValue, getOutgoingSyncUpdaterNodeMetatype, getOutgoingSyncUpdaterNodePrintValue, getOutgoingSyncUpdaterNodeRange, getOutgoingSyncUpdaterNodeValidityCheck, getParent, getRecursionLevel, getRecursionLevelActualVals, getRecursionLevelDefaultValue, getRecursionLevelEnumSummary, getRecursionLevelFieldPrintValue, getRecursionLevelFlag, getRecursionLevelInvalidValue, getRecursionLevelKeyVals, getRecursionLevelMetatype, getRecursionLevelPrintVals, getRecursionLevelPrintValue, getRecursionLevelRange, getRecursionLevelValidityCheck, 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, init, log, log, logLevelActual2Print, logLevelLabelToValue, logLevelPrint2Actual, logLevelPrint2Key, logLevelValueToLabel, notifyStateChange, onFailure, onRestart, onResume, onShutdown, onSuspend, receive, receive, recursionLevelActual2Print, recursionLevelLabelToValue, recursionLevelPrint2Actual, recursionLevelPrint2Key, recursionLevelValueToLabel, restart, resume, sandNodeStateActual2Print, sandNodeStateLabelToValue, sandNodeStatePrint2Actual, sandNodeStatePrint2Key, sandNodeStateValueToLabel, send, setHelperNodes, setIDLookupInstanceName, setIDLookupInstanceName, setIncomingSyncPlanRecalc, setIncomingSyncPlanRecalc, setLogger, setLogger, setLogLevel, setMessager, setMessager, setNodeInstance, setNodeInstance, setOutgoingAsyncPlan, setOutgoingAsyncPlan, setOutgoingSyncExternalPlanQuery, setOutgoingSyncExternalPlanQuery, setOutgoingSyncPlanQuery, setOutgoingSyncPlanQuery, setOutgoingSyncTaskQuery, setOutgoingSyncTaskQuery, setOutgoingSyncUpdaterNode, setOutgoingSyncUpdaterNode, setParent, setRecursionLevel, setSandNodeErrorMessage, setSandNodeErrorMessage, setSandNodeState, setSandRoot, 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
 

Field Detail

idLookup

protected org.sandev.basics.util.IDLookup idLookup
Our IDLookup instance used for retrieving plan component information not passed in with the PlanRecalc message.

Constructor Detail

PlanCalculatorNode

public PlanCalculatorNode()
Method Detail

onStartup

protected void onStartup()
                  throws org.sandev.basics.structs.SandException
When we startup, we ping the node we use for updates to make sure our support infrastructure is up. If not, then we log a warning and continue.

Overrides:
onStartup in class PlanCalculatorNodeBase
Throws:
org.sandev.basics.structs.SandException

onReceive

public PlanRecalc onReceive(PlanRecalc planRecalc)
                     throws org.sandev.basics.structs.SandException

Walk the PlanComponents. If this is a sequential plan, then add up the component time estimates, if it is parallel plan, then find the maximum component time estimate. For each plan component, recurse as necessary to get the time estimate.

Overrides:
onReceive in class PlanCalculatorNodeBase
Throws:
org.sandev.basics.structs.SandException

getIDLookup

public org.sandev.basics.util.IDLookup getIDLookup()
initializing accessor for idLookup. Not synchronized


setIDLookup

public void setIDLookup(org.sandev.basics.util.IDLookup val)
mutator for idLookup


recalculatePlan

protected long recalculatePlan(Plan plan,
                               org.sandev.basics.util.AuthUser user,
                               PlanRecalc pr,
                               org.sandev.basics.util.UserWorkLog uwl)
                        throws org.sandev.basics.structs.SandException
Calculate the timeEstimate of the given plan, appending an update to the PlanRecalc if the estimate has changed. This method may be called recursively to compute sub-plans.

Throws:
org.sandev.basics.structs.SandException

getTimeEstimateForID

protected long getTimeEstimateForID(long id,
                                    org.sandev.basics.util.AuthUser user,
                                    PlanRecalc pr,
                                    org.sandev.basics.util.UserWorkLog uwl)
                             throws org.sandev.basics.structs.SandException
Given the ID of a PlanComponent, return the timeEstimate for it. To find the component, we first look through the given updates so that we are working from the latest computed information, if not found, then we look it up.

Throws:
org.sandev.basics.structs.SandException

findIDInUpdates

protected org.sandev.basics.structs.SandPersistMessage findIDInUpdates(long id,
                                                                       org.sandev.basics.structs.SandUpdateMessage[] sums)
Find the specified id in the given updates and return it. Return null if not found. Note that we walk all the updates so we return the information from the latest one.


getUserForID

public org.sandev.basics.util.AuthUser getUserForID(long id)
                                             throws org.sandev.basics.structs.SandException
Given a userID, return the AuthUser for it. We are assuming here that our IDLookup also implements AuthUserLookup, otherwise this will throw a ClassCastException.

Throws:
org.sandev.basics.structs.SandException