geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zho...@apache.org
Subject incubator-geode git commit: GEODE-669 Add CacheObserver for ShutdownAll
Date Tue, 15 Dec 2015 19:24:19 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/develop 0b288a21d -> ae2d52940


GEODE-669
Add CacheObserver for ShutdownAll

Let GatewayReceiverCommand to throw CacheClosedException instead of
RegionDestroyedException when ShutdownAll happened.


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

Branch: refs/heads/develop
Commit: ae2d529405f28caa0ab9fc1a3d309ebddbda4920
Parents: 0b288a2
Author: zhouxh <gzhou@pivotal.io>
Authored: Tue Dec 15 11:21:32 2015 -0800
Committer: zhouxh <gzhou@pivotal.io>
Committed: Tue Dec 15 11:22:56 2015 -0800

----------------------------------------------------------------------
 .../gemfire/internal/cache/CacheObserver.java   |  5 ++++
 .../internal/cache/CacheObserverAdapter.java    |  4 ++++
 .../internal/cache/GemFireCacheImpl.java        |  7 ++++++
 .../sockets/command/GatewayReceiverCommand.java | 24 +++++++++++++-------
 4 files changed, 32 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ae2d5294/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/CacheObserver.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/CacheObserver.java
b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/CacheObserver.java
index 9cd6c28..6b18d86 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/CacheObserver.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/CacheObserver.java
@@ -183,4 +183,9 @@ public interface CacheObserver
    */
   public void beforeDeletingEmptyOplog(Oplog emptyOplog);
   
+  /**
+   * Invoked just before ShutdownAll operation
+   * @param emptyOplog
+   */
+  void beforeShutdownAll();
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ae2d5294/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/CacheObserverAdapter.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/CacheObserverAdapter.java
b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/CacheObserverAdapter.java
index 82c4507..ef66739 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/CacheObserverAdapter.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/CacheObserverAdapter.java
@@ -147,4 +147,8 @@ public class CacheObserverAdapter implements CacheObserver {
   public void beforeDeletingEmptyOplog(Oplog emptyOplog)
   {
   }
+  
+  @Override
+  public void beforeShutdownAll() {
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ae2d5294/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/GemFireCacheImpl.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/GemFireCacheImpl.java
b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/GemFireCacheImpl.java
index 27bb813..506bd7a 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/GemFireCacheImpl.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/GemFireCacheImpl.java
@@ -1639,6 +1639,13 @@ public class GemFireCacheImpl implements InternalCache, ClientCache,
HasCachePer
       // it's already doing shutdown by another thread
       return;
     }
+    if (LocalRegion.ISSUE_CALLBACKS_TO_CACHE_OBSERVER) {
+      try {
+        CacheObserverHolder.getInstance().beforeShutdownAll();
+      } finally {
+        LocalRegion.ISSUE_CALLBACKS_TO_CACHE_OBSERVER = false;
+      }
+    }
     this.isShutDownAll = true;
 
     // bug 44031 requires multithread shutdownall should be grouped

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ae2d5294/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/GatewayReceiverCommand.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/GatewayReceiverCommand.java
b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/GatewayReceiverCommand.java
index 6d252e4..e2fb686 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/GatewayReceiverCommand.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/GatewayReceiverCommand.java
@@ -24,6 +24,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 import com.gemstone.gemfire.CancelException;
+import com.gemstone.gemfire.cache.CacheClosedException;
 import com.gemstone.gemfire.cache.EntryNotFoundException;
 import com.gemstone.gemfire.cache.RegionDestroyedException;
 import com.gemstone.gemfire.cache.operations.DestroyOperationContext;
@@ -36,6 +37,7 @@ import com.gemstone.gemfire.i18n.LogWriterI18n;
 import com.gemstone.gemfire.internal.Version;
 import com.gemstone.gemfire.internal.cache.EntryEventImpl;
 import com.gemstone.gemfire.internal.cache.EventID;
+import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
 import com.gemstone.gemfire.internal.cache.KeyWithRegionContext;
 import com.gemstone.gemfire.internal.cache.LocalRegion;
 import com.gemstone.gemfire.internal.cache.tier.CachedRegionHelper;
@@ -67,6 +69,16 @@ public class GatewayReceiverCommand extends BaseCommand {
   private GatewayReceiverCommand() {
   }
 
+  private void handleRegionNull(ServerConnection servConn, String regionName, int batchId)
{
+    GemFireCacheImpl gfc = (GemFireCacheImpl)servConn.getCachedRegionHelper().getCache();
+    if (gfc != null && gfc.isCacheAtShutdownAll()) {
+      throw new CacheClosedException("Shutdown occurred during message processing");
+    } else {
+      String reason = LocalizedStrings.ProcessBatch_WAS_NOT_FOUND_DURING_BATCH_CREATE_REQUEST_0.toLocalizedString(new
Object[] {regionName, Integer.valueOf(batchId)});
+      throw new RegionDestroyedException(reason, regionName);
+    }
+  }
+  
   @Override
   public void cmdExecute(Message msg, ServerConnection servConn, long start)
       throws IOException, InterruptedException {
@@ -292,8 +304,7 @@ public class GatewayReceiverCommand extends BaseCommand {
           }
           region = (LocalRegion)crHelper.getRegion(regionName);
           if (region == null) {
-            String reason = LocalizedStrings.ProcessBatch_WAS_NOT_FOUND_DURING_BATCH_CREATE_REQUEST_0.toLocalizedString(new
Object[] {regionName, Integer.valueOf(batchId)});
-            throw new RegionDestroyedException(reason, regionName);
+            handleRegionNull(servConn, regionName, batchId);
           } else {
             clientEvent = new EntryEventImpl(eventId);
             if (versionTimeStamp > 0) {
@@ -402,8 +413,7 @@ public class GatewayReceiverCommand extends BaseCommand {
           }
           region = (LocalRegion)crHelper.getRegion(regionName);
           if (region == null) {
-            String reason = LocalizedStrings.ProcessBatch_WAS_NOT_FOUND_DURING_BATCH_CREATE_REQUEST_0.toLocalizedString(new
Object[] {regionName, Integer.valueOf(batchId)});
-            throw new RegionDestroyedException(reason, regionName);
+            handleRegionNull(servConn, regionName, batchId);
           } else {
             clientEvent = new EntryEventImpl(eventId);
             if (versionTimeStamp > 0) {
@@ -502,8 +512,7 @@ public class GatewayReceiverCommand extends BaseCommand {
           }
           region = (LocalRegion)crHelper.getRegion(regionName);
           if (region == null) {
-            String reason = LocalizedStrings.ProcessBatch_WAS_NOT_FOUND_DURING_BATCH_CREATE_REQUEST_0.toLocalizedString(new
Object[] {regionName, Integer.valueOf(batchId)});
-            throw new RegionDestroyedException(reason, regionName);
+            handleRegionNull(servConn, regionName, batchId);
           } else {
             clientEvent = new EntryEventImpl(eventId);
             if (versionTimeStamp > 0) {
@@ -584,8 +593,7 @@ public class GatewayReceiverCommand extends BaseCommand {
             region = (LocalRegion)crHelper.getRegion(regionName);
             
             if (region == null) {
-              String reason = LocalizedStrings.ProcessBatch_WAS_NOT_FOUND_DURING_BATCH_UPDATE_VERSION_REQUEST_0.toLocalizedString(new
Object[] {regionName});
-              throw new RegionDestroyedException(reason, regionName);
+              handleRegionNull(servConn, regionName, batchId);
             } else {
 
               clientEvent = new EntryEventImpl(eventId);


Mime
View raw message