airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From samin...@apache.org
Subject [2/2] git commit: https://issues.apache.org/jira/browse/AIRAVATA-1145
Date Fri, 18 Apr 2014 12:24:06 GMT
https://issues.apache.org/jira/browse/AIRAVATA-1145


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

Branch: refs/heads/master
Commit: d4e3985454656d901244c1a5eb20d5e40bfe0fbc
Parents: 20306cd
Author: Saminda Wijeratne <samindaw@gmail.com>
Authored: Fri Apr 18 05:23:42 2014 -0700
Committer: Saminda Wijeratne <samindaw@gmail.com>
Committed: Fri Apr 18 05:23:42 2014 -0700

----------------------------------------------------------------------
 .../AiravataExperimentStatusUpdator.java        |  81 ++++++++++++++
 .../job/monitor/AiravataTaskStatusUpdator.java  | 111 +++++++++++++++++++
 .../job/monitor/state/ExperimentStatus.java     |  65 +++++++++++
 .../airavata/job/monitor/state/TaskStatus.java  |  65 +++++++++++
 4 files changed, 322 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/d4e39854/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/job/monitor/AiravataExperimentStatusUpdator.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/job/monitor/AiravataExperimentStatusUpdator.java
b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/job/monitor/AiravataExperimentStatusUpdator.java
new file mode 100644
index 0000000..f0fd239
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/job/monitor/AiravataExperimentStatusUpdator.java
@@ -0,0 +1,81 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+package org.apache.airavata.job.monitor;
+
+import java.util.Calendar;
+
+import org.apache.airavata.job.monitor.state.ExperimentStatus;
+import org.apache.airavata.model.workspace.experiment.Experiment;
+import org.apache.airavata.model.workspace.experiment.ExperimentState;
+import org.apache.airavata.registry.cpi.DataType;
+import org.apache.airavata.registry.cpi.Registry;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.eventbus.Subscribe;
+
+public class AiravataExperimentStatusUpdator implements AbstractActivityListener{
+    private final static Logger logger = LoggerFactory.getLogger(AiravataExperimentStatusUpdator.class);
+
+    private Registry airavataRegistry;
+
+    public Registry getAiravataRegistry() {
+        return airavataRegistry;
+    }
+
+    public void setAiravataRegistry(Registry airavataRegistry) {
+        this.airavataRegistry = airavataRegistry;
+    }
+
+    @Subscribe
+    public void updateRegistry(ExperimentStatus taskStatus) {
+        ExperimentState state = taskStatus.getState();
+        if (state != null) {
+            try {
+                String taskID = taskStatus.getMonitorID().getTaskID();
+                updateExperimentStatus(taskID, state);
+            } catch (Exception e) {
+                logger.error("Error persisting data" + e.getLocalizedMessage(), e);
+            }
+        }
+    }
+    
+    public  void updateExperimentStatus(String experimentId, ExperimentState state) throws
Exception {
+    	Experiment details = (Experiment)airavataRegistry.get(DataType.EXPERIMENT, experimentId);
+        if(details == null) {
+            details = new Experiment();
+            details.setExperimentID(experimentId);
+        }
+        org.apache.airavata.model.workspace.experiment.ExperimentStatus status = new org.apache.airavata.model.workspace.experiment.ExperimentStatus();
+        status.setExperimentState(state);
+        status.setTimeOfStateChange(Calendar.getInstance().getTimeInMillis());
+        airavataRegistry.update(org.apache.airavata.registry.cpi.DataType.EXPERIMENT, details,
experimentId);
+    }
+
+	@Override
+	public void setup(Object... configurations) {
+		for (Object configuration : configurations) {
+			if (configuration instanceof Registry){
+				this.airavataRegistry=(Registry)configuration;
+			} 
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/d4e39854/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/job/monitor/AiravataTaskStatusUpdator.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/job/monitor/AiravataTaskStatusUpdator.java
b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/job/monitor/AiravataTaskStatusUpdator.java
new file mode 100644
index 0000000..bcee819
--- /dev/null
+++ b/modules/gfac/gfac-monitor/src/main/java/org/apache/airavata/job/monitor/AiravataTaskStatusUpdator.java
@@ -0,0 +1,111 @@
+/*
+ *
+ * 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.job.monitor;
+
+import java.util.Calendar;
+
+import org.apache.airavata.job.monitor.event.MonitorPublisher;
+import org.apache.airavata.job.monitor.state.ExperimentStatus;
+import org.apache.airavata.job.monitor.state.TaskStatus;
+import org.apache.airavata.model.workspace.experiment.ExperimentState;
+import org.apache.airavata.model.workspace.experiment.TaskDetails;
+import org.apache.airavata.model.workspace.experiment.TaskState;
+import org.apache.airavata.registry.cpi.DataType;
+import org.apache.airavata.registry.cpi.Registry;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.eventbus.Subscribe;
+
+public class AiravataTaskStatusUpdator implements AbstractActivityListener{
+    private final static Logger logger = LoggerFactory.getLogger(AiravataTaskStatusUpdator.class);
+
+    private Registry airavataRegistry;
+
+    private MonitorPublisher monitorPublisher;
+    
+    public Registry getAiravataRegistry() {
+        return airavataRegistry;
+    }
+
+    public void setAiravataRegistry(Registry airavataRegistry) {
+        this.airavataRegistry = airavataRegistry;
+    }
+
+    @Subscribe
+    public void updateRegistry(TaskStatus taskStatus) {
+        TaskState state = taskStatus.getState();
+        if (state != null) {
+            try {
+                String taskID = taskStatus.getMonitorID().getTaskID();
+                updateTaskStatus(taskID, state);
+            } catch (Exception e) {
+                logger.error("Error persisting data" + e.getLocalizedMessage(), e);
+            }
+        }
+    }
+    
+    @Subscribe
+    public void setupExperimentStatus(TaskStatus taskStatus){
+    	ExperimentState state=ExperimentState.UNKNOWN;
+    	switch(taskStatus.getState()){
+    	case CANCELED:
+    		state=ExperimentState.CANCELED; break;
+    	case COMPLETED:
+    		state=ExperimentState.COMPLETED; break;
+    	case CONFIGURING_WORKSPACE:
+    		state=ExperimentState.LAUNCHED; break;
+    	case FAILED:
+    		state=ExperimentState.FAILED; break;
+    	case EXECUTING: case WAITING: case PRE_PROCESSING: case POST_PROCESSING: case OUTPUT_DATA_STAGING:
case INPUT_DATA_STAGING:
+    		state=ExperimentState.EXECUTING; break;
+    	case STARTED:
+    		state=ExperimentState.LAUNCHED; break;
+		default:
+			break;
+    	}
+    	logger.debug("Publishing Experiment Status "+state.toString());
+    	monitorPublisher.publish(new ExperimentStatus(taskStatus.getMonitorID(),state));
+    }
+    
+    public  void updateTaskStatus(String taskId, TaskState state) throws Exception {
+    	TaskDetails details = (TaskDetails)airavataRegistry.get(DataType.TASK_DETAIL, taskId);
+        if(details == null) {
+            details = new TaskDetails();
+            details.setTaskID(taskId);
+        }
+        org.apache.airavata.model.workspace.experiment.TaskStatus status = new org.apache.airavata.model.workspace.experiment.TaskStatus();
+        status.setExecutionState(state);
+        status.setTimeOfStateChange(Calendar.getInstance().getTimeInMillis());
+        airavataRegistry.update(org.apache.airavata.registry.cpi.DataType.TASK_DETAIL, details,
taskId);
+    }
+
+	@Override
+	public void setup(Object... configurations) {
+		for (Object configuration : configurations) {
+			if (configuration instanceof Registry){
+				this.airavataRegistry=(Registry)configuration;
+			} else if (configuration instanceof MonitorPublisher){
+				this.monitorPublisher=(MonitorPublisher) configuration;
+			} 
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/d4e39854/tools/job-monitor/src/main/java/org/apache/airavata/job/monitor/state/ExperimentStatus.java
----------------------------------------------------------------------
diff --git a/tools/job-monitor/src/main/java/org/apache/airavata/job/monitor/state/ExperimentStatus.java
b/tools/job-monitor/src/main/java/org/apache/airavata/job/monitor/state/ExperimentStatus.java
new file mode 100644
index 0000000..4070275
--- /dev/null
+++ b/tools/job-monitor/src/main/java/org/apache/airavata/job/monitor/state/ExperimentStatus.java
@@ -0,0 +1,65 @@
+/*
+ *
+ * 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.job.monitor.state;
+
+import org.apache.airavata.job.monitor.MonitorID;
+import org.apache.airavata.model.workspace.experiment.ExperimentState;
+
+/**
+ * This is the primary job state object used in
+ * through out the monitor module. This use airavata-data-model JobState enum
+ * Ideally after processing each event or monitoring message from remote system
+ * Each monitoring implementation has to return this object with a state and
+ * the monitoring ID
+ */
+public class ExperimentStatus {
+    private ExperimentState state;
+
+    private MonitorID monitorID;
+
+
+    // this constructor can be used in Qstat monitor to handle errors
+    public ExperimentStatus() {
+    }
+
+    public ExperimentStatus(MonitorID monitorID, ExperimentState state) {
+        this.monitorID = monitorID;
+        this.state = state;
+    }
+
+    public ExperimentState getState() {
+        return state;
+    }
+
+    public void setState(ExperimentState state) {
+       this.state = state;
+    }
+
+    public MonitorID getMonitorID() {
+        return monitorID;
+    }
+
+    public void setMonitorID(MonitorID monitorID) {
+        this.monitorID = monitorID;
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/d4e39854/tools/job-monitor/src/main/java/org/apache/airavata/job/monitor/state/TaskStatus.java
----------------------------------------------------------------------
diff --git a/tools/job-monitor/src/main/java/org/apache/airavata/job/monitor/state/TaskStatus.java
b/tools/job-monitor/src/main/java/org/apache/airavata/job/monitor/state/TaskStatus.java
new file mode 100644
index 0000000..4151a66
--- /dev/null
+++ b/tools/job-monitor/src/main/java/org/apache/airavata/job/monitor/state/TaskStatus.java
@@ -0,0 +1,65 @@
+/*
+ *
+ * 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.job.monitor.state;
+
+import org.apache.airavata.job.monitor.MonitorID;
+import org.apache.airavata.model.workspace.experiment.TaskState;
+
+/**
+ * This is the primary job state object used in
+ * through out the monitor module. This use airavata-data-model JobState enum
+ * Ideally after processing each event or monitoring message from remote system
+ * Each monitoring implementation has to return this object with a state and
+ * the monitoring ID
+ */
+public class TaskStatus {
+    private TaskState state;
+
+    private MonitorID monitorID;
+
+
+    // this constructor can be used in Qstat monitor to handle errors
+    public TaskStatus() {
+    }
+
+    public TaskStatus(MonitorID monitorID, TaskState state) {
+        this.monitorID = monitorID;
+        this.state = state;
+    }
+
+    public TaskState getState() {
+        return state;
+    }
+
+    public void setState(TaskState state) {
+       this.state = state;
+    }
+
+    public MonitorID getMonitorID() {
+        return monitorID;
+    }
+
+    public void setMonitorID(MonitorID monitorID) {
+        this.monitorID = monitorID;
+    }
+
+
+}


Mime
View raw message