Search in sources :

Example 11 with Controller

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);
    }
}
Also used : ArrayList(java.util.ArrayList) DataObject(com.emc.storageos.db.client.model.DataObject) Controller(com.emc.storageos.Controller) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException)

Example 12 with Controller

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);
    }
}
Also used : HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Method(java.lang.reflect.Method) Controller(com.emc.storageos.Controller) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Aggregations

Controller (com.emc.storageos.Controller)12 AbstractDiscoveredSystemController (com.emc.storageos.impl.AbstractDiscoveredSystemController)9 BlockController (com.emc.storageos.volumecontroller.BlockController)7 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)5 RetryableDatabaseException (com.emc.storageos.db.exceptions.RetryableDatabaseException)5 DiscoveredSystemObject (com.emc.storageos.db.client.model.DiscoveredSystemObject)2 HashMap (java.util.HashMap)2 DataObject (com.emc.storageos.db.client.model.DataObject)1 RPController (com.emc.storageos.protectioncontroller.RPController)1 RPDeviceController (com.emc.storageos.protectioncontroller.impl.recoverpoint.RPDeviceController)1 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)1 ObjectController (com.emc.storageos.volumecontroller.ObjectController)1 Method (java.lang.reflect.Method)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1