airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chath...@apache.org
Subject airavata git commit: fixing NPE at recover
Date Tue, 28 Apr 2015 19:26:27 GMT
Repository: airavata
Updated Branches:
  refs/heads/master 1fba5f95c -> 2527fe8a0


fixing NPE at recover


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

Branch: refs/heads/master
Commit: 2527fe8a0b889a9d348a612f753495c45343f1b6
Parents: 1fba5f9
Author: Chathuri Wimalasena <chathuri@apache.org>
Authored: Tue Apr 28 15:26:18 2015 -0400
Committer: Chathuri Wimalasena <chathuri@apache.org>
Committed: Tue Apr 28 15:26:18 2015 -0400

----------------------------------------------------------------------
 .../apache/airavata/gfac/server/GfacServerHandler.java   |  5 ++++-
 .../apache/airavata/gfac/core/cpi/BetterGfacImpl.java    | 11 +++++++++--
 2 files changed, 13 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/2527fe8a/modules/gfac/airavata-gfac-service/src/main/java/org/apache/airavata/gfac/server/GfacServerHandler.java
----------------------------------------------------------------------
diff --git a/modules/gfac/airavata-gfac-service/src/main/java/org/apache/airavata/gfac/server/GfacServerHandler.java
b/modules/gfac/airavata-gfac-service/src/main/java/org/apache/airavata/gfac/server/GfacServerHandler.java
index befda78..efd2005 100644
--- a/modules/gfac/airavata-gfac-service/src/main/java/org/apache/airavata/gfac/server/GfacServerHandler.java
+++ b/modules/gfac/airavata-gfac-service/src/main/java/org/apache/airavata/gfac/server/GfacServerHandler.java
@@ -301,7 +301,10 @@ public class GfacServerHandler implements GfacService.Iface, Watcher
{
 
     private GFac getGfac() throws TException {
         try {
-            return new BetterGfacImpl(registry, appCatalog, new ZooKeeper(AiravataZKUtils.getZKhostPort(),
AiravataZKUtils.getZKTimeout(), this), publisher);
+            if (zk == null || !zk.getState().isConnected()) {
+                zk = new ZooKeeper(AiravataZKUtils.getZKhostPort(), AiravataZKUtils.getZKTimeout(),
this);
+            }
+            return new BetterGfacImpl(registry, appCatalog, zk, publisher);
         } catch (Exception e) {
             throw new TException("Error initializing gfac instance", e);
         }

http://git-wip-us.apache.org/repos/asf/airavata/blob/2527fe8a/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 12533bb..30889b8 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
@@ -959,7 +959,10 @@ public class BetterGfacImpl implements GFac,Watcher {
 
     public void invokeOutFlowHandlers(JobExecutionContext jobExecutionContext) throws GFacException
{
         try {
-            jobExecutionContext.setZk(new ZooKeeper(AiravataZKUtils.getZKhostPort(), AiravataZKUtils.getZKTimeout(),this));
+            if (zk == null || !zk.getState().isConnected()){
+                zk = new ZooKeeper(AiravataZKUtils.getZKhostPort(), AiravataZKUtils.getZKTimeout(),this);
+            }
+            jobExecutionContext.setZk(zk);
             synchronized (mutex) {
                 mutex.wait();  // waiting for the syncConnected event
             }
@@ -1086,6 +1089,7 @@ public class BetterGfacImpl implements GFac,Watcher {
                             // if these already ran we re-run only recoverable handlers
                             log.info(handlerClassName.getClassName() + " is a recoverable
handler so we recover the handler");
                             GFacUtils.createPluginZnode(zk, jobExecutionContext, handlerClassName.getClassName(),
GfacPluginState.INVOKING);
+                            handler.initProperties(handlerClassName.getProperties());
                             ((GFacRecoverableHandler) handler).recover(jobExecutionContext);
                             GFacUtils.updatePluginState(zk, jobExecutionContext, handlerClassName.getClassName(),
GfacPluginState.COMPLETED);
                         } else {
@@ -1124,7 +1128,10 @@ public class BetterGfacImpl implements GFac,Watcher {
 
     public void reInvokeOutFlowHandlers(JobExecutionContext jobExecutionContext) throws GFacException
{
         try {
-            jobExecutionContext.setZk(new ZooKeeper(AiravataZKUtils.getZKhostPort(), AiravataZKUtils.getZKTimeout(),this));
+            if (zk == null || !zk.getState().isConnected()){
+                zk = new ZooKeeper(AiravataZKUtils.getZKhostPort(), AiravataZKUtils.getZKTimeout(),this);
+            }
+            jobExecutionContext.setZk(zk);
 
         } catch (IOException e) {
             log.error(e.getMessage(), e);


Mime
View raw message