Partially implemented DAG processing
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/b338f4ac Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/b338f4ac Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/b338f4ac Branch: refs/heads/new-workflow-design Commit: b338f4acb1b6aab86cd9ca1bc64f953c111fc7a8 Parents: d05cbdc Author: shamrath <[email protected]> Authored: Wed Feb 11 14:45:16 2015 -0500 Committer: shamrath <[email protected]> Committed: Wed Feb 11 14:45:16 2015 -0500 ---------------------------------------------------------------------- modules/simple-workflow/pom.xml | 27 ++ .../workflow/engine/AiravataDefaultParser.java | 111 ++++++++ .../engine/SimpleWorkflowInterpreter.java | 254 ++++++++++++++++++- .../simple/workflow/engine/WfNodeContainer.java | 33 +++ .../simple/workflow/engine/WorkflowFactory.java | 10 + .../workflow/engine/WorkflowFactoryImpl.java | 52 ++++ .../simple/workflow/engine/WorkflowParser.java | 34 +++ .../simple/workflow/engine/WorkflowUtil.java | 25 ++ .../workflow/engine/dag/links/DirectedLink.java | 8 +- .../simple/workflow/engine/dag/links/Edge.java | 37 +++ .../simple/workflow/engine/dag/links/Link.java | 14 - .../engine/dag/nodes/ApplicationNode.java | 83 +++--- .../engine/dag/nodes/ApplicationNodeImpl.java | 108 ++++++++ .../workflow/engine/dag/nodes/NodeState.java | 28 +- .../engine/dag/nodes/WorkflowInputNode.java | 70 ++--- .../engine/dag/nodes/WorkflowInputNodeImpl.java | 81 ++++++ .../workflow/engine/dag/nodes/WorkflowNode.java | 28 +- .../engine/dag/nodes/WorkflowOutputNode.java | 53 ++-- .../dag/nodes/WorkflowOutputNodeImpl.java | 75 ++++++ .../simple/workflow/engine/dag/port/InPort.java | 36 +++ .../workflow/engine/dag/port/InputPortIml.java | 44 ++++ .../workflow/engine/dag/port/OutPort.java | 39 +++ .../simple/workflow/engine/dag/port/Port.java | 31 +++ 23 files changed, 1135 insertions(+), 146 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/airavata/blob/b338f4ac/modules/simple-workflow/pom.xml ---------------------------------------------------------------------- diff --git a/modules/simple-workflow/pom.xml b/modules/simple-workflow/pom.xml index c54ab83..a296417 100644 --- a/modules/simple-workflow/pom.xml +++ b/modules/simple-workflow/pom.xml @@ -8,5 +8,32 @@ <artifactId>simple-workflow</artifactId> <version>0.15-SNAPSHOT</version> + <dependencies> + <dependency> + <groupId>org.apache.airavata</groupId> + <artifactId>airavata-data-models</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.airavata</groupId> + <artifactId>airavata-registry-cpi</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.airavata</groupId> + <artifactId>airavata-model-utils</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.airavata</groupId> + <artifactId>airavata-jpa-registry</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + <version>18.0</version> + </dependency> + </dependencies> </project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/b338f4ac/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/AiravataDefaultParser.java ---------------------------------------------------------------------- diff --git a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/AiravataDefaultParser.java b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/AiravataDefaultParser.java new file mode 100644 index 0000000..837d0f7 --- /dev/null +++ b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/AiravataDefaultParser.java @@ -0,0 +1,111 @@ +package org.apache.ariavata.simple.workflow.engine; + +import org.airavata.appcatalog.cpi.AppCatalogException; +import org.airavata.appcatalog.cpi.WorkflowCatalog; +import org.apache.aiaravata.application.catalog.data.impl.AppCatalogFactory; +import org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType; +import org.apache.airavata.model.workspace.experiment.Experiment; +import org.apache.airavata.persistance.registry.jpa.impl.RegistryFactory; +import org.apache.airavata.registry.cpi.Registry; +import org.apache.airavata.registry.cpi.RegistryException; +import org.apache.airavata.registry.cpi.RegistryModelType; +import org.apache.airavata.workflow.model.component.ComponentException; +import org.apache.airavata.workflow.model.component.system.ConstantComponent; +import org.apache.airavata.workflow.model.component.system.InputComponent; +import org.apache.airavata.workflow.model.component.system.S3InputComponent; +import org.apache.airavata.workflow.model.graph.GraphException; +import org.apache.airavata.workflow.model.graph.Node; +import org.apache.airavata.workflow.model.graph.impl.NodeImpl; +import org.apache.airavata.workflow.model.wf.Workflow; +import org.apache.ariavata.simple.workflow.engine.dag.links.Edge; +import org.apache.ariavata.simple.workflow.engine.dag.nodes.WorkflowInputNode; +import org.apache.ariavata.simple.workflow.engine.dag.nodes.WorkflowNode; +import org.apache.ariavata.simple.workflow.engine.dag.port.OutPort; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +//import org.apache.airavata.model.Workflow; + +/** + * Created by shameera on 2/11/15. + */ +public class AiravataDefaultParser implements WorkflowParser { + + private String experimentId; + private String credentialToken ; + private Workflow workflow; + private Experiment experiment; + + + public AiravataDefaultParser(String experimentId, String credentialToken) { + this.experimentId = experimentId; + this.credentialToken = credentialToken; + } + + @Override + public List<WorkflowInputNode> parse() throws RegistryException, AppCatalogException, + ComponentException, GraphException { + return parseWorkflow(getWorkflowFromExperiment()); + } + + private List<WorkflowInputNode> parseWorkflow(Workflow workflow) { + List<Node> gNodes = getInputNodes(workflow); + List<WorkflowInputNode> wfInputNodes = new ArrayList<WorkflowInputNode>(); + List<WorkflowNode> wfNodes = new ArrayList<WorkflowNode>(); + List<InputDataObjectType> experimentInputs = experiment.getExperimentInputs(); + Map<String,InputDataObjectType> inputDataMap=new HashMap<String, InputDataObjectType>(); + WorkflowInputNode wfInputNode = null; + for (InputDataObjectType dataObjectType : experimentInputs) { + inputDataMap.put(dataObjectType.getName(), dataObjectType); + } + for (Node gNode : gNodes) { + // create a new wfInputNode instance by passing node name and node Id + wfInputNode.setInputObject(inputDataMap.get(wfInputNode.getNodeName())); + if (wfInputNode.getInputObject() == null) { + // TODO: throw an error and exit. + } + Edge edge = null;//= new Edge + OutPort outPort = null; + outPort. + link.setOutPort(null); // new Output + wfInputNodes.add(wfInputNode); + } + + + + + + return null; + } + + private WorkflowInputNode getWorkflowInputNode(Node inputNode) { + // FIXME: create a new workflow input node implementation with input node data. + return null; + } + + private Workflow getWorkflowFromExperiment() throws RegistryException, AppCatalogException, GraphException, ComponentException { + Registry registry = RegistryFactory.getDefaultRegistry(); + experiment = (Experiment)registry.get(RegistryModelType.EXPERIMENT, experimentId); + WorkflowCatalog workflowCatalog = getWorkflowCatalog(); + return new Workflow(workflowCatalog.getWorkflow(experiment.getApplicationId()).getGraph()); + } + + private WorkflowCatalog getWorkflowCatalog() throws AppCatalogException { + return AppCatalogFactory.getAppCatalog().getWorkflowCatalog(); + } + + private ArrayList<Node> getInputNodes(Workflow wf) { + ArrayList<Node> list = new ArrayList<Node>(); + List<NodeImpl> nodes = wf.getGraph().getNodes(); + for (Node node : nodes) { + String name = node.getComponent().getName(); + if (InputComponent.NAME.equals(name) || ConstantComponent.NAME.equals(name) || S3InputComponent.NAME.equals(name)) { + list.add(node); + } + } + return list; + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/b338f4ac/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/SimpleWorkflowInterpreter.java ---------------------------------------------------------------------- diff --git a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/SimpleWorkflowInterpreter.java b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/SimpleWorkflowInterpreter.java index b7bb261..d8818e1 100644 --- a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/SimpleWorkflowInterpreter.java +++ b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/SimpleWorkflowInterpreter.java @@ -21,36 +21,270 @@ package org.apache.ariavata.simple.workflow.engine; +import com.google.common.eventbus.Subscribe; +import org.apache.airavata.model.messaging.event.TaskOutputChangeEvent; +import org.apache.airavata.model.messaging.event.TaskStatusChangeEvent; +import org.apache.airavata.model.util.ExperimentModelUtil; +import org.apache.airavata.model.workspace.experiment.ExecutionUnit; import org.apache.airavata.model.workspace.experiment.Experiment; import org.apache.airavata.model.workspace.experiment.TaskDetails; +import org.apache.airavata.model.workspace.experiment.WorkflowNodeDetails; +import org.apache.airavata.model.workspace.experiment.WorkflowNodeState; +import org.apache.airavata.model.workspace.experiment.WorkflowNodeStatus; +import org.apache.airavata.persistance.registry.jpa.impl.RegistryFactory; +import org.apache.airavata.registry.cpi.ChildDataType; +import org.apache.airavata.registry.cpi.Registry; +import org.apache.airavata.registry.cpi.RegistryException; +import org.apache.airavata.registry.cpi.RegistryModelType; +import org.apache.ariavata.simple.workflow.engine.dag.links.Edge; +import org.apache.ariavata.simple.workflow.engine.dag.nodes.ApplicationNode; +import org.apache.ariavata.simple.workflow.engine.dag.nodes.NodeState; import org.apache.ariavata.simple.workflow.engine.dag.nodes.WorkflowInputNode; +import org.apache.ariavata.simple.workflow.engine.dag.nodes.WorkflowNode; +import org.apache.ariavata.simple.workflow.engine.dag.nodes.WorkflowOutputNode; +import org.apache.ariavata.simple.workflow.engine.dag.port.InPort; +import org.apache.ariavata.simple.workflow.engine.dag.port.OutPort; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; +import java.util.Map; +import java.util.Set; -/** - * Created by shameera on 1/29/15. - */ public class SimpleWorkflowInterpreter { + private List<WorkflowInputNode> workflowInputNodes; + + private Experiment experiment; + + private String credentialToken; + + private List<WorkflowNode> readList = new ArrayList<WorkflowNode>(); + private List<WorkflowNode> waitingList = new ArrayList<WorkflowNode>(); + private Map<String,WfNodeContainer> processingQueue = new HashMap<String, WfNodeContainer>(); + private List<WorkflowNode> completeList = new ArrayList<WorkflowNode>(); + private Registry registry; + public SimpleWorkflowInterpreter(Experiment experiment, String credentialStoreToken) { // read the workflow file and build the topology to a DAG. Then execute that dag // get workflowInputNode list and start processing // next() will return ready task and block the thread if no task in ready state. + this.experiment = experiment; + this.credentialToken = credentialStoreToken; } - /** - * This method block the calling thread until next task is ready to return; - * - * @return nest task to launch; - */ - public TaskDetails next() { - return null; + + public void launchWorkflow() { + // process workflow input nodes + processWorkflowInputNodes(getWorkflowInputNodes()); + processReadyList(); + // process workflow application nodes + // process workflow output nodes + } + + // try to remove synchronization tag + private synchronized void processReadyList() { + for (WorkflowNode readyNode : readList) { + try { + WorkflowNodeDetails workflowNodeDetails = createWorkflowNodeDetails(readyNode); + TaskDetails process = getProcess(workflowNodeDetails); + processingQueue.put(process.getTaskID(), new WfNodeContainer(readyNode, workflowNodeDetails)); + publishToProcessQueue(process); + } catch (RegistryException e) { + // FIXME : handle this exception + } + } + } + + private void publishToProcessQueue(TaskDetails process) { + //TODO: publish to process queue. + } + + private TaskDetails getProcess(WorkflowNodeDetails wfNodeDetails) throws RegistryException { + // create workflow taskDetails from workflowNodeDetails + TaskDetails taskDetails = ExperimentModelUtil.cloneTaskFromWorkflowNodeDetails(getExperiment(), wfNodeDetails); + taskDetails.setTaskID(getRegistry() + .add(ChildDataType.TASK_DETAIL, taskDetails, wfNodeDetails.getNodeInstanceId()).toString()); + return taskDetails; + } + + private WorkflowNodeDetails createWorkflowNodeDetails(WorkflowNode readyNode) throws RegistryException { + WorkflowNodeDetails wfNodeDetails = ExperimentModelUtil.createWorkflowNode(readyNode.getNodeId(), null); + ExecutionUnit executionUnit = ExecutionUnit.APPLICATION; + String executionData = null; + if (readyNode instanceof ApplicationNode) { + executionUnit = ExecutionUnit.APPLICATION; + executionData = ((ApplicationNode) readyNode).getApplicationId(); + } else if (readyNode instanceof WorkflowInputNode) { + executionUnit = ExecutionUnit.INPUT; + } else if (readyNode instanceof WorkflowOutputNode) { + executionUnit = ExecutionUnit.OUTPUT; + } + wfNodeDetails.setExecutionUnit(executionUnit); + wfNodeDetails.setExecutionUnitData(executionData); + setupNodeDetailsInput(readyNode, wfNodeDetails); + wfNodeDetails.setNodeInstanceId((String) getRegistry() + .add(ChildDataType.WORKFLOW_NODE_DETAIL, wfNodeDetails, getExperiment().getExperimentID())); +// nodeInstanceList.put(node, wfNodeDetails); + return wfNodeDetails; + } + + private void setupNodeDetailsInput(WorkflowNode readyNode, WorkflowNodeDetails wfNodeDetails) { + if (readyNode instanceof ApplicationNode) { + ApplicationNode applicationNode = (ApplicationNode) readyNode; + if (applicationNode.isSatisfy()) { + for (InPort inPort : applicationNode.getInputPorts()) { + wfNodeDetails.addToNodeInputs(inPort.getInputObject()); + } + } else { + // TODO: handle this scenario properly. + } + } else { + // TODO: do we support for other type of workflow nodes ? + } + } + + + private void processWorkflowInputNodes(List<WorkflowInputNode> wfInputNodes) { + Set<WorkflowNode> tempNodeSet = new HashSet<WorkflowNode>(); + for (WorkflowInputNode wfInputNode : wfInputNodes) { + if (wfInputNode.isSatisfy()) { + for (Edge edge : wfInputNode.getOutputLinks()) { + WorkflowUtil.copyValues(wfInputNode.getInputObject(), edge.getInPort().getInputObject()); + tempNodeSet.add(edge.getInPort().getNode()); + } + } + } + for (WorkflowNode workflowNode : tempNodeSet) { + if (workflowNode.isSatisfy()) { + readList.add(workflowNode); + } else { + waitingList.add(workflowNode); + } + } + } + + + public List<WorkflowInputNode> getWorkflowInputNodes() { + if (workflowInputNodes == null) { + // read workflow description from registry and parse it + WorkflowFactoryImpl wfFactory = WorkflowFactoryImpl.getInstance(); + List<WorkflowInputNode> wfInputNodes = wfFactory.getWorkflowParser().parse(); + setWorkflowInputNodes(wfInputNodes); + } + return workflowInputNodes; + } + + public void setWorkflowInputNodes(List<WorkflowInputNode> workflowInputNodes) { + this.workflowInputNodes = workflowInputNodes; } + private List<WorkflowInputNode> parseWorkflowDescription(){ return null; } + private Registry getRegistry() throws RegistryException { + if (registry==null){ + registry = RegistryFactory.getDefaultRegistry(); + } + return registry; + } + + public Experiment getExperiment() { + return experiment; + } + + private void updateWorkflowNodeStatus(WorkflowNodeDetails wfNodeDetails, WorkflowNodeState state) throws RegistryException{ + WorkflowNodeStatus status = ExperimentModelUtil.createWorkflowNodeStatus(state); + wfNodeDetails.setWorkflowNodeStatus(status); + getRegistry().update(RegistryModelType.WORKFLOW_NODE_STATUS, status, wfNodeDetails.getNodeInstanceId()); + } + + @Subscribe + public void taskOutputChanged(TaskOutputChangeEvent taskOutputEvent){ + String taskId = taskOutputEvent.getTaskIdentity().getTaskId(); + WfNodeContainer wfNodeContainer = processingQueue.get(taskId); + Set<WorkflowNode> tempWfNodeSet = new HashSet<WorkflowNode>(); + if (wfNodeContainer != null) { + WorkflowNode workflowNode = wfNodeContainer.getWorkflowNode(); + if (workflowNode instanceof ApplicationNode) { + ApplicationNode applicationNode = (ApplicationNode) workflowNode; + // Workflow node can have one to many output ports and each output port can have one to many links + for (OutPort outPort : applicationNode.getOutputPorts()) { + for (Edge edge : outPort.getOutputLinks()) { + WorkflowUtil.copyValues(outPort.getOutputObject(), edge.getInPort().getInputObject()); + tempWfNodeSet.add(edge.getInPort().getNode()); + } + } + + for (WorkflowNode node : tempWfNodeSet) { + if (node.isSatisfy()) { + waitingList.remove(node); + readList.add(node); + } + } + } + processingQueue.remove(taskId); + processReadyList(); + } + + } + + @Subscribe + public void taskStatusChanged(TaskStatusChangeEvent taskStatus){ + String taskId = taskStatus.getTaskIdentity().getTaskId(); + WfNodeContainer wfNodeContainer = processingQueue.get(taskId); + if (wfNodeContainer != null) { + WorkflowNodeState wfNodeState = WorkflowNodeState.UNKNOWN; + switch (taskStatus.getState()) { + case WAITING: + break; + case STARTED: + break; + case PRE_PROCESSING: + wfNodeContainer.getWorkflowNode().setNodeState(NodeState.PRE_PROCESSING); + break; + case INPUT_DATA_STAGING: + wfNodeContainer.getWorkflowNode().setNodeState(NodeState.PRE_PROCESSING); + break; + case OUTPUT_DATA_STAGING: + wfNodeContainer.getWorkflowNode().setNodeState(NodeState.POST_PROCESSING); + break; + case EXECUTING: + wfNodeContainer.getWorkflowNode().setNodeState(NodeState.EXECUTING); + break; + case POST_PROCESSING: + wfNodeContainer.getWorkflowNode().setNodeState(NodeState.POST_PROCESSING); + break; + case COMPLETED: + wfNodeContainer.getWorkflowNode().setNodeState(NodeState.EXECUTED); + break; + case FAILED: + wfNodeContainer.getWorkflowNode().setNodeState(NodeState.FAILED); + break; + case UNKNOWN: + break; + case CONFIGURING_WORKSPACE: + break; + case CANCELED: + case CANCELING: + wfNodeContainer.getWorkflowNode().setNodeState(NodeState.FAILED); + break; + default: + break; + } + if (wfNodeState != WorkflowNodeState.UNKNOWN) { + try { + updateWorkflowNodeStatus(wfNodeContainer.getWfNodeDetails(), wfNodeState); + } catch (RegistryException e) { + // TODO: handle this. + } + } + } + + } } http://git-wip-us.apache.org/repos/asf/airavata/blob/b338f4ac/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/WfNodeContainer.java ---------------------------------------------------------------------- diff --git a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/WfNodeContainer.java b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/WfNodeContainer.java new file mode 100644 index 0000000..d7e0c2a --- /dev/null +++ b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/WfNodeContainer.java @@ -0,0 +1,33 @@ +package org.apache.ariavata.simple.workflow.engine; + +import org.apache.airavata.model.workspace.experiment.WorkflowNodeDetails; +import org.apache.ariavata.simple.workflow.engine.dag.nodes.WorkflowNode; + +/** + * Created by shameera on 2/9/15. + */ +public class WfNodeContainer { + private WorkflowNode workflowNode; + private WorkflowNodeDetails wfNodeDetails; + + public WfNodeContainer(WorkflowNode workflowNode, WorkflowNodeDetails wfNodeDetails) { + this.workflowNode = workflowNode; + this.wfNodeDetails = wfNodeDetails; + } + + public WorkflowNode getWorkflowNode() { + return workflowNode; + } + + public void setWorkflowNode(WorkflowNode workflowNode) { + this.workflowNode = workflowNode; + } + + public WorkflowNodeDetails getWfNodeDetails() { + return wfNodeDetails; + } + + public void setWfNodeDetails(WorkflowNodeDetails wfNodeDetails) { + this.wfNodeDetails = wfNodeDetails; + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/b338f4ac/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/WorkflowFactory.java ---------------------------------------------------------------------- diff --git a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/WorkflowFactory.java b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/WorkflowFactory.java new file mode 100644 index 0000000..867bc80 --- /dev/null +++ b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/WorkflowFactory.java @@ -0,0 +1,10 @@ +package org.apache.ariavata.simple.workflow.engine; + +/** + * All classes implement this WorkflowFactory interface, should be abstract or singleton. + */ +public interface WorkflowFactory { + + public WorkflowParser getWorkflowParser(); + +} http://git-wip-us.apache.org/repos/asf/airavata/blob/b338f4ac/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/WorkflowFactoryImpl.java ---------------------------------------------------------------------- diff --git a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/WorkflowFactoryImpl.java b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/WorkflowFactoryImpl.java new file mode 100644 index 0000000..a43f010 --- /dev/null +++ b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/WorkflowFactoryImpl.java @@ -0,0 +1,52 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +package org.apache.ariavata.simple.workflow.engine; + +/** + * Singleton class, only one instance can exist in runtime. + */ +public class WorkflowFactoryImpl implements WorkflowFactory { + + private static WorkflowFactoryImpl workflowFactoryImpl; + + private WorkflowFactoryImpl(){ + + } + + public static WorkflowFactoryImpl getInstance() { + if (workflowFactoryImpl == null) { + synchronized (workflowFactoryImpl) { + if (workflowFactoryImpl == null) { + workflowFactoryImpl = new WorkflowFactoryImpl(); + } + } + } + return workflowFactoryImpl; + } + + + @Override + public WorkflowParser getWorkflowParser() { + + return null; // TODO: Auto generated method body. + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/b338f4ac/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/WorkflowParser.java ---------------------------------------------------------------------- diff --git a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/WorkflowParser.java b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/WorkflowParser.java new file mode 100644 index 0000000..b8b6367 --- /dev/null +++ b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/WorkflowParser.java @@ -0,0 +1,34 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +package org.apache.ariavata.simple.workflow.engine; + +import org.airavata.appcatalog.cpi.AppCatalogException; +import org.apache.airavata.registry.cpi.RegistryException; +import org.apache.ariavata.simple.workflow.engine.dag.nodes.WorkflowInputNode; + +import java.util.List; + +public interface WorkflowParser { + + public List<WorkflowInputNode> parse() throws Exception; + +} http://git-wip-us.apache.org/repos/asf/airavata/blob/b338f4ac/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/WorkflowUtil.java ---------------------------------------------------------------------- diff --git a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/WorkflowUtil.java b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/WorkflowUtil.java new file mode 100644 index 0000000..0d720b0 --- /dev/null +++ b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/WorkflowUtil.java @@ -0,0 +1,25 @@ +package org.apache.ariavata.simple.workflow.engine; + +import org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType; +import org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType; + +/** + * Created by shameera on 2/9/15. + */ +public class WorkflowUtil { + + public static InputDataObjectType copyValues(InputDataObjectType fromInputObj, InputDataObjectType toInputObj){ + toInputObj.setValue(fromInputObj.getValue()); + if (fromInputObj.getApplicationArgument() != null + && !fromInputObj.getApplicationArgument().trim().equals("")) { + toInputObj.setApplicationArgument(fromInputObj.getApplicationArgument()); + } + return fromInputObj; + } + + public static InputDataObjectType copyValues(OutputDataObjectType outputData, InputDataObjectType inputData) { + inputData.setValue(outputData.getValue()); + return inputData; + } + +} http://git-wip-us.apache.org/repos/asf/airavata/blob/b338f4ac/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/links/DirectedLink.java ---------------------------------------------------------------------- diff --git a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/links/DirectedLink.java b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/links/DirectedLink.java index f28fec6..bff9079 100644 --- a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/links/DirectedLink.java +++ b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/links/DirectedLink.java @@ -1,11 +1,14 @@ +/* package org.apache.ariavata.simple.workflow.engine.dag.links; import org.apache.ariavata.simple.workflow.engine.dag.nodes.WorkflowNode; +*/ /** * Created by shameera on 1/29/15. - */ -public class DirectedLink implements Link{ + *//* + +public class DirectedLink implements Edge{ private WorkflowNode _fromNode; @@ -34,3 +37,4 @@ public class DirectedLink implements Link{ this._toNode = _toNode; } } +*/ http://git-wip-us.apache.org/repos/asf/airavata/blob/b338f4ac/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/links/Edge.java ---------------------------------------------------------------------- diff --git a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/links/Edge.java b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/links/Edge.java new file mode 100644 index 0000000..0ef076c --- /dev/null +++ b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/links/Edge.java @@ -0,0 +1,37 @@ +package org.apache.ariavata.simple.workflow.engine.dag.links; + +import org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType; +import org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType; +import org.apache.ariavata.simple.workflow.engine.dag.nodes.WorkflowNode; +import org.apache.ariavata.simple.workflow.engine.dag.port.InPort; +import org.apache.ariavata.simple.workflow.engine.dag.port.OutPort; + +/** + * Created by shameera on 1/29/15. + */ +public interface Edge { + +// public WorkflowNode fromNode(); + +// public WorkflowNode toNode(); + +/* public InputDataObjectType getInputObject(); + + public void setInputObject(); + + public OutputDataObjectType getOutputObject(); + + public void setOutputObject();*/ + + public InPort getInPort(); + + public void setInPort(InPort inPort); + + public OutPort getOutPort(); + + public void setOutPort(OutPort outPort); + + + + +} http://git-wip-us.apache.org/repos/asf/airavata/blob/b338f4ac/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/links/Link.java ---------------------------------------------------------------------- diff --git a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/links/Link.java b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/links/Link.java deleted file mode 100644 index 0406b13..0000000 --- a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/links/Link.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.apache.ariavata.simple.workflow.engine.dag.links; - -import org.apache.ariavata.simple.workflow.engine.dag.nodes.WorkflowNode; - -/** - * Created by shameera on 1/29/15. - */ -public interface Link { - - public WorkflowNode fromNode(); - - public WorkflowNode toNode(); - -} http://git-wip-us.apache.org/repos/asf/airavata/blob/b338f4ac/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/ApplicationNode.java ---------------------------------------------------------------------- diff --git a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/ApplicationNode.java b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/ApplicationNode.java index d0dbf8d..daa0038 100644 --- a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/ApplicationNode.java +++ b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/ApplicationNode.java @@ -1,66 +1,41 @@ -package org.apache.ariavata.simple.workflow.engine.dag.nodes; - -import org.apache.ariavata.simple.workflow.engine.dag.links.Link; - -import java.util.ArrayList; -import java.util.List; - -/** - * Created by shameera on 1/29/15. +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * */ -public class ApplicationNode implements WorkflowNode { - private final String nodeId; - private NodeState myState = NodeState.WAITING; - private List<Link> inputLinks = new ArrayList<Link>(); - private List<Link> outputLinks = new ArrayList<Link>(); - - public ApplicationNode(String nodeId) { - this.nodeId = nodeId; - } - - @Override - public String getNodeId() { - return this.nodeId; - } +package org.apache.ariavata.simple.workflow.engine.dag.nodes; - @Override - public NodeType getNodeType() { - return NodeType.APPLICATION; - } +import org.apache.ariavata.simple.workflow.engine.dag.port.InPort; +import org.apache.ariavata.simple.workflow.engine.dag.port.OutPort; - @Override - public NodeState getNodeState() { - return myState; - } +import java.util.List; - @Override - public void setNodeState(NodeState newNodeState) { - // TODO: node state can't be reversed , correct order WAITING --> READY --> EXECUTING --> EXECUTED --> COMPLETE - myState = newNodeState; - } +public interface ApplicationNode extends WorkflowNode { - public List<Link> getInputLinks() { - return inputLinks; - } + public void addInputPort(InPort inPort); - public List<Link> getOutputLinks() { - return outputLinks; - } + public List<InPort> getInputPorts(); - public void setInputLinks(List<Link> inputLinks) { - this.inputLinks = inputLinks; - } + public void addOutputPort(OutPort outPort); - public void setOutputLinks(List<Link> outputLinks) { - this.outputLinks = outputLinks; - } + public List<OutPort> getOutputPorts(); - public void addInputLink(Link inputLink) { - inputLinks.add(inputLink); - } + public String getApplicationId(); - public void addOutputLink(Link outputLink) { - outputLinks.add(outputLink); - } } http://git-wip-us.apache.org/repos/asf/airavata/blob/b338f4ac/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/ApplicationNodeImpl.java ---------------------------------------------------------------------- diff --git a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/ApplicationNodeImpl.java b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/ApplicationNodeImpl.java new file mode 100644 index 0000000..4f4f6f4 --- /dev/null +++ b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/ApplicationNodeImpl.java @@ -0,0 +1,108 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + *//* + + +package org.apache.ariavata.simple.workflow.engine.dag.nodes; + +import org.apache.ariavata.simple.workflow.engine.dag.links.Edge; +import org.apache.ariavata.simple.workflow.engine.dag.port.InputPort; +import org.apache.ariavata.simple.workflow.engine.dag.port.OutputPort; + +import java.util.ArrayList; +import java.util.List; + +public class ApplicationNodeImpl implements ApplicationNode { + + private final String nodeId; + private NodeState myState = NodeState.WAITING; + private List<Edge> inputLinks = new ArrayList<Edge>(); + private List<Edge> outputLinks = new ArrayList<Edge>(); + + public ApplicationNodeImpl(String nodeId) { + this.nodeId = nodeId; + } + + @Override + public String getNodeId() { + return this.nodeId; + } + + @Override + public NodeType getNodeType() { + return NodeType.APPLICATION; + } + + @Override + public NodeState getNodeState() { + return myState; + } + + @Override + public void setNodeState(NodeState newNodeState) { + // TODO: node state can't be reversed , correct order WAITING --> READY --> EXECUTING --> EXECUTED --> COMPLETE + myState = newNodeState; + } + + @Override + public void addInputPort(InputPort inputPort) { + + } + + @Override + public List<InputPort> getInputPorts() { + return null; + } + + @Override + public void addOutputPort(OutputPort outputPort) { + + } + + @Override + public List<OutputPort> getOutputPorts() { + return null; + } + + public List<Edge> getInputLinks() { + return inputLinks; + } + + public List<Edge> getOutputLinks() { + return outputLinks; + } + + public void setInputLinks(List<Edge> inputLinks) { + this.inputLinks = inputLinks; + } + + public void setOutputLinks(List<Edge> outputLinks) { + this.outputLinks = outputLinks; + } + + public void addInputLink(Edge inputLink) { + inputLinks.add(inputLink); + } + + public void addOutputLink(Edge outputLink) { + outputLinks.add(outputLink); + } +} +*/ http://git-wip-us.apache.org/repos/asf/airavata/blob/b338f4ac/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/NodeState.java ---------------------------------------------------------------------- diff --git a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/NodeState.java b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/NodeState.java index 1442c80..088336b 100644 --- a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/NodeState.java +++ b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/NodeState.java @@ -1,12 +1,34 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + package org.apache.ariavata.simple.workflow.engine.dag.nodes; -/** - * Created by shameera on 1/29/15. - */ public enum NodeState { WAITING, // waiting on inputs READY, // all inputs are available and ready to execute + QUEUED, // + PRE_PROCESSING, // EXECUTING, // task has been submitted , not yet finish EXECUTED, // task executed + POST_PROCESSING, // + FAILED, COMPLETE // all works done } http://git-wip-us.apache.org/repos/asf/airavata/blob/b338f4ac/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowInputNode.java ---------------------------------------------------------------------- diff --git a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowInputNode.java b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowInputNode.java index 8f29f5d..42fa18c 100644 --- a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowInputNode.java +++ b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowInputNode.java @@ -1,35 +1,41 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + package org.apache.ariavata.simple.workflow.engine.dag.nodes; -/** - * Created by shameera on 1/29/15. - */ -public class WorkflowInputNode implements WorkflowNode { - - private NodeState myState = NodeState.READY; - private final String nodeId; - - public WorkflowInputNode(String nodeId) { - this.nodeId = nodeId; - } - - @Override - public String getNodeId() { - return null; - } - - @Override - public NodeType getNodeType() { - return NodeType.WORKFLOW_INPUT; - } - - @Override - public NodeState getNodeState() { - return myState; - } - - @Override - public void setNodeState(NodeState newNodeState) { - // TODO: node state can't be reversed , correct order WAITING --> READY --> EXECUTING --> EXECUTED --> COMPLETE - myState = newNodeState; - } +import org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType; +import org.apache.ariavata.simple.workflow.engine.dag.links.Edge; + +import java.util.List; + +public interface WorkflowInputNode extends WorkflowNode { + + public InputDataObjectType getInputObject(); + + public void setInputObject(InputDataObjectType inputObject); + + public void addOutputLink(Edge outputEdge); + + public void addOutputLink(List<Edge> outputEdges); + + public List<Edge> getOutputLinks(); + } http://git-wip-us.apache.org/repos/asf/airavata/blob/b338f4ac/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowInputNodeImpl.java ---------------------------------------------------------------------- diff --git a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowInputNodeImpl.java b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowInputNodeImpl.java new file mode 100644 index 0000000..54ea438 --- /dev/null +++ b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowInputNodeImpl.java @@ -0,0 +1,81 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + *//* + + +package org.apache.ariavata.simple.workflow.engine.dag.nodes; + +import org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType; +import org.apache.ariavata.simple.workflow.engine.dag.port.OutputPort; + +import java.util.List; + +public class WorkflowInputNodeImpl implements WorkflowInputNode { + + private NodeState myState = NodeState.READY; + private final String nodeId; + + public WorkflowInputNodeImpl(String nodeId) { + this.nodeId = nodeId; + } + + @Override + public String getNodeId() { + return null; + } + + @Override + public NodeType getNodeType() { + return NodeType.WORKFLOW_INPUT; + } + + @Override + public NodeState getNodeState() { + return myState; + } + + @Override + public void setNodeState(NodeState newNodeState) { + // TODO: node state can't be reversed , correct order WAITING --> READY --> EXECUTING --> EXECUTED --> COMPLETE + myState = newNodeState; + } + + @Override + public boolean isSatisfy() { + return false; // TODO: Auto generated method body. + } + + @Override + public InputDataObjectType getInputObject() { + return null; // TODO: Auto generated method body. + } + + @Override + public void addOutputPort(OutputPort outputPort) { + // TODO: Auto generated method body. + } + + @Override + public List<OutputPort> getOutputPorts() { + return null; // TODO: Auto generated method body. + } + +} +*/ http://git-wip-us.apache.org/repos/asf/airavata/blob/b338f4ac/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowNode.java ---------------------------------------------------------------------- diff --git a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowNode.java b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowNode.java index b2ba704..043f6cb 100644 --- a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowNode.java +++ b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowNode.java @@ -1,16 +1,38 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + package org.apache.ariavata.simple.workflow.engine.dag.nodes; -/** - * Created by shameera on 1/29/15. - */ public interface WorkflowNode { public String getNodeId(); + public String getNodeName(); + public NodeType getNodeType(); public NodeState getNodeState(); public void setNodeState(NodeState newNodeState); + public boolean isSatisfy(); + } http://git-wip-us.apache.org/repos/asf/airavata/blob/b338f4ac/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowOutputNode.java ---------------------------------------------------------------------- diff --git a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowOutputNode.java b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowOutputNode.java index 54f93b4..6ace5d5 100644 --- a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowOutputNode.java +++ b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowOutputNode.java @@ -1,36 +1,33 @@ -package org.apache.ariavata.simple.workflow.engine.dag.nodes; - -/** - * Created by shameera on 1/29/15. +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * */ -public class WorkflowOutputNode implements WorkflowNode { - private NodeState myState = NodeState.WAITING; - private final String nodeId; - - public WorkflowOutputNode(String nodeId) { - this.nodeId = nodeId; - } +package org.apache.ariavata.simple.workflow.engine.dag.nodes; - @Override - public String getNodeId() { - return null; - } +import org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType; +import org.apache.ariavata.simple.workflow.engine.dag.links.Edge; - @Override - public NodeType getNodeType() { - return NodeType.WORKFLOW_OUTPUT; - } +public interface WorkflowOutputNode extends WorkflowNode { - @Override - public NodeState getNodeState() { - return myState; - } + public OutputDataObjectType getOutputObject(); - @Override - public void setNodeState(NodeState newNodeState) { - // TODO: node state can't be reversed , correct order WAITING --> READY --> EXECUTING --> EXECUTED --> COMPLETE - myState = newNodeState; - } + public Edge getInputLink(); } http://git-wip-us.apache.org/repos/asf/airavata/blob/b338f4ac/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowOutputNodeImpl.java ---------------------------------------------------------------------- diff --git a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowOutputNodeImpl.java b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowOutputNodeImpl.java new file mode 100644 index 0000000..5978884 --- /dev/null +++ b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowOutputNodeImpl.java @@ -0,0 +1,75 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + *//* + + +package org.apache.ariavata.simple.workflow.engine.dag.nodes; + +import org.apache.ariavata.simple.workflow.engine.dag.port.InputPort; + +import java.util.List; + +public class WorkflowOutputNodeImpl implements WorkflowOutputNode { + + private NodeState myState = NodeState.WAITING; + private final String nodeId; + + public WorkflowOutputNodeImpl(String nodeId) { + this.nodeId = nodeId; + } + + @Override + public String getNodeId() { + return null; + } + + @Override + public NodeType getNodeType() { + return NodeType.WORKFLOW_OUTPUT; + } + + @Override + public NodeState getNodeState() { + return myState; + } + + @Override + public void setNodeState(NodeState newNodeState) { + // TODO: node state can't be reversed , correct order WAITING --> READY --> EXECUTING --> EXECUTED --> COMPLETE + myState = newNodeState; + } + + @Override + public boolean isSatisfy() { + return false; // TODO: Auto generated method body. + } + + @Override + public void addInputPort(InputPort inputPort) { + + } + + @Override + public List<InputPort> getInputPorts() { + return null; + } + +} +*/ http://git-wip-us.apache.org/repos/asf/airavata/blob/b338f4ac/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/port/InPort.java ---------------------------------------------------------------------- diff --git a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/port/InPort.java b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/port/InPort.java new file mode 100644 index 0000000..263ccdd --- /dev/null +++ b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/port/InPort.java @@ -0,0 +1,36 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +package org.apache.ariavata.simple.workflow.engine.dag.port; + +import org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType; +import org.apache.ariavata.simple.workflow.engine.dag.links.Edge; + +public interface InPort extends Port { + + public void setInputObject(InputDataObjectType inputObject); + + public InputDataObjectType getInputObject(); + + public Edge getInputLink(); + + public void setInputLink(); +} http://git-wip-us.apache.org/repos/asf/airavata/blob/b338f4ac/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/port/InputPortIml.java ---------------------------------------------------------------------- diff --git a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/port/InputPortIml.java b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/port/InputPortIml.java new file mode 100644 index 0000000..59f64bd --- /dev/null +++ b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/port/InputPortIml.java @@ -0,0 +1,44 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + *//* + + +package org.apache.ariavata.simple.workflow.engine.dag.port; + +import org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType; +import org.apache.ariavata.simple.workflow.engine.dag.links.Edge; + +public class InputPortIml implements InputPort { + @Override + public InputDataObjectType getInputObject() { + return null; + } + + @Override + public Edge getInputLink() { + return null; + } + + @Override + public boolean isSatisfy() { + return false; + } +} +*/ http://git-wip-us.apache.org/repos/asf/airavata/blob/b338f4ac/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/port/OutPort.java ---------------------------------------------------------------------- diff --git a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/port/OutPort.java b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/port/OutPort.java new file mode 100644 index 0000000..0f0b1e1 --- /dev/null +++ b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/port/OutPort.java @@ -0,0 +1,39 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +package org.apache.ariavata.simple.workflow.engine.dag.port; + +import org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType; +import org.apache.ariavata.simple.workflow.engine.dag.links.Edge; + +import java.util.List; + +public interface OutPort extends Port { + + public void setOutputObject(OutputDataObjectType outputObject); + + public OutputDataObjectType getOutputObject(); + + public List<Edge> getOutputLinks(); + + public void addOutputLink(); + +} http://git-wip-us.apache.org/repos/asf/airavata/blob/b338f4ac/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/port/Port.java ---------------------------------------------------------------------- diff --git a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/port/Port.java b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/port/Port.java new file mode 100644 index 0000000..ca8246a --- /dev/null +++ b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/port/Port.java @@ -0,0 +1,31 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +package org.apache.ariavata.simple.workflow.engine.dag.port; + +import org.apache.ariavata.simple.workflow.engine.dag.nodes.WorkflowNode; + +public interface Port { + + public boolean isSatisfy(); + + public WorkflowNode getNode(); +}
