airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lah...@apache.org
Subject [5/5] git commit: adding new type of handler
Date Tue, 24 Jun 2014 18:05:52 GMT
adding new type of handler


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

Branch: refs/heads/master
Commit: d56dd443e6fb4242d475e15264e08e9cab2edc59
Parents: 3481653
Author: lahiru <lahiru@apache.org>
Authored: Tue Jun 24 14:05:28 2014 -0400
Committer: lahiru <lahiru@apache.org>
Committed: Tue Jun 24 14:05:28 2014 -0400

----------------------------------------------------------------------
 .../handler/AbstractRecoverableHandler.java     | 65 ++++++++++++++++++++
 .../core/handler/GFacRecoverableHandler.java    | 44 +++++++++++++
 2 files changed, 109 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/d56dd443/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/handler/AbstractRecoverableHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/handler/AbstractRecoverableHandler.java
b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/handler/AbstractRecoverableHandler.java
new file mode 100644
index 0000000..0c6810b
--- /dev/null
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/handler/AbstractRecoverableHandler.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.gfac.core.handler;
+
+import org.apache.airavata.gfac.core.context.JobExecutionContext;
+import org.apache.airavata.gfac.core.cpi.GFacImpl;
+import org.apache.airavata.gfac.core.notification.MonitorPublisher;
+import org.apache.airavata.persistance.registry.jpa.impl.RegistryFactory;
+import org.apache.airavata.registry.cpi.Registry;
+import org.apache.airavata.registry.cpi.RegistryException;
+
+public abstract class AbstractRecoverableHandler implements GFacRecoverableHandler {
+    protected Registry registry = null;
+
+    protected MonitorPublisher publisher = null;
+
+    protected AbstractRecoverableHandler() {
+        publisher = GFacImpl.getMonitorPublisher();   // This will not be null because this
will be initialize in GFacIml
+    }
+
+    public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException
{
+		registry = jobExecutionContext.getRegistry();
+        if(registry == null){
+            try {
+                registry = RegistryFactory.getDefaultRegistry();
+            } catch (RegistryException e) {
+                throw new GFacHandlerException("unable to create registry instance", e);
+            }
+        }
+	}
+
+    public MonitorPublisher getPublisher() {
+        return publisher;
+    }
+
+    public void setPublisher(MonitorPublisher publisher) {
+        this.publisher = publisher;
+    }
+
+    public Registry getRegistry() {
+        return registry;
+    }
+
+    public void setRegistry(Registry registry) {
+        this.registry = registry;
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/d56dd443/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/handler/GFacRecoverableHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/handler/GFacRecoverableHandler.java
b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/handler/GFacRecoverableHandler.java
new file mode 100644
index 0000000..fef6b76
--- /dev/null
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/handler/GFacRecoverableHandler.java
@@ -0,0 +1,44 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+package org.apache.airavata.gfac.core.handler;
+
+import org.apache.airavata.gfac.core.context.JobExecutionContext;
+
+/**
+ * This handler type can be used to implement stateful Operation and
+ * we recommend to use the ZK client to store and retrieve the states
+ * of the handler implementation. Framework level we use
+ * ZK to decide handler ran successfully or not so each handler
+ * execution details can be found in following zk path
+ * /gfac-experiment/<gfac-node-name>/experimentId+taskId/full-qualified-handlername/state
+ * ex: /gfac-experiment/gfac-node0/echoExperiment_2c6c11b8-dea0-4ec8-9832-f3e69fe2e6bb+IDontNeedaNode_682faa66-6218-4897-9271-656bfb8b2bd1/org.apache.airavata.gfac.handlers.Test/state
+ */
+public interface GFacRecoverableHandler extends GFacHandler {
+
+    /**
+     * This method can be used to implement recovering part of the stateful handler
+     * If you do not want to recover an already ran handler you can simply implement
+     * GfacAbstract Handler or GFacHandler or leave this recover method empty.
+     * @param jobExecutionContext
+     */
+    public void recover(JobExecutionContext jobExecutionContext);
+
+}


Mime
View raw message