geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jinmeil...@apache.org
Subject [1/2] incubator-geode git commit: Destory and Invalidate
Date Tue, 21 Jun 2016 16:24:34 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/feature/GEODE-1571 6cd2ff956 -> 756d8216e


Destory and Invalidate


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

Branch: refs/heads/feature/GEODE-1571
Commit: b32a510fece74f52a53583eecf79067e6ba354a5
Parents: ea9a585
Author: Kevin J. Duling <kduling@pivotal.io>
Authored: Mon Jun 20 16:02:56 2016 -0700
Committer: Kevin J. Duling <kduling@pivotal.io>
Committed: Mon Jun 20 16:02:56 2016 -0700

----------------------------------------------------------------------
 .../cache/tier/sockets/command/Destroy.java     | 233 +++++++++----------
 .../cache/tier/sockets/command/Destroy65.java   | 216 +++++++++--------
 .../cache/tier/sockets/command/Invalidate.java  | 126 +++++-----
 .../security/IntegratedClientAuthDUnitTest.java |  65 ++++++
 4 files changed, 338 insertions(+), 302 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b32a510f/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Destroy.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Destroy.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Destroy.java
index 593cc08..cc99962 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Destroy.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Destroy.java
@@ -15,11 +15,20 @@
  * limitations under the License.
  */
 /**
- * 
+ *
  */
+
 package com.gemstone.gemfire.internal.cache.tier.sockets.command;
 
-import com.gemstone.gemfire.internal.cache.EntryEventImpl;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+import com.gemstone.gemfire.cache.DynamicRegionFactory;
+import com.gemstone.gemfire.cache.EntryNotFoundException;
+import com.gemstone.gemfire.cache.RegionDestroyedException;
+import com.gemstone.gemfire.cache.operations.DestroyOperationContext;
+import com.gemstone.gemfire.cache.operations.RegionDestroyOperationContext;
+import com.gemstone.gemfire.distributed.internal.DistributionStats;
 import com.gemstone.gemfire.internal.cache.EventID;
 import com.gemstone.gemfire.internal.cache.EventIDHolder;
 import com.gemstone.gemfire.internal.cache.LocalRegion;
@@ -27,36 +36,32 @@ import com.gemstone.gemfire.internal.cache.PartitionedRegion;
 import com.gemstone.gemfire.internal.cache.tier.CachedRegionHelper;
 import com.gemstone.gemfire.internal.cache.tier.Command;
 import com.gemstone.gemfire.internal.cache.tier.MessageType;
-import com.gemstone.gemfire.internal.cache.tier.sockets.*;
+import com.gemstone.gemfire.internal.cache.tier.sockets.BaseCommand;
+import com.gemstone.gemfire.internal.cache.tier.sockets.CacheServerStats;
+import com.gemstone.gemfire.internal.cache.tier.sockets.Message;
+import com.gemstone.gemfire.internal.cache.tier.sockets.Part;
+import com.gemstone.gemfire.internal.cache.tier.sockets.ServerConnection;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage;
 import com.gemstone.gemfire.internal.security.AuthorizeRequest;
+import com.gemstone.gemfire.internal.security.GeodeSecurityUtil;
 import com.gemstone.gemfire.security.GemFireSecurityException;
