You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sh...@apache.org on 2015/06/15 19:35:43 UTC

airavata git commit: Added SSHEnvironmentSetupTask

Repository: airavata
Updated Branches:
  refs/heads/master 59d2f2507 -> 0924a6e49


Added SSHEnvironmentSetupTask


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/0924a6e4
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/0924a6e4
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/0924a6e4

Branch: refs/heads/master
Commit: 0924a6e49ac01b585901398d0832a2f4febb5858
Parents: 59d2f25
Author: Shameera Rathanyaka <sh...@gmail.com>
Authored: Mon Jun 15 13:35:41 2015 -0400
Committer: Shameera Rathanyaka <sh...@gmail.com>
Committed: Mon Jun 15 13:35:41 2015 -0400

----------------------------------------------------------------------
 .../gfac/core/cluster/RemoteCluster.java        |  2 +-
 .../gfac/core/context/ProcessContext.java       | 20 +++++++
 .../apache/airavata/gfac/core/task/Task.java    | 10 ++--
 .../airavata/gfac/core/task/TaskException.java  | 45 ++++++++++++++++
 .../apache/airavata/gfac/impl/GFacEngine.java   |  1 +
 .../gfac/impl/task/SSHEnvironmentSetupTask.java | 55 ++++++++++++++++++++
 6 files changed, 128 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/0924a6e4/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cluster/RemoteCluster.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cluster/RemoteCluster.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cluster/RemoteCluster.java
index 2bd4558..d61bd0c 100644
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cluster/RemoteCluster.java
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cluster/RemoteCluster.java
@@ -32,7 +32,7 @@ import java.util.Map;
  * End users of the API can implement this and come up with their own
  * implementations, but mostly this interface is for internal usage.
  */
