geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mark...@apache.org
Subject [28/50] [abbrv] incubator-geode git commit: GEODE-542: Send a function response after a CancelException
Date Mon, 23 Nov 2015 20:48:58 GMT
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/88da7025
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/88da7025
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/88da7025

Branch: refs/heads/feature/GEODE-53
Commit: 88da702593157d8a0c014295cab16149fc088dfc
Parents: 5a0d43e
Author: Dan Smith <upthewaterspout@apache.org>
Authored: Wed Nov 11 12:24:16 2015 -0800
Committer: Dan Smith <upthewaterspout@apache.org>
Committed: Fri Nov 13 15:22:42 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/88da7025/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/88da7025/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);


Mime
View raw message