Search in sources :

Example 1 with JsonDataModelTree

use of org.onosproject.workflow.api.JsonDataModelTree in project onos by opennetworkinglab.

the class WorkflowManager method createWorkplace.

@Override
public void createWorkplace(WorkplaceDescription wpDesc) throws WorkflowException {
    log.info("createWorkplace: {}", wpDesc);
    JsonNode root;
    if (wpDesc.data().isPresent()) {
        root = wpDesc.data().get();
    } else {
        root = JsonNodeFactory.instance.objectNode();
    }
    DefaultWorkplace workplace = new DefaultWorkplace(wpDesc.name(), new JsonDataModelTree(root));
    workplaceStore.registerWorkplace(wpDesc.name(), workplace);
}
Also used : DefaultWorkplace(org.onosproject.workflow.api.DefaultWorkplace) JsonDataModelTree(org.onosproject.workflow.api.JsonDataModelTree) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 2 with JsonDataModelTree

use of org.onosproject.workflow.api.JsonDataModelTree in project onos by opennetworkinglab.

the class WorkflowStatusCommand method invoke.

private void invoke() {
    try {
        WorkflowStore workflowStore = get(WorkflowStore.class);
        WorkplaceStore workplaceStore = get(WorkplaceStore.class);
        System.out.printf("%-25s %-45s %-10s%n", "DEVICEIP", " WORKFLOW NAME", "WORKFLOW STATE");
        for (WorkflowContext context : workplaceStore.getContexts()) {
            for (Workflow workflow : workflowStore.getAll()) {
                if (context.workflowId().equals(workflow.id())) {
                    JsonDataModelTree tree = (JsonDataModelTree) context.data();
                    JsonNode mgmtIp = tree.nodeAt("/mgmtIp");
                    System.out.printf("%-25s %-45s %-10s%n", mgmtIp, context.name(), context.state().toString());
                }
            }
        }
    } catch (WorkflowException e) {
        e.printStackTrace();
    }
}
Also used : WorkflowStore(org.onosproject.workflow.api.WorkflowStore) WorkplaceStore(org.onosproject.workflow.api.WorkplaceStore) WorkflowContext(org.onosproject.workflow.api.WorkflowContext) WorkflowException(org.onosproject.workflow.api.WorkflowException) JsonDataModelTree(org.onosproject.workflow.api.JsonDataModelTree) Workflow(org.onosproject.workflow.api.Workflow) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 3 with JsonDataModelTree

use of org.onosproject.workflow.api.JsonDataModelTree in project onos by opennetworkinglab.

the class WorkFlowEngine method activate.

@Activate
public void activate() {
    appId = coreService.registerApplication(APPID);
    workplaceStore.setDelegate(workplaceStoreDelegate);
    localNodeId = clusterService.getLocalNode().id();
    leadershipService.runForLeadership(appId.name());
    workflowBatchExecutor = newSingleThreadExecutor(groupedThreads("onos/workflow", "workflow-batch", log));
    workflowExecutor = newFixedThreadPool(DEFAULT_WORKFLOW_THREADS, groupedThreads("onos/workflow-exec", "worker-%d", log));
    handlerTaskBatchExecutor = newSingleThreadExecutor(groupedThreads("onos/workflow", "handlertask-batch", log));
    handlerTaskExecutor = newFixedThreadPool(DEFAULT_EVENTTASK_THREADS, groupedThreads("onos/handlertask-exec", "worker-%d", log));
    eventMapTriggerExecutor = newSingleThreadScheduledExecutor(groupedThreads("onos/workflow-engine", "eventmap-trigger-executor"));
    (new WorkplaceWorkflow(this, workflowStore)).registerWorkflows();
    JsonDataModelTree data = new JsonDataModelTree(JsonNodeFactory.instance.objectNode());
    workplaceStore.registerWorkplace(Workplace.SYSTEM_WORKPLACE, new DefaultWorkplace(Workplace.SYSTEM_WORKPLACE, data));
    log.info("Started");
}
Also used : DefaultWorkplace(org.onosproject.workflow.api.DefaultWorkplace) JsonDataModelTree(org.onosproject.workflow.api.JsonDataModelTree) Activate(org.osgi.service.component.annotations.Activate)

Example 4 with JsonDataModelTree

use of org.onosproject.workflow.api.JsonDataModelTree in project onos by opennetworkinglab.

the class WorkflowManager method invokeWorkflow.

@Override
public void invokeWorkflow(JsonNode worklowDescJson) throws WorkflowException {
    log.info("invokeWorkflow: {}", worklowDescJson);
    Workplace workplace = workplaceStore.getWorkplace(Workplace.SYSTEM_WORKPLACE);
    if (Objects.isNull(workplace)) {
        throw new WorkflowException("Invalid system workplace");
    }
    Workflow workflow = workflowStore.get(URI.create(worklowDescJson.get("id").asText()));
    if (Objects.isNull(workflow)) {
        throw new WorkflowException("Invalid Workflow");
    }
    checkWorkflowDataModelSchema(workflow, worklowDescJson);
    Workflow wfCreationWf = workflowStore.get(URI.create(WorkplaceWorkflow.WF_CREATE_WORKFLOW));
    if (Objects.isNull(wfCreationWf)) {
        throw new WorkflowException("Invalid workflow " + WorkplaceWorkflow.WF_CREATE_WORKFLOW);
    }
    WorkflowContext context = wfCreationWf.buildSystemContext(workplace, new JsonDataModelTree(worklowDescJson));
    workflowExecutionService.execInitWorklet(context);
}
Also used : WorkflowException(org.onosproject.workflow.api.WorkflowException) WorkflowContext(org.onosproject.workflow.api.WorkflowContext) JsonDataModelTree(org.onosproject.workflow.api.JsonDataModelTree) Workflow(org.onosproject.workflow.api.Workflow) Workplace(org.onosproject.workflow.api.Workplace) DefaultWorkplace(org.onosproject.workflow.api.DefaultWorkplace)

Aggregations

JsonDataModelTree (org.onosproject.workflow.api.JsonDataModelTree)4 DefaultWorkplace (org.onosproject.workflow.api.DefaultWorkplace)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 Workflow (org.onosproject.workflow.api.Workflow)2 WorkflowContext (org.onosproject.workflow.api.WorkflowContext)2 WorkflowException (org.onosproject.workflow.api.WorkflowException)2 WorkflowStore (org.onosproject.workflow.api.WorkflowStore)1 Workplace (org.onosproject.workflow.api.Workplace)1 WorkplaceStore (org.onosproject.workflow.api.WorkplaceStore)1 Activate (org.osgi.service.component.annotations.Activate)1