-public interface RemoteCluster {
+public interface RemoteCluster { // FIXME: replace SSHApiException with suitable exception.
 
     /**
      * This will submit a job to the cluster with a given pbs file and some parameters

http://git-wip-us.apache.org/repos/asf/airavata/blob/0924a6e4/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/context/ProcessContext.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/context/ProcessContext.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/context/ProcessContext.java
index 7ac2807..10c881c 100644
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/context/ProcessContext.java
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/context/ProcessContext.java
@@ -22,7 +22,9 @@
 package org.apache.airavata.gfac.core.context;
 
 import org.apache.airavata.common.utils.LocalEventPublisher;
+import org.apache.airavata.gfac.core.cluster.RemoteCluster;
 import org.apache.airavata.gfac.core.task.Task;
+import org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile;
 import org.apache.airavata.model.process.ProcessModel;
 import org.apache.airavata.registry.cpi.AppCatalog;
 import org.apache.airavata.registry.cpi.ExperimentCatalog;
@@ -42,6 +44,8 @@ public class ProcessContext {
 	private ProcessModel processModel;
 	private String workingDir;
 	private List<Task> taskChain;
+	private GatewayResourceProfile gatewayResourceProfile;
+	private RemoteCluster remoteCluster;
 
 	public ProcessContext(String processId, String gatewayId, String tokenId) {
 		this.processId = processId;
@@ -118,4 +122,20 @@ public class ProcessContext {
 	public void setTaskChain(List<Task> taskChain) {
 		this.taskChain = taskChain;
 	}
+
+	public GatewayResourceProfile getGatewayResourceProfile() {
+		return gatewayResourceProfile;
+	}
+
+	public void setGatewayResourceProfile(GatewayResourceProfile gatewayResourceProfile) {
+		this.gatewayResourceProfile = gatewayResourceProfile;
+	}
+
+	public RemoteCluster getRemoteCluster() {
+		return remoteCluster;
+	}
+
+	public void setRemoteCluster(RemoteCluster remoteCluster) {
+		this.remoteCluster = remoteCluster;
+	}
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/0924a6e4/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/task/Task.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/task/Task.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/task/Task.java
index 4019138..0cf1ae8 100644
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/task/Task.java
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/task/Task.java
@@ -22,7 +22,6 @@ package org.apache.airavata.gfac.core.task;
 
 import org.apache.airavata.gfac.core.context.TaskContext;
 import org.apache.airavata.model.status.TaskState;
-import org.apache.airavata.model.task.TaskModel;
 
 import java.util.Map;
 
@@ -34,22 +33,25 @@ public interface Task {
 	/**
 	 * Task initialization method, this method will be invoked after create a new task instance.
 	 * @param propertyMap
+	 * @throws TaskException
 	 */
-	public void init(Map<String, String> propertyMap);
+	public void init(Map<String, String> propertyMap) throws TaskException;
 
 	/**
 	 * This method will be called at the first time of task chain execution. This method should called before recover
 	 * method. For a given task chain execute method only call one time. recover method may be called more than once.
 	 * @param taskContext
+	 * @throws TaskException
 	 * @return
 	 */
-	public TaskState execute(TaskContext taskContext);
+	public TaskState execute(TaskContext taskContext) throws TaskException;
 
 	/**
 	 * This methond will be invoked at recover path.Before this method is invoked, execute method should be invoked.
 	 * This method may be called zero or few time in a process chain.
 	 * @param taskContext
+	 * @throws TaskException
 	 * @return
 	 */
-	public TaskState recover(TaskContext taskContext);
+	public TaskState recover(TaskContext taskContext) throws TaskException;
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/0924a6e4/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/task/TaskException.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/task/TaskException.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/task/TaskException.java
new file mode 100644
index 0000000..7c3962b
--- /dev/null
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/task/TaskException.java
@@ -0,0 +1,45 @@
+/*
+ *
+ * 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.airavata.gfac.core.task;
+
+public class TaskException extends Exception {
+	private static final long serialVersionUID = 8662332011259328779L;
+
+	public TaskException() {
+		super();
+	}
+
+	public TaskException(String message) {
+		super(message);
+	}
+
+	public TaskException(String message, Throwable cause) {
+		super(message, cause);
+	}
+
+	public TaskException(Throwable cause) {
+		super(cause);
+	}
+
+	protected TaskException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
+		super(message, cause, enableSuppression, writableStackTrace);
+	}
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/0924a6e4/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/GFacEngine.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/GFacEngine.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/GFacEngine.java
index 0085dde..9c32913 100644
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/GFacEngine.java
+++ b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/GFacEngine.java
@@ -76,6 +76,7 @@ public class GFacEngine {
 	public ProcessContext populateProcessContext(ProcessContext processContext) {
 		processContext.setProcessModel(new ProcessModel()); // TODO: get rocess model from app catalog
 		// TODO: set datamovement protocol and jobsubmission protocol
+		//TODO: set up gatewayResourceProfile.
 		return processContext;
 	}
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/0924a6e4/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/task/SSHEnvironmentSetupTask.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/task/SSHEnvironmentSetupTask.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/task/SSHEnvironmentSetupTask.java
new file mode 100644
index 0000000..4b93a80
--- /dev/null
+++ b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/task/SSHEnvironmentSetupTask.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.airavata.gfac.impl.task;
+
+import org.apache.airavata.gfac.core.task.TaskException;
+import org.apache.airavata.gfac.core.SSHApiException;
+import org.apache.airavata.gfac.core.cluster.RemoteCluster;
+import org.apache.airavata.gfac.core.context.TaskContext;
+import org.apache.airavata.gfac.core.task.Task;
+import org.apache.airavata.model.status.TaskState;
+
+import java.util.Map;
+
+public class SSHEnvironmentSetupTask implements Task {
+
+	@Override
+	public void init(Map<String, String> propertyMap) throws TaskException {
+
+	}
+
+	@Override
+	public TaskState execute(TaskContext taskContext) throws TaskException {
+
+		try {
+			RemoteCluster remoteCluster = taskContext.getParentProcessContext().getRemoteCluster();
+			remoteCluster.makeDirectory(taskContext.getParentProcessContext().getWorkingDir());
+		} catch (SSHApiException e) {
+			throw new TaskException("Error while environment setup", e);
+		}
+		return null;
+	}
+
+	@Override
+	public TaskState recover(TaskContext taskContext) throws TaskException {
+		return execute(taskContext);
+	}
+}