airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lah...@apache.org
Subject airavata git commit: fixing issue with output handler invoation
Date Sat, 25 Apr 2015 00:09:50 GMT
Repository: airavata
Updated Branches:
  refs/heads/master b419e5b7a -> b47e4a933


fixing issue with output handler invoation


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

Branch: refs/heads/master
Commit: b47e4a9330e6e48bafa49442861388bbb7a40243
Parents: b419e5b
Author: Lahiru Gunathilake <glahiru@gmail.com>
Authored: Fri Apr 24 20:09:55 2015 -0400
Committer: Lahiru Gunathilake <glahiru@gmail.com>
Committed: Fri Apr 24 20:09:55 2015 -0400

----------------------------------------------------------------------
 .../client/samples/CreateLaunchExperiment.java  |  6 +--
 .../airavata/gfac/core/cpi/BetterGfacImpl.java  | 48 +++++++++++++++++++-
 2 files changed, 49 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/b47e4a93/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java
b/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java
index 829ed85..1d5de23 100644
--- a/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java
+++ b/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CreateLaunchExperiment.java
@@ -58,7 +58,7 @@ public class CreateLaunchExperiment {
     private static final String DEFAULT_GATEWAY = "php_reference_gateway";
     private static Airavata.Client airavataClient;
 
-    private static String echoAppId = "Echo_418d87fe-c720-4079-acd9-7e78aaa6cf76";
+    private static String echoAppId = "Echo_a3c69094-2591-47d9-b5c4-e14c9fa5abf5";
     private static String mpiAppId = "HelloMPI_bfd56d58-6085-4b7f-89fc-646576830518";
     private static String wrfAppId = "WRF_7ad5da38-c08b-417c-a9ea-da9298839762";
     private static String amberAppId = "Amber_dda3d2bb-e128-4814-9ade-7de9070169be";
@@ -167,13 +167,13 @@ public class CreateLaunchExperiment {
 //                final String expId = createEchoExperimentForFSD(airavataClient);
 //                final String expId = createMPIExperimentForFSD(airavataClient);
 //               final String expId = createEchoExperimentForStampede(airavataClient);
-//                final String expId = createEchoExperimentForTrestles(airavataClient);
+                final String expId = createEchoExperimentForTrestles(airavataClient);
 //                final String expId = createExperimentEchoForLocalHost(airavataClient);
 //                final String expId = createExperimentWRFTrestles(airavataClient);
 //                final String expId = createExperimentForBR2(airavataClient);
 //                final String expId = createExperimentForBR2Amber(airavataClient);
 //                final String expId = createExperimentWRFStampede(airavataClient);
-                final String expId = createExperimentForStampedeAmber(airavataClient);
+//                final String expId = createExperimentForStampedeAmber(airavataClient);
 //                String expId = createExperimentForTrestlesAmber(airavataClient);
 //                final String expId = createExperimentGROMACSStampede(airavataClient);
 //                final String expId = createExperimentESPRESSOStampede(airavataClient);

http://git-wip-us.apache.org/repos/asf/airavata/blob/b47e4a93/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 1f5124e..12533bb 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
@@ -100,6 +100,8 @@ public class BetterGfacImpl implements GFac,Watcher {
 
     private boolean cancelled = false;
 
+    private static Integer mutex = -1;
+
     /**
      * Constructor for GFac
      *
@@ -956,6 +958,18 @@ public class BetterGfacImpl implements GFac,Watcher {
     }
 
     public void invokeOutFlowHandlers(JobExecutionContext jobExecutionContext) throws GFacException
{
+        try {
+            jobExecutionContext.setZk(new ZooKeeper(AiravataZKUtils.getZKhostPort(), AiravataZKUtils.getZKTimeout(),this));
+            synchronized (mutex) {
+                mutex.wait();  // waiting for the syncConnected event
+            }
+        } catch (IOException e) {
+            log.error(e.getMessage(), e);
+        } catch (ApplicationSettingsException e) {
+            log.error(e.getMessage(), e);
+        } catch (InterruptedException e) {
+            log.error(e.getMessage(), e);
+        }
         GFacConfiguration gFacConfiguration = jobExecutionContext.getGFacConfiguration();
         List<GFacHandlerConfig> handlers = null;
         if (gFacConfiguration != null) {
@@ -1109,6 +1123,14 @@ public class BetterGfacImpl implements GFac,Watcher {
     }
 
     public void reInvokeOutFlowHandlers(JobExecutionContext jobExecutionContext) throws GFacException
{
+        try {
+            jobExecutionContext.setZk(new ZooKeeper(AiravataZKUtils.getZKhostPort(), AiravataZKUtils.getZKTimeout(),this));
+
+        } catch (IOException e) {
+            log.error(e.getMessage(), e);
+        } catch (ApplicationSettingsException e) {
+            log.error(e.getMessage(), e);
+        }
         GFacConfiguration gFacConfiguration = jobExecutionContext.getGFacConfiguration();
         List<GFacHandlerConfig> handlers = null;
         if (gFacConfiguration != null) {
@@ -1253,10 +1275,32 @@ public class BetterGfacImpl implements GFac,Watcher {
 
     public void process(WatchedEvent watchedEvent) {
         log.info(watchedEvent.getPath());
-        if(Event.EventType.NodeDataChanged.equals(watchedEvent.getType())){
+        if (Event.EventType.NodeDataChanged.equals(watchedEvent.getType())) {
             // node data is changed, this means node is cancelled.
-            log.info("Experiment is cancelled with this path:"+watchedEvent.getPath());
+            log.info("Experiment is cancelled with this path:" + watchedEvent.getPath());
             this.cancelled = true;
         }
+        synchronized (mutex) {
+            Event.KeeperState state = watchedEvent.getState();
+            log.info(state.name());
+            switch (state) {
+                case SyncConnected:
+                    mutex.notify();
+                    break;
+                case Expired:
+                case Disconnected:
+                    log.info("ZK Connection is " + state.toString());
+                    try {
+                        zk = new ZooKeeper(AiravataZKUtils.getZKhostPort(), AiravataZKUtils.getZKTimeout(),
this);
+                    } catch (IOException e) {
+                        log.error(e.getMessage(), e);
+                    } catch (ApplicationSettingsException e) {
+                        log.error(e.getMessage(), e);
+                    }
+//                    synchronized (mutex) {
+//                        mutex.wait();  // waiting for the syncConnected event
+//                    }
+            }
+        }
     }
 }


Mime
View raw message