You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by mb...@apache.org on 2015/11/16 21:15:20 UTC

[2/2] incubator-geode git commit: GEODE-542: Send a function response after a CancelException

GEODE-542: Send a function response after a CancelException

There was a catch clause of a CancelException that was causing us not to
reply to a function call if a CacheClosedException was thrown from the
function. That caused as hang waiting for replies.


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

Branch: refs/heads/feature/GEODE-151
Commit: d6c58e86a2abdb1670b02e4ac8089edb894f8f7c
Parents: aab0568
Author: Dan Smith <up...@apache.org>
Authored: Wed Nov 11 12:24:16 2015 -0800
Committer: Mark Bretl <mb...@pivotal.io>
Committed: Mon Nov 16 12:12:59 2015 -0800

----------------------------------------------------------------------
 .../cache/MemberFunctionStreamingMessage.java   |  9 ++--
 .../MemberFunctionExecutionDUnitTest.java       | 49 ++++++++++++++++++++
 2 files changed, 54 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d6c58e86/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/MemberFunctionStreamingMessage.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/MemberFunctionStreamingMessage.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/MemberFunctionStreamingMessage.java
index 9ea6f28..b3bdc85 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/MemberFunctionStreamingMessage.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/MemberFunctionStreamingMessage.java
@@ -32,6 +32,7 @@ import com.gemstone.gemfire.cache.CacheException;
 import com.gemstone.gemfire.cache.Region;
 import com.gemstone.gemfire.cache.execute.Function;
 import com.gemstone.gemfire.cache.execute.FunctionException;
+import com.gemstone.gemfire.cache.execute.FunctionInvocationTargetException;
 import com.gemstone.gemfire.cache.execute.FunctionService;
 import com.gemstone.gemfire.cache.execute.ResultSender;
 import com.gemstone.gemfire.cache.query.QueryException;
@@ -213,10 +214,10 @@ public class MemberFunctionStreamingMessage extends DistributionMessage implemen
       // bug 37026: this is too noisy...
       // throw new CacheClosedException("remote system shutting down");
       // thr = se; cache is closed, no point trying to send a reply
-      thr = null;
-      if (logger.isDebugEnabled()) {
-        logger.debug("shutdown caught, abandoning message: {}",exception.getMessage(), exception);
-      }
+      thr = new FunctionInvocationTargetException(exception);
+      stats.endFunctionExecutionWithException(this.functionObject.hasResult());
+      rex = new ReplyException(thr);
+      replyWithException(dm, rex);
     }
     catch (Exception exception) {
       if (logger.isDebugEnabled()) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d6c58e86/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/MemberFunctionExecutionDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/MemberFunctionExecutionDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/MemberFunctionExecutionDUnitTest.java
index 129cd18..4b8f009 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/MemberFunctionExecutionDUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/MemberFunctionExecutionDUnitTest.java
@@ -25,12 +25,16 @@ import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
+import java.util.concurrent.TimeUnit;
 
+import com.gemstone.gemfire.cache.CacheClosedException;
+import com.gemstone.gemfire.cache.CacheFactory;
 import com.gemstone.gemfire.cache.execute.Execution;
 import com.gemstone.gemfire.cache.execute.Function;
 import com.gemstone.gemfire.cache.execute.FunctionAdapter;
 import com.gemstone.gemfire.cache.execute.FunctionContext;
 import com.gemstone.gemfire.cache.execute.FunctionException;
+import com.gemstone.gemfire.cache.execute.FunctionInvocationTargetException;
 import com.gemstone.gemfire.cache.execute.FunctionService;
 import com.gemstone.gemfire.cache.execute.ResultCollector;
 import com.gemstone.gemfire.cache30.CacheTestCase;
@@ -46,6 +50,8 @@ import com.gemstone.gemfire.internal.cache.functions.TestFunction;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 
 import dunit.Host;
+import dunit.SerializableCallable;
+import dunit.SerializableRunnable;
 import dunit.VM;
 
 public class MemberFunctionExecutionDUnitTest extends CacheTestCase {
@@ -300,6 +306,49 @@ public class MemberFunctionExecutionDUnitTest extends CacheTestCase {
     member1.invoke(MemberFunctionExecutionDUnitTest.class, "bug41118");
   }
   
+  public void testOnMembersWithoutCache()
+      throws Exception {
+    DistributedMember member1Id = (DistributedMember) member1.invoke(new SerializableCallable() {
+      
+      @Override
+      public Object call() {
+        disconnectFromDS();
+        return getSystem().getDistributedMember();
+      }
+    });
+    
+    member2.invoke(new SerializableRunnable() {
+      
+      @Override
+      public void run() {
+        getSystem();
+        ResultCollector<?, ?> rc = FunctionService.onMember(member1Id).execute(new FunctionAdapter() {
+          
+          @Override
+          public String getId() {
+            return getClass().getName();
+          }
+          
+          @Override
+          public void execute(FunctionContext context) {
+            //This will throw an exception because the cache is not yet created.
+            CacheFactory.getAnyInstance();
+          }
+        });
+        
+        try {
+          rc.getResult(30, TimeUnit.SECONDS);
+          fail("Should have seen an exception");
+        } catch (Exception e) {
+          if(!(e.getCause() instanceof FunctionInvocationTargetException)) {
+            fail("failed", e);
+          }
+        }
+        
+      }
+    });
+  }
+  
   public static void bug41118(){
     ds = new MemberFunctionExecutionDUnitTest("temp").getSystem();
     assertNotNull(ds);