You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ds...@apache.org on 2016/04/12 01:05:48 UTC

[1/3] incubator-geode git commit: added @Retained for getEventForListener

Repository: incubator-geode
Updated Branches:
  refs/heads/feature/GEODE-1199 b5836abba -> dabfb000f


added @Retained for getEventForListener


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

Branch: refs/heads/feature/GEODE-1199
Commit: 3e6281f28bbe95fe81326585247e463e0d59f2f0
Parents: b5836ab
Author: Darrel Schneider <ds...@pivotal.io>
Authored: Fri Apr 8 11:36:51 2016 -0700
Committer: Darrel Schneider <ds...@pivotal.io>
Committed: Fri Apr 8 11:36:51 2016 -0700

----------------------------------------------------------------------
 .../gemfire/internal/cache/SearchLoadAndWriteProcessor.java | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3e6281f2/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/SearchLoadAndWriteProcessor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/SearchLoadAndWriteProcessor.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/SearchLoadAndWriteProcessor.java
index f197dc6..7d576e9 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/SearchLoadAndWriteProcessor.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/SearchLoadAndWriteProcessor.java
@@ -74,6 +74,7 @@ import com.gemstone.gemfire.internal.cache.versions.VersionTag;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage;
+import com.gemstone.gemfire.internal.offheap.annotations.Retained;
 
 
 /**
@@ -220,6 +221,7 @@ public class SearchLoadAndWriteProcessor implements MembershipListener {
     if (scope == Scope.LOCAL && (region.getPartitionAttributes() == null)) {
       return false;
     }
+    @Retained
     CacheEvent listenerEvent = getEventForListener(event);
     try {
     if (action == BEFOREUPDATE && listenerEvent.getOperation().isCreate()) {
@@ -817,16 +819,20 @@ public class SearchLoadAndWriteProcessor implements MembershipListener {
 
   /**
    * Returns an event for listener notification.  The event's operation
-   * may be altered to conform to the ConcurrentMap implementation specification
+   * may be altered to conform to the ConcurrentMap implementation specification.
+   * If the returned value is not == to the event parameter then the caller
+   * is responsible for releasing it.
    * @param event the original event
    * @return the original event or a new event having a change in operation
    */
