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/03/05 01:51:34 UTC

[34/38] incubator-geode git commit: renamed ObjectChunkWithHeapForm to OffHeapStoredObjectWithHeapForm

renamed ObjectChunkWithHeapForm to OffHeapStoredObjectWithHeapForm


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

Branch: refs/heads/feature/GEODE-982
Commit: 07405647e358cb55143ca40d1e74990a1eae99a2
Parents: b6eca04
Author: Darrel Schneider <ds...@pivotal.io>
Authored: Fri Mar 4 15:41:42 2016 -0800
Committer: Darrel Schneider <ds...@pivotal.io>
Committed: Fri Mar 4 15:41:42 2016 -0800

----------------------------------------------------------------------
 .../cache/wan/GatewaySenderEventImpl.java       |  5 +-
 .../internal/offheap/AbstractStoredObject.java  |  9 ++-
 .../offheap/ObjectChunkWithHeapForm.java        | 40 ------------
 .../OffHeapStoredObjectWithHeapForm.java        | 41 +++++++++++++
 .../offheap/SimpleMemoryAllocatorImpl.java      |  2 +-
 .../gemfire/internal/offheap/StoredObject.java  |  9 +++
 .../ObjectChunkWithHeapFormJUnitTest.java       | 64 --------------------
 .../offheap/OffHeapStoredObjectJUnitTest.java   |  2 +-
 ...ffHeapStoredObjectWithHeapFormJUnitTest.java | 64 ++++++++++++++++++++
 .../internal/offheap/StoredObjectTestSuite.java |  2 +-
 10 files changed, 126 insertions(+), 112 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/07405647/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderEventImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderEventImpl.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderEventImpl.java
index 71d3f17..b64a654 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderEventImpl.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/wan/GatewaySenderEventImpl.java
@@ -50,7 +50,6 @@ import com.gemstone.gemfire.internal.cache.WrappedCallbackArgument;
 import com.gemstone.gemfire.internal.cache.lru.Sizeable;
 import com.gemstone.gemfire.internal.cache.tier.sockets.CacheServerHelper;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
-import com.gemstone.gemfire.internal.offheap.ObjectChunkWithHeapForm;
 import com.gemstone.gemfire.internal.offheap.OffHeapHelper;
 import com.gemstone.gemfire.internal.offheap.ReferenceCountHelper;
 import com.gemstone.gemfire.internal.offheap.Releasable;
@@ -965,9 +964,7 @@ public class GatewaySenderEventImpl implements
 //    if (so != null  && !event.hasDelta()) {
       // Since GatewaySenderEventImpl instances can live for a long time in the gateway region queue
       // we do not want the StoredObject to be one that keeps the heap form cached.
