This is an automated email from the ASF dual-hosted git repository.

agingade pushed a commit to branch feature/GEODE-3583-storage
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/feature/GEODE-3583-storage by 
this push:
     new ef9a316  GEODE-4208: remove GemFireCacheImpl.getInstance from 
DistTxEntryEvent
ef9a316 is described below

commit ef9a3168095de1d2f0bf020bb36b4da15fdf8496
Author: Anil <aging...@pivotal.io>
AuthorDate: Fri Jan 12 15:28:53 2018 -0800

    GEODE-4208: remove GemFireCacheImpl.getInstance from DistTxEntryEvent
---
 .../apache/geode/internal/cache/DistTXState.java   | 10 ++++++++
 .../geode/internal/cache/EntryEventImpl.java       |  2 +-
 .../geode/internal/cache/tx/DistTxEntryEvent.java  | 27 +++++++++++++---------
 .../codeAnalysis/sanctionedDataSerializables.txt   |  4 ++--
 4 files changed, 29 insertions(+), 14 deletions(-)

diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/cache/DistTXState.java 
b/geode-core/src/main/java/org/apache/geode/internal/cache/DistTXState.java
index 30850bc..8276316 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/DistTXState.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/DistTXState.java
@@ -22,6 +22,7 @@ import java.util.Map.Entry;
 import java.util.Set;
 import java.util.TreeMap;
 
+import org.apache.geode.InternalGemFireException;
 import org.apache.geode.InvalidDeltaException;
 import org.apache.geode.SystemFailure;
 import org.apache.geode.cache.CacheWriterException;
@@ -368,11 +369,20 @@ public class DistTXState extends TXState {
         }
         dtop.setDistributedMember(sender);
         dtop.setOriginRemote(false);
+
         /*
          * [DISTTX} TODO handle call back argument version tag and other 
settings in PutMessage
          */
         String failureReason = null;
         try {
+          if (dtop.getRegion() == null) {
+            // Tx event from the peer.
+            if (dtop.getRegionName() == null) {
+              throw new InternalGemFireException("Region is unavailable on 
DistTxEntryEvent.");
+            }
+            dtop.setRegion((LocalRegion) 
getCache().getRegion(dtop.getRegionName()));
+          }
+
           if (dtop.getKeyInfo().isDistKeyInfo()) {
             dtop.getKeyInfo().setCheckPrimary(false);
           } else {
diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/cache/EntryEventImpl.java 
b/geode-core/src/main/java/org/apache/geode/internal/cache/EntryEventImpl.java
index 95d87be..575417a 100644
--- 
a/geode-core/src/main/java/org/apache/geode/internal/cache/EntryEventImpl.java
+++ 
b/geode-core/src/main/java/org/apache/geode/internal/cache/EntryEventImpl.java
@@ -516,7 +516,7 @@ public class EntryEventImpl
     setEventFlag(EventFlags.FLAG_LOCAL_INVALID, b);
   }
 
-  void setGenerateCallbacks(boolean b) {
+  public void setGenerateCallbacks(boolean b) {
     setEventFlag(EventFlags.FLAG_GENERATE_CALLBACKS, b);
   }
 
diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/cache/tx/DistTxEntryEvent.java
 
b/geode-core/src/main/java/org/apache/geode/internal/cache/tx/DistTxEntryEvent.java
index 2702ccd..85d1bad 100644
--- 
a/geode-core/src/main/java/org/apache/geode/internal/cache/tx/DistTxEntryEvent.java
+++ 
b/geode-core/src/main/java/org/apache/geode/internal/cache/tx/DistTxEntryEvent.java
@@ -42,6 +42,8 @@ public class DistTxEntryEvent extends EntryEventImpl {
   protected static final byte HAS_PUTALL_OP = 0x1;
   protected static final byte HAS_REMOVEALL_OP = 0x2;
 
+  private String regionName;
+
   /**
    * TODO DISTTX: callers of this constructor need to make sure that release 
is called. In general
    * the distributed tx code needs to be reviewed to see if it correctly 
handles off-heap.
@@ -54,6 +56,10 @@ public class DistTxEntryEvent extends EntryEventImpl {
   // For Serialization
   public DistTxEntryEvent() {}
 
+  public String getRegionName() {
+    return this.regionName;
+  }
+
   @Override
   public Version[] getSerializationVersions() {
     // TODO Auto-generated method stub
@@ -96,9 +102,7 @@ public class DistTxEntryEvent extends EntryEventImpl {
   @Override
   public void fromData(DataInput in) throws IOException, 
ClassNotFoundException {
     this.eventID = (EventID) DataSerializer.readObject(in);
-    String regionName = DataSerializer.readString(in);
-    InternalCache cache = GemFireCacheImpl.getInstance();
-    this.region = (LocalRegion) cache.getRegion(regionName);
+    this.regionName = DataSerializer.readString(in);
     this.op = Operation.fromOrdinal(in.readByte());
     Object key = DataSerializer.readObject(in);
     Integer bucketId = DataSerializer.readInteger(in);
@@ -168,11 +172,11 @@ public class DistTxEntryEvent extends EntryEventImpl {
         }
       }
     }
-    // TODO DISTTX: release this event?
-    EntryEventImpl e = EntryEventImpl.create(this.region, 
Operation.PUTALL_CREATE, null, null, null,
-        true, this.getDistributedMember(), true, true);
+    this.op = Operation.PUTALL_CREATE;
+    this.setOriginRemote(true);
+    this.setGenerateCallbacks(true);
 
-    this.putAllOp = new DistributedPutAllOperation(e, putAllSize, false /* 
[DISTTX] TODO */);
+    this.putAllOp = new DistributedPutAllOperation(this, putAllSize, false /* 
[DISTTX] TODO */);
     this.putAllOp.setPutAllEntryData(putAllEntries);
   }
 
@@ -224,11 +228,12 @@ public class DistTxEntryEvent extends EntryEventImpl {
         removeAllData[i].versionTag = versionTags.get(i);
       }
     }
-    // TODO DISTTX: release this event
-    EntryEventImpl e = EntryEventImpl.create(this.region, 
Operation.REMOVEALL_DESTROY, null, null,
-        null, true, this.getDistributedMember(), true, true);
+    this.op = Operation.REMOVEALL_DESTROY;
+    this.setOriginRemote(true);
+    this.setGenerateCallbacks(true);
+
     this.removeAllOp =
-        new DistributedRemoveAllOperation(e, removeAllSize, false /* [DISTTX] 
TODO */);
+        new DistributedRemoveAllOperation(this, removeAllSize, false /* 
[DISTTX] TODO */);
     this.removeAllOp.setRemoveAllEntryData(removeAllData);
   }
 