+  @Retained
   private CacheEvent getEventForListener(CacheEvent event) {
     Operation op = event.getOperation();
     if (!op.isEntry()) {
       return event;
     } else {
       EntryEventImpl r = (EntryEventImpl)event;
+      @Retained
       EntryEventImpl result = r;
       if (r.isSingleHop()) {
         // fix for bug #46130 - origin remote incorrect for one-hop operation in receiver
@@ -863,6 +869,7 @@ public class SearchLoadAndWriteProcessor implements MembershipListener {
         return false;
       }
     }
+    @Retained
     CacheEvent event = getEventForListener(pevent);
     
     int action = paction;


[2/3] incubator-geode git commit: added unit test

Posted by ds...@apache.org.
added unit test


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

Branch: refs/heads/feature/GEODE-1199
Commit: b99fbc6119761870c5b0e04a65b9f3b4094bd2c3
Parents: 3e6281f
Author: Darrel Schneider <ds...@pivotal.io>
Authored: Mon Apr 11 15:59:40 2016 -0700
Committer: Darrel Schneider <ds...@pivotal.io>
Committed: Mon Apr 11 15:59:40 2016 -0700

----------------------------------------------------------------------
 .../cache/SearchLoadAndWriteProcessor.java      | 12 ++--
 .../cache/SearchLoadAndWriteProcessorTest.java  | 70 ++++++++++++++++++++
 2 files changed, 77 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b99fbc61/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/SearchLoadAndWriteProcessor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/SearchLoadAndWriteProcessor.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/SearchLoadAndWriteProcessor.java
index 7d576e9..d9729a7 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/SearchLoadAndWriteProcessor.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/SearchLoadAndWriteProcessor.java
@@ -74,6 +74,7 @@ import com.gemstone.gemfire.internal.cache.versions.VersionTag;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
 import com.gemstone.gemfire.internal.logging.LogService;
 import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage;
+import com.gemstone.gemfire.internal.offheap.annotations.Released;
 import com.gemstone.gemfire.internal.offheap.annotations.Retained;
 
 
@@ -212,7 +213,7 @@ public class SearchLoadAndWriteProcessor implements MembershipListener {
 
     int action = paction;
     this.requestInProgress = true;
-    Scope scope = this.region.scope;
+    Scope scope = this.region.getScope();
     if (localWriter != null) {
       doLocalWrite(localWriter, event, action);
       this.requestInProgress = false;
@@ -221,7 +222,7 @@ public class SearchLoadAndWriteProcessor implements MembershipListener {
     if (scope == Scope.LOCAL && (region.getPartitionAttributes() == null)) {
       return false;
     }
-    @Retained
+    @Released
     CacheEvent listenerEvent = getEventForListener(event);
     try {
     if (action == BEFOREUPDATE && listenerEvent.getOperation().isCreate()) {
@@ -869,7 +870,7 @@ public class SearchLoadAndWriteProcessor implements MembershipListener {
         return false;
       }
     }
-    @Retained
+    @Released
     CacheEvent event = getEventForListener(pevent);
     
     int action = paction;
@@ -912,8 +913,9 @@ public class SearchLoadAndWriteProcessor implements MembershipListener {
   /** Return true if cache writer was invoked */
   private boolean netWrite(CacheEvent event, int action, Set writeCandidateSet)
   throws CacheWriterException, TimeoutException {
-
-    // assert !writeCandidateSet.isEmpty();
+    if (writeCandidateSet == null || writeCandidateSet.isEmpty()) {
+      return false;
+    }
     ArrayList list = new ArrayList(writeCandidateSet);
     Collections.shuffle(list);
     InternalDistributedMember[] writeCandidates = (InternalDistributedMember[])list.

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b99fbc61/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/SearchLoadAndWriteProcessorTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/SearchLoadAndWriteProcessorTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/SearchLoadAndWriteProcessorTest.java
new file mode 100644
index 0000000..39b9dc8
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/SearchLoadAndWriteProcessorTest.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.internal.cache;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.cache.Operation;
+import com.gemstone.gemfire.cache.Scope;
+import com.gemstone.gemfire.internal.offheap.StoredObject;
+import com.gemstone.gemfire.test.fake.Fakes;
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
+
+@Category(UnitTest.class)
+public class SearchLoadAndWriteProcessorTest {
+
+  /**
+   * This test verifies the fix for GEODE-1199.
+   * It verifies that when doNetWrite is called with an event
+   * that has a StoredObject value that it will have "release"
+   * called on it.
+   */
+  @Test
+  public void verifyThatOffHeapReleaseIsCalledAfterNetWrite() {
+    // setup
+    GemFireCacheImpl cache = Fakes.cache();
+    SearchLoadAndWriteProcessor processor = SearchLoadAndWriteProcessor.getProcessor();
+    LocalRegion lr = mock(LocalRegion.class);
+    when(lr.getScope()).thenReturn(Scope.DISTRIBUTED_ACK);
+    Object key = "key";
+    StoredObject value = mock(StoredObject.class);
+    when(value.hasRefCount()).thenReturn(true);
+    when(value.retain()).thenReturn(true);
+    Object cbArg = null;
+    KeyInfo keyInfo = new KeyInfo(key, value, cbArg);
+    when(lr.getKeyInfo(any(), any(), any())).thenReturn(keyInfo);
+    processor.region = lr;
+    EntryEventImpl event = EntryEventImpl.create(lr, Operation.REPLACE, key, value, cbArg, false, null);
+    
+    try {
+      // the test
+      processor.doNetWrite(event, null, null, 0);
+      
+      // verification
+      verify(value, times(2)).retain();
+      verify(value, times(1)).release();
+      
+    } finally {
+      processor.release();
+    }
+  }
+
+}


[3/3] incubator-geode git commit: removed dead code

Posted by ds...@apache.org.
removed dead code


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

Branch: refs/heads/feature/GEODE-1199
Commit: dabfb000f7adc6e2e0055165c725557c221c4d02
Parents: b99fbc6
Author: Darrel Schneider <ds...@pivotal.io>
Authored: Mon Apr 11 16:00:46 2016 -0700
Committer: Darrel Schneider <ds...@pivotal.io>
Committed: Mon Apr 11 16:00:46 2016 -0700

----------------------------------------------------------------------
 .../gemfire/internal/cache/SearchLoadAndWriteProcessorTest.java    | 2 --
 1 file changed, 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/dabfb000/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/SearchLoadAndWriteProcessorTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/SearchLoadAndWriteProcessorTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/SearchLoadAndWriteProcessorTest.java
index 39b9dc8..57aca37 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/SearchLoadAndWriteProcessorTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/SearchLoadAndWriteProcessorTest.java
@@ -25,7 +25,6 @@ import org.junit.experimental.categories.Category;
 import com.gemstone.gemfire.cache.Operation;
 import com.gemstone.gemfire.cache.Scope;
 import com.gemstone.gemfire.internal.offheap.StoredObject;
-import com.gemstone.gemfire.test.fake.Fakes;
 import com.gemstone.gemfire.test.junit.categories.UnitTest;
 
 @Category(UnitTest.class)
@@ -40,7 +39,6 @@ public class SearchLoadAndWriteProcessorTest {
   @Test
   public void verifyThatOffHeapReleaseIsCalledAfterNetWrite() {
     // setup
-    GemFireCacheImpl cache = Fakes.cache();
     SearchLoadAndWriteProcessor processor = SearchLoadAndWriteProcessor.getProcessor();
     LocalRegion lr = mock(LocalRegion.class);
     when(lr.getScope()).thenReturn(Scope.DISTRIBUTED_ACK);