use of com.emc.storageos.Controller in project coprhd-controller by CoprHD.
the class WorkflowService method dispatchStep.
/**
* Send a step to the Dispatcher for execution. Must be in the QUEUED state.
*
* @param step
* Step to be dispatched.
* @param isNested
* True if this Workflow is nested within another workflow
* @throws WorkflowException
*/
private void dispatchStep(Step step, boolean isNested) throws WorkflowException {
assert (step.status.state == StepState.QUEUED);
// The stepId is automatically added as the last argument to the step.
List<Object> argList = new ArrayList<Object>(Arrays.asList(step.executeMethod.args));
argList.add(step.stepId);
// Look up the controller
Controller controller = _dispatcher.getControllerMap().get(step.controllerName);
// Handle the NULL_METHOD defined in Workflow
if (step.executeMethod == Workflow.NULL_METHOD) {
controller = this;
}
if (controller == null) {
throw new WorkflowException("Cannot locate controller for: " + step.controllerName);
}
// than if we're the top-level Workflow.
try {
_dispatcher.queue((isNested ? Dispatcher.QueueName.workflow_inner : Dispatcher.QueueName.workflow_outer), step.deviceURI, step.deviceType, step.lockDevice, controller, step.executeMethod.methodName, argList.toArray());
} catch (InternalException ex) {
throw new WorkflowException(String.format("Cannot queue step %s for controller %s method %s", step.stepId, step.controllerName, step.executeMethod.methodName), ex);
}
}
use of com.emc.storageos.Controller in project coprhd-controller by CoprHD.
the class Dispatcher method setController.
/**
* Sets device specific controller implementations
*
* @param controller
*/
public void setController(Set<Controller> controller) {
_controller = new HashMap<String, Controller>();
_methodMap = new HashMap<Controller, Map<String, Method>>();
Iterator<Controller> it = controller.iterator();
while (it.hasNext()) {
Controller c = it.next();
_controller.put(c.getClass().getName(), c);
Map<String, Method> methodMap = new HashMap<String, Method>();
Method[] methods = c.getClass().getMethods();
for (int i = 0; i < methods.length; i++) {
methodMap.put(methods[i].getName(), methods[i]);
}
_methodMap.put(c, methodMap);
}
}
Aggregations