Repository: airavata
Updated Branches:
  refs/heads/master 747d766ff -> 6f8fa3e90


renaming PluginState to HandlerState


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

Branch: refs/heads/master
Commit: 6f8fa3e9093f0845eb38ac7ba57eda8b1ad12791
Parents: 747d766
Author: Chathuri Wimalasena <[email protected]>
Authored: Tue May 12 15:22:34 2015 -0400
Committer: Chathuri Wimalasena <[email protected]>
Committed: Tue May 12 15:22:34 2015 -0400

----------------------------------------------------------------------
 .../airavata/gfac/core/cpi/BetterGfacImpl.java  | 36 ++++++------
 .../gfac/core/handler/AbstractHandler.java      |  4 +-
 .../core/handler/AppDescriptorCheckHandler.java |  5 +-
 .../gfac/core/states/GfacPluginState.java       | 59 --------------------
 .../airavata/gfac/core/utils/GFacUtils.java     | 24 ++++----
 5 files changed, 34 insertions(+), 94 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/6f8fa3e9/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cpi/BetterGfacImpl.java
----------------------------------------------------------------------
diff --git 
a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cpi/BetterGfacImpl.java
 
b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cpi/BetterGfacImpl.java
index 8385d48..82798d1 100644
--- 
a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cpi/BetterGfacImpl.java
+++ 
b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cpi/BetterGfacImpl.java
@@ -44,7 +44,7 @@ import 
org.apache.airavata.gfac.core.notification.listeners.LoggingListener;
 import org.apache.airavata.gfac.core.provider.GFacProvider;
 import org.apache.airavata.gfac.core.provider.GFacProviderException;
 import org.apache.airavata.gfac.core.states.GfacExperimentState;
-import org.apache.airavata.gfac.core.states.GfacPluginState;
+import org.apache.airavata.gfac.core.states.GfacHandlerState;
 import org.apache.airavata.gfac.core.utils.GFacUtils;
 import org.apache.airavata.messaging.core.Publisher;
 import org.apache.airavata.messaging.core.PublisherFactory;
