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);
}
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();
}
}
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");
}
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);
}
Aggregations