diff --git 
a/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedDataSerializables.txt
 
b/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedDataSerializables.txt
index 9c8d945..1c5a36d 100644
--- 
a/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedDataSerializables.txt
+++ 
b/geode-core/src/test/resources/org/apache/geode/codeAnalysis/sanctionedDataSerializables.txt
@@ -1951,8 +1951,8 @@ 
toData,40,2ab400023d2a59b400022ab4000460b500022ab400032b1c2ab400042ab400052ab400
 toDataPre_GFE_8_0_0_0,20,2ab400029a000a2ab40003b8000c2a2bb6000db1
 
 org/apache/geode/internal/cache/tx/DistTxEntryEvent,2
-fromData,118,2a2bb80018c00019b500042bb8001a4db8001b4e2a2d2cb9001c0200c0001db500062a2bb9001e0100b8001fb500082bb800183a042bb800203a052abb002159190401011905b70022b5000c2a2bb80018b600232bb80024b6002536061506047e9900082a2bb700261506057e9900082a2bb70027b1
-toData,121,2ab400042bb800052ab40006b600072bb800052b2ab40008b40009b9000a02002ab6000b2bb800052ab4000cb6000db8000e2bb8000f2ab600102bb80005033d2ab40011c600081c0480913d2ab40013c600081c0580913d1cb800142bb800152ab40011c600082a2bb700162ab40013c600082a2bb70017b1
+fromData,99,2a2bb80019c0001ab500052a2bb8001bb500032a2bb9001c0100b8001db500092bb800194d2bb8001e4e2abb001f592c01012db70020b5000d2a2bb80019b600212bb80022b6002336041504047e9900082a2bb700241504057e9900082a2bb70025b1
+toData,121,2ab400052bb800062ab40007b600082bb800062b2ab40009b4000ab9000b02002ab6000c2bb800062ab4000db6000eb8000f2bb800102ab600112bb80006033d2ab40012c600081c0480913d2ab40014c600081c0580913d1cb800152bb800162ab40012c600082a2bb700172ab40014c600082a2bb70018b1
 
 org/apache/geode/internal/cache/versions/RVVException,2
 fromData,1,b1

-- 
To stop receiving notification emails like this one, please contact
['"commits@geode.apache.org" <commits@geode.apache.org>'].

Reply via email to