You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@taverna.apache.org by re...@apache.org on 2015/03/23 17:38:32 UTC
[48/51] [partial] incubator-taverna-engine git commit:
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/ExecutionService.java
----------------------------------------------------------------------
diff --git a/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/ExecutionService.java b/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/ExecutionService.java
new file mode 100755
index 0000000..f0c58b3
--- /dev/null
+++ b/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/ExecutionService.java
@@ -0,0 +1,148 @@
+/*
+* 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.taverna.platform.execution.api;
+
+import java.util.Set;
+
+import org.apache.taverna.robundle.Bundle;
+
+import org.apache.taverna.platform.report.WorkflowReport;
+import org.apache.taverna.scufl2.api.container.WorkflowBundle;
+import org.apache.taverna.scufl2.api.core.Workflow;
+import org.apache.taverna.scufl2.api.profiles.Profile;
+
+/**
+ * Service for executing Taverna workflows. There may be several <code>ExecutionService</code>s
+ * available that offer different execution environments, e.g. one <code>ExecutionService</code> may
+ * execute workflows on a remote server while another executes workflows on the local machine.
+ *
+ * @author David Withers
+ */
+public interface ExecutionService {
+
+ /**
+ * Returns the identifier for this ExecutionService.
+ *
+ * @return the identifier for this ExecutionService
+ */
+ public String getID();
+
+ /**
+ * Returns the name of this ExecutionService.
+ *
+ * @return the name of this ExecutionService
+ */
+ public String getName();
+
+ /**
+ * Returns a description of this ExecutionService.
+ *
+ * @return a description of this ExecutionService
+ */
+ public String getDescription();
+
+ /**
+ * Returns the ExecutionEnvironments available for this ExecutionService.
+ *
+ * @return the ExecutionEnvironments available for this ExecutionService
+ */
+ public Set<ExecutionEnvironment> getExecutionEnvironments();
+
+ /**
+ * Creates a workflow execution and returns its ID.
+ *
+ * @param executionEnvironment
+ * the {@link ExecutionEnvironment} used to execute the
+ * <code>Workflow</code>
+ * @param workflowBundle
+ * the <code>WorkflowBundle</code> containing the workflows required for execution
+ * @param workflow
+ * the workflow to execute
+ * @param profile
+ * the profile to use when executing the workflow
+ * @param dataBundle
+ * the <code>Bundle</code> containing the data values for the <code>Workflow</code>
+ * @return the ID of the created workflow execution
+ * @throws InvalidWorkflowException
+ */
+ public String createExecution(ExecutionEnvironment executionEnvironment, WorkflowBundle workflowBundle, Workflow workflow, Profile profile,
+ Bundle dataBundle)
+ throws InvalidWorkflowException;
+
+ /**
+ * Returns the workflow report for the specified execution.
+ *
+ * @param executionID
+ * the ID of the execution
+ * @return the workflow report for this execution
+ */
+ public WorkflowReport getWorkflowReport(String executionID) throws InvalidExecutionIdException;
+
+ /**
+ * Deletes the execution of a workflow.
+ *
+ * @param executionID
+ * the ID of the execution to delete
+ * @throws InvalidExecutionIdException
+ * if the execution ID is not valid
+ */
+ public void delete(String executionID) throws InvalidExecutionIdException;
+
+ /**
+ * Starts the execution of a workflow.
+ *
+ * @param executionID
+ * the ID of the execution to start
+ * @throws InvalidExecutionIdException
+ * if the execution ID is not valid
+ */
+ public void start(String executionID) throws InvalidExecutionIdException;
+
+ /**
+ * Pauses the execution of a workflow.
+ *
+ * @param executionID
+ * the ID of the execution to pause
+ * @throws InvalidExecutionIdException
+ * if the execution ID is not valid
+ */
+ public void pause(String executionID) throws InvalidExecutionIdException;
+
+ /**
+ * Resumes the execution of a paused workflow.
+ *
+ * @param executionID
+ * the ID of the execution to resume
+ * @throws InvalidExecutionIdException
+ * if the execution ID is not valid
+ */
+ public void resume(String executionID) throws InvalidExecutionIdException;
+
+ /**
+ * Cancels the execution of a workflow.
+ *
+ * @param executionID
+ * the ID of the execution to cancel
+ * @throws InvalidExecutionIdException
+ * if the execution ID is not valid
+ */
+ public void cancel(String executionID) throws InvalidExecutionIdException;
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/InvalidExecutionIdException.java
----------------------------------------------------------------------
diff --git a/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/InvalidExecutionIdException.java b/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/InvalidExecutionIdException.java
new file mode 100644
index 0000000..09e2a57
--- /dev/null
+++ b/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/InvalidExecutionIdException.java
@@ -0,0 +1,47 @@
+/*
+* 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.taverna.platform.execution.api;
+
+/**
+ * Thrown when an executionID is not valid for an ExecutionService.
+ *
+ * @author David Withers
+ */
+public class InvalidExecutionIdException extends Exception {
+
+ private static final long serialVersionUID = 4086661335641172903L;
+
+ public InvalidExecutionIdException() {
+ super();
+ }
+
+ public InvalidExecutionIdException(String message) {
+ super(message);
+ }
+
+ public InvalidExecutionIdException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InvalidExecutionIdException(Throwable cause) {
+ super(cause);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/InvalidWorkflowException.java
----------------------------------------------------------------------
diff --git a/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/InvalidWorkflowException.java b/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/InvalidWorkflowException.java
new file mode 100644
index 0000000..6b74bae
--- /dev/null
+++ b/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/InvalidWorkflowException.java
@@ -0,0 +1,47 @@
+/*
+* 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.taverna.platform.execution.api;
+
+/**
+ * Thrown when a Workflow fails to validate.
+ *
+ * @author David Withers
+ */
+public class InvalidWorkflowException extends Exception {
+
+ private static final long serialVersionUID = 7491175798204912590L;
+
+ public InvalidWorkflowException() {
+ super();
+ }
+
+ public InvalidWorkflowException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InvalidWorkflowException(String message) {
+ super(message);
+ }
+
+ public InvalidWorkflowException(Throwable cause) {
+ super(cause);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/WorkflowCompiler.java
----------------------------------------------------------------------
diff --git a/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/WorkflowCompiler.java b/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/WorkflowCompiler.java
new file mode 100644
index 0000000..e63c49a
--- /dev/null
+++ b/taverna-execution-api/src/main/java/org/apache/taverna/platform/execution/api/WorkflowCompiler.java
@@ -0,0 +1,55 @@
+/*
+* 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.taverna.platform.execution.api;
+
+import org.apache.taverna.workflowmodel.Dataflow;
+import org.apache.taverna.scufl2.api.container.WorkflowBundle;
+import org.apache.taverna.scufl2.api.core.Workflow;
+
+/**
+ * A workflow compilation service converts a workflow (in a
+ * {@link WorkflowBundle}) into a dataflow. Most code should ignore this.
+ *
+ * @author Donal Fellows
+ */
+public interface WorkflowCompiler {
+ /**
+ * Convert a workflow into a dataflow. May cache.
+ *
+ * @param workflow
+ * the workflow to convert; must not be <tt>null</tt>
+ * @return the dataflow, which should not be modified.
+ * @throws InvalidWorkflowException
+ * If the compilation fails.
+ */
+ Dataflow getDataflow(Workflow workflow) throws InvalidWorkflowException;
+
+ /**
+ * Convert a workflow bundle into a dataflow. May cache. Only the the
+ * primary workflow is guaranteed to be converted.
+ *
+ * @param bundle
+ * the workflow bundle to convert; must not be <tt>null</tt>
+ * @return the dataflow, which should not be modified.
+ * @throws InvalidWorkflowException
+ * If the compilation fails.
+ */
+ Dataflow getDataflow(WorkflowBundle bundle) throws InvalidWorkflowException;
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/AbstractExecution.java
----------------------------------------------------------------------
diff --git a/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/AbstractExecution.java b/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/AbstractExecution.java
deleted file mode 100644
index 5688460..0000000
--- a/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/AbstractExecution.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.execution.api;
-
-import java.util.UUID;
-
-import org.apache.taverna.robundle.Bundle;
-
-import uk.org.taverna.platform.report.ActivityReport;
-import uk.org.taverna.platform.report.ProcessorReport;
-import uk.org.taverna.platform.report.WorkflowReport;
-import org.apache.taverna.scufl2.api.activity.Activity;
-import org.apache.taverna.scufl2.api.common.Scufl2Tools;
-import org.apache.taverna.scufl2.api.container.WorkflowBundle;
-import org.apache.taverna.scufl2.api.core.Processor;
-import org.apache.taverna.scufl2.api.core.Workflow;
-import org.apache.taverna.scufl2.api.profiles.ProcessorBinding;
-import org.apache.taverna.scufl2.api.profiles.Profile;
-
-/**
- * Abstract implementation of an {@link Execution}.
- *
- * @author David Withers
- */
-public abstract class AbstractExecution implements Execution {
-
- private final String ID;
- private final WorkflowBundle workflowBundle;
- private final Bundle dataBundle;
- private final Workflow workflow;
- private final Profile profile;
- private final WorkflowReport workflowReport;
-
- private final Scufl2Tools scufl2Tools = new Scufl2Tools();
-
- /**
- * Constructs an abstract implementation of an Execution.
- *
- * @param workflowBundle
- * the <code>WorkflowBundle</code> containing the <code>Workflow</code>s required for
- * execution
- * @param workflow
- * the <code>Workflow</code> to execute
- * @param profile
- * the <code>Profile</code> to use when executing the <code>Workflow</code>
- * @param dataBundle
- * the <code>Bundle</code> containing the data values for the <code>Workflow</code>
- * @throws InvalidWorkflowException
- * if the specified workflow is invalid
- */
- public AbstractExecution(WorkflowBundle workflowBundle, Workflow workflow, Profile profile,
- Bundle dataBundle) {
- this.workflowBundle = workflowBundle;
- this.workflow = workflow;
- this.profile = profile;
- this.dataBundle = dataBundle;
- ID = UUID.randomUUID().toString();
- workflowReport = generateWorkflowReport(workflow);
- }
-
- protected abstract WorkflowReport createWorkflowReport(Workflow workflow);
-
- protected abstract ProcessorReport createProcessorReport(Processor processor);
-
- protected abstract ActivityReport createActivityReport(Activity activity);
-
- public WorkflowReport generateWorkflowReport(Workflow workflow) {
- WorkflowReport workflowReport = createWorkflowReport(workflow);
- for (Processor processor : workflow.getProcessors()) {
- ProcessorReport processorReport = createProcessorReport(processor);
- processorReport.setParentReport(workflowReport);
- workflowReport.addProcessorReport(processorReport);
- for (ProcessorBinding processorBinding : scufl2Tools.processorBindingsForProcessor(
- processor, profile)) {
- Activity boundActivity = processorBinding.getBoundActivity();
- ActivityReport activityReport = createActivityReport(boundActivity);
- activityReport.setParentReport(processorReport);
- if (scufl2Tools.containsNestedWorkflow(processor, profile)) {
- Workflow nestedWorkflow = scufl2Tools.nestedWorkflowForProcessor(processor,
- profile);
- WorkflowReport nestedWorkflowReport = generateWorkflowReport(nestedWorkflow);
- nestedWorkflowReport.setParentReport(activityReport);
- activityReport.setNestedWorkflowReport(nestedWorkflowReport);
- }
- processorReport.addActivityReport(activityReport);
- }
- }
- return workflowReport;
- }
-
- @Override
- public String getID() {
- return ID;
- }
-
- @Override
- public WorkflowBundle getWorkflowBundle() {
- return workflowBundle;
- }
-
- @Override
- public Bundle getDataBundle() {
- return dataBundle;
- }
-
- @Override
- public Workflow getWorkflow() {
- return workflow;
- }
-
- @Override
- public Profile getProfile() {
- return profile;
- }
-
- @Override
- public WorkflowReport getWorkflowReport() {
- return workflowReport;
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/AbstractExecutionEnvironment.java
----------------------------------------------------------------------
diff --git a/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/AbstractExecutionEnvironment.java b/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/AbstractExecutionEnvironment.java
deleted file mode 100644
index a6475e5..0000000
--- a/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/AbstractExecutionEnvironment.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2011 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.execution.api;
-
-import java.net.URI;
-
-/**
- * A common super type for concrete implementations of <code>ExecutionEnvironment</code>s.
- *
- * @author David Withers
- */
-public abstract class AbstractExecutionEnvironment implements ExecutionEnvironment {
- private final String ID;
- private final String name;
- private final String description;
- private final ExecutionService executionService;
-
- public AbstractExecutionEnvironment(String ID, String name, String description,
- ExecutionService executionService) {
- this.ID = ID;
- this.name = name;
- this.description = description;
- this.executionService = executionService;
- }
-
- @Override
- public String getID() {
- return ID;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public String getDescription() {
- return description;
- }
-
- @Override
- public ExecutionService getExecutionService() {
- return executionService;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append(ID + "\n");
- sb.append(name + "\n");
- sb.append(description + "\n");
- sb.append("Activities : \n");
- for (URI uri : getActivityTypes())
- sb.append(" " + uri + "\n");
- sb.append("Dispatch Layers : \n");
- for (URI uri : getDispatchLayerTypes())
- sb.append(" " + uri + "\n");
- return sb.toString();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/AbstractExecutionService.java
----------------------------------------------------------------------
diff --git a/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/AbstractExecutionService.java b/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/AbstractExecutionService.java
deleted file mode 100755
index 18b5a09..0000000
--- a/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/AbstractExecutionService.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.execution.api;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.taverna.robundle.Bundle;
-
-import uk.org.taverna.platform.report.WorkflowReport;
-import org.apache.taverna.scufl2.api.container.WorkflowBundle;
-import org.apache.taverna.scufl2.api.core.Workflow;
-import org.apache.taverna.scufl2.api.profiles.Profile;
-
-/**
- * A common super type for concrete implementations of <code>ExecutionService</code>s.
- *
- * @author David Withers
- */
-public abstract class AbstractExecutionService implements ExecutionService {
- private final String ID;
- private final String name;
- private final String description;
- private final Map<String, Execution> executionMap;
-
- public AbstractExecutionService(String ID, String name, String description) {
- this.ID = ID;
- this.name = name;
- this.description = description;
- executionMap = Collections.synchronizedMap(new HashMap<String, Execution>());
- }
-
- @Override
- public String getID() {
- return ID;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public String getDescription() {
- return description;
- }
-
- @Override
- public String createExecution(ExecutionEnvironment executionEnvironment,
- WorkflowBundle workflowBundle, Workflow workflow, Profile profile,
- Bundle dataBundle) throws InvalidWorkflowException {
- Execution execution = createExecutionImpl(workflowBundle, workflow, profile, dataBundle);
- executionMap.put(execution.getID(), execution);
- return execution.getID();
- }
-
- /**
- * Creates an implementation of an Execution.
- *
- * To be implemented by concrete implementations of <code>ExecutionService</code>.
- *
- * @param workflowBundle
- * the <code>WorkflowBundle</code> containing the <code>Workflow</code>s required for
- * execution
- * @param workflow
- * the <code>Workflow</code> to execute
- * @param profile
- * the <code>Profile</code> to use when executing the <code>Workflow</code>
- * @param dataBundle
- * the <code>Bundle</code> containing the data values for the <code>Workflow</code>
- * @return a new Execution implementation
- * @throws InvalidWorkflowException
- * if the specified workflow is invalid
- */
- protected abstract Execution createExecutionImpl(
- WorkflowBundle workflowBundle, Workflow workflow, Profile profile,
- Bundle dataBundle) throws InvalidWorkflowException;
-
- @Override
- public WorkflowReport getWorkflowReport(String executionID)
- throws InvalidExecutionIdException {
- return getExecution(executionID).getWorkflowReport();
- }
-
- @Override
- public void delete(String executionID) throws InvalidExecutionIdException {
- getExecution(executionID).delete();
- executionMap.remove(executionID);
- }
-
- @Override
- public void start(String executionID) throws InvalidExecutionIdException {
- getExecution(executionID).start();
- }
-
- @Override
- public void pause(String executionID) throws InvalidExecutionIdException {
- getExecution(executionID).pause();
- }
-
- @Override
- public void resume(String executionID) throws InvalidExecutionIdException {
- getExecution(executionID).resume();
- }
-
- @Override
- public void cancel(String executionID) throws InvalidExecutionIdException {
- getExecution(executionID).cancel();
- }
-
- protected Execution getExecution(String executionID)
- throws InvalidExecutionIdException {
- Execution execution = executionMap.get(executionID);
- if (execution == null)
- throw new InvalidExecutionIdException("Execution ID " + executionID
- + " is not valid");
- return execution;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/Execution.java
----------------------------------------------------------------------
diff --git a/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/Execution.java b/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/Execution.java
deleted file mode 100644
index 6f12edd..0000000
--- a/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/Execution.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.execution.api;
-
-import org.apache.taverna.robundle.Bundle;
-
-import uk.org.taverna.platform.report.WorkflowReport;
-import org.apache.taverna.scufl2.api.container.WorkflowBundle;
-import org.apache.taverna.scufl2.api.core.Workflow;
-import org.apache.taverna.scufl2.api.profiles.Profile;
-
-/**
- * Interface for a single execution of a Taverna workflow.
- *
- * @author David Withers
- */
-public interface Execution {
-
- /**
- * Returns the identifier for this execution.
- *
- * @return the identifier for this execution
- */
- public abstract String getID();
-
- /**
- * Returns the <code>WorkflowBundle</code> containing the <code>Workflow</code>s required for execution.
- *
- * @return the <code>WorkflowBundle</code> containing the <code>Workflow</code>s required for execution
- */
- public abstract WorkflowBundle getWorkflowBundle();
-
- /**
- * Returns the <code>Bundle</code> containing the data values for the <code>Workflow</code>.
- *
- * @return the <code>Bundle</code> containing the data values for the <code>Workflow</code>
- */
- public abstract Bundle getDataBundle();
-
- /**
- * Returns the <code>Workflow</code> to execute.
- *
- * @return the <code>Workflow</code> to execute
- */
- public abstract Workflow getWorkflow();
-
- /**
- * Returns the <code>Profile</code> to use when executing the <code>Workflow</code>.
- *
- * @return the <code>Profile</code> to use when executing the <code>Workflow</code>
- */
- public abstract Profile getProfile();
-
- /**
- * Returns the <code>WorkflowReport</code> for the execution.
- *
- * @return the <code>WorkflowReport</code> for the execution
- */
- public abstract WorkflowReport getWorkflowReport();
-
- /**
- * Deletes the execution.
- */
- public abstract void delete();
-
- /**
- * Starts the execution.
- */
- public abstract void start();
-
- /**
- * Pauses the execution.
- */
- public abstract void pause();
-
- /**
- * Resumes a paused execution.
- */
- public abstract void resume();
-
- /**
- * Cancels the execution.
- */
- public abstract void cancel();
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/ExecutionEnvironment.java
----------------------------------------------------------------------
diff --git a/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/ExecutionEnvironment.java b/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/ExecutionEnvironment.java
deleted file mode 100644
index a61e68d..0000000
--- a/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/ExecutionEnvironment.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2011 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.execution.api;
-
-import java.net.URI;
-import java.util.Set;
-
-import org.apache.taverna.platform.capability.api.ActivityConfigurationException;
-import org.apache.taverna.platform.capability.api.ActivityNotFoundException;
-import org.apache.taverna.platform.capability.api.DispatchLayerConfigurationException;
-import org.apache.taverna.platform.capability.api.DispatchLayerNotFoundException;
-
-import com.fasterxml.jackson.databind.JsonNode;
-
-/**
- * The ExecutionEnvironment specifies the capabilities of a workflow execution environment.
- *
- * @author David Withers
- */
-public interface ExecutionEnvironment {
-
- /**
- * Returns the identifier for this ExecutionEnvironment.
- *
- * @return the identifier for this ExecutionEnvironment
- */
- public String getID();
-
- /**
- * Returns the name of this ExecutionEnvironment.
- *
- * @return the name of this ExecutionEnvironment
- */
- public String getName();
-
- /**
- * Returns a description of this ExecutionEnvironment.
- *
- * @return a description of this ExecutionEnvironment
- */
- public String getDescription();
-
- /**
- * Returns the ExecutionService that provides this ExecutionEnvironment.
- *
- * @return the ExecutionService that provides this ExecutionEnvironment
- */
- public ExecutionService getExecutionService();
-
- /**
- * Returns the activity types available in this ExecutionEnvironment.
- *
- * @return the activity types available in this ExecutionEnvironment
- */
- public Set<URI> getActivityTypes();
-
- /**
- * Returns true iff an activity exists for the specified URI in this ExecutionEnvironment.
- *
- * @param uri
- * the activity URI to check
- * @return true if an activity exists for the specified URI in this ExecutionEnvironment
- */
- public boolean activityExists(URI uri);
-
- /**
- * Returns a JSON Schema for the configuration required by an activity.
- *
- * @param uri
- * a URI that identifies an activity
- * @return a JSON Schema for the configuration required by an activity
- * @throws ActivityNotFoundException
- * if an activity cannot be found for the specified URI
- * @throws ActivityConfigurationException
- * if the ConfigurationDefinition cannot be created
- */
- public JsonNode getActivityConfigurationSchema(URI uri)
- throws ActivityNotFoundException, ActivityConfigurationException;
-
- /**
- * Returns the dispatch layer types available in this ExecutionEnvironment.
- *
- * @return the dispatch layer types available in this ExecutionEnvironment
- */
- public Set<URI> getDispatchLayerTypes();
-
- /**
- * Returns true iff a dispatch layer exists for the specified URI in this ExecutionEnvironment.
- *
- * @param uri
- * the dispatch layer URI to check
- * @return true if a dispatch layer exists for the specified URI in this ExecutionEnvironment
- */
- public boolean dispatchLayerExists(URI uri);
-
- /**
- * Returns a JSON Schema for the configuration required by a dispatch layer.
- *
- * @param uri
- * a URI that identifies a dispatch layer
- * @return
- * @return a JSON Schema for the configuration required by a dispatch layer
- * @throws DispatchLayerNotFoundException
- * if a dispatch layer cannot be found for the specified URI
- * @throws DispatchLayerConfigurationException
- * if the ConfigurationDefinition cannot be created
- */
- public JsonNode getDispatchLayerConfigurationSchema(URI uri)
- throws DispatchLayerNotFoundException, DispatchLayerConfigurationException;
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/ExecutionEnvironmentService.java
----------------------------------------------------------------------
diff --git a/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/ExecutionEnvironmentService.java b/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/ExecutionEnvironmentService.java
deleted file mode 100644
index 9f0b5fd..0000000
--- a/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/ExecutionEnvironmentService.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2011 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.execution.api;
-
-import java.util.Set;
-
-import org.apache.taverna.scufl2.api.profiles.Profile;
-
-/**
- * Service for finding <code>ExecutionEnvironment</code>s.
- *
- * @author David Withers
- */
-public interface ExecutionEnvironmentService {
-
- /**
- * Returns the available <code>ExecutionEnvironment</code>s.
- *
- * @return the available <code>ExecutionEnvironment</code>s
- */
- public Set<ExecutionEnvironment> getExecutionEnvironments();
-
- /**
- * Returns the <code>ExecutionEnvironment</code>s that can execute the specified
- * <code>Profile</code>.
- *
- * @param profile
- * the <code>Profile</code> to find <code>ExecutionEnvironment</code>s for
- * @return the <code>ExecutionEnvironment</code>s that can execute a workflow with the specified
- * <code>Profile</code>
- */
- public Set<ExecutionEnvironment> getExecutionEnvironments(Profile profile);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/ExecutionService.java
----------------------------------------------------------------------
diff --git a/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/ExecutionService.java b/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/ExecutionService.java
deleted file mode 100755
index 0f73ab3..0000000
--- a/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/ExecutionService.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.execution.api;
-
-import java.util.Set;
-
-import org.apache.taverna.robundle.Bundle;
-
-import uk.org.taverna.platform.report.WorkflowReport;
-import org.apache.taverna.scufl2.api.container.WorkflowBundle;
-import org.apache.taverna.scufl2.api.core.Workflow;
-import org.apache.taverna.scufl2.api.profiles.Profile;
-
-/**
- * Service for executing Taverna workflows. There may be several <code>ExecutionService</code>s
- * available that offer different execution environments, e.g. one <code>ExecutionService</code> may
- * execute workflows on a remote server while another executes workflows on the local machine.
- *
- * @author David Withers
- */
-public interface ExecutionService {
-
- /**
- * Returns the identifier for this ExecutionService.
- *
- * @return the identifier for this ExecutionService
- */
- public String getID();
-
- /**
- * Returns the name of this ExecutionService.
- *
- * @return the name of this ExecutionService
- */
- public String getName();
-
- /**
- * Returns a description of this ExecutionService.
- *
- * @return a description of this ExecutionService
- */
- public String getDescription();
-
- /**
- * Returns the ExecutionEnvironments available for this ExecutionService.
- *
- * @return the ExecutionEnvironments available for this ExecutionService
- */
- public Set<ExecutionEnvironment> getExecutionEnvironments();
-
- /**
- * Creates a workflow execution and returns its ID.
- *
- * @param executionEnvironment
- * the {@link ExecutionEnvironment} used to execute the
- * <code>Workflow</code>
- * @param workflowBundle
- * the <code>WorkflowBundle</code> containing the workflows required for execution
- * @param workflow
- * the workflow to execute
- * @param profile
- * the profile to use when executing the workflow
- * @param dataBundle
- * the <code>Bundle</code> containing the data values for the <code>Workflow</code>
- * @return the ID of the created workflow execution
- * @throws InvalidWorkflowException
- */
- public String createExecution(ExecutionEnvironment executionEnvironment, WorkflowBundle workflowBundle, Workflow workflow, Profile profile,
- Bundle dataBundle)
- throws InvalidWorkflowException;
-
- /**
- * Returns the workflow report for the specified execution.
- *
- * @param executionID
- * the ID of the execution
- * @return the workflow report for this execution
- */
- public WorkflowReport getWorkflowReport(String executionID) throws InvalidExecutionIdException;
-
- /**
- * Deletes the execution of a workflow.
- *
- * @param executionID
- * the ID of the execution to delete
- * @throws InvalidExecutionIdException
- * if the execution ID is not valid
- */
- public void delete(String executionID) throws InvalidExecutionIdException;
-
- /**
- * Starts the execution of a workflow.
- *
- * @param executionID
- * the ID of the execution to start
- * @throws InvalidExecutionIdException
- * if the execution ID is not valid
- */
- public void start(String executionID) throws InvalidExecutionIdException;
-
- /**
- * Pauses the execution of a workflow.
- *
- * @param executionID
- * the ID of the execution to pause
- * @throws InvalidExecutionIdException
- * if the execution ID is not valid
- */
- public void pause(String executionID) throws InvalidExecutionIdException;
-
- /**
- * Resumes the execution of a paused workflow.
- *
- * @param executionID
- * the ID of the execution to resume
- * @throws InvalidExecutionIdException
- * if the execution ID is not valid
- */
- public void resume(String executionID) throws InvalidExecutionIdException;
-
- /**
- * Cancels the execution of a workflow.
- *
- * @param executionID
- * the ID of the execution to cancel
- * @throws InvalidExecutionIdException
- * if the execution ID is not valid
- */
- public void cancel(String executionID) throws InvalidExecutionIdException;
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/InvalidExecutionIdException.java
----------------------------------------------------------------------
diff --git a/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/InvalidExecutionIdException.java b/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/InvalidExecutionIdException.java
deleted file mode 100644
index 9cb8ef2..0000000
--- a/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/InvalidExecutionIdException.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.execution.api;
-
-/**
- * Thrown when an executionID is not valid for an ExecutionService.
- *
- * @author David Withers
- */
-public class InvalidExecutionIdException extends Exception {
-
- private static final long serialVersionUID = 4086661335641172903L;
-
- public InvalidExecutionIdException() {
- super();
- }
-
- public InvalidExecutionIdException(String message) {
- super(message);
- }
-
- public InvalidExecutionIdException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public InvalidExecutionIdException(Throwable cause) {
- super(cause);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/InvalidWorkflowException.java
----------------------------------------------------------------------
diff --git a/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/InvalidWorkflowException.java b/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/InvalidWorkflowException.java
deleted file mode 100644
index b0cc3fa..0000000
--- a/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/InvalidWorkflowException.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.execution.api;
-
-/**
- * Thrown when a Workflow fails to validate.
- *
- * @author David Withers
- */
-public class InvalidWorkflowException extends Exception {
-
- private static final long serialVersionUID = 7491175798204912590L;
-
- public InvalidWorkflowException() {
- super();
- }
-
- public InvalidWorkflowException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public InvalidWorkflowException(String message) {
- super(message);
- }
-
- public InvalidWorkflowException(Throwable cause) {
- super(cause);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/WorkflowCompiler.java
----------------------------------------------------------------------
diff --git a/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/WorkflowCompiler.java b/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/WorkflowCompiler.java
deleted file mode 100644
index a183cd1..0000000
--- a/taverna-execution-api/src/main/java/uk/org/taverna/platform/execution/api/WorkflowCompiler.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package uk.org.taverna.platform.execution.api;
-
-import net.sf.taverna.t2.workflowmodel.Dataflow;
-import org.apache.taverna.scufl2.api.container.WorkflowBundle;
-import org.apache.taverna.scufl2.api.core.Workflow;
-
-/**
- * A workflow compilation service converts a workflow (in a
- * {@link WorkflowBundle}) into a dataflow. Most code should ignore this.
- *
- * @author Donal Fellows
- */
-public interface WorkflowCompiler {
- /**
- * Convert a workflow into a dataflow. May cache.
- *
- * @param workflow
- * the workflow to convert; must not be <tt>null</tt>
- * @return the dataflow, which should not be modified.
- * @throws InvalidWorkflowException
- * If the compilation fails.
- */
- Dataflow getDataflow(Workflow workflow) throws InvalidWorkflowException;
-
- /**
- * Convert a workflow bundle into a dataflow. May cache. Only the the
- * primary workflow is guaranteed to be converted.
- *
- * @param bundle
- * the workflow bundle to convert; must not be <tt>null</tt>
- * @return the dataflow, which should not be modified.
- * @throws InvalidWorkflowException
- * If the compilation fails.
- */
- Dataflow getDataflow(WorkflowBundle bundle) throws InvalidWorkflowException;
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-api/src/test/java/org/apache/taverna/platform/execution/api/AbstractExecutionTest.java
----------------------------------------------------------------------
diff --git a/taverna-execution-api/src/test/java/org/apache/taverna/platform/execution/api/AbstractExecutionTest.java b/taverna-execution-api/src/test/java/org/apache/taverna/platform/execution/api/AbstractExecutionTest.java
new file mode 100644
index 0000000..95a5bca
--- /dev/null
+++ b/taverna-execution-api/src/test/java/org/apache/taverna/platform/execution/api/AbstractExecutionTest.java
@@ -0,0 +1,127 @@
+/*
+* 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.taverna.platform.execution.api;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.apache.taverna.robundle.Bundle;
+
+import org.apache.taverna.databundle.DataBundles;
+import org.apache.taverna.platform.report.ActivityReport;
+import org.apache.taverna.platform.report.ProcessorReport;
+import org.apache.taverna.platform.report.WorkflowReport;
+import org.apache.taverna.scufl2.api.activity.Activity;
+import org.apache.taverna.scufl2.api.container.WorkflowBundle;
+import org.apache.taverna.scufl2.api.core.Processor;
+import org.apache.taverna.scufl2.api.core.Workflow;
+import org.apache.taverna.scufl2.api.profiles.Profile;
+
+/**
+ * @author David Withers
+ */
+@Ignore
+public class AbstractExecutionTest {
+ private WorkflowBundle workflowBundle;
+ private Execution execution;
+ private Workflow workflow;
+ private Profile profile;
+ private Bundle dataBundle;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Before
+ public void setUp() throws Exception {
+ workflowBundle = new WorkflowBundle();
+ workflow = new Workflow();
+ profile = new Profile();
+ dataBundle = DataBundles.createBundle();
+ execution = new AbstractExecution(workflowBundle, workflow, profile, dataBundle) {
+ @Override
+ public void start() {}
+ @Override
+ public void resume() {}
+ @Override
+ public void pause() {}
+ @Override
+ public void cancel() {}
+ @Override
+ public void delete() {}
+ @Override
+ protected WorkflowReport createWorkflowReport(Workflow workflow) {
+ return new WorkflowReport(workflow) {
+ };
+ }
+ @Override
+ public ProcessorReport createProcessorReport(Processor processor) {
+ return null;
+ }
+ @Override
+ public ActivityReport createActivityReport(Activity activity) {
+ return null;
+ }
+ };
+ }
+
+ /**
+ * Test method for {@link uk.org.taverna.platform.execution.api.AbstractExecution#getID()}.
+ */
+ @Test
+ public void testGetID() {
+ assertNotNull(execution.getID());
+ assertEquals(execution.getID(), execution.getID());
+ }
+
+ /**
+ * Test method for {@link uk.org.taverna.platform.execution.api.AbstractExecution#getWorkflowBundle()}.
+ */
+ @Test
+ public void testGetWorkflowBundle() {
+ assertEquals(workflowBundle, execution.getWorkflowBundle());
+ }
+
+ /**
+ * Test method for {@link uk.org.taverna.platform.execution.api.AbstractExecution#getWorkflow()}.
+ */
+ @Test
+ public void testGetWorkflow() {
+ assertEquals(workflow, execution.getWorkflow());
+ }
+
+ /**
+ * Test method for {@link uk.org.taverna.platform.execution.api.AbstractExecution#getInputs()}.
+ */
+ @Test
+ public void testGetInputs() {
+ assertEquals(dataBundle, execution.getDataBundle());
+ }
+
+ /**
+ * Test method for {@link uk.org.taverna.platform.execution.api.AbstractExecution#getWorkflowReport()}.
+ */
+ @Test
+ public void testGetWorkflowReport() {
+ assertNotNull(execution.getWorkflowReport());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-api/src/test/java/uk/org/taverna/platform/execution/api/AbstractExecutionTest.java
----------------------------------------------------------------------
diff --git a/taverna-execution-api/src/test/java/uk/org/taverna/platform/execution/api/AbstractExecutionTest.java b/taverna-execution-api/src/test/java/uk/org/taverna/platform/execution/api/AbstractExecutionTest.java
deleted file mode 100644
index 9b3361e..0000000
--- a/taverna-execution-api/src/test/java/uk/org/taverna/platform/execution/api/AbstractExecutionTest.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2010 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package uk.org.taverna.platform.execution.api;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.apache.taverna.robundle.Bundle;
-
-import org.apache.taverna.databundle.DataBundles;
-import uk.org.taverna.platform.report.ActivityReport;
-import uk.org.taverna.platform.report.ProcessorReport;
-import uk.org.taverna.platform.report.WorkflowReport;
-import org.apache.taverna.scufl2.api.activity.Activity;
-import org.apache.taverna.scufl2.api.container.WorkflowBundle;
-import org.apache.taverna.scufl2.api.core.Processor;
-import org.apache.taverna.scufl2.api.core.Workflow;
-import org.apache.taverna.scufl2.api.profiles.Profile;
-
-/**
- * @author David Withers
- */
-@Ignore
-public class AbstractExecutionTest {
- private WorkflowBundle workflowBundle;
- private Execution execution;
- private Workflow workflow;
- private Profile profile;
- private Bundle dataBundle;
-
- /**
- * @throws java.lang.Exception
- */
- @Before
- public void setUp() throws Exception {
- workflowBundle = new WorkflowBundle();
- workflow = new Workflow();
- profile = new Profile();
- dataBundle = DataBundles.createBundle();
- execution = new AbstractExecution(workflowBundle, workflow, profile, dataBundle) {
- @Override
- public void start() {}
- @Override
- public void resume() {}
- @Override
- public void pause() {}
- @Override
- public void cancel() {}
- @Override
- public void delete() {}
- @Override
- protected WorkflowReport createWorkflowReport(Workflow workflow) {
- return new WorkflowReport(workflow) {
- };
- }
- @Override
- public ProcessorReport createProcessorReport(Processor processor) {
- return null;
- }
- @Override
- public ActivityReport createActivityReport(Activity activity) {
- return null;
- }
- };
- }
-
- /**
- * Test method for {@link uk.org.taverna.platform.execution.api.AbstractExecution#getID()}.
- */
- @Test
- public void testGetID() {
- assertNotNull(execution.getID());
- assertEquals(execution.getID(), execution.getID());
- }
-
- /**
- * Test method for {@link uk.org.taverna.platform.execution.api.AbstractExecution#getWorkflowBundle()}.
- */
- @Test
- public void testGetWorkflowBundle() {
- assertEquals(workflowBundle, execution.getWorkflowBundle());
- }
-
- /**
- * Test method for {@link uk.org.taverna.platform.execution.api.AbstractExecution#getWorkflow()}.
- */
- @Test
- public void testGetWorkflow() {
- assertEquals(workflow, execution.getWorkflow());
- }
-
- /**
- * Test method for {@link uk.org.taverna.platform.execution.api.AbstractExecution#getInputs()}.
- */
- @Test
- public void testGetInputs() {
- assertEquals(dataBundle, execution.getDataBundle());
- }
-
- /**
- * Test method for {@link uk.org.taverna.platform.execution.api.AbstractExecution#getWorkflowReport()}.
- */
- @Test
- public void testGetWorkflowReport() {
- assertNotNull(execution.getWorkflowReport());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/CrossProductInputFormat.java
----------------------------------------------------------------------
diff --git a/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/CrossProductInputFormat.java b/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/CrossProductInputFormat.java
new file mode 100644
index 0000000..d130cd3
--- /dev/null
+++ b/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/CrossProductInputFormat.java
@@ -0,0 +1,107 @@
+/*
+* 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.taverna.platform.execution.impl.hadoop;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.fs.BlockLocation;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.PathFilter;
+import org.apache.hadoop.io.ArrayWritable;
+import org.apache.hadoop.io.MapWritable;
+import org.apache.hadoop.io.Text;
+import org.apache.hadoop.mapreduce.InputSplit;
+import org.apache.hadoop.mapreduce.JobContext;
+import org.apache.hadoop.mapreduce.RecordReader;
+import org.apache.hadoop.mapreduce.TaskAttemptContext;
+import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
+
+/**
+ * An input format that receives an input directory containing a number of directories with input files
+ * for each input port to a Taverna processor/activity that will be executed as part of this
+ * MapReduce job. Mapping between directory name -> Taverna processor/activity input port name
+ * is carried in the job's Context.
+ *
+ * @author Alex Nenadic
+ *
+ */
+public class CrossProductInputFormat extends
+ FileInputFormat<Text, TextArrayWritable> {
+
+ private static final Log Logger = LogFactory.getLog(CrossProductInputFormat.class);
+
+ // Do not split files into blocks
+ @Override
+ protected boolean isSplitable(JobContext context, Path filename) {
+ return false;
+ }
+
+ @Override
+ public RecordReader<Text, TextArrayWritable> createRecordReader(
+ InputSplit split, TaskAttemptContext context) {
+ return new CrossProductRecordReader();
+ }
+
+ @Override
+ public List<InputSplit> getSplits(JobContext job) throws IOException {
+
+ // Generate splits. Split is a list of directories where each directory
+ // contains inputs for one input port of the Taverna processor/activity we
+ // are invoking.
+ // We will have only one split for cross product that will know about all
+ // the files in all input directories and will generate RecordReaders
+ // for every combination of files inside these directories.
+// CrossProductInputSplit split = new CrossProductInputSplit();
+
+ // List the input port directories contained in the input directory passed
+ // in from the command line.
+ List<FileStatus> inputPortDirectories = listStatus(job);
+
+ final FileSystem fs = job.getWorkingDirectory().getFileSystem(job.getConfiguration());
+ Path workingDirectory = job.getWorkingDirectory();
+ System.out.println("Working directory: " + workingDirectory);
+ System.out.println("Adding directories to the cross product split:");
+ ArrayList<Path> inputPortDirectoriesPaths = new ArrayList<Path>();
+ for (FileStatus inputPortDirectory : inputPortDirectories){
+ // TODO input port directories need to be ordered in the order of the
+ // input ports of the Taverna processor/activity they are going into
+
+ //inputPortDirectoriesPaths.add(new Text(inputPortDirectory.getPath().toString()));
+ inputPortDirectoriesPaths.add(inputPortDirectory.getPath());
+ System.out.println(inputPortDirectory.getPath());
+
+ }
+ CrossProductInputSplit split = new CrossProductInputSplit(workingDirectory, inputPortDirectoriesPaths);
+
+
+ List<InputSplit> splits = new ArrayList<InputSplit>();
+ splits.add(split);
+
+ return splits;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/CrossProductInputSplit.java
----------------------------------------------------------------------
diff --git a/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/CrossProductInputSplit.java b/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/CrossProductInputSplit.java
new file mode 100644
index 0000000..d19bf85
--- /dev/null
+++ b/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/CrossProductInputSplit.java
@@ -0,0 +1,87 @@
+/*
+* 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.taverna.platform.execution.impl.hadoop;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.io.Text;
+import org.apache.hadoop.mapreduce.lib.input.FileSplit;
+
+/**
+ *
+ *
+ * @author Alex Nenadic
+ */
+public class CrossProductInputSplit extends FileSplit {
+ //
+ // private long length = 0;
+ // private String[] hosts;
+ private List<Path> inputPortDirectories;
+ private Path workingDirectory;
+
+ public CrossProductInputSplit() {
+ super(null,0,0,null);
+ inputPortDirectories = new ArrayList<Path>();
+ System.out.println("Calling default constructor for cross product split");
+ }
+
+ public CrossProductInputSplit(Path workingDirectory, List<Path> inputPortDirectories) {
+ // this.length = length;
+ // this.hosts = hosts;
+ super(workingDirectory, 0, 0, new String[0]);
+ this.workingDirectory = workingDirectory;
+ this.inputPortDirectories = inputPortDirectories;
+ System.out.println("Calling non-default constructor for cross product split");
+ }
+
+ public void addInputPortDirectory(Path path) {
+ inputPortDirectories.add(path);
+ }
+
+ public List<Path> getInputPortDirectories() {
+ return inputPortDirectories;
+ }
+
+ @Override
+ public void write(DataOutput out) throws IOException {
+ super.write(out);
+ Text.writeString(out, workingDirectory.toString());
+ out.writeInt(inputPortDirectories.size());
+ for (Path path : inputPortDirectories) {
+ Text.writeString(out, path.toString());
+ }
+ }
+
+ @Override
+ public void readFields(DataInput in) throws IOException {
+ super.readFields(in);
+ workingDirectory = new Path(Text.readString(in));
+ int length = in.readInt();
+ for (int i = 0; i < length; i++) {
+ inputPortDirectories.add(new Path(Text.readString(in)));
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/CrossProductRecordReader.java
----------------------------------------------------------------------
diff --git a/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/CrossProductRecordReader.java b/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/CrossProductRecordReader.java
new file mode 100644
index 0000000..94479ef
--- /dev/null
+++ b/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/CrossProductRecordReader.java
@@ -0,0 +1,131 @@
+/*
+* 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.taverna.platform.execution.impl.hadoop;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.io.Text;
+import org.apache.hadoop.mapreduce.InputSplit;
+import org.apache.hadoop.mapreduce.RecordReader;
+import org.apache.hadoop.mapreduce.TaskAttemptContext;
+import org.pingel.util.CrossProduct;
+
+public class CrossProductRecordReader extends RecordReader<Text, TextArrayWritable>{
+
+ private static final Log Logger = LogFactory.getLog(CrossProductRecordReader.class);
+
+ // Input directories (one for each port) containing files that are used
+ // as inputs to Taverna processor/activity
+ private List<Path> inputPortDirectories;
+
+ private CrossProduct<String> crossProduct ;
+
+ private Iterator<List<String>> crossProductIterator;
+
+ private List<String> currentIndexes;
+
+ @Override
+ public void initialize(InputSplit split, TaskAttemptContext context)
+ throws IOException, InterruptedException {
+
+ System.out.println("Inside record reader's initialize");
+
+ CrossProductInputSplit crossProductSplit = (CrossProductInputSplit)split;
+ inputPortDirectories = crossProductSplit.getInputPortDirectories();
+ System.out.println("Record reader received " + +inputPortDirectories.size() + " input port directories");
+
+ List<List<String>> iterables = new ArrayList<List<String>>();
+ for (int i=0; i<inputPortDirectories.size();i++ ){
+
+ Path inputPortDirectory = inputPortDirectories.get(i);
+ //Path inputPortDirectory = inputPortDirectories.get(i);
+ FileStatus[] files = inputPortDirectory.getFileSystem(context.getConfiguration()).listStatus(inputPortDirectory);
+ List<String> fileNames = new ArrayList<String>();
+ for (FileStatus file : files){
+ fileNames.add(file.getPath().getName());
+ }
+ iterables.add(fileNames);
+ }
+
+ crossProduct = new CrossProduct<String>(iterables);
+ crossProductIterator = crossProduct.iterator();
+
+ }
+
+ @Override
+ public boolean nextKeyValue(){
+
+ boolean hasNextKey = crossProductIterator.hasNext();
+ System.out.println("Has record reader next key value? " + hasNextKey);
+ if (hasNextKey){
+ currentIndexes = crossProductIterator.next();
+ }
+ return hasNextKey;
+ }
+
+ @Override
+ public Text getCurrentKey() throws IOException, InterruptedException {
+
+ StringBuffer sb = new StringBuffer();
+ for (String index : currentIndexes){
+ sb.append(index + ".");
+ }
+ // Remove last "."
+ String indexesString = sb.toString();
+ System.out.println("Get current key: " + indexesString);
+ if (indexesString.contains(".")){
+ indexesString = indexesString.substring(0, indexesString.length() - 1);
+ }
+ return new Text(indexesString);
+ }
+
+ @Override
+ public TextArrayWritable getCurrentValue() {
+
+ TextArrayWritable arrayWritable = new TextArrayWritable();
+ Text[] array = new Text[currentIndexes.size()];
+ for(int i= 0; i< currentIndexes.size(); i++){
+ Path file = new Path(inputPortDirectories.get(i).toString(), currentIndexes.get(i));
+ array[i] = new Text(file.toString());
+ }
+ arrayWritable.set(array);
+ return arrayWritable;
+ }
+
+ @Override
+ public float getProgress() throws IOException, InterruptedException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public void close() throws IOException {
+ // TODO Auto-generated method stub
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/CrossProductTest.java
----------------------------------------------------------------------
diff --git a/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/CrossProductTest.java b/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/CrossProductTest.java
new file mode 100644
index 0000000..17275eb
--- /dev/null
+++ b/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/CrossProductTest.java
@@ -0,0 +1,115 @@
+/*
+* 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.taverna.platform.execution.impl.hadoop;
+
+import java.io.IOException;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.conf.Configured;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.io.ArrayWritable;
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.io.MapWritable;
+import org.apache.hadoop.io.Text;
+import org.apache.hadoop.mapreduce.Job;
+import org.apache.hadoop.mapreduce.Mapper;
+import org.apache.hadoop.mapreduce.Reducer;
+import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
+import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
+import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
+import org.apache.hadoop.util.Tool;
+import org.apache.hadoop.util.ToolRunner;
+
+public class CrossProductTest extends Configured implements Tool {
+
+ public static class Map extends Mapper<Text, TextArrayWritable, Text, TextArrayWritable> {
+ public void map(Text key, TextArrayWritable value, Context context) throws IOException,
+ InterruptedException {
+ System.out.println("Map key = " + key);
+ System.out.println("Map value = " );
+
+ for (int i = 0; i < value.get().length; i++){
+ System.out.println(" " + value.get()[i]);
+ }
+
+ context.write(key, value);
+ }
+ }
+
+ public static class Reduce extends Reducer<Text, TextArrayWritable, Text, Text> {
+ public void reduce(Text key, Iterable<TextArrayWritable> values, Context context)
+ throws IOException, InterruptedException {
+
+ System.out.println("Reduce key = " + key);
+ context.write(key, f(values));
+ }
+
+ private Text f(Iterable<TextArrayWritable> values) {
+ StringBuilder sb = new StringBuilder();
+
+ // There should be only one array
+ TextArrayWritable arrayValue = values.iterator().next();
+
+ for (int i = 0; i < arrayValue.get().length; i++){
+ sb.append(arrayValue.get()[i] + "\nx");
+ }
+ String str = sb.toString();
+ if (str.contains("\nx")){
+ str = str.substring(0, sb.lastIndexOf("\nx") -1);
+ }
+ System.out.println("Result of function f(): " + str);
+
+ return new Text(str);
+ }
+ }
+
+ public int run(String[] args) throws Exception {
+
+ Configuration configuration = getConf();
+ configuration.set("taverna.datalinks", "A|X,B|Y");
+ System.out.println(configuration);
+ Job job = new Job(configuration);
+ job.setJarByClass(CrossProductTest.class);
+ job.setJobName("crossproduct");
+
+ job.setOutputKeyClass(Text.class);
+ job.setOutputValueClass(TextArrayWritable.class);
+
+ job.setMapperClass(Map.class);
+// job.setCombinerClass(Reduce.class);
+ job.setReducerClass(Reduce.class);
+
+ job.setInputFormatClass(CrossProductInputFormat.class);
+ job.setOutputFormatClass(TextOutputFormat.class);
+
+ FileInputFormat.setInputPaths(job, new Path(args[0]));
+ System.out.println("Input dir: " + args[0]);
+ FileOutputFormat.setOutputPath(job, new Path(args[1]));
+ System.out.println("Output dir: " + args[1]);
+
+ boolean success = job.waitForCompletion(true);
+ return success ? 0 : 1;
+ }
+
+ public static void main(String[] args) throws Exception {
+ int ret = ToolRunner.run(new CrossProductTest(), args);
+ System.exit(ret);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/DotProductTest.java
----------------------------------------------------------------------
diff --git a/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/DotProductTest.java b/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/DotProductTest.java
new file mode 100644
index 0000000..ff9cf37
--- /dev/null
+++ b/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/DotProductTest.java
@@ -0,0 +1,105 @@
+/*
+* 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.taverna.platform.execution.impl.hadoop;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.conf.Configured;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.io.MapWritable;
+import org.apache.hadoop.io.Text;
+import org.apache.hadoop.mapreduce.Job;
+import org.apache.hadoop.mapreduce.Mapper;
+import org.apache.hadoop.mapreduce.Reducer;
+import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
+import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
+import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
+import org.apache.hadoop.util.Tool;
+import org.apache.hadoop.util.ToolRunner;
+
+public class DotProductTest extends Configured implements Tool {
+
+ public static class Map extends Mapper<LongWritable, MapWritable, LongWritable, MapWritable> {
+ public void map(LongWritable key, MapWritable value, Context context) throws IOException,
+ InterruptedException {
+ System.out.println("Map key = " + key);
+ System.out.println("Map value tag = " + value.get(new Text("tag")));
+ System.out.println("Map value record = " + value.get(new Text("record")));
+ context.write(key, value);
+ }
+ }
+
+ public static class Reduce extends Reducer<LongWritable, MapWritable, LongWritable, Text> {
+ public void reduce(LongWritable key, Iterable<MapWritable> values, Context context)
+ throws IOException, InterruptedException {
+
+ System.out.println("Reduce key = " + key);
+ context.write(key, f(values));
+ context.write(key, f(values));
+ }
+
+ private Text f(Iterable<MapWritable> values) {
+ StringBuilder sb = new StringBuilder();
+ for (MapWritable value : values) {
+ System.out.println("Reduce tag = " + value.get(new Text("tag")));
+ System.out.println("Reduce value = " + value.get(new Text("record")));
+ sb.append(value.get(new Text("record")) + " ");
+ }
+ return new Text(sb.toString());
+ }
+ }
+
+ public int run(String[] args) throws Exception {
+ java.util.Map datalinks = new HashMap();
+
+
+ Configuration configuration = getConf();
+ configuration.set("taverna.datalinks", "A|X,B|Y");
+ System.out.println(configuration);
+ Job job = new Job(configuration);
+ job.setJarByClass(DotProductTest.class);
+ job.setJobName("dotproduct");
+
+ job.setOutputKeyClass(LongWritable.class);
+ job.setOutputValueClass(MapWritable.class);
+
+ job.setMapperClass(Map.class);
+// job.setCombinerClass(Reduce.class);
+ job.setReducerClass(Reduce.class);
+
+ job.setInputFormatClass(TavernaInputFormat.class);
+ job.setOutputFormatClass(TextOutputFormat.class);
+
+ FileInputFormat.setInputPaths(job, new Path(args[0]));
+ FileOutputFormat.setOutputPath(job, new Path(args[1]));
+
+ boolean success = job.waitForCompletion(true);
+ return success ? 0 : 1;
+ }
+
+ public static void main(String[] args) throws Exception {
+ int ret = ToolRunner.run(new DotProductTest(), args);
+ System.exit(ret);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/TavernaInputFormat.java
----------------------------------------------------------------------
diff --git a/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/TavernaInputFormat.java b/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/TavernaInputFormat.java
new file mode 100644
index 0000000..1b95a95
--- /dev/null
+++ b/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/TavernaInputFormat.java
@@ -0,0 +1,51 @@
+/*
+* 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.taverna.platform.execution.impl.hadoop;
+
+import java.io.IOException;
+
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.io.MapWritable;
+import org.apache.hadoop.mapreduce.InputSplit;
+import org.apache.hadoop.mapreduce.JobContext;
+import org.apache.hadoop.mapreduce.RecordReader;
+import org.apache.hadoop.mapreduce.TaskAttemptContext;
+import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
+
+/**
+ *
+ *
+ * @author David Withers
+ */
+public class TavernaInputFormat extends FileInputFormat<LongWritable, MapWritable> {
+
+ @Override
+ public RecordReader<LongWritable, MapWritable> createRecordReader(InputSplit split,
+ TaskAttemptContext context) throws IOException, InterruptedException {
+ return new TavernaRecordReader();
+ }
+
+ @Override
+ protected boolean isSplitable(JobContext context, Path filename) {
+ return false;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/TavernaInputSplit.java
----------------------------------------------------------------------
diff --git a/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/TavernaInputSplit.java b/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/TavernaInputSplit.java
new file mode 100644
index 0000000..6ce3cfa
--- /dev/null
+++ b/taverna-execution-hadoop/src/main/java/org/apache/taverna/platform/execution/impl/hadoop/TavernaInputSplit.java
@@ -0,0 +1,68 @@
+/*
+* 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.taverna.platform.execution.impl.hadoop;
+
+import java.io.IOException;
+import java.util.Map;
+
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.mapreduce.InputSplit;
+
+/**
+ *
+ *
+ * @author David Withers
+ */
+public class TavernaInputSplit extends InputSplit {
+ private int[] index;
+ private Map<String, Path> inputs;
+ private long length;
+ private String[] hosts;
+
+ public TavernaInputSplit(int[] index, Map<String, Path> inputs, long length, String[] hosts) {
+ this.index = index;
+ this.inputs = inputs;
+ this.length = length;
+ this.hosts = hosts;
+ }
+
+ public int[] getIndex() {
+ return index;
+ }
+
+ public Map<String, Path> getInputs() {
+ return inputs;
+ }
+
+ @Override
+ public long getLength() throws IOException, InterruptedException {
+ return length;
+ }
+
+ @Override
+ public String[] getLocations() throws IOException, InterruptedException {
+ if (hosts == null) {
+ return new String[] {};
+ } else {
+ return this.hosts;
+ }
+ }
+
+}