Search in sources :

Example 1 with Workplace

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

the class WorkplaceStoreCommand method printAllWorkplace.

/**
 * Prints all workplaces.
 */
private void printAllWorkplace() {
    WorkplaceStore workplaceStore = get(WorkplaceStore.class);
    for (Workplace workplace : workplaceStore.getWorkplaces()) {
        print(getWorkplaceString(workplace));
        printWorkplaceContexts(workplaceStore, workplace.name());
    }
}
Also used : WorkplaceStore(org.onosproject.workflow.api.WorkplaceStore) Workplace(org.onosproject.workflow.api.Workplace)

Example 2 with Workplace

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

the class WorkplaceStoreCommand method printWorkplace.

/**
 * Prints workplace.
 * @param name workplace name
 */
private void printWorkplace(String name) {
    WorkplaceStore workplaceStore = get(WorkplaceStore.class);
    Workplace workplace = workplaceStore.getWorkplace(name);
    if (Objects.isNull(workplace)) {
        print("Not existing workplace " + name);
        return;
    }
    print(getWorkplaceString(workplace));
    printWorkplaceContexts(workplaceStore, workplace.name());
}
Also used : WorkplaceStore(org.onosproject.workflow.api.WorkplaceStore) Workplace(org.onosproject.workflow.api.Workplace)

Example 3 with Workplace

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

the class DistributedWorkplaceStore method activate.

@Activate
public void activate() {
    appId = coreService.registerApplication("org.onosproject.workplacestore");
    log.info("appId=" + appId);
    KryoNamespace workplaceNamespace = KryoNamespace.newBuilder().register(KryoNamespaces.API).register(WorkflowData.class).register(Workplace.class).register(DefaultWorkplace.class).register(WorkflowContext.class).register(DefaultWorkflowContext.class).register(SystemWorkflowContext.class).register(WorkflowState.class).register(ProgramCounter.class).register(DataModelTree.class).register(JsonDataModelTree.class).register(List.class).register(ArrayList.class).register(JsonNode.class).register(ObjectNode.class).register(TextNode.class).register(LinkedHashMap.class).register(ArrayNode.class).register(BaseJsonNode.class).register(BigIntegerNode.class).register(BinaryNode.class).register(BooleanNode.class).register(ContainerNode.class).register(DecimalNode.class).register(DoubleNode.class).register(FloatNode.class).register(IntNode.class).register(JsonNodeType.class).register(LongNode.class).register(MissingNode.class).register(NullNode.class).register(NumericNode.class).register(POJONode.class).register(ShortNode.class).register(ValueNode.class).register(JsonNodeCreator.class).register(JsonNodeFactory.class).build();
    localWorkplaceMap.clear();
    workplaceMap = storageService.<String, WorkflowData>consistentMapBuilder().withSerializer(Serializer.using(workplaceNamespace)).withName("workplace-map").withApplicationId(appId).build();
    workplaceMap.addListener(workplaceMapEventListener);
    localContextMap.clear();
    contextMap = storageService.<String, WorkflowData>consistentMapBuilder().withSerializer(Serializer.using(workplaceNamespace)).withName("workflow-context-map").withApplicationId(appId).build();
    contextMap.addListener(contextMapEventListener);
    workplaceMapEventListener.syncLocal();
    contextMapEventListener.syncLocal();
    log.info("Started");
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) DefaultWorkflowContext(org.onosproject.workflow.api.DefaultWorkflowContext) WorkflowContext(org.onosproject.workflow.api.WorkflowContext) SystemWorkflowContext(org.onosproject.workflow.api.SystemWorkflowContext) JsonDataModelTree(org.onosproject.workflow.api.JsonDataModelTree) ArrayList(java.util.ArrayList) BaseJsonNode(com.fasterxml.jackson.databind.node.BaseJsonNode) DoubleNode(com.fasterxml.jackson.databind.node.DoubleNode) POJONode(com.fasterxml.jackson.databind.node.POJONode) Workplace(org.onosproject.workflow.api.Workplace) DefaultWorkplace(org.onosproject.workflow.api.DefaultWorkplace) LongNode(com.fasterxml.jackson.databind.node.LongNode) LinkedHashMap(java.util.LinkedHashMap) JsonNodeFactory(com.fasterxml.jackson.databind.node.JsonNodeFactory) SystemWorkflowContext(org.onosproject.workflow.api.SystemWorkflowContext) IntNode(com.fasterxml.jackson.databind.node.IntNode) BinaryNode(com.fasterxml.jackson.databind.node.BinaryNode) ValueNode(com.fasterxml.jackson.databind.node.ValueNode) KryoNamespace(org.onlab.util.KryoNamespace) ContainerNode(com.fasterxml.jackson.databind.node.ContainerNode) ProgramCounter(org.onosproject.workflow.api.ProgramCounter) NullNode(com.fasterxml.jackson.databind.node.NullNode) Activate(org.osgi.service.component.annotations.Activate)

Example 4 with Workplace

use of org.onosproject.workflow.api.Workplace 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

Workplace (org.onosproject.workflow.api.Workplace)4 DefaultWorkplace (org.onosproject.workflow.api.DefaultWorkplace)2 JsonDataModelTree (org.onosproject.workflow.api.JsonDataModelTree)2 WorkflowContext (org.onosproject.workflow.api.WorkflowContext)2 WorkplaceStore (org.onosproject.workflow.api.WorkplaceStore)2 BaseJsonNode (com.fasterxml.jackson.databind.node.BaseJsonNode)1 BinaryNode (com.fasterxml.jackson.databind.node.BinaryNode)1 ContainerNode (com.fasterxml.jackson.databind.node.ContainerNode)1 DoubleNode (com.fasterxml.jackson.databind.node.DoubleNode)1 IntNode (com.fasterxml.jackson.databind.node.IntNode)1 JsonNodeFactory (com.fasterxml.jackson.databind.node.JsonNodeFactory)1 LongNode (com.fasterxml.jackson.databind.node.LongNode)1 NullNode (com.fasterxml.jackson.databind.node.NullNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 POJONode (com.fasterxml.jackson.databind.node.POJONode)1 ValueNode (com.fasterxml.jackson.databind.node.ValueNode)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 KryoNamespace (org.onlab.util.KryoNamespace)1 DefaultWorkflowContext (org.onosproject.workflow.api.DefaultWorkflowContext)1