-import com.gemstone.gemfire.cache.DynamicRegionFactory;
-import com.gemstone.gemfire.cache.EntryNotFoundException;
-import com.gemstone.gemfire.cache.RegionDestroyedException;
-import com.gemstone.gemfire.cache.operations.DestroyOperationContext;
-import com.gemstone.gemfire.cache.operations.RegionDestroyOperationContext;
-import com.gemstone.gemfire.distributed.internal.DistributionStats;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
 
 
 public class Destroy extends BaseCommand {
 
   private final static Destroy singleton = new Destroy();
 
-  public static Command getCommand() {
-    return singleton;
+  private Destroy() {
   }
 
-  private Destroy() {
+  public static Command getCommand() {
+    return singleton;
   }
 
   @Override
   public void cmdExecute(Message msg, ServerConnection servConn, long startparam)
-      throws IOException, InterruptedException {
+    throws IOException, InterruptedException {
     long start = startparam;
 
     Part regionNamePart = null, keyPart = null, callbackArgPart = null;
@@ -77,13 +82,12 @@ public class Destroy extends BaseCommand {
     regionNamePart = msg.getPart(0);
     keyPart = msg.getPart(1);
     eventPart = msg.getPart(2);
-//    callbackArgPart = null; (redundant assignment)
+    //    callbackArgPart = null; (redundant assignment)
     if (msg.getNumberOfParts() > 3) {
       callbackArgPart = msg.getPart(3);
       try {
         callbackArg = callbackArgPart.getObject();
-      }
-      catch (Exception e) {
+      } catch (Exception e) {
         writeException(msg, e, false, servConn);
         servConn.setAsTrue(RESPONDED);
         return;
@@ -92,129 +96,118 @@ public class Destroy extends BaseCommand {
     regionName = regionNamePart.getString();
     try {
       key = keyPart.getStringOrObject();
-    }
-    catch (Exception e) {
+    } catch (Exception e) {
       writeException(msg, e, false, servConn);
       servConn.setAsTrue(RESPONDED);
       return;
     }
     if (logger.isDebugEnabled()) {
-      logger.debug("{}: Received destroy request ({} bytes) from {} for region {} key {}", servConn.getName(), msg.getPayloadLength(), servConn.getSocketString(), regionName, key);
+      logger.debug("{}: Received destroy request ({} bytes) from {} for region {} key {}", servConn.getName(), msg.getPayloadLength(), servConn
+        .getSocketString(), regionName, key);
     }
 
     // Process the destroy request
     if (key == null || regionName == null) {
       if (key == null) {
-        logger.warn(LocalizedMessage.create(LocalizedStrings.Destroy_0_THE_INPUT_KEY_FOR_THE_DESTROY_REQUEST_IS_NULL, servConn.getName()));
+        logger.warn(LocalizedMessage.create(LocalizedStrings.Destroy_0_THE_INPUT_KEY_FOR_THE_DESTROY_REQUEST_IS_NULL, servConn
+          .getName()));
         errMessage.append(LocalizedStrings.Destroy__THE_INPUT_KEY_FOR_THE_DESTROY_REQUEST_IS_NULL.toLocalizedString());
       }
       if (regionName == null) {
-        logger.warn(LocalizedMessage.create(LocalizedStrings.Destroy_0_THE_INPUT_REGION_NAME_FOR_THE_DESTROY_REQUEST_IS_NULL, servConn.getName()));
-        errMessage
-            .append(LocalizedStrings.Destroy__THE_INPUT_REGION_NAME_FOR_THE_DESTROY_REQUEST_IS_NULL.toLocalizedString());
+        logger.warn(LocalizedMessage.create(LocalizedStrings.Destroy_0_THE_INPUT_REGION_NAME_FOR_THE_DESTROY_REQUEST_IS_NULL, servConn
+          .getName()));
+        errMessage.append(LocalizedStrings.Destroy__THE_INPUT_REGION_NAME_FOR_THE_DESTROY_REQUEST_IS_NULL.toLocalizedString());
       }
-      writeErrorResponse(msg, MessageType.DESTROY_DATA_ERROR, errMessage
-          .toString(), servConn);
+      writeErrorResponse(msg, MessageType.DESTROY_DATA_ERROR, errMessage.toString(), servConn);
       servConn.setAsTrue(RESPONDED);
+      return;
     }
-    else {
-      LocalRegion region = (LocalRegion)crHelper.getRegion(regionName);
-      if (region == null) {
-        String reason = LocalizedStrings.Destroy__0_WAS_NOT_FOUND_DURING_DESTROY_REQUEST.toLocalizedString(regionName);
-        writeRegionDestroyedEx(msg, regionName, reason, servConn);
-        servConn.setAsTrue(RESPONDED);
-      }
-      else {
-        // Destroy the entry
-        ByteBuffer eventIdPartsBuffer = ByteBuffer.wrap(eventPart
-            .getSerializedForm());
-        long threadId = EventID
-            .readEventIdPartsFromOptmizedByteArray(eventIdPartsBuffer);
-        long sequenceId = EventID
-            .readEventIdPartsFromOptmizedByteArray(eventIdPartsBuffer);
-        EventID eventId = new EventID(servConn.getEventMemberIDByteArray(),
-            threadId, sequenceId);
-
-        try {
-          AuthorizeRequest authzRequest = servConn.getAuthzRequest();
-          if (authzRequest != null) {
-            // TODO SW: This is to handle DynamicRegionFactory destroy
-            // calls. Rework this when the semantics of DynamicRegionFactory are
-            // cleaned up.
-            if (DynamicRegionFactory.regionIsDynamicRegionList(regionName)) {
-              RegionDestroyOperationContext destroyContext = authzRequest
-                  .destroyRegionAuthorize((String)key, callbackArg);
-              callbackArg = destroyContext.getCallbackArg();
-            }
-            else {
-              DestroyOperationContext destroyContext = authzRequest
-                  .destroyAuthorize(regionName, key, callbackArg);
-              callbackArg = destroyContext.getCallbackArg();
-            }
-          }
-          region.basicBridgeDestroy(key, callbackArg, servConn.getProxyID(),
-              true, new EventIDHolder(eventId));
-          servConn.setModificationInfo(true, regionName, key);
-        }
-        catch (EntryNotFoundException e) {
-          // Don't send an exception back to the client if this
-          // exception happens. Just log it and continue.
-          logger.info(LocalizedMessage.create(LocalizedStrings.Destroy_0_DURING_ENTRY_DESTROY_NO_ENTRY_WAS_FOUND_FOR_KEY_1, new Object[] {servConn.getName(), key})); 
-        }
-        catch (RegionDestroyedException rde) {
-          writeException(msg, rde, false, servConn);
-          servConn.setAsTrue(RESPONDED);
-          return;
-        }
-        catch (Exception e) {
-          // If an interrupted exception is thrown , rethrow it
-          checkForInterrupt(servConn, e);
-
-          // If an exception occurs during the destroy, preserve the connection
-          writeException(msg, e, false, servConn);
-          servConn.setAsTrue(RESPONDED);
-          if (e instanceof GemFireSecurityException) {
-            // Fine logging for security exceptions since these are already
-            // logged by the security logger
-            if (logger.isDebugEnabled()) {
-              logger.debug("{}: Unexpected Security exception", servConn.getName(), e);
-            }
-          }
-          else {
-            logger.warn(LocalizedMessage.create(LocalizedStrings.Destroy_0_UNEXPECTED_EXCEPTION, servConn.getName()), e); 
-          }
-          return;
-        }
 
-        // Update the statistics and write the reply
-        {
-          long oldStart = start;
-          start = DistributionStats.getStatTime();
-          stats.incProcessDestroyTime(start - oldStart);
-        }
-        if (region instanceof PartitionedRegion) {
-          PartitionedRegion pr = (PartitionedRegion)region;
-          if (pr.isNetworkHop() != (byte)0) {
-            writeReplyWithRefreshMetadata(msg, servConn, pr, pr.isNetworkHop());
-            pr.setIsNetworkHop((byte)0);
-            pr.setMetadataVersion(Byte.valueOf((byte)0));
-          }
-          else {
-            writeReply(msg, servConn);
-          }
-        }
-        else {
-          writeReply(msg, servConn);
+    LocalRegion region = (LocalRegion) crHelper.getRegion(regionName);
+    if (region == null) {
+      String reason = LocalizedStrings.Destroy__0_WAS_NOT_FOUND_DURING_DESTROY_REQUEST.toLocalizedString(regionName);
+      writeRegionDestroyedEx(msg, regionName, reason, servConn);
+      servConn.setAsTrue(RESPONDED);
+      return;
+    }
+
+    // Destroy the entry
+    ByteBuffer eventIdPartsBuffer = ByteBuffer.wrap(eventPart.getSerializedForm());
+    long threadId = EventID.readEventIdPartsFromOptmizedByteArray(eventIdPartsBuffer);
+    long sequenceId = EventID.readEventIdPartsFromOptmizedByteArray(eventIdPartsBuffer);
+    EventID eventId = new EventID(servConn.getEventMemberIDByteArray(), threadId, sequenceId);
+
+    // for integrated security
+    GeodeSecurityUtil.authorizeRegionWrite(regionName, key.toString());
+
+    try {
+      AuthorizeRequest authzRequest = servConn.getAuthzRequest();
+      if (authzRequest != null) {
+        // TODO SW: This is to handle DynamicRegionFactory destroy
+        // calls. Rework this when the semantics of DynamicRegionFactory are
+        // cleaned up.
+        if (DynamicRegionFactory.regionIsDynamicRegionList(regionName)) {
+          RegionDestroyOperationContext destroyContext = authzRequest.destroyRegionAuthorize((String) key, callbackArg);
+          callbackArg = destroyContext.getCallbackArg();
+        } else {
+          DestroyOperationContext destroyContext = authzRequest.destroyAuthorize(regionName, key, callbackArg);
+          callbackArg = destroyContext.getCallbackArg();
         }
-        servConn.setAsTrue(RESPONDED);
+      }
+      region.basicBridgeDestroy(key, callbackArg, servConn.getProxyID(), true, new EventIDHolder(eventId));
+      servConn.setModificationInfo(true, regionName, key);
+    } catch (EntryNotFoundException e) {
+      // Don't send an exception back to the client if this
+      // exception happens. Just log it and continue.
+      logger.info(LocalizedMessage.create(LocalizedStrings.Destroy_0_DURING_ENTRY_DESTROY_NO_ENTRY_WAS_FOUND_FOR_KEY_1, new Object[] {
+        servConn.getName(),
+        key
+      }));
+    } catch (RegionDestroyedException rde) {
+      writeException(msg, rde, false, servConn);
+      servConn.setAsTrue(RESPONDED);
+      return;
+    } catch (Exception e) {
+      // If an interrupted exception is thrown , rethrow it
+      checkForInterrupt(servConn, e);
+
+      // If an exception occurs during the destroy, preserve the connection
+      writeException(msg, e, false, servConn);
+      servConn.setAsTrue(RESPONDED);
+      if (e instanceof GemFireSecurityException) {
+        // Fine logging for security exceptions since these are already
+        // logged by the security logger
         if (logger.isDebugEnabled()) {
-          logger.debug("{}: Sent destroy response for region {} key {}", servConn.getName(), regionName, key);
+          logger.debug("{}: Unexpected Security exception", servConn.getName(), e);
         }
-        stats.incWriteDestroyResponseTime(DistributionStats.getStatTime()
-            - start);
+      } else {
+        logger.warn(LocalizedMessage.create(LocalizedStrings.Destroy_0_UNEXPECTED_EXCEPTION, servConn.getName()), e);
       }
+      return;
     }
 
+    // Update the statistics and write the reply
+    {
+      long oldStart = start;
+      start = DistributionStats.getStatTime();
+      stats.incProcessDestroyTime(start - oldStart);
+    }
+    if (region instanceof PartitionedRegion) {
+      PartitionedRegion pr = (PartitionedRegion) region;
+      if (pr.isNetworkHop() != (byte) 0) {
+        writeReplyWithRefreshMetadata(msg, servConn, pr, pr.isNetworkHop());
+        pr.setIsNetworkHop((byte) 0);
+        pr.setMetadataVersion(Byte.valueOf((byte) 0));
+      } else {
+        writeReply(msg, servConn);
+      }
+    } else {
+      writeReply(msg, servConn);
+    }
+    servConn.setAsTrue(RESPONDED);
+    if (logger.isDebugEnabled()) {
+      logger.debug("{}: Sent destroy response for region {} key {}", servConn.getName(), regionName, key);
+    }
+    stats.incWriteDestroyResponseTime(DistributionStats.getStatTime() - start);
   }
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b32a510f/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Destroy65.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Destroy65.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Destroy65.java
index 27ebbd9..c88ea24 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Destroy65.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Destroy65.java
@@ -15,86 +15,92 @@
  * limitations under the License.
  */
 /**
- * 
+ *
  */
+
 package com.gemstone.gemfire.internal.cache.tier.sockets.command;
 
-import com.gemstone.gemfire.i18n.LogWriterI18n;
-import com.gemstone.gemfire.internal.cache.Token;
-import com.gemstone.gemfire.internal.cache.OpType;
-import com.gemstone.gemfire.internal.cache.EntryEventImpl;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+import com.gemstone.gemfire.cache.DynamicRegionFactory;
+import com.gemstone.gemfire.cache.EntryNotFoundException;
+import com.gemstone.gemfire.cache.Operation;
+import com.gemstone.gemfire.cache.RegionDestroyedException;
+import com.gemstone.gemfire.cache.operations.DestroyOperationContext;
+import com.gemstone.gemfire.cache.operations.RegionDestroyOperationContext;
+import com.gemstone.gemfire.distributed.internal.DistributionStats;
 import com.gemstone.gemfire.internal.cache.EventID;
 import com.gemstone.gemfire.internal.cache.EventIDHolder;
 import com.gemstone.gemfire.internal.cache.LocalRegion;
+import com.gemstone.gemfire.internal.cache.OpType;
 import com.gemstone.gemfire.internal.cache.PartitionedRegion;
+import com.gemstone.gemfire.internal.cache.Token;
 import com.gemstone.gemfire.internal.cache.tier.CachedRegionHelper;
 import com.gemstone.gemfire.internal.cache.tier.Command;
 import com.gemstone.gemfire.internal.cache.tier.MessageType;
-import com.gemstone.gemfire.internal.cache.tier.sockets.*;
+import com.gemstone.gemfire.internal.cache.tier.sockets.BaseCommand;
+import com.gemstone.gemfire.internal.cache.tier.sockets.CacheServerStats;
+import com.gemstone.gemfire.internal.cache.tier.sockets.Message;
+import com.gemstone.gemfire.internal.cache.tier.sockets.Part;
+import com.gemstone.gemfire.internal.cache.tier.sockets.ServerConnection;
 import com.gemstone.gemfire.internal.cache.versions.VersionTag;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage;
 import com.gemstone.gemfire.internal.security.AuthorizeRequest;
+import com.gemstone.gemfire.internal.security.GeodeSecurityUtil;
 import com.gemstone.gemfire.internal.util.Breadcrumbs;
 import com.gemstone.gemfire.security.GemFireSecurityException;
-import com.gemstone.gemfire.cache.DynamicRegionFactory;
-import com.gemstone.gemfire.cache.EntryNotFoundException;
-import com.gemstone.gemfire.cache.Operation;
-import com.gemstone.gemfire.cache.RegionDestroyedException;
-import com.gemstone.gemfire.cache.client.internal.DestroyOp;
-import com.gemstone.gemfire.cache.operations.DestroyOperationContext;
-import com.gemstone.gemfire.cache.operations.RegionDestroyOperationContext;
-import com.gemstone.gemfire.distributed.internal.DistributionStats;
-import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
 
 
 public class Destroy65 extends BaseCommand {
 
   private final static Destroy65 singleton = new Destroy65();
 
-  public static Command getCommand() {
-    return singleton;
+  protected Destroy65() {
   }
 
-  protected Destroy65() {
+  public static Command getCommand() {
+    return singleton;
   }
 
   @Override
   protected void writeReplyWithRefreshMetadata(Message origMsg,
-      ServerConnection servConn, PartitionedRegion pr, byte nwHop) throws IOException {
+                                               ServerConnection servConn,
+                                               PartitionedRegion pr,
+                                               byte nwHop) throws IOException {
     throw new UnsupportedOperationException();
   }
-  
+
   protected void writeReplyWithRefreshMetadata(Message origMsg,
-      ServerConnection servConn, PartitionedRegion pr,
-      boolean entryNotFoundForRemove, byte nwHop, VersionTag tag) throws IOException {
+                                               ServerConnection servConn,
+                                               PartitionedRegion pr,
+                                               boolean entryNotFoundForRemove,
+                                               byte nwHop,
+                                               VersionTag tag) throws IOException {
     Message replyMsg = servConn.getReplyMessage();
     servConn.getCache().getCancelCriterion().checkCancelInProgress(null);
     replyMsg.setMessageType(MessageType.REPLY);
     replyMsg.setNumberOfParts(2);
     replyMsg.setTransactionId(origMsg.getTransactionId());
-    replyMsg.addBytesPart(new byte[]{pr.getMetadataVersion().byteValue(), nwHop});
+    replyMsg.addBytesPart(new byte[] { pr.getMetadataVersion(), nwHop });
     pr.getPrStats().incPRMetaDataSentCount();
-    replyMsg.addIntPart(entryNotFoundForRemove? 1 : 0);
+    replyMsg.addIntPart(entryNotFoundForRemove ? 1 : 0);
     replyMsg.send(servConn);
     if (logger.isTraceEnabled()) {
       logger.trace("{}: rpl with REFRESH_METADAT tx: {}", servConn.getName(), origMsg.getTransactionId());
     }
   }
 
-  protected void writeReply(Message origMsg, ServerConnection servConn,
-      boolean entryNotFound, VersionTag tag)
-  throws IOException {
+  protected void writeReply(Message origMsg, ServerConnection servConn, boolean entryNotFound, VersionTag tag)
+    throws IOException {
     Message replyMsg = servConn.getReplyMessage();
     servConn.getCache().getCancelCriterion().checkCancelInProgress(null);
     replyMsg.setMessageType(MessageType.REPLY);
     replyMsg.setNumberOfParts(2);
     replyMsg.setTransactionId(origMsg.getTransactionId());
     replyMsg.addBytesPart(OK_BYTES);
-    replyMsg.addIntPart(entryNotFound? 1 : 0);
+    replyMsg.addIntPart(entryNotFound ? 1 : 0);
     replyMsg.send(servConn);
     if (logger.isTraceEnabled()) {
       logger.trace("{}: rpl tx: {} parts={}", servConn.getName(), origMsg.getTransactionId(), replyMsg.getNumberOfParts());
@@ -102,8 +108,7 @@ public class Destroy65 extends BaseCommand {
   }
 
   @Override
-  public void cmdExecute(Message msg, ServerConnection servConn, long start)
-      throws IOException, InterruptedException {
+  public void cmdExecute(Message msg, ServerConnection servConn, long start) throws IOException, InterruptedException {
     Part regionNamePart;
     Part keyPart;
     Part callbackArgPart;
@@ -120,23 +125,22 @@ public class Destroy65 extends BaseCommand {
     CacheServerStats stats = servConn.getCacheServerStats();
     servConn.setAsTrue(REQUIRES_RESPONSE);
 
-    long now =  DistributionStats.getStatTime();
+    long now = DistributionStats.getStatTime();
     stats.incReadDestroyRequestTime(now - start);
-    
+
     // Retrieve the data from the message parts
     regionNamePart = msg.getPart(0);
     keyPart = msg.getPart(1);
     expectedOldValuePart = msg.getPart(2);
     try {
-    	
-        operation = msg.getPart(3).getObject();                
-        
-        if (( (operation instanceof Operation) && ((Operation)operation == Operation.REMOVE ))
-        		|| ((operation instanceof Byte) && (Byte)operation == OpType.DESTROY ))
-        		
-        {        	
-          expectedOldValue = expectedOldValuePart.getObject();
-        }
+
+      operation = msg.getPart(3).getObject();
+
+      if (((operation instanceof Operation) && ((Operation) operation == Operation.REMOVE)) || ((operation instanceof Byte) && (Byte) operation == OpType.DESTROY))
+
+      {
+        expectedOldValue = expectedOldValuePart.getObject();
+      }
     } catch (Exception e) {
       writeException(msg, e, false, servConn);
       servConn.setAsTrue(RESPONDED);
@@ -149,8 +153,7 @@ public class Destroy65 extends BaseCommand {
       callbackArgPart = msg.getPart(5);
       try {
         callbackArg = callbackArgPart.getObject();
-      }
-      catch (Exception e) {
+      } catch (Exception e) {
         writeException(msg, e, false, servConn);
         servConn.setAsTrue(RESPONDED);
         return;
@@ -159,58 +162,53 @@ public class Destroy65 extends BaseCommand {
     regionName = regionNamePart.getString();
     try {
       key = keyPart.getStringOrObject();
-    }
-    catch (Exception e) {
+    } catch (Exception e) {
       writeException(msg, e, false, servConn);
       servConn.setAsTrue(RESPONDED);
       return;
     }
     if (logger.isDebugEnabled()) {
-      logger.debug("{}: Received destroy65 request ({} bytes; op={}) from {} for region {} key {}{} txId {}", servConn.getName(), msg.getPayloadLength(), operation, servConn.getSocketString(), regionName, key, (operation == Operation.REMOVE? " value=" + expectedOldValue : ""), msg.getTransactionId());
+      logger.debug("{}: Received destroy65 request ({} bytes; op={}) from {} for region {} key {}{} txId {}", servConn.getName(), msg
+        .getPayloadLength(), operation, servConn.getSocketString(), regionName, key, (operation == Operation.REMOVE ? " value=" + expectedOldValue : ""), msg
+        .getTransactionId());
     }
     boolean entryNotFoundForRemove = false;
 
     // Process the destroy request
     if (key == null || regionName == null) {
       if (key == null) {
-        logger.warn(LocalizedMessage.create(LocalizedStrings.Destroy_0_THE_INPUT_KEY_FOR_THE_DESTROY_REQUEST_IS_NULL, servConn.getName()));
+        logger.warn(LocalizedMessage.create(LocalizedStrings.Destroy_0_THE_INPUT_KEY_FOR_THE_DESTROY_REQUEST_IS_NULL, servConn
+          .getName()));
         errMessage.append(LocalizedStrings.Destroy__THE_INPUT_KEY_FOR_THE_DESTROY_REQUEST_IS_NULL.toLocalizedString());
       }
       if (regionName == null) {
-        logger.warn(LocalizedMessage.create(LocalizedStrings.Destroy_0_THE_INPUT_REGION_NAME_FOR_THE_DESTROY_REQUEST_IS_NULL, servConn.getName()));
-        errMessage
-            .append(LocalizedStrings.Destroy__THE_INPUT_REGION_NAME_FOR_THE_DESTROY_REQUEST_IS_NULL.toLocalizedString());
+        logger.warn(LocalizedMessage.create(LocalizedStrings.Destroy_0_THE_INPUT_REGION_NAME_FOR_THE_DESTROY_REQUEST_IS_NULL, servConn
+          .getName()));
+        errMessage.append(LocalizedStrings.Destroy__THE_INPUT_REGION_NAME_FOR_THE_DESTROY_REQUEST_IS_NULL.toLocalizedString());
       }
-      writeErrorResponse(msg, MessageType.DESTROY_DATA_ERROR, errMessage
-          .toString(), servConn);
+      writeErrorResponse(msg, MessageType.DESTROY_DATA_ERROR, errMessage.toString(), servConn);
       servConn.setAsTrue(RESPONDED);
-    }
-    else {
-      LocalRegion region = (LocalRegion)crHelper.getRegion(regionName);
+    } else {
+      LocalRegion region = (LocalRegion) crHelper.getRegion(regionName);
       if (region == null) {
         String reason = LocalizedStrings.Destroy__0_WAS_NOT_FOUND_DURING_DESTROY_REQUEST.toLocalizedString(regionName);
         writeRegionDestroyedEx(msg, regionName, reason, servConn);
         servConn.setAsTrue(RESPONDED);
-      }
-      else {
+      } else {
         // Destroy the entry
-        ByteBuffer eventIdPartsBuffer = ByteBuffer.wrap(eventPart
-            .getSerializedForm());
-        long threadId = EventID
-            .readEventIdPartsFromOptmizedByteArray(eventIdPartsBuffer);
-        long sequenceId = EventID
-            .readEventIdPartsFromOptmizedByteArray(eventIdPartsBuffer);
-        EventID eventId = new EventID(servConn.getEventMemberIDByteArray(),
-            threadId, sequenceId);
+        ByteBuffer eventIdPartsBuffer = ByteBuffer.wrap(eventPart.getSerializedForm());
+        long threadId = EventID.readEventIdPartsFromOptmizedByteArray(eventIdPartsBuffer);
+        long sequenceId = EventID.readEventIdPartsFromOptmizedByteArray(eventIdPartsBuffer);
+        EventID eventId = new EventID(servConn.getEventMemberIDByteArray(), threadId, sequenceId);
         EventIDHolder clientEvent = new EventIDHolder(eventId);
-        
+
         Breadcrumbs.setEventId(eventId);
 
         // msg.isRetry might be set by v7.0 and later clients
         if (msg.isRetry()) {
-//          if (logger.isDebugEnabled()) {
-//            logger.debug("DEBUG: encountered isRetry in Destroy65");
-//          }
+          //          if (logger.isDebugEnabled()) {
+          //            logger.debug("DEBUG: encountered isRetry in Destroy65");
+          //          }
           clientEvent.setPossibleDuplicate(true);
           if (region.getAttributes().getConcurrencyChecksEnabled()) {
             // recover the version tag from other servers
@@ -220,7 +218,10 @@ public class Destroy65 extends BaseCommand {
             }
           }
         }
-        
+
+        // for integrated security
+        GeodeSecurityUtil.authorizeRegionWrite(regionName, key.toString());
+
         try {
           AuthorizeRequest authzRequest = servConn.getAuthzRequest();
           if (authzRequest != null) {
@@ -228,26 +229,22 @@ public class Destroy65 extends BaseCommand {
             // calls. Rework this when the semantics of DynamicRegionFactory are
             // cleaned up.
             if (DynamicRegionFactory.regionIsDynamicRegionList(regionName)) {
-              RegionDestroyOperationContext destroyContext = authzRequest
-                  .destroyRegionAuthorize((String)key, callbackArg);
+              RegionDestroyOperationContext destroyContext = authzRequest.destroyRegionAuthorize((String) key, callbackArg);
               callbackArg = destroyContext.getCallbackArg();
-            }
-            else {
-              DestroyOperationContext destroyContext = authzRequest
-                  .destroyAuthorize(regionName, key, callbackArg);
+            } else {
+              DestroyOperationContext destroyContext = authzRequest.destroyAuthorize(regionName, key, callbackArg);
               callbackArg = destroyContext.getCallbackArg();
             }
           }
-          if (operation == null  ||  operation == Operation.DESTROY) {        	  
-            region.basicBridgeDestroy(key, callbackArg, servConn.getProxyID(),
-                true, clientEvent);
+          if (operation == null || operation == Operation.DESTROY) {
+            region.basicBridgeDestroy(key, callbackArg, servConn.getProxyID(), true, clientEvent);
           } else {
             // this throws exceptions if expectedOldValue checks fail
             try {
-              if (expectedOldValue == null && operation != null) {
-            	  expectedOldValue = Token.INVALID;
+              if (expectedOldValue == null) {
+                expectedOldValue = Token.INVALID;
               }
-              if (operation == Operation.REMOVE  &&  msg.isRetry()  &&  clientEvent.getVersionTag() != null) {
+              if (operation == Operation.REMOVE && msg.isRetry() && clientEvent.getVersionTag() != null) {
                 // the operation was successful last time it was tried, so there's
                 // no need to perform it again.  Just return the version tag and
                 // success status
@@ -256,15 +253,13 @@ public class Destroy65 extends BaseCommand {
                 }
                 // try the operation anyway to ensure that it's been distributed to all servers
                 try {
-                  region.basicBridgeRemove(key, expectedOldValue, 
-                      callbackArg, servConn.getProxyID(), true, clientEvent);
+                  region.basicBridgeRemove(key, expectedOldValue, callbackArg, servConn.getProxyID(), true, clientEvent);
                 } catch (EntryNotFoundException e) {
                   // ignore, and don't set entryNotFoundForRemove because this was a successful
                   // operation - bug #51664
                 }
               } else {
-                region.basicBridgeRemove(key, expectedOldValue, 
-                    callbackArg, servConn.getProxyID(), true, clientEvent);
+                region.basicBridgeRemove(key, expectedOldValue, callbackArg, servConn.getProxyID(), true, clientEvent);
                 if (logger.isDebugEnabled()) {
                   logger.debug("region.remove succeeded");
                 }
@@ -278,19 +273,19 @@ public class Destroy65 extends BaseCommand {
             }
           }
           servConn.setModificationInfo(true, regionName, key);
-        }
-        catch (EntryNotFoundException e) {
+        } catch (EntryNotFoundException e) {
           // Don't send an exception back to the client if this
           // exception happens. Just log it and continue.
-          logger.info(LocalizedMessage.create(LocalizedStrings.Destroy_0_DURING_ENTRY_DESTROY_NO_ENTRY_WAS_FOUND_FOR_KEY_1, new Object[] {servConn.getName(), key})); 
+          logger.info(LocalizedMessage.create(LocalizedStrings.Destroy_0_DURING_ENTRY_DESTROY_NO_ENTRY_WAS_FOUND_FOR_KEY_1, new Object[] {
+            servConn.getName(),
+            key
+          }));
           entryNotFoundForRemove = true;
-        }
-        catch (RegionDestroyedException rde) {
+        } catch (RegionDestroyedException rde) {
           writeException(msg, rde, false, servConn);
           servConn.setAsTrue(RESPONDED);
           return;
-        }
-        catch (Exception e) {
+        } catch (Exception e) {
           // If an interrupted exception is thrown , rethrow it
           checkForInterrupt(servConn, e);
 
@@ -300,11 +295,11 @@ public class Destroy65 extends BaseCommand {
           if (e instanceof GemFireSecurityException) {
             // Fine logging for security exceptions since these are already
             // logged by the security logger
-            if (logger.isDebugEnabled())
+            if (logger.isDebugEnabled()) {
               logger.debug("{}: Unexpected Security exception", servConn.getName(), e);
-          }
-          else {
-            logger.warn(LocalizedMessage.create(LocalizedStrings.Destroy_0_UNEXPECTED_EXCEPTION, servConn.getName()), e); 
+            }
+          } else {
+            logger.warn(LocalizedMessage.create(LocalizedStrings.Destroy_0_UNEXPECTED_EXCEPTION, servConn.getName()), e);
           }
           return;
         }
@@ -312,30 +307,27 @@ public class Destroy65 extends BaseCommand {
         // Update the statistics and write the reply
         now = DistributionStats.getStatTime();
         stats.incProcessDestroyTime(now - start);
-        
+
         if (region instanceof PartitionedRegion) {
-          PartitionedRegion pr = (PartitionedRegion)region;
-          if (pr.isNetworkHop() != (byte)0) {
+          PartitionedRegion pr = (PartitionedRegion) region;
+          if (pr.isNetworkHop() != (byte) 0) {
             writeReplyWithRefreshMetadata(msg, servConn, pr, entryNotFoundForRemove, pr.isNetworkHop(), clientEvent.getVersionTag());
-            pr.setIsNetworkHop((byte)0);
-            pr.setMetadataVersion(Byte.valueOf((byte)0));
-          }
-          else {
+            pr.setIsNetworkHop((byte) 0);
+            pr.setMetadataVersion((byte) 0);
+          } else {
             writeReply(msg, servConn, entryNotFoundForRemove | clientEvent.getIsRedestroyedEntry(), clientEvent.getVersionTag());
           }
-        }
-        else {
+        } else {
           writeReply(msg, servConn, entryNotFoundForRemove | clientEvent.getIsRedestroyedEntry(), clientEvent.getVersionTag());
         }
         servConn.setAsTrue(RESPONDED);
         if (logger.isDebugEnabled()) {
           logger.debug("{}: Sent destroy response for region {} key {}", servConn.getName(), regionName, key);
         }
-        stats.incWriteDestroyResponseTime(DistributionStats.getStatTime()
-            - start);
+        stats.incWriteDestroyResponseTime(DistributionStats.getStatTime() - start);
       }
     }
 
-    
+
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b32a510f/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Invalidate.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Invalidate.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Invalidate.java
index 3f313c9..ee64872 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Invalidate.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/command/Invalidate.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 /**
- * 
+ *
  */
 package com.gemstone.gemfire.internal.cache.tier.sockets.command;
 
@@ -26,7 +26,6 @@ import com.gemstone.gemfire.cache.EntryNotFoundException;
 import com.gemstone.gemfire.cache.RegionDestroyedException;
 import com.gemstone.gemfire.cache.operations.InvalidateOperationContext;
 import com.gemstone.gemfire.distributed.internal.DistributionStats;
-import com.gemstone.gemfire.internal.cache.EntryEventImpl;
 import com.gemstone.gemfire.internal.cache.EventID;
 import com.gemstone.gemfire.internal.cache.EventIDHolder;
 import com.gemstone.gemfire.internal.cache.LocalRegion;
@@ -43,6 +42,7 @@ import com.gemstone.gemfire.internal.cache.versions.VersionTag;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage;
 import com.gemstone.gemfire.internal.security.AuthorizeRequest;
+import com.gemstone.gemfire.internal.security.GeodeSecurityUtil;
 import com.gemstone.gemfire.internal.util.Breadcrumbs;
 import com.gemstone.gemfire.security.GemFireSecurityException;
 
@@ -51,16 +51,15 @@ public class Invalidate extends BaseCommand {
 
   private final static Invalidate singleton = new Invalidate();
 
-  public static Command getCommand() {
-    return singleton;
+  Invalidate() {
   }
 
-  Invalidate() {
+  public static Command getCommand() {
+    return singleton;
   }
 
   @Override
-  public void cmdExecute(Message msg, ServerConnection servConn, long start)
-      throws IOException, InterruptedException {
+  public void cmdExecute(Message msg, ServerConnection servConn, long start) throws IOException, InterruptedException {
     Part regionNamePart = null, keyPart = null, callbackArgPart = null;
     String regionName = null;
     Object callbackArg = null, key = null;
@@ -79,13 +78,12 @@ public class Invalidate extends BaseCommand {
     regionNamePart = msg.getPart(0);
     keyPart = msg.getPart(1);
     eventPart = msg.getPart(2);
-//    callbackArgPart = null; (redundant assignment)
+    //    callbackArgPart = null; (redundant assignment)
     if (msg.getNumberOfParts() > 3) {
       callbackArgPart = msg.getPart(3);
       try {
         callbackArg = callbackArgPart.getObject();
-      }
-      catch (Exception e) {
+      } catch (Exception e) {
         writeException(msg, e, false, servConn);
         servConn.setAsTrue(RESPONDED);
         return;
@@ -94,17 +92,14 @@ public class Invalidate extends BaseCommand {
     regionName = regionNamePart.getString();
     try {
       key = keyPart.getStringOrObject();
-    }
-    catch (Exception e) {
+    } catch (Exception e) {
       writeException(msg, e, false, servConn);
       servConn.setAsTrue(RESPONDED);
       return;
     }
     if (logger.isDebugEnabled()) {
-      logger.debug(servConn.getName() + ": Received invalidate request ("
-          + msg.getPayloadLength() + " bytes) from "
-          + servConn.getSocketString() + " for region " + regionName + " key "
-          + key);
+      logger.debug(servConn.getName() + ": Received invalidate request (" + msg.getPayloadLength() + " bytes) from " + servConn
+        .getSocketString() + " for region " + regionName + " key " + key);
     }
 
     // Process the invalidate request
@@ -115,52 +110,47 @@ public class Invalidate extends BaseCommand {
       }
       if (regionName == null) {
         logger.warn(LocalizedMessage.create(LocalizedStrings.BaseCommand__THE_INPUT_REGION_NAME_FOR_THE_0_REQUEST_IS_NULL, "invalidate"));
-        errMessage
-            .append(LocalizedStrings.BaseCommand__THE_INPUT_REGION_NAME_FOR_THE_0_REQUEST_IS_NULL.toLocalizedString("invalidate"));
+        errMessage.append(LocalizedStrings.BaseCommand__THE_INPUT_REGION_NAME_FOR_THE_0_REQUEST_IS_NULL.toLocalizedString("invalidate"));
       }
-      writeErrorResponse(msg, MessageType.DESTROY_DATA_ERROR, errMessage
-          .toString(), servConn);
+      writeErrorResponse(msg, MessageType.DESTROY_DATA_ERROR, errMessage.toString(), servConn);
       servConn.setAsTrue(RESPONDED);
-    }
-    else {
-      LocalRegion region = (LocalRegion)crHelper.getRegion(regionName);
+    } else {
+      LocalRegion region = (LocalRegion) crHelper.getRegion(regionName);
       if (region == null) {
-        String reason = LocalizedStrings.BaseCommand__0_WAS_NOT_FOUND_DURING_1_REQUEST.toLocalizedString(regionName,"invalidate");
+        String reason = LocalizedStrings.BaseCommand__0_WAS_NOT_FOUND_DURING_1_REQUEST.toLocalizedString(regionName, "invalidate");
         writeRegionDestroyedEx(msg, regionName, reason, servConn);
         servConn.setAsTrue(RESPONDED);
-      }
-      else {
+      } else {
         // Invalidate the entry
-        ByteBuffer eventIdPartsBuffer = ByteBuffer.wrap(eventPart
-            .getSerializedForm());
-        long threadId = EventID
-            .readEventIdPartsFromOptmizedByteArray(eventIdPartsBuffer);
-        long sequenceId = EventID
-            .readEventIdPartsFromOptmizedByteArray(eventIdPartsBuffer);
-        EventID eventId = new EventID(servConn.getEventMemberIDByteArray(),
-            threadId, sequenceId);
-        
+        ByteBuffer eventIdPartsBuffer = ByteBuffer.wrap(eventPart.getSerializedForm());
+        long threadId = EventID.readEventIdPartsFromOptmizedByteArray(eventIdPartsBuffer);
+        long sequenceId = EventID.readEventIdPartsFromOptmizedByteArray(eventIdPartsBuffer);
+        EventID eventId = new EventID(servConn.getEventMemberIDByteArray(), threadId, sequenceId);
+
         Breadcrumbs.setEventId(eventId);
 
         VersionTag tag = null;
+
+        // for integrated security
+        GeodeSecurityUtil.authorizeRegionWrite(regionName, key.toString());
+
         try {
           /*
            * 
            * txtodo: doesn't seem like there is any notion of authzInvalidate
-           */ 
+           */
           AuthorizeRequest authzRequest = servConn.getAuthzRequest();
           if (authzRequest != null) {
-            InvalidateOperationContext invalidateContext = authzRequest
-                .invalidateAuthorize(regionName, key, callbackArg);
+            InvalidateOperationContext invalidateContext = authzRequest.invalidateAuthorize(regionName, key, callbackArg);
             callbackArg = invalidateContext.getCallbackArg();
           }
           EventIDHolder clientEvent = new EventIDHolder(eventId);
 
           // msg.isRetry might be set by v7.0 and later clients
           if (msg.isRetry()) {
-//            if (logger.isDebugEnabled()) {
-//              logger.debug("DEBUG: encountered isRetry in Invalidate");
-//            }
+            //            if (logger.isDebugEnabled()) {
+            //              logger.debug("DEBUG: encountered isRetry in Invalidate");
+            //            }
             clientEvent.setPossibleDuplicate(true);
             if (region.getAttributes().getConcurrencyChecksEnabled()) {
               // recover the version tag from other servers
@@ -170,23 +160,22 @@ public class Invalidate extends BaseCommand {
               }
             }
           }
-          
-          region.basicBridgeInvalidate(key, callbackArg, servConn.getProxyID(),
-              true, clientEvent);
+
+          region.basicBridgeInvalidate(key, callbackArg, servConn.getProxyID(), true, clientEvent);
           tag = clientEvent.getVersionTag();
           servConn.setModificationInfo(true, regionName, key);
-        }
-        catch (EntryNotFoundException e) {
+        } catch (EntryNotFoundException e) {
           // Don't send an exception back to the client if this
           // exception happens. Just log it and continue.
-          logger.info(LocalizedMessage.create(LocalizedStrings.BaseCommand_DURING_0_NO_ENTRY_WAS_FOUND_FOR_KEY_1, new Object[] {"invalidate", key}));
-        }
-        catch (RegionDestroyedException rde) {
+          logger.info(LocalizedMessage.create(LocalizedStrings.BaseCommand_DURING_0_NO_ENTRY_WAS_FOUND_FOR_KEY_1, new Object[] {
+            "invalidate",
+            key
+          }));
+        } catch (RegionDestroyedException rde) {
           writeException(msg, rde, false, servConn);
           servConn.setAsTrue(RESPONDED);
           return;
-        }
-        catch (Exception e) {
+        } catch (Exception e) {
           // If an interrupted exception is thrown , rethrow it
           checkForInterrupt(servConn, e);
 
@@ -196,11 +185,11 @@ public class Invalidate extends BaseCommand {
           if (e instanceof GemFireSecurityException) {
             // Fine logging for security exceptions since these are already
             // logged by the security logger
-            if (logger.isDebugEnabled())
+            if (logger.isDebugEnabled()) {
               logger.debug("{}: Unexpected Security exception", servConn.getName(), e);
-          }
-          else {
-            logger.warn(LocalizedMessage.create(LocalizedStrings.BaseCommand_0_UNEXPECTED_EXCEPTION, servConn.getName()), e); 
+            }
+          } else {
+            logger.warn(LocalizedMessage.create(LocalizedStrings.BaseCommand_0_UNEXPECTED_EXCEPTION, servConn.getName()), e);
           }
           return;
         }
@@ -212,39 +201,36 @@ public class Invalidate extends BaseCommand {
           stats.incProcessInvalidateTime(start - oldStart);
         }
         if (region instanceof PartitionedRegion) {
-          PartitionedRegion pr = (PartitionedRegion)region;
-          if (pr.isNetworkHop() != (byte)0) {
+          PartitionedRegion pr = (PartitionedRegion) region;
+          if (pr.isNetworkHop() != (byte) 0) {
             writeReplyWithRefreshMetadata(msg, servConn, pr, pr.isNetworkHop(), tag);
-            pr.setIsNetworkHop((byte)0);
-            pr.setMetadataVersion(Byte.valueOf((byte)0));
-          }
-          else {
+            pr.setIsNetworkHop((byte) 0);
+            pr.setMetadataVersion(Byte.valueOf((byte) 0));
+          } else {
             writeReply(msg, servConn, tag);
           }
-        }
-        else {
+        } else {
           writeReply(msg, servConn, tag);
         }
         servConn.setAsTrue(RESPONDED);
         if (logger.isDebugEnabled()) {
           logger.debug("{}: Sent invalidate response for region {} key {}", servConn.getName(), regionName, key);
         }
-        stats.incWriteInvalidateResponseTime(DistributionStats.getStatTime()
-            - start);
+        stats.incWriteInvalidateResponseTime(DistributionStats.getStatTime() - start);
       }
     }
 
   }
 
-  protected void writeReply(Message origMsg, ServerConnection servConn,
-      VersionTag tag)
-  throws IOException {
+  protected void writeReply(Message origMsg, ServerConnection servConn, VersionTag tag) throws IOException {
     writeReply(origMsg, servConn);
   }
 
   protected void writeReplyWithRefreshMetadata(Message origMsg,
-      ServerConnection servConn, PartitionedRegion pr,
-      byte nwHop, VersionTag tag) throws IOException {
+                                               ServerConnection servConn,
+                                               PartitionedRegion pr,
+                                               byte nwHop,
+                                               VersionTag tag) throws IOException {
     writeReplyWithRefreshMetadata(origMsg, servConn, pr, nwHop);
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b32a510f/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientAuthDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientAuthDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientAuthDUnitTest.java
index dbd88a9..8359736 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientAuthDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientAuthDUnitTest.java
@@ -17,6 +17,7 @@
 
 package com.gemstone.gemfire.security;
 
+import static com.gemstone.gemfire.cache.query.CacheUtils.*;
 import static org.assertj.core.api.Assertions.*;
 import static org.junit.Assert.*;
 
@@ -36,6 +37,7 @@ import com.gemstone.gemfire.cache.Region;
 import com.gemstone.gemfire.management.internal.security.JSONAuthorization;
 import com.gemstone.gemfire.test.dunit.AsyncInvocation;
 import com.gemstone.gemfire.test.dunit.Host;
+import com.gemstone.gemfire.test.dunit.SerializableRunnable;
 import com.gemstone.gemfire.test.dunit.VM;
 import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
 import com.gemstone.gemfire.test.junit.categories.DistributedTest;
@@ -171,6 +173,69 @@ public class IntegratedClientAuthDUnitTest extends JUnit4DistributedTestCase {
     ai3.checkException();
   }
 
+  @Test
+  public void testDestroyInvalidate() throws InterruptedException {
+
+    // First, load up 5 keys to work with
+    SerializableRunnable putKeys = new SerializableRunnable() {
+      @Override
+      public void run() {
+        Cache cache = getCache();
+        Region region = cache.getRegion(SecurityTestUtils.REGION_NAME);
+        assertNotNull(region);
+        region.clear();
+        for (int i = 0; i < 5; i++) {
+          String key = "key" + i;
+          String value = "value" + i;
+          region.put(key, value);
+        }
+        assertEquals(5, region.size());
+      }
+    };
+    server1.invoke(putKeys);
+
+    // Delete one key and invalidate another key with an authorized user.
+    AsyncInvocation ai1 = client1.invokeAsync(() -> {
+      Cache cache = SecurityTestUtils.createCacheClient("authRegionUser", "1234567", serverPort, SecurityTestUtils.NO_EXCEPTION);
+      final Region region = cache.getRegion(SecurityTestUtils.REGION_NAME);
+
+      assertEquals(region.get("key1"), "value1");
+      assertTrue(region.containsKey("key1")); // will only be true after we first get it, then it's cached locally
+
+      // Destroy key1
+      region.destroy("key1");
+      assertFalse(region.containsKey("key1"));
+
+      // Invalidate key2
+      assertNotNull("Value of key2 should not be null", region.get("key2"));
+      region.invalidate("key2");
+      assertNull("Value of key2 should have been null", region.get("key2"));
+      cache.close();
+    });
+
+    // Delete one key and invalidate another key with an unauthorized user.
+    AsyncInvocation ai2 = client2.invokeAsync(() -> {
+      Cache cache = SecurityTestUtils.createCacheClient("authRegionReader", "1234567", serverPort, SecurityTestUtils.NO_EXCEPTION);
+      final Region region = cache.getRegion(SecurityTestUtils.REGION_NAME);
+
+      assertEquals(region.get("key3"), "value3");
+      assertTrue(region.containsKey("key3")); // will only be true after we first get it, then it's cached locally
+
+      // Destroy key1
+      assertNotAuthorized(() -> region.destroy("key3"), "DATA:WRITE:AuthRegion");
+      assertTrue(region.containsKey("key3"));
+
+      // Invalidate key2
+      assertNotNull("Value of key4 should not be null", region.get("key4"));
+      assertNotAuthorized(() -> region.invalidate("key4"), "DATA:WRITE:AuthRegion");
+      assertNotNull("Value of key4 should not be null", region.get("key4"));
+      cache.close();
+    });
+    ai1.join();
+    ai2.join();
+    ai1.checkException();
+    ai2.checkException();
+  }
 
   public static void assertNotAuthorized(ThrowingCallable shouldRaiseThrowable, String permString){
     assertThatThrownBy(shouldRaiseThrowable).hasMessageContaining(permString);


Mime
View raw message