-      if (so instanceof ObjectChunkWithHeapForm) {
-        so = ((ObjectChunkWithHeapForm) so).getChunkWithoutHeapForm(); // fixes 51999
-      }
+      so = so.getStoredObjectWithoutHeapForm(); // fixes 51999
       this.valueObj = so;
       if (!so.isSerialized()) {
         this.valueIsObject = 0x00;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/07405647/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/AbstractStoredObject.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/AbstractStoredObject.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/AbstractStoredObject.java
index 7a9c5f6..22e2d55 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/AbstractStoredObject.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/AbstractStoredObject.java
@@ -120,5 +120,12 @@ public abstract class AbstractStoredObject implements StoredObject {
     byte dsCode = this.readDataByte(0);
     return dsCode == DSCODE.PDX || dsCode == DSCODE.PDX_ENUM || dsCode == DSCODE.PDX_INLINE_ENUM;
   }
-  
+
+  @Override
+  public StoredObject getStoredObjectWithoutHeapForm() {
+    // the only implementation that needs to override this
+    // is OffHeapStoredObjectWithHeapForm.
+    return this;
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/07405647/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/ObjectChunkWithHeapForm.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/ObjectChunkWithHeapForm.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/ObjectChunkWithHeapForm.java
deleted file mode 100644
index 2df96e6..0000000
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/ObjectChunkWithHeapForm.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.offheap;
-
-/**
- * Used to keep the heapForm around while an operation is still in progress.
- * This allows the operation to access the serialized heap form instead of copying
- * it from offheap. See bug 48135.
- */
-public class ObjectChunkWithHeapForm extends OffHeapStoredObject {
-  private final byte[] heapForm;
-  
-  public ObjectChunkWithHeapForm(OffHeapStoredObject chunk, byte[] heapForm) {
-    super(chunk);
-    this.heapForm = heapForm;
-  }
-
-  @Override
-  protected byte[] getRawBytes() {
-    return this.heapForm;
-  }
-  
-  public OffHeapStoredObject getChunkWithoutHeapForm() {
-    return new OffHeapStoredObject(this);
-  }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/07405647/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectWithHeapForm.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectWithHeapForm.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectWithHeapForm.java
new file mode 100644
index 0000000..aea2319
--- /dev/null
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectWithHeapForm.java
@@ -0,0 +1,41 @@
+/*
+ * 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.offheap;
+
+/**
+ * Used to keep the heapForm around while an operation is still in progress.
+ * This allows the operation to access the serialized heap form instead of copying
+ * it from offheap. See bug 48135.
+ */
+public class OffHeapStoredObjectWithHeapForm extends OffHeapStoredObject {
+  private final byte[] heapForm;
+  
+  public OffHeapStoredObjectWithHeapForm(OffHeapStoredObject chunk, byte[] heapForm) {
+    super(chunk);
+    this.heapForm = heapForm;
+  }
+
+  @Override
+  protected byte[] getRawBytes() {
+    return this.heapForm;
+  }
+  
+  @Override
+  public StoredObject getStoredObjectWithoutHeapForm() {
+    return new OffHeapStoredObject(this);
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/07405647/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorImpl.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorImpl.java
index 0198f02..be7a88b 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorImpl.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorImpl.java
@@ -339,7 +339,7 @@ public class SimpleMemoryAllocatorImpl implements MemoryAllocator {
     result.setSerialized(isSerialized);
     result.setCompressed(isCompressed);
     if (originalHeapData != null) {
-      result = new ObjectChunkWithHeapForm(result, originalHeapData);
+      result = new OffHeapStoredObjectWithHeapForm(result, originalHeapData);
     }
     return result;
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/07405647/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/StoredObject.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/StoredObject.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/StoredObject.java
index af31134..26cb81f 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/StoredObject.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/offheap/StoredObject.java
@@ -162,4 +162,13 @@ public interface StoredObject extends Sendable, CachedDeserializable, Releasable
    * Returns true if the data is serialized with PDX
    */
   public boolean isSerializedPdxInstance();
+  
+  /**
+   * Returns a StoredObject that does not cache the heap form.
+   * If a StoredObject is going to be kept around for a while then
+   * it is good to call this so that it will not also keep the heap
+   * form in memory.
+   */
+  public StoredObject getStoredObjectWithoutHeapForm();
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/07405647/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/ObjectChunkWithHeapFormJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/ObjectChunkWithHeapFormJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/ObjectChunkWithHeapFormJUnitTest.java
deleted file mode 100644
index 4262e90..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/ObjectChunkWithHeapFormJUnitTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.offheap;
-
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertSame;
-
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
-
-@Category(UnitTest.class)
-public class ObjectChunkWithHeapFormJUnitTest extends OffHeapStoredObjectJUnitTest {
-
-  @Test
-  public void getRawBytesShouldReturnCachedHeapForm() {
-    OffHeapStoredObject chunk = createValueAsUnserializedStoredObject(getValue());
-
-    byte[] valueInBytes = getValueAsByteArray();
-    ObjectChunkWithHeapForm heapForm = new ObjectChunkWithHeapForm(chunk, valueInBytes);
-
-    assertNotNull(heapForm);
-
-    assertSame(valueInBytes, heapForm.getRawBytes());
-  }
-
-  @Test
-  public void getChunkWithoutHeapFormShouldReturnGemFireChunk() {
-    OffHeapStoredObject chunk = createValueAsSerializedStoredObject(getValue());
-
-    byte[] valueInBytes = getValueAsByteArray();
-    ObjectChunkWithHeapForm heapForm = new ObjectChunkWithHeapForm(chunk, valueInBytes);
-
-    OffHeapStoredObject chunkWithOutHeapForm = heapForm.getChunkWithoutHeapForm();
-
-    assertNotNull(chunkWithOutHeapForm);
-    assertEquals(OffHeapStoredObject.class, chunkWithOutHeapForm.getClass());
-
-    assertEquals(chunk, heapForm.getChunkWithoutHeapForm());
-
-    assertEquals(chunk.getAddress(), chunkWithOutHeapForm.getAddress());
-    assertArrayEquals(chunk.getRawBytes(), chunkWithOutHeapForm.getRawBytes());
-    assertNotSame(valueInBytes, chunkWithOutHeapForm.getRawBytes());
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/07405647/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectJUnitTest.java
index c0ec983..e17e5be 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectJUnitTest.java
@@ -201,7 +201,7 @@ public class OffHeapStoredObjectJUnitTest extends AbstractStoredObjectTestBase {
   @Test
   public void getShortClassNameShouldReturnShortClassName() {
     OffHeapStoredObject chunk = createValueAsUnserializedStoredObject(getValue());
-    assertThat(chunk.getShortClassName()).isEqualTo("ObjectStoredInMemory");
+    assertThat(chunk.getShortClassName()).isEqualTo("OffHeapStoredObject");
 
     chunk.release();
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/07405647/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectWithHeapFormJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectWithHeapFormJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectWithHeapFormJUnitTest.java
new file mode 100644
index 0000000..a763e76
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapStoredObjectWithHeapFormJUnitTest.java
@@ -0,0 +1,64 @@
+/*
+ * 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.offheap;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertSame;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
+
+@Category(UnitTest.class)
+public class OffHeapStoredObjectWithHeapFormJUnitTest extends OffHeapStoredObjectJUnitTest {
+
+  @Test
+  public void getRawBytesShouldReturnCachedHeapForm() {
+    OffHeapStoredObject chunk = createValueAsUnserializedStoredObject(getValue());
+
+    byte[] valueInBytes = getValueAsByteArray();
+    OffHeapStoredObjectWithHeapForm heapForm = new OffHeapStoredObjectWithHeapForm(chunk, valueInBytes);
+
+    assertNotNull(heapForm);
+
+    assertSame(valueInBytes, heapForm.getRawBytes());
+  }
+
+  @Test
+  public void getChunkWithoutHeapFormShouldReturnGemFireChunk() {
+    OffHeapStoredObject chunk = createValueAsSerializedStoredObject(getValue());
+
+    byte[] valueInBytes = getValueAsByteArray();
+    OffHeapStoredObjectWithHeapForm heapForm = new OffHeapStoredObjectWithHeapForm(chunk, valueInBytes);
+
+    OffHeapStoredObject chunkWithOutHeapForm = (OffHeapStoredObject)heapForm.getStoredObjectWithoutHeapForm();
+
+    assertNotNull(chunkWithOutHeapForm);
+    assertEquals(OffHeapStoredObject.class, chunkWithOutHeapForm.getClass());
+
+    assertEquals(chunk, heapForm.getStoredObjectWithoutHeapForm());
+
+    assertEquals(chunk.getAddress(), chunkWithOutHeapForm.getAddress());
+    assertArrayEquals(chunk.getRawBytes(), chunkWithOutHeapForm.getRawBytes());
+    assertNotSame(valueInBytes, chunkWithOutHeapForm.getRawBytes());
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/07405647/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/StoredObjectTestSuite.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/StoredObjectTestSuite.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/StoredObjectTestSuite.java
index 4bd2850..789c0fa 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/StoredObjectTestSuite.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/StoredObjectTestSuite.java
@@ -23,7 +23,7 @@ import org.junit.runners.Suite;
 @Suite.SuiteClasses({
 	TinyStoredObjectJUnitTest.class,
 	OffHeapStoredObjectJUnitTest.class,
-	ObjectChunkWithHeapFormJUnitTest.class,
+	OffHeapStoredObjectWithHeapFormJUnitTest.class,
 	ObjectChunkSliceJUnitTest.class,
 })
 @RunWith(Suite.class)