@@ -798,7 +798,7 @@ public class BetterGfacImpl implements GFac,Watcher {
             initProvider(provider, jobExecutionContext);
             executeProvider(provider, jobExecutionContext);
             disposeProvider(provider, jobExecutionContext);
-            GFacUtils.updatePluginState(zk, jobExecutionContext, 
provider.getClass().getName(), GfacPluginState.COMPLETED);
+            GFacUtils.updateHandlerState(zk, jobExecutionContext, 
provider.getClass().getName(), GfacHandlerState.COMPLETED);
             monitorPublisher.publish(new GfacExperimentStateChangeRequest(new 
MonitorID(jobExecutionContext), GfacExperimentState.PROVIDERINVOKED));
         }
         if (GFacUtils.isSynchronousMode(jobExecutionContext)) {
@@ -810,16 +810,16 @@ public class BetterGfacImpl implements GFac,Watcher {
         GFacProvider provider = jobExecutionContext.getProvider();
         if (provider != null) {
             monitorPublisher.publish(new GfacExperimentStateChangeRequest(new 
MonitorID(jobExecutionContext), GfacExperimentState.PROVIDERINVOKING));
-            GfacPluginState plState = GFacUtils.getHandlerState(zk, 
jobExecutionContext, provider.getClass().getName());
+            GfacHandlerState plState = GFacUtils.getHandlerState(zk, 
jobExecutionContext, provider.getClass().getName());
             GFacUtils.createPluginZnode(zk, jobExecutionContext, 
provider.getClass().getName());
-            if (plState != null && plState == GfacPluginState.INVOKING) {    
// this will make sure if a plugin crashes it will not launch from the scratch, 
but plugins have to save their invoked state
+            if (plState != null && plState == GfacHandlerState.INVOKING) {    
// this will make sure if a plugin crashes it will not launch from the scratch, 
but plugins have to save their invoked state
                 initProvider(provider, jobExecutionContext);
                 executeProvider(provider, jobExecutionContext);
                 disposeProvider(provider, jobExecutionContext);
             } else {
                 provider.recover(jobExecutionContext);
             }
-            GFacUtils.updatePluginState(zk, jobExecutionContext, 
provider.getClass().getName(), GfacPluginState.COMPLETED);
+            GFacUtils.updateHandlerState(zk, jobExecutionContext, 
provider.getClass().getName(), GfacHandlerState.COMPLETED);
             monitorPublisher.publish(new GfacExperimentStateChangeRequest(new 
MonitorID(jobExecutionContext), GfacExperimentState.PROVIDERINVOKED));
         }
 
@@ -850,16 +850,16 @@ public class BetterGfacImpl implements GFac,Watcher {
         GFacProvider provider = jobExecutionContext.getProvider();
         if (provider != null) {
             monitorPublisher.publish(new GfacExperimentStateChangeRequest(new 
MonitorID(jobExecutionContext), GfacExperimentState.PROVIDERINVOKING));
-            GfacPluginState plState = GFacUtils.getHandlerState(zk, 
jobExecutionContext, provider.getClass().getName());
+            GfacHandlerState plState = GFacUtils.getHandlerState(zk, 
jobExecutionContext, provider.getClass().getName());
             GFacUtils.createPluginZnode(zk, jobExecutionContext, 
provider.getClass().getName());
-            if (plState == GfacPluginState.UNKNOWN || plState == 
GfacPluginState.INVOKING) {    // this will make sure if a plugin crashes it 
will not launch from the scratch, but plugins have to save their invoked state
+            if (plState == GfacHandlerState.UNKNOWN || plState == 
GfacHandlerState.INVOKING) {    // this will make sure if a plugin crashes it 
will not launch from the scratch, but plugins have to save their invoked state
                 initProvider(provider, jobExecutionContext);
                 cancelProvider(provider, jobExecutionContext);
                 disposeProvider(provider, jobExecutionContext);
             } else {
                 provider.recover(jobExecutionContext);
             }
-            GFacUtils.updatePluginState(zk, jobExecutionContext, 
provider.getClass().getName(), GfacPluginState.COMPLETED);
+            GFacUtils.updateHandlerState(zk, jobExecutionContext, 
provider.getClass().getName(), GfacHandlerState.COMPLETED);
             monitorPublisher.publish(new GfacExperimentStateChangeRequest(new 
MonitorID(jobExecutionContext), GfacExperimentState.PROVIDERINVOKED));
         }
 
@@ -936,7 +936,7 @@ public class BetterGfacImpl implements GFac,Watcher {
                     }
                     try {
                         handler.invoke(jobExecutionContext);
-                        GFacUtils.updatePluginState(zk, jobExecutionContext, 
handlerClassName.getClassName(), GfacPluginState.COMPLETED);
+                        GFacUtils.updateHandlerState(zk, jobExecutionContext, 
handlerClassName.getClassName(), GfacHandlerState.COMPLETED);
                         // if exception thrown before that we do not make it 
finished
                     } catch (GFacHandlerException e) {
                         throw new GFacException("Error Executing a InFlow 
Handler", e.getCause());
@@ -1017,7 +1017,7 @@ public class BetterGfacImpl implements GFac,Watcher {
                         }
                         try {
                             handler.invoke(jobExecutionContext);
-                            GFacUtils.updatePluginState(zk, 
jobExecutionContext, handlerClassName.getClassName(), 
GfacPluginState.COMPLETED);
+                            GFacUtils.updateHandlerState(zk, 
jobExecutionContext, handlerClassName.getClassName(), 
GfacHandlerState.COMPLETED);
                         } catch (Exception e) {
                             TaskIdentifier taskIdentity = new 
TaskIdentifier(jobExecutionContext.getTaskData().getTaskID(),
                                     
jobExecutionContext.getWorkflowNodeDetails().getNodeInstanceId(),
@@ -1092,10 +1092,10 @@ public class BetterGfacImpl implements GFac,Watcher {
                 try {
                     handlerClass = 
Class.forName(handlerClassName.getClassName().trim()).asSubclass(GFacHandler.class);
                     handler = handlerClass.newInstance();
-                    GfacPluginState plState = GFacUtils.getHandlerState(zk, 
jobExecutionContext, handlerClassName.getClassName());
-                    GFacUtils.createPluginZnode(zk, jobExecutionContext, 
handlerClassName.getClassName(), GfacPluginState.INVOKING);
+                    GfacHandlerState plState = GFacUtils.getHandlerState(zk, 
jobExecutionContext, handlerClassName.getClassName());
+                    GFacUtils.createHandlerZnode(zk, jobExecutionContext, 
handlerClassName.getClassName(), GfacHandlerState.INVOKING);
                     handler.initProperties(handlerClassName.getProperties());
-                    if (plState == GfacPluginState.UNKNOWN || plState == 
GfacPluginState.INVOKING) {
+                    if (plState == GfacHandlerState.UNKNOWN || plState == 
GfacHandlerState.INVOKING) {
                         log.info(handlerClassName.getClassName() + " never ran 
so we run this is normal mode");
                         handler.invoke(jobExecutionContext);
                     } else {
@@ -1103,7 +1103,7 @@ public class BetterGfacImpl implements GFac,Watcher {
                         log.info(handlerClassName.getClassName() + " is a 
recoverable handler so we recover the handler");
                         handler.recover(jobExecutionContext);
                     }
-                    GFacUtils.updatePluginState(zk, jobExecutionContext, 
handlerClassName.getClassName(), GfacPluginState.COMPLETED);
+                    GFacUtils.updateHandlerState(zk, jobExecutionContext, 
handlerClassName.getClassName(), GfacHandlerState.COMPLETED);
                 } catch (GFacHandlerException e) {
                     throw new GFacException("Error Executing a InFlow 
Handler", e.getCause());
                 } catch (ClassNotFoundException e) {
@@ -1174,9 +1174,9 @@ public class BetterGfacImpl implements GFac,Watcher {
             try {
                 handlerClass = 
Class.forName(handlerClassName.getClassName().trim()).asSubclass(GFacHandler.class);
                 handler = handlerClass.newInstance();
-                GfacPluginState plState = GFacUtils.getHandlerState(zk, 
jobExecutionContext, handlerClassName.getClassName());
-                GFacUtils.createPluginZnode(zk, jobExecutionContext, 
handlerClassName.getClassName(), GfacPluginState.INVOKING);
-                if (plState == GfacPluginState.UNKNOWN || plState == 
GfacPluginState.INVOKING) {
+                GfacHandlerState plState = GFacUtils.getHandlerState(zk, 
jobExecutionContext, handlerClassName.getClassName());
+                GFacUtils.createHandlerZnode(zk, jobExecutionContext, 
handlerClassName.getClassName(), GfacHandlerState.INVOKING);
+                if (plState == GfacHandlerState.UNKNOWN || plState == 
GfacHandlerState.INVOKING) {
                     log.info(handlerClassName.getClassName() + " never ran so 
we run this in normal mode");
                     handler.initProperties(handlerClassName.getProperties());
                     handler.invoke(jobExecutionContext);
@@ -1184,7 +1184,7 @@ public class BetterGfacImpl implements GFac,Watcher {
                     // if these already ran we re-run only recoverable handlers
                     handler.recover(jobExecutionContext);
                 }
-                GFacUtils.updatePluginState(zk, jobExecutionContext, 
handlerClassName.getClassName(), GfacPluginState.COMPLETED);
+                GFacUtils.updateHandlerState(zk, jobExecutionContext, 
handlerClassName.getClassName(), GfacHandlerState.COMPLETED);
             } catch (ClassNotFoundException e) {
                 try {
                     StringWriter errors = new StringWriter();

http://git-wip-us.apache.org/repos/asf/airavata/blob/6f8fa3e9/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/handler/AbstractHandler.java
----------------------------------------------------------------------
diff --git 
a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/handler/AbstractHandler.java
 
b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/handler/AbstractHandler.java
index 1bdfa97..ee28c1d 100644
--- 
a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/handler/AbstractHandler.java
+++ 
b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/handler/AbstractHandler.java
@@ -23,7 +23,7 @@ package org.apache.airavata.gfac.core.handler;
 import org.apache.airavata.common.utils.MonitorPublisher;
 import org.apache.airavata.gfac.core.context.JobExecutionContext;
 import org.apache.airavata.gfac.core.cpi.BetterGfacImpl;
-import org.apache.airavata.gfac.core.states.GfacPluginState;
+import org.apache.airavata.gfac.core.states.GfacHandlerState;
 import org.apache.airavata.gfac.core.utils.GFacUtils;
 import org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType;
 import org.apache.airavata.model.messaging.event.TaskIdentifier;
@@ -48,7 +48,7 @@ public abstract class AbstractHandler implements GFacHandler {
 
     public void invoke(JobExecutionContext jobExecutionContext) throws 
GFacHandlerException {
         try {
-            GFacUtils.updatePluginState(jobExecutionContext.getZk(), 
jobExecutionContext, this.getClass().getName(), GfacPluginState.INVOKED);
+            GFacUtils.updateHandlerState(jobExecutionContext.getZk(), 
jobExecutionContext, this.getClass().getName(), GfacHandlerState.INVOKED);
         } catch (Exception e) {
             logger.error("Error saving Recoverable provider state", e);
         }

http://git-wip-us.apache.org/repos/asf/airavata/blob/6f8fa3e9/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/handler/AppDescriptorCheckHandler.java
----------------------------------------------------------------------
diff --git 
a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/handler/AppDescriptorCheckHandler.java
 
b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/handler/AppDescriptorCheckHandler.java
index 7302fcf..fbd35b5 100644
--- 
a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/handler/AppDescriptorCheckHandler.java
+++ 
b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/handler/AppDescriptorCheckHandler.java
@@ -21,9 +21,8 @@
 package org.apache.airavata.gfac.core.handler;
 
 import org.apache.airavata.gfac.core.context.JobExecutionContext;
-import org.apache.airavata.gfac.core.states.GfacPluginState;
+import org.apache.airavata.gfac.core.states.GfacHandlerState;
 import org.apache.airavata.gfac.core.utils.GFacUtils;
-import 
org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -35,7 +34,7 @@ public class AppDescriptorCheckHandler implements GFacHandler 
{
     public void invoke(JobExecutionContext jobExecutionContext) throws 
GFacHandlerException {
         logger.info("Invoking ApplicationDescriptorCheckHandler ...");
         try {
-            GFacUtils.updatePluginState(jobExecutionContext.getZk(), 
jobExecutionContext, this.getClass().getName(), GfacPluginState.INVOKED);
+            GFacUtils.updateHandlerState(jobExecutionContext.getZk(), 
jobExecutionContext, this.getClass().getName(), GfacHandlerState.INVOKED);
         } catch (Exception e) {
             logger.info("Error saving plugin status to ZK");
         }

http://git-wip-us.apache.org/repos/asf/airavata/blob/6f8fa3e9/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/states/GfacPluginState.java
----------------------------------------------------------------------
diff --git 
a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/states/GfacPluginState.java
 
b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/states/GfacPluginState.java
deleted file mode 100644
index 818a144..0000000
--- 
a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/states/GfacPluginState.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- *
- * 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.states;
-
-public enum GfacPluginState {
-    INVOKING(0),
-    INVOKED(1),
-    COMPLETED(2),
-    UNKNOWN(3);
-
-    private final int value;
-
-    private GfacPluginState(int value) {
-        this.value = value;
-    }
-
-    /**
-     * Get the integer value of this enum value, as defined in the Thrift IDL.
-     */
-    public int getValue() {
-        return value;
-    }
-
-    /**
-     * Find a the enum type by its integer value, as defined in the Thrift IDL.
-     *
-     * @return null if the value is not found.
-     */
-    public static GfacPluginState findByValue(int value) {
-        switch (value) {
-            case 0:
-                return INVOKING;
-            case 1:
-                return INVOKED;
-            case 2:
-                return COMPLETED;
-            default:
-                return UNKNOWN;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/6f8fa3e9/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/utils/GFacUtils.java
----------------------------------------------------------------------
diff --git 
a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/utils/GFacUtils.java
 
b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/utils/GFacUtils.java
index 3b5d0ef..b49c041 100644
--- 
a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/utils/GFacUtils.java
+++ 
b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/utils/GFacUtils.java
@@ -36,7 +36,7 @@ import org.apache.airavata.gfac.GFacException;
 import org.apache.airavata.gfac.core.context.JobExecutionContext;
 import org.apache.airavata.gfac.core.handler.GFacHandlerException;
 import org.apache.airavata.gfac.core.states.GfacExperimentState;
-import org.apache.airavata.gfac.core.states.GfacPluginState;
+import org.apache.airavata.gfac.core.states.GfacHandlerState;
 import org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType;
 import org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType;
 import org.apache.airavata.model.appcatalog.computeresource.*;
@@ -960,15 +960,15 @@ public class GFacUtils {
                if (exists != null) {
                        zk.setData(expState + File.separator
                                        + 
AiravataZKUtils.ZK_EXPERIMENT_STATE_NODE,
-                                       
String.valueOf(GfacPluginState.INVOKING.getValue())
+                                       
String.valueOf(GfacHandlerState.INVOKING.getValue())
                                                        .getBytes(), 
exists.getVersion());
                }
                return true;
        }
 
-       public static boolean createPluginZnode(ZooKeeper zk,
-                       JobExecutionContext jobExecutionContext, String 
className,
-                       GfacPluginState state) throws 
ApplicationSettingsException,
+       public static boolean createHandlerZnode(ZooKeeper zk,
+                                             JobExecutionContext 
jobExecutionContext, String className,
+                                             GfacHandlerState state) throws 
ApplicationSettingsException,
                        KeeperException, InterruptedException {
                String expState = AiravataZKUtils.getExpZnodeHandlerPath(
                                jobExecutionContext.getExperimentID(), 
className);
@@ -1002,9 +1002,9 @@ public class GFacUtils {
                return true;
        }
 
-       public static boolean updatePluginState(ZooKeeper zk,
-                       JobExecutionContext jobExecutionContext, String 
className,
-                       GfacPluginState state) throws 
ApplicationSettingsException,
+       public static boolean updateHandlerState(ZooKeeper zk,
+                                             JobExecutionContext 
jobExecutionContext, String className,
+                                             GfacHandlerState state) throws 
ApplicationSettingsException,
                        KeeperException, InterruptedException {
                if(zk.getState().isConnected()) {
                        String expState = 
AiravataZKUtils.getExpZnodeHandlerPath(
@@ -1018,14 +1018,14 @@ public class GFacUtils {
                                                
String.valueOf(state.getValue()).getBytes(),
                                                exists.getVersion());
                        } else {
-                               createPluginZnode(zk, jobExecutionContext, 
className, state);
+                               createHandlerZnode(zk, jobExecutionContext, 
className, state);
                        }
                        return true;
                }
                return false;
        }
 
-       public static GfacPluginState getHandlerState(ZooKeeper zk,
+       public static GfacHandlerState getHandlerState(ZooKeeper zk,
                                                   JobExecutionContext 
jobExecutionContext, String className) {
                try {
                        String expState = 
AiravataZKUtils.getExpZnodeHandlerPath(
@@ -1037,9 +1037,9 @@ public class GFacUtils {
                 String stateVal = new String(zk.getData(expState + 
File.separator
                                 + AiravataZKUtils.ZK_EXPERIMENT_STATE_NODE, 
false,
                         exists));
-                return GfacPluginState.findByValue(Integer.valueOf(stateVal));
+                return GfacHandlerState.findByValue(Integer.valueOf(stateVal));
             }
-                       return GfacPluginState.UNKNOWN; // if the node doesn't 
exist or any other error we
+                       return GfacHandlerState.UNKNOWN; // if the node doesn't 
exist or any other error we
                                                        // return false
                } catch (Exception e) {
                        log.error("Error occured while getting zk node status", 
e);

Reply via email to