You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2015/12/07 18:14:45 UTC
[01/13] incubator-geode git commit: [GEODE-619]: Add
GMSMemberJUnitTest Adding unit tests that should improve code coverage of
GMSMember to ~90% Fixing array index out of bounds issue when one address is
longer than the other
Repository: incubator-geode
Updated Branches:
refs/heads/feature/GEODE-291 3884684bd -> 998206b21
[GEODE-619]: Add GMSMemberJUnitTest
Adding unit tests that should improve code coverage of GMSMember to ~90%
Fixing array index out of bounds issue when one address is longer than the other
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/2258d74c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/2258d74c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/2258d74c
Branch: refs/heads/feature/GEODE-291
Commit: 2258d74cac3e13a162a06079b78eb83141eaa641
Parents: 442faa0
Author: Jason Huynh <hu...@gmail.com>
Authored: Tue Dec 1 14:01:53 2015 -0800
Committer: Jason Huynh <hu...@gmail.com>
Committed: Tue Dec 1 14:06:15 2015 -0800
----------------------------------------------------------------------
.../internal/membership/gms/GMSMember.java | 20 +--
.../membership/gms/GMSMemberJUnitTest.java | 148 +++++++++++++++++++
2 files changed, 159 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/2258d74c/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/GMSMember.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/GMSMember.java b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/GMSMember.java
index f4784ed..05b3aee 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/GMSMember.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/GMSMember.java
@@ -211,7 +211,7 @@ public class GMSMember implements NetMember, DataSerializableFixedID {
byte[] hisAddr = his.inetAddr.getAddress();
if (myAddr != hisAddr) {
for (int idx=0; idx < myAddr.length; idx++) {
- if (idx > hisAddr.length) {
+ if (idx >= hisAddr.length) {
return 1;
} else if (myAddr[idx] > hisAddr[idx]) {
return 1;
@@ -219,6 +219,10 @@ public class GMSMember implements NetMember, DataSerializableFixedID {
return -1;
}
}
+ //After checking both addresses we have only gone up to myAddr.length, their address could be longer
+ if (hisAddr.length > myAddr.length) {
+ return -1;
+ }
}
if (udpPort < his.udpPort) return -1;
if (his.udpPort < udpPort) return 1;
@@ -226,16 +230,14 @@ public class GMSMember implements NetMember, DataSerializableFixedID {
// bug #41983, address of kill-9'd member is reused
// before it can be ejected from membership
- if (result == 0) {
- if (this.vmViewId >= 0 && his.vmViewId >= 0) {
- if (this.vmViewId < his.vmViewId) {
- result = -1;
- } else if (his.vmViewId < this.vmViewId) {
- result = 1;
- }
+ if (this.vmViewId >= 0 && his.vmViewId >= 0) {
+ if (this.vmViewId < his.vmViewId) {
+ result = -1;
+ } else if (his.vmViewId < this.vmViewId) {
+ result = 1;
}
}
- if (result == 0 && this.uuidMSBs != 0 && his.uuidMSBs != 0) {
+ if (result == 0 && this.uuidMSBs != 0 && his.uuidMSBs != 0) {
if (this.uuidMSBs < his.uuidMSBs) {
result = -1;
} else if (his.uuidMSBs < this.uuidMSBs) {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/2258d74c/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/GMSMemberJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/GMSMemberJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/GMSMemberJUnitTest.java
new file mode 100644
index 0000000..0b75d3d
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/GMSMemberJUnitTest.java
@@ -0,0 +1,148 @@
+package com.gemstone.gemfire.distributed.internal.membership.gms;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.net.InetAddress;
+
+import org.jgroups.util.UUID;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.distributed.internal.membership.MemberAttributes;
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
+
+@Category(UnitTest.class)
+public class GMSMemberJUnitTest {
+
+ @Test
+ public void testEqualsNotSameType() {
+ GMSMember member = new GMSMember();
+ Assert.assertFalse(member.equals("Not a GMSMember"));
+ }
+
+ @Test
+ public void testEqualsIsSame() {
+ GMSMember member = new GMSMember();
+ Assert.assertTrue(member.equals(member));
+ }
+
+ @Test
+ public void testCompareToIsSame() {
+ GMSMember member = new GMSMember();
+ UUID uuid = new UUID(0, 0);
+ member.setUUID(uuid);
+ Assert.assertEquals(0, member.compareTo(member));
+ }
+
+ private GMSMember createGMSMember(byte[] inetAddress, int viewId, long msb, long lsb) {
+ GMSMember member = new GMSMember();
+ InetAddress addr1 = mock(InetAddress.class);
+ when(addr1.getAddress()).thenReturn(inetAddress);
+ member.setInetAddr(addr1);
+ member.setBirthViewId(viewId);
+ member.setUUID(new UUID(msb, lsb));
+ return member;
+ }
+
+ @Test
+ public void testCompareToInetAddressIsLongerThan() {
+ GMSMember member1 = createGMSMember(new byte[] {1, 1, 1, 1, 1}, 1, 1, 1);
+ GMSMember member2 = createGMSMember(new byte[] {1, 1, 1, 1}, 1, 1, 1);
+ Assert.assertEquals(1, member1.compareTo(member2));
+ }
+
+ @Test
+ public void testCompareToInetAddressIsShorterThan() {
+ GMSMember member1 = createGMSMember(new byte[] {1, 1, 1, 1}, 1, 1, 1);
+ GMSMember member2 = createGMSMember(new byte[] {1, 1, 1, 1, 1}, 1, 1, 1);
+ Assert.assertEquals(-1, member1.compareTo(member2));
+ }
+
+ @Test
+ public void testCompareToInetAddressIsGreater() {
+ GMSMember member1 = createGMSMember(new byte[] {1, 2, 1, 1, 1}, 1, 1, 1);
+ GMSMember member2 = createGMSMember(new byte[] {1, 1, 1, 1, 1}, 1, 1, 1);
+ Assert.assertEquals(1, member1.compareTo(member2));
+ }
+
+ @Test
+ public void testCompareToInetAddressIsLessThan() {
+ GMSMember member1 = createGMSMember(new byte[] {1, 1, 1, 1, 1}, 1, 1, 1);
+ GMSMember member2 = createGMSMember(new byte[] {1, 2, 1, 1, 1}, 1, 1, 1);
+ Assert.assertEquals(-1, member1.compareTo(member2));
+ }
+
+ @Test
+ public void testCompareToMyViewIdLarger() {
+ GMSMember member1 = createGMSMember(new byte[] {1}, 2, 1, 1);
+ GMSMember member2 = createGMSMember(new byte[] {1}, 1, 1, 1);
+ Assert.assertEquals(1, member1.compareTo(member2));
+ }
+
+ @Test
+ public void testCompareToTheirViewIdLarger() {
+ GMSMember member1 = createGMSMember(new byte[] {1}, 1, 1, 1);
+ GMSMember member2 = createGMSMember(new byte[] {1}, 2, 1, 1);
+ Assert.assertEquals(-1, member1.compareTo(member2));
+ }
+
+ @Test
+ public void testCompareToMyMSBLarger() {
+ GMSMember member1 = createGMSMember(new byte[] {1}, 1, 2, 1);
+ GMSMember member2 = createGMSMember(new byte[] {1}, 1, 1, 1);
+ Assert.assertEquals(1, member1.compareTo(member2));
+ }
+
+ @Test
+ public void testCompareToTheirMSBLarger() {
+ GMSMember member1 = createGMSMember(new byte[] {1}, 1, 1, 1);
+ GMSMember member2 = createGMSMember(new byte[] {1}, 1, 2, 1);
+ Assert.assertEquals(-1, member1.compareTo(member2));
+ }
+
+ @Test
+ public void testCompareToMyLSBLarger() {
+ GMSMember member1 = createGMSMember(new byte[] {1}, 1, 1, 2);
+ GMSMember member2 = createGMSMember(new byte[] {1}, 1, 1, 1);
+ Assert.assertEquals(1, member1.compareTo(member2));
+ }
+
+ @Test
+ public void testCompareToTheirLSBLarger() {
+ GMSMember member1 = createGMSMember(new byte[] {1}, 1, 1, 1);
+ GMSMember member2 = createGMSMember(new byte[] {1}, 1, 1, 2);
+ Assert.assertEquals(-1, member1.compareTo(member2));
+ }
+
+
+ //Makes sure a NPE is not thrown
+ @Test
+ public void testNoNPEWhenSetAttributesWithNull() {
+ GMSMember member = new GMSMember();
+ member.setAttributes(null);
+ MemberAttributes attrs = member.getAttributes();
+ MemberAttributes invalid = MemberAttributes.INVALID;
+ Assert.assertEquals(attrs.getVmKind(), invalid.getVmKind());
+ Assert.assertEquals(attrs.getPort(), invalid.getPort());
+ Assert.assertEquals(attrs.getVmViewId(), invalid.getVmViewId());
+ Assert.assertEquals(attrs.getName(), invalid.getName());
+ }
+
+ @Test
+ public void testGetUUIDReturnsNullWhenUUIDIs0() {
+ GMSMember member = new GMSMember();
+ UUID uuid = new UUID(0, 0);
+ member.setUUID(uuid);
+ Assert.assertNull(member.getUUID());
+ }
+
+ @Test
+ public void testGetUUID() {
+ GMSMember member = new GMSMember();
+ UUID uuid = new UUID(1, 1);
+ member.setUUID(uuid);
+ Assert.assertNotNull(member.getUUID());
+ }
+}
[07/13] incubator-geode git commit: GEODE-184: The gfsh 'locate
entry' command fails to find the entry on partitioned regions if the key is
not a string
Posted by kl...@apache.org.
GEODE-184: The gfsh 'locate entry' command fails to find the entry on partitioned regions if the key is not a string
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/74e13640
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/74e13640
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/74e13640
Branch: refs/heads/feature/GEODE-291
Commit: 74e136401fa0d0a01d562c8e3f3db48b30ad56bc
Parents: f974462
Author: Jens Deppe <jd...@pivotal.io>
Authored: Wed Dec 2 08:10:13 2015 -0800
Committer: Jens Deppe <jd...@pivotal.io>
Committed: Wed Dec 2 15:10:06 2015 -0800
----------------------------------------------------------------------
.../cli/functions/DataCommandFunction.java | 6 +-
.../functions/DataCommandFunctionJUnitTest.java | 132 +++++++++++++++++++
2 files changed, 135 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/74e13640/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/functions/DataCommandFunction.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/functions/DataCommandFunction.java b/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/functions/DataCommandFunction.java
index d4dac05..af849f8 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/functions/DataCommandFunction.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/management/internal/cli/functions/DataCommandFunction.java
@@ -536,10 +536,10 @@ public class DataCommandFunction extends FunctionAdapter implements InternalEnt
//Following code is adaptation of which.java of old Gfsh
PartitionedRegion pr = (PartitionedRegion)region;
Region localRegion = PartitionRegionHelper.getLocalData((PartitionedRegion)region);
- value = localRegion.get(key);
+ value = localRegion.get(keyObject);
if(value!=null){
- DistributedMember primaryMember = PartitionRegionHelper.getPrimaryMemberForKey(region, key);
- int bucketId = pr.getKeyInfo(key).getBucketId();
+ DistributedMember primaryMember = PartitionRegionHelper.getPrimaryMemberForKey(region, keyObject);
+ int bucketId = pr.getKeyInfo(keyObject).getBucketId();
boolean isPrimary = member == primaryMember;
keyInfo.addLocation(new Object[]{region.getFullPath(),true,getJSONForNonPrimitiveObject(value)[1],isPrimary,""+bucketId});
}else{
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/74e13640/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/cli/functions/DataCommandFunctionJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/cli/functions/DataCommandFunctionJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/cli/functions/DataCommandFunctionJUnitTest.java
new file mode 100644
index 0000000..905a9cd
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/management/internal/cli/functions/DataCommandFunctionJUnitTest.java
@@ -0,0 +1,132 @@
+/*
+ * 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.management.internal.cli.functions;
+
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.RegionFactory;
+import com.gemstone.gemfire.cache.RegionShortcut;
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.management.internal.cli.domain.DataCommandResult;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * TODO: Add additional tests for all methods in DataCommandFunction.
+ *
+ * @author Jens Deppe
+ */
+@Category(IntegrationTest.class)
+public class DataCommandFunctionJUnitTest {
+
+ private static Cache cache;
+
+ private static Region region1;
+
+ private static final String PARTITIONED_REGION = "part_region";
+
+ public static class StringCheese {
+ private String cheese;
+
+ public StringCheese() {
+ // Empty constructor
+ }
+
+ public StringCheese(final String cheese) {
+ this.cheese = cheese;
+ }
+
+ public void setCheese(final String cheese) {
+ this.cheese = cheese;
+ }
+
+ @Override
+ public String toString() {
+ return cheese;
+ }
+
+ @Override
+ public int hashCode() {
+ int h = this.cheese.hashCode();
+ return h;
+ }
+
+ public boolean equals(Object other) {
+ if (this == other) {
+ return true;
+ }
+ if (other instanceof StringCheese) {
+ return this.cheese.equals(((StringCheese)other).cheese);
+ }
+ return false;
+ }
+ }
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ cache = new CacheFactory().
+ set(DistributionConfig.MCAST_PORT_NAME, "0").
+ create();
+ RegionFactory factory = cache.createRegionFactory(RegionShortcut.PARTITION);
+ region1 = factory.create(PARTITIONED_REGION);
+
+ region1.put(new StringCheese("key_1"), "value_1");
+ region1.put("key_2", "value_2");
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ cache.close();
+ cache = null;
+ }
+
+ /*
+ * This test addresses GEODE-184
+ */
+ @Test
+ public void testLocateKeyIsObject() throws Exception {
+ DataCommandFunction dataCmdFn = new DataCommandFunction();
+
+ DataCommandResult result = dataCmdFn.locateEntry("{'cheese': 'key_1'}", StringCheese.class.getName(), String.class.getName(), PARTITIONED_REGION, false);
+
+ assertNotNull(result);
+ result.aggregate(null);
+ List<DataCommandResult.KeyInfo> keyInfos = result.getLocateEntryLocations();
+ assertEquals(1, keyInfos.size());
+ }
+
+ @Test
+ public void testLocateKeyIsString() throws Exception {
+ DataCommandFunction dataCmdFn = new DataCommandFunction();
+
+ DataCommandResult result = dataCmdFn.locateEntry("key_2", String.class.getName(), String.class.getName(), PARTITIONED_REGION, false);
+
+ assertNotNull(result);
+ result.aggregate(null);
+ List<DataCommandResult.KeyInfo> keyInfos = result.getLocateEntryLocations();
+ assertEquals(1, keyInfos.size());
+ }
+}
[02/13] incubator-geode git commit: added null check
Posted by kl...@apache.org.
added null check
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/dce479e4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/dce479e4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/dce479e4
Branch: refs/heads/feature/GEODE-291
Commit: dce479e4c54ff3f355158ee911ae4dae90857827
Parents: 2258d74
Author: Hitesh Khamesra <hk...@pivotal.io>
Authored: Tue Dec 1 10:30:25 2015 -0800
Committer: Hitesh Khamesra <hk...@pivotal.io>
Committed: Tue Dec 1 16:50:35 2015 -0800
----------------------------------------------------------------------
.../internal/membership/gms/messenger/JGroupsMessenger.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/dce479e4/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
index 3a00f62..4e68b63 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessenger.java
@@ -404,7 +404,7 @@ public class JGroupsMessenger implements Messenger {
logger.info("processing JGroups IOException: " + e.getMessage());
NetView v = this.view;
JGAddress jgMbr = (JGAddress)dest;
- if (v != null) {
+ if (jgMbr != null && v != null) {
List<InternalDistributedMember> members = v.getMembers();
InternalDistributedMember recipient = null;
for (InternalDistributedMember mbr: members) {
[06/13] incubator-geode git commit: GEODE-607: improve
SimpleMemoryAllocatorImpl unit test coverage
Posted by kl...@apache.org.
GEODE-607: improve SimpleMemoryAllocatorImpl unit test coverage
Also changed ChunkType to an interface and removed dead code.
Refactored duplicate code into AbstractStoredObject.
Removed some more sqlf 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/f9744623
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/f9744623
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/f9744623
Branch: refs/heads/feature/GEODE-291
Commit: f9744623ddb03b2920e85be5a68c4d4c2b4a3243
Parents: e19fa40
Author: Darrel Schneider <ds...@pivotal.io>
Authored: Wed Nov 25 11:43:15 2015 -0800
Committer: Darrel Schneider <ds...@pivotal.io>
Committed: Wed Dec 2 11:34:34 2015 -0800
----------------------------------------------------------------------
.../internal/offheap/AbstractStoredObject.java | 107 ++++++
.../gemfire/internal/offheap/Chunk.java | 1 -
.../gemfire/internal/offheap/ChunkType.java | 14 +-
.../gemfire/internal/offheap/DataAsAddress.java | 87 +----
.../gemfire/internal/offheap/Fragment.java | 14 +
.../internal/offheap/FreeListManager.java | 14 +
.../gemfire/internal/offheap/GemFireChunk.java | 8 -
.../internal/offheap/MemoryAllocator.java | 2 -
.../internal/offheap/MemoryBlockNode.java | 14 +-
.../internal/offheap/MemoryInspector.java | 6 -
.../offheap/OffHeapCachedDeserializable.java | 85 +----
.../internal/offheap/OffHeapStorage.java | 1 -
.../offheap/SimpleMemoryAllocatorImpl.java | 284 +++++++-------
.../internal/offheap/UnsafeMemoryChunk.java | 10 +
.../offheap/NullOffHeapMemoryStats.java | 6 +
.../offheap/NullOutOfOffHeapMemoryListener.java | 6 +
.../offheap/SimpleMemoryAllocatorJUnitTest.java | 369 +++++++++++++++++--
17 files changed, 643 insertions(+), 385 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f9744623/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/AbstractStoredObject.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/AbstractStoredObject.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/AbstractStoredObject.java
new file mode 100644
index 0000000..6dad277
--- /dev/null
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/AbstractStoredObject.java
@@ -0,0 +1,107 @@
+/*
+ * 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 java.io.DataOutput;
+import java.io.IOException;
+
+import com.gemstone.gemfire.DataSerializer;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.internal.DataSerializableFixedID;
+import com.gemstone.gemfire.internal.InternalDataSerializer;
+import com.gemstone.gemfire.internal.cache.RegionEntry;
+import com.gemstone.gemfire.internal.lang.StringUtils;
+
+public abstract class AbstractStoredObject implements StoredObject {
+ @Override
+ public Object getValueAsDeserializedHeapObject() {
+ return getDeserializedValue(null,null);
+ }
+
+ @Override
+ public byte[] getValueAsHeapByteArray() {
+ if (isSerialized()) {
+ return getSerializedValue();
+ } else {
+ return (byte[])getDeserializedForReading();
+ }
+ }
+
+ @Override
+ public String getStringForm() {
+ try {
+ return StringUtils.forceToString(getDeserializedForReading());
+ } catch (RuntimeException ex) {
+ return "Could not convert object to string because " + ex;
+ }
+ }
+
+ @Override
+ public Object getDeserializedForReading() {
+ return getDeserializedValue(null,null);
+ }
+
+ @Override
+ public Object getDeserializedWritableCopy(Region r, RegionEntry re) {
+ return getDeserializedValue(null,null);
+ }
+
+ @Override
+ public Object getValue() {
+ if (isSerialized()) {
+ return getSerializedValue();
+ } else {
+ throw new IllegalStateException("Can not call getValue on StoredObject that is not serialized");
+ }
+ }
+
+ @Override
+ public void writeValueAsByteArray(DataOutput out) throws IOException {
+ DataSerializer.writeByteArray(getSerializedValue(), out);
+ }
+
+ @Override
+ public void sendTo(DataOutput out) throws IOException {
+ if (isSerialized()) {
+ out.write(getSerializedValue());
+ } else {
+ Object objToSend = (byte[]) getDeserializedForReading(); // deserialized as a byte[]
+ DataSerializer.writeObject(objToSend, out);
+ }
+ }
+
+ @Override
+ public void sendAsByteArray(DataOutput out) throws IOException {
+ byte[] bytes;
+ if (isSerialized()) {
+ bytes = getSerializedValue();
+ } else {
+ bytes = (byte[]) getDeserializedForReading();
+ }
+ DataSerializer.writeByteArray(bytes, out);
+
+ }
+
+ @Override
+ public void sendAsCachedDeserializable(DataOutput out) throws IOException {
+ if (!isSerialized()) {
+ throw new IllegalStateException("sendAsCachedDeserializable can only be called on serialized StoredObjects");
+ }
+ InternalDataSerializer.writeDSFIDHeader(DataSerializableFixedID.VM_CACHED_DESERIALIZABLE, out);
+ sendAsByteArray(out);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f9744623/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/Chunk.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/Chunk.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/Chunk.java
index e32a1c6..ed4bc43 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/Chunk.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/Chunk.java
@@ -389,7 +389,6 @@ import com.gemstone.gemfire.internal.offheap.annotations.Unretained;
@Override
public void writeBytes(int offset, byte[] bytes, int bytesOffset, int size) {
assert offset+size <= getDataSize();
- SimpleMemoryAllocatorImpl.validateAddressAndSizeWithinSlab(getBaseDataAddress() + offset, size);
UnsafeMemoryChunk.writeAbsoluteBytes(getBaseDataAddress() + offset, bytes, bytesOffset, size);
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f9744623/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/ChunkType.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/ChunkType.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/ChunkType.java
index 9841368..e48bb62 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/ChunkType.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/ChunkType.java
@@ -17,10 +17,14 @@
package com.gemstone.gemfire.internal.offheap;
/**
- * Used to create new chunks of a certain type.
+ * Describes the type of data stored in a chunk.
*/
-public abstract class ChunkType {
- public abstract int getSrcType();
- public abstract Chunk newChunk(long memoryAddress);
- public abstract Chunk newChunk(long memoryAddress, int chunkSize);
+public interface ChunkType {
+ /**
+ * Returns an int that describes that type of
+ * data stored in the chunk.
+ * Currently the only supported type is
+ * Chunk.SRC_TYPE_GFE.
+ */
+ public int getSrcType();
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f9744623/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/DataAsAddress.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/DataAsAddress.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/DataAsAddress.java
index 61204ba..5b14389 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/DataAsAddress.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/DataAsAddress.java
@@ -16,18 +16,11 @@
*/
package com.gemstone.gemfire.internal.offheap;
-import java.io.DataOutput;
-import java.io.IOException;
-
-import com.gemstone.gemfire.DataSerializer;
import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.internal.DataSerializableFixedID;
-import com.gemstone.gemfire.internal.InternalDataSerializer;
import com.gemstone.gemfire.internal.cache.BytesAndBitsForCompactor;
import com.gemstone.gemfire.internal.cache.EntryBits;
import com.gemstone.gemfire.internal.cache.RegionEntry;
import com.gemstone.gemfire.internal.cache.RegionEntryContext;
-import com.gemstone.gemfire.internal.lang.StringUtils;
/**
* Used to represent offheap addresses whose
@@ -35,7 +28,7 @@ import com.gemstone.gemfire.internal.lang.StringUtils;
* location.
* Instances of this class have a very short lifetime.
*/
-public class DataAsAddress implements StoredObject {
+public class DataAsAddress extends AbstractStoredObject {
private final long address;
public DataAsAddress(long addr) {
@@ -88,53 +81,6 @@ public class DataAsAddress implements StoredObject {
}
@Override
- public Object getDeserializedForReading() {
- return getDeserializedValue(null,null);
- }
-
- @Override
- public Object getValueAsDeserializedHeapObject() {
- return getDeserializedValue(null,null);
- }
-
- @Override
- public byte[] getValueAsHeapByteArray() {
- if (isSerialized()) {
- return getSerializedValue();
- } else {
- return (byte[])getDeserializedForReading();
- }
- }
-
- @Override
- public String getStringForm() {
- try {
- return StringUtils.forceToString(getDeserializedForReading());
- } catch (RuntimeException ex) {
- return "Could not convert object to string because " + ex;
- }
- }
-
- @Override
- public Object getDeserializedWritableCopy(Region r, RegionEntry re) {
- return getDeserializedValue(null,null);
- }
-
- @Override
- public Object getValue() {
- if (isSerialized()) {
- return getSerializedValue();
- } else {
- throw new IllegalStateException("Can not call getValue on StoredObject that is not serialized");
- }
- }
-
- @Override
- public void writeValueAsByteArray(DataOutput out) throws IOException {
- DataSerializer.writeByteArray(getSerializedValue(), out);
- }
-
- @Override
public void fillSerializedValue(BytesAndBitsForCompactor wrapper,
byte userBits) {
byte[] value;
@@ -153,37 +99,6 @@ public class DataAsAddress implements StoredObject {
}
@Override
- public void sendTo(DataOutput out) throws IOException {
- if (isSerialized()) {
- out.write(getSerializedValue());
- } else {
- Object objToSend = (byte[]) getDeserializedForReading(); // deserialized as a byte[]
- DataSerializer.writeObject(objToSend, out);
- }
- }
-
- @Override
- public void sendAsByteArray(DataOutput out) throws IOException {
- byte[] bytes;
- if (isSerialized()) {
- bytes = getSerializedValue();
- } else {
- bytes = (byte[]) getDeserializedForReading();
- }
- DataSerializer.writeByteArray(bytes, out);
-
- }
-
- @Override
- public void sendAsCachedDeserializable(DataOutput out) throws IOException {
- if (!isSerialized()) {
- throw new IllegalStateException("sendAsCachedDeserializable can only be called on serialized StoredObjects");
- }
- InternalDataSerializer.writeDSFIDHeader(DataSerializableFixedID.VM_CACHED_DESERIALIZABLE, out);
- sendAsByteArray(out);
- }
-
- @Override
public boolean isSerialized() {
return OffHeapRegionEntryHelper.isSerialized(this.address);
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f9744623/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/Fragment.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/Fragment.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/Fragment.java
index bd05ddb..ef56627 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/Fragment.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/Fragment.java
@@ -122,4 +122,18 @@ public class Fragment implements MemoryBlock {
public ChunkType getChunkType() {
return null;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof Fragment) {
+ return getMemoryAddress() == ((Fragment) o).getMemoryAddress();
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ long value = this.getMemoryAddress();
+ return (int)(value ^ (value >>> 32));
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f9744623/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/FreeListManager.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/FreeListManager.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/FreeListManager.java
index 48a0756..10e4148 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/FreeListManager.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/FreeListManager.java
@@ -803,5 +803,19 @@ public class FreeListManager {
public ChunkType getChunkType() {
return null;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof TinyMemoryBlock) {
+ return getMemoryAddress() == ((TinyMemoryBlock) o).getMemoryAddress();
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ long value = this.getMemoryAddress();
+ return (int)(value ^ (value >>> 32));
+ }
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f9744623/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/GemFireChunk.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/GemFireChunk.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/GemFireChunk.java
index 3167613..20e4a2f 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/GemFireChunk.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/GemFireChunk.java
@@ -28,14 +28,6 @@ public class GemFireChunk extends Chunk {
public int getSrcType() {
return Chunk.SRC_TYPE_GFE;
}
- @Override
- public Chunk newChunk(long memoryAddress) {
- return new GemFireChunk(memoryAddress);
- }
- @Override
- public Chunk newChunk(long memoryAddress, int chunkSize) {
- return new GemFireChunk(memoryAddress, chunkSize);
- }
};
public GemFireChunk(long memoryAddress, int chunkSize) {
super(memoryAddress, chunkSize, TYPE);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f9744623/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryAllocator.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryAllocator.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryAllocator.java
index 231ff3a..0a014de 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryAllocator.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryAllocator.java
@@ -16,8 +16,6 @@
*/
package com.gemstone.gemfire.internal.offheap;
-import com.gemstone.gemfire.compression.Compressor;
-
/**
* Basic contract for a heap that manages off heap memory. Any MemoryChunks allocated from a heap
* are returned to that heap when freed.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f9744623/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryBlockNode.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryBlockNode.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryBlockNode.java
index 3f5f4dc..546feee 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryBlockNode.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryBlockNode.java
@@ -21,7 +21,6 @@ import java.util.Arrays;
import com.gemstone.gemfire.DataSerializer;
import com.gemstone.gemfire.cache.CacheClosedException;
-import com.gemstone.gemfire.internal.offheap.MemoryBlock.State;
/**
* Basic implementation of MemoryBlock for test validation only.
@@ -155,4 +154,17 @@ public class MemoryBlockNode implements MemoryBlock {
public ChunkType getChunkType() {
return this.block.getChunkType();
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof MemoryBlockNode) {
+ o = ((MemoryBlockNode)o).block;
+ }
+ return this.block.equals(o);
+ }
+
+ @Override
+ public int hashCode() {
+ return this.block.hashCode();
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f9744623/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryInspector.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryInspector.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryInspector.java
index acf6d04..cde24bc 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryInspector.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/MemoryInspector.java
@@ -36,12 +36,6 @@ public interface MemoryInspector {
public List<MemoryBlock> getAllocatedBlocks();
- public List<MemoryBlock> getDeallocatedBlocks();
-
- public List<MemoryBlock> getUnusedBlocks();
-
- public MemoryBlock getBlockContaining(long memoryAddress);
-
public MemoryBlock getBlockAfter(MemoryBlock block);
public List<MemoryBlock> getOrphans();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f9744623/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapCachedDeserializable.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapCachedDeserializable.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapCachedDeserializable.java
index 143fb25..1ec722d 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapCachedDeserializable.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapCachedDeserializable.java
@@ -16,20 +16,11 @@
*/
package com.gemstone.gemfire.internal.offheap;
-import java.io.DataOutput;
-import java.io.IOException;
-import java.util.Arrays;
-
-import com.gemstone.gemfire.DataSerializer;
import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.internal.DSCODE;
-import com.gemstone.gemfire.internal.DataSerializableFixedID;
-import com.gemstone.gemfire.internal.InternalDataSerializer;
import com.gemstone.gemfire.internal.cache.BytesAndBitsForCompactor;
-import com.gemstone.gemfire.internal.cache.CachedDeserializableFactory;
import com.gemstone.gemfire.internal.cache.EntryBits;
import com.gemstone.gemfire.internal.cache.RegionEntry;
-import com.gemstone.gemfire.internal.lang.StringUtils;
import com.gemstone.gemfire.internal.offheap.annotations.Unretained;
/**
@@ -39,7 +30,7 @@ import com.gemstone.gemfire.internal.offheap.annotations.Unretained;
* @author darrel
* @since 9.0
*/
-public abstract class OffHeapCachedDeserializable implements MemoryChunkWithRefCount {
+public abstract class OffHeapCachedDeserializable extends AbstractStoredObject implements MemoryChunkWithRefCount {
public abstract void setSerializedValue(byte[] value);
@Override
public abstract byte[] getSerializedValue();
@@ -51,53 +42,6 @@ public abstract class OffHeapCachedDeserializable implements MemoryChunkWithRefC
public abstract Object getDeserializedValue(Region r, RegionEntry re);
@Override
- public Object getValueAsDeserializedHeapObject() {
- return getDeserializedValue(null, null);
- }
-
- @Override
- public byte[] getValueAsHeapByteArray() {
- if (isSerialized()) {
- return getSerializedValue();
- } else {
- return (byte[])getDeserializedForReading();
- }
- }
-
- @Override
- public Object getDeserializedForReading() {
- return getDeserializedValue(null, null);
- }
-
- @Override
- public String getStringForm() {
- try {
- return StringUtils.forceToString(getDeserializedForReading());
- } catch (RuntimeException ex) {
- return "Could not convert object to string because " + ex;
- }
- }
-
- @Override
- public Object getDeserializedWritableCopy(Region r, RegionEntry re) {
- return getDeserializedValue(null, null);
- }
-
- @Override
- public Object getValue() {
- if (isSerialized()) {
- return getSerializedValue();
- } else {
- throw new IllegalStateException("Can not call getValue on StoredObject that is not serialized");
- }
- }
-
- @Override
- public void writeValueAsByteArray(DataOutput out) throws IOException {
- DataSerializer.writeByteArray(getSerializedValue(), out);
- }
-
- @Override
public void fillSerializedValue(BytesAndBitsForCompactor wrapper, byte userBits) {
if (isSerialized()) {
userBits = EntryBits.setSerialized(userBits, true);
@@ -114,33 +58,6 @@ public abstract class OffHeapCachedDeserializable implements MemoryChunkWithRefC
public String toString() {
return getShortClassName()+"@"+this.hashCode();
}
- @Override
- public void sendTo(DataOutput out) throws IOException {
- if (isSerialized()) {
- out.write(getSerializedValue());
- } else {
- Object objToSend = (byte[]) getDeserializedForReading(); // deserialized as a byte[]
- DataSerializer.writeObject(objToSend, out);
- }
- }
- @Override
- public void sendAsByteArray(DataOutput out) throws IOException {
- byte[] bytes;
- if (isSerialized()) {
- bytes = getSerializedValue();
- } else {
- bytes = (byte[]) getDeserializedForReading();
- }
- DataSerializer.writeByteArray(bytes, out);
- }
- @Override
- public void sendAsCachedDeserializable(DataOutput out) throws IOException {
- if (!isSerialized()) {
- throw new IllegalStateException("sendAsCachedDeserializable can only be called on serialized StoredObjects");
- }
- InternalDataSerializer.writeDSFIDHeader(DataSerializableFixedID.VM_CACHED_DESERIALIZABLE, out);
- sendAsByteArray(out);
- }
public boolean checkDataEquals(@Unretained OffHeapCachedDeserializable other) {
if (this == other) {
return true;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f9744623/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStorage.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStorage.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStorage.java
index 1a6cc8b..ef584f1 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStorage.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/OffHeapStorage.java
@@ -183,7 +183,6 @@ public class OffHeapStorage implements OffHeapMemoryStats {
}
}
- //TODO:Asif: Fix it
MemoryAllocator result;
if (offHeapMemorySize == 0 || Boolean.getBoolean(InternalLocator.FORCE_LOCATOR_DM_TYPE)) {
// Checking the FORCE_LOCATOR_DM_TYPE is a quick hack to keep our locator from allocating off heap memory.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f9744623/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorImpl.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorImpl.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorImpl.java
index f16253e..dfd05c6 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorImpl.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorImpl.java
@@ -70,6 +70,8 @@ public final class SimpleMemoryAllocatorImpl implements MemoryAllocator, MemoryI
* Sizes are always rounded up to the next multiple of this constant
* so internal fragmentation will be limited to TINY_MULTIPLE-1 bytes per allocation
* and on average will be TINY_MULTIPLE/2 given a random distribution of size requests.
+ * This does not account for the additional internal fragmentation caused by the off-heap header
+ * which currently is always 8 bytes.
*/
public final static int TINY_MULTIPLE = Integer.getInteger("gemfire.OFF_HEAP_ALIGNMENT", 8);
/**
@@ -77,6 +79,9 @@ public final class SimpleMemoryAllocatorImpl implements MemoryAllocator, MemoryI
*/
public final static int TINY_FREE_LIST_COUNT = Integer.getInteger("gemfire.OFF_HEAP_FREE_LIST_COUNT", 16384);
public final static int MAX_TINY = TINY_MULTIPLE*TINY_FREE_LIST_COUNT;
+ /**
+ * How many unused bytes are allowed in a huge memory allocation.
+ */
public final static int HUGE_MULTIPLE = 256;
volatile OffHeapMemoryStats stats;
@@ -95,7 +100,7 @@ public final class SimpleMemoryAllocatorImpl implements MemoryAllocator, MemoryI
private volatile MemoryUsageListener[] memoryUsageListeners = new MemoryUsageListener[0];
private static SimpleMemoryAllocatorImpl singleton = null;
- private static final AtomicReference<Thread> asyncCleanupThread = new AtomicReference<Thread>();
+ private static final AtomicReference<Thread> asyncCleanupThread = new AtomicReference<>();
final ChunkFactory chunkFactory;
public static SimpleMemoryAllocatorImpl getAllocator() {
@@ -106,69 +111,116 @@ public final class SimpleMemoryAllocatorImpl implements MemoryAllocator, MemoryI
return result;
}
- private static final boolean PRETOUCH = Boolean.getBoolean("gemfire.OFF_HEAP_PRETOUCH_PAGES");
- static final int OFF_HEAP_PAGE_SIZE = Integer.getInteger("gemfire.OFF_HEAP_PAGE_SIZE", UnsafeMemoryChunk.getPageSize());
- private static final boolean DO_EXPENSIVE_VALIDATION = Boolean.getBoolean("gemfire.OFF_HEAP_DO_EXPENSIVE_VALIDATION");;
-
- public static MemoryAllocator create(OutOfOffHeapMemoryListener ooohml, OffHeapMemoryStats stats, LogWriter lw, int slabCount, long offHeapMemorySize, long maxSlabSize) {
+ private static final boolean DO_EXPENSIVE_VALIDATION = Boolean.getBoolean("gemfire.OFF_HEAP_DO_EXPENSIVE_VALIDATION");
+
+ public static MemoryAllocator create(OutOfOffHeapMemoryListener ooohml, OffHeapMemoryStats stats, LogWriter lw,
+ int slabCount, long offHeapMemorySize, long maxSlabSize) {
+ return create(ooohml, stats, lw, slabCount, offHeapMemorySize, maxSlabSize,
+ null, TINY_MULTIPLE, BATCH_SIZE, TINY_FREE_LIST_COUNT, HUGE_MULTIPLE,
+ new UnsafeMemoryChunk.Factory() {
+ @Override
+ public UnsafeMemoryChunk create(int size) {
+ return new UnsafeMemoryChunk(size);
+ }
+ });
+ }
+
+ private static SimpleMemoryAllocatorImpl create(OutOfOffHeapMemoryListener ooohml, OffHeapMemoryStats stats, LogWriter lw,
+ int slabCount, long offHeapMemorySize, long maxSlabSize,
+ UnsafeMemoryChunk[] slabs, int tinyMultiple, int batchSize, int tinyFreeListCount, int hugeMultiple,
+ UnsafeMemoryChunk.Factory memChunkFactory) {
SimpleMemoryAllocatorImpl result = singleton;
boolean created = false;
try {
if (result != null) {
- result.reuse(ooohml, lw, stats, offHeapMemorySize);
- lw.config("Reusing " + result.getTotalMemory() + " bytes of off-heap memory. The maximum size of a single off-heap object is " + result.largestSlab + " bytes.");
+ result.reuse(ooohml, lw, stats, offHeapMemorySize, slabs);
+ if (lw != null) {
+ lw.config("Reusing " + result.getTotalMemory() + " bytes of off-heap memory. The maximum size of a single off-heap object is " + result.largestSlab + " bytes.");
+ }
created = true;
LifecycleListener.invokeAfterReuse(result);
} else {
- // allocate memory chunks
- //SimpleMemoryAllocatorImpl.cleanupPreviousAllocator();
- lw.config("Allocating " + offHeapMemorySize + " bytes of off-heap memory. The maximum size of a single off-heap object is " + maxSlabSize + " bytes.");
- UnsafeMemoryChunk[] slabs = new UnsafeMemoryChunk[slabCount];
- long uncreatedMemory = offHeapMemorySize;
- for (int i=0; i < slabCount; i++) {
- try {
- if (uncreatedMemory >= maxSlabSize) {
- slabs[i] = new UnsafeMemoryChunk((int) maxSlabSize);
- uncreatedMemory -= maxSlabSize;
- } else {
- // the last slab can be smaller then maxSlabSize
- slabs[i] = new UnsafeMemoryChunk((int) uncreatedMemory);
+ if (slabs == null) {
+ // allocate memory chunks
+ //SimpleMemoryAllocatorImpl.cleanupPreviousAllocator();
+ if (lw != null) {
+ lw.config("Allocating " + offHeapMemorySize + " bytes of off-heap memory. The maximum size of a single off-heap object is " + maxSlabSize + " bytes.");
}
- } catch (OutOfMemoryError err) {
- if (i > 0) {
- lw.severe("Off-heap memory creation failed after successfully allocating " + (i*maxSlabSize) + " bytes of off-heap memory.");
- }
- for (int j=0; j < i; j++) {
- if (slabs[j] != null) {
- slabs[j].release();
+ slabs = new UnsafeMemoryChunk[slabCount];
+ long uncreatedMemory = offHeapMemorySize;
+ for (int i=0; i < slabCount; i++) {
+ try {
+ if (uncreatedMemory >= maxSlabSize) {
+ slabs[i] = memChunkFactory.create((int) maxSlabSize);
+ uncreatedMemory -= maxSlabSize;
+ } else {
+ // the last slab can be smaller then maxSlabSize
+ slabs[i] = memChunkFactory.create((int) uncreatedMemory);
+ }
+ } catch (OutOfMemoryError err) {
+ if (i > 0) {
+ if (lw != null) {
+ lw.severe("Off-heap memory creation failed after successfully allocating " + (i*maxSlabSize) + " bytes of off-heap memory.");
+ }
}
+ for (int j=0; j < i; j++) {
+ if (slabs[j] != null) {
+ slabs[j].release();
+ }
+ }
+ throw err;
}
- throw err;
}
}
- result = new SimpleMemoryAllocatorImpl(ooohml, stats, slabs);
- created = true;
+ result = new SimpleMemoryAllocatorImpl(ooohml, stats, slabs, tinyMultiple, batchSize, tinyFreeListCount, hugeMultiple);
singleton = result;
LifecycleListener.invokeAfterCreate(result);
+ created = true;
}
} finally {
if (!created) {
- stats.close();
- ooohml.close();
+ if (stats != null) {
+ stats.close();
+ }
+ if (ooohml != null) {
+ ooohml.close();
+ }
}
}
return result;
}
// for unit tests
+ static SimpleMemoryAllocatorImpl create(OutOfOffHeapMemoryListener ooohml, OffHeapMemoryStats stats, LogWriter lw,
+ int slabCount, long offHeapMemorySize, long maxSlabSize, UnsafeMemoryChunk.Factory memChunkFactory) {
+ return create(ooohml, stats, lw, slabCount, offHeapMemorySize, maxSlabSize,
+ null, TINY_MULTIPLE, BATCH_SIZE, TINY_FREE_LIST_COUNT, HUGE_MULTIPLE, memChunkFactory);
+ }
+ // for unit tests
public static SimpleMemoryAllocatorImpl create(OutOfOffHeapMemoryListener oooml, OffHeapMemoryStats stats, UnsafeMemoryChunk[] slabs) {
- SimpleMemoryAllocatorImpl result = new SimpleMemoryAllocatorImpl(oooml, stats, slabs);
- singleton = result;
- LifecycleListener.invokeAfterCreate(result);
- return result;
+ return create(oooml, stats, slabs, TINY_MULTIPLE, BATCH_SIZE, TINY_FREE_LIST_COUNT, HUGE_MULTIPLE);
}
+ // for unit tests
+ static SimpleMemoryAllocatorImpl create(OutOfOffHeapMemoryListener oooml, OffHeapMemoryStats stats, UnsafeMemoryChunk[] slabs,
+ int tinyMultiple, int batchSize, int tinyFreeListCount, int hugeMultiple) {
+ int slabCount = 0;
+ long offHeapMemorySize = 0;
+ long maxSlabSize = 0;
+ if (slabs != null) {
+ slabCount = slabs.length;
+ for (int i=0; i < slabCount; i++) {
+ int slabSize = slabs[i].getSize();
+ offHeapMemorySize += slabSize;
+ if (slabSize > maxSlabSize) {
+ maxSlabSize = slabSize;
+ }
+ }
+ }
+ return create(oooml, stats, null, slabCount, offHeapMemorySize, maxSlabSize, slabs, tinyMultiple, batchSize, tinyFreeListCount, hugeMultiple, null);
+ }
+
- private void reuse(OutOfOffHeapMemoryListener oooml, LogWriter lw, OffHeapMemoryStats newStats, long offHeapMemorySize) {
+ private void reuse(OutOfOffHeapMemoryListener oooml, LogWriter lw, OffHeapMemoryStats newStats, long offHeapMemorySize, UnsafeMemoryChunk[] slabs) {
if (isClosed()) {
throw new IllegalStateException("Can not reuse a closed off-heap memory manager.");
}
@@ -176,100 +228,55 @@ public final class SimpleMemoryAllocatorImpl implements MemoryAllocator, MemoryI
throw new IllegalArgumentException("OutOfOffHeapMemoryListener is null");
}
if (getTotalMemory() != offHeapMemorySize) {
- lw.warning("Using " + getTotalMemory() + " bytes of existing off-heap memory instead of the requested " + offHeapMemorySize);
+ if (lw != null) {
+ lw.warning("Using " + getTotalMemory() + " bytes of existing off-heap memory instead of the requested " + offHeapMemorySize);
+ }
+ }
+ if (slabs != null) {
+ // this will only happen in unit tests
+ if (slabs != this.slabs) {
+ // If the unit test gave us a different array
+ // of slabs then something is wrong because we
+ // are trying to reuse the old already allocated
+ // array which means that the new one will never
+ // be used. Note that this code does not bother
+ // comparing the contents of the arrays.
+ throw new IllegalStateException("attempted to reuse existing off-heap memory even though new off-heap memory was allocated");
+ }
}
this.ooohml = oooml;
newStats.initialize(this.stats);
this.stats = newStats;
}
- public static void cleanupPreviousAllocator() {
- Thread t = asyncCleanupThread.getAndSet(null);
- if (t != null) {
-// try {
-// // HACK to see if a delay fixes bug 47883
-// Thread.sleep(3000);
-// } catch (InterruptedException ignore) {
-// }
- t.interrupt();
- try {
- t.join(FREE_PAUSE_MILLIS);
- } catch (InterruptedException ignore) {
- Thread.currentThread().interrupt();
- }
- }
- }
-
- private SimpleMemoryAllocatorImpl(final OutOfOffHeapMemoryListener oooml, final OffHeapMemoryStats stats, final UnsafeMemoryChunk[] slabs) {
+ private SimpleMemoryAllocatorImpl(final OutOfOffHeapMemoryListener oooml, final OffHeapMemoryStats stats, final UnsafeMemoryChunk[] slabs,
+ int tinyMultiple, int batchSize, int tinyFreeListCount, int hugeMultiple) {
if (oooml == null) {
throw new IllegalArgumentException("OutOfOffHeapMemoryListener is null");
}
- if (TINY_MULTIPLE <= 0 || (TINY_MULTIPLE & 3) != 0) {
+ if (tinyMultiple <= 0 || (tinyMultiple & 3) != 0) {
throw new IllegalStateException("gemfire.OFF_HEAP_ALIGNMENT must be a multiple of 8.");
}
- if (TINY_MULTIPLE > 256) {
+ if (tinyMultiple > 256) {
// this restriction exists because of the dataSize field in the object header.
throw new IllegalStateException("gemfire.OFF_HEAP_ALIGNMENT must be <= 256 and a multiple of 8.");
}
- if (BATCH_SIZE <= 0) {
+ if (batchSize <= 0) {
throw new IllegalStateException("gemfire.OFF_HEAP_BATCH_ALLOCATION_SIZE must be >= 1.");
}
- if (TINY_FREE_LIST_COUNT <= 0) {
+ if (tinyFreeListCount <= 0) {
throw new IllegalStateException("gemfire.OFF_HEAP_FREE_LIST_COUNT must be >= 1.");
}
- assert HUGE_MULTIPLE <= 256;
+ if (hugeMultiple > 256 || hugeMultiple < 0) {
+ // this restriction exists because of the dataSize field in the object header.
+ throw new IllegalStateException("HUGE_MULTIPLE must be >= 0 and <= 256 but it was " + hugeMultiple);
+ }
this.ooohml = oooml;
this.stats = stats;
this.slabs = slabs;
- if(GemFireCacheImpl.sqlfSystem()) {
- throw new IllegalStateException("offheap sqlf not supported");
-// String provider = GemFireCacheImpl.SQLF_FACTORY_PROVIDER;
-// try {
-// Class<?> factoryProvider = Class.forName(provider);
-// Method method = factoryProvider.getDeclaredMethod("getChunkFactory");
-// this.chunkFactory = (ChunkFactory)method.invoke(null, (Object [])null);
-// }catch (Exception e) {
-// throw new IllegalStateException("Exception in obtaining ChunkFactory class", e);
-// }
-
- }else {
-
- this.chunkFactory = new GemFireChunkFactory();
- }
+ this.chunkFactory = new GemFireChunkFactory();
- if (PRETOUCH) {
- final int tc;
- if (Runtime.getRuntime().availableProcessors() > 1) {
- tc = Runtime.getRuntime().availableProcessors() / 2;
- } else {
- tc = 1;
- }
- Thread[] threads = new Thread[tc];
- for (int i=0; i < tc; i++) {
- final int threadId = i;
- threads[i] = new Thread(new Runnable() {
- @Override
- public void run() {
- for (int slabId=threadId; slabId < slabs.length; slabId+=tc) {
- final int slabSize = slabs[slabId].getSize();
- for (int pageId=0; pageId < slabSize; pageId+=OFF_HEAP_PAGE_SIZE) {
- slabs[slabId].writeByte(pageId, (byte) 0);
- }
- }
- }
- });
- threads[i].start();
- }
- for (int i=0; i < tc; i++) {
- try {
- threads[i].join();
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- break;
- }
- }
- }
//OSProcess.printStacks(0, InternalDistributedSystem.getAnyInstance().getLogWriter(), false);
this.stats.setFragments(slabs.length);
largestSlab = slabs[0].getSize();
@@ -437,7 +444,7 @@ public final class SimpleMemoryAllocatorImpl implements MemoryAllocator, MemoryI
private void realClose() {
// Removing this memory immediately can lead to a SEGV. See 47885.
if (setClosed()) {
- freeSlabsAsync(this.slabs);
+ freeSlabs(this.slabs);
this.stats.close();
singleton = null;
}
@@ -456,41 +463,11 @@ public final class SimpleMemoryAllocatorImpl implements MemoryAllocator, MemoryI
}
- private static final int FREE_PAUSE_MILLIS = Integer.getInteger("gemfire.OFF_HEAP_FREE_PAUSE_MILLIS", 90000);
-
-
-
- private static void freeSlabsAsync(final UnsafeMemoryChunk[] slabs) {
- //debugLog("called freeSlabsAsync", false);
- // since we no longer free off-heap memory on every cache close
- // and production code does not free it but instead reuses it
- // we should be able to free it sync.
- // If it turns out that it does need to be async then we need
- // to make sure we call cleanupPreviousAllocator.
+ private static void freeSlabs(final UnsafeMemoryChunk[] slabs) {
+ //debugLog("called freeSlabs", false);
for (int i=0; i < slabs.length; i++) {
slabs[i].release();
}
-// Thread t = new Thread(new Runnable() {
-// @Override
-// public void run() {
-// // pause this many millis before freeing the slabs.
-// try {
-// Thread.sleep(FREE_PAUSE_MILLIS);
-// } catch (InterruptedException ignore) {
-// // If we are interrupted we should wakeup
-// // and free our slabs.
-// }
-// //debugLog("returning offheap memory to OS", false);
-// for (int i=0; i < slabs.length; i++) {
-// slabs[i].free();
-// }
-// //debugLog("returned offheap memory to OS", false);
-// asyncCleanupThread.compareAndSet(Thread.currentThread(), null);
-// }
-// }, "asyncSlabDeallocator");
-// t.setDaemon(true);
-// t.start();
-// asyncCleanupThread.set(t);
}
void freeChunk(long addr) {
@@ -504,7 +481,7 @@ public final class SimpleMemoryAllocatorImpl implements MemoryAllocator, MemoryI
/**
* Return the slabId of the slab that contains the given addr.
*/
- protected int findSlab(long addr) {
+ int findSlab(long addr) {
for (int i=0; i < this.slabs.length; i++) {
UnsafeMemoryChunk slab = this.slabs[i];
long slabAddr = slab.getMemoryAddress();
@@ -591,11 +568,11 @@ public final class SimpleMemoryAllocatorImpl implements MemoryAllocator, MemoryI
if (addr >= 0 && addr < 1024) {
throw new IllegalStateException("addr was smaller than expected 0x" + addr);
}
- validateAddressAndSizeWithinSlab(addr, size);
+ validateAddressAndSizeWithinSlab(addr, size, DO_EXPENSIVE_VALIDATION);
}
- static void validateAddressAndSizeWithinSlab(long addr, int size) {
- if (DO_EXPENSIVE_VALIDATION) {
+ static void validateAddressAndSizeWithinSlab(long addr, int size, boolean doExpensiveValidation) {
+ if (doExpensiveValidation) {
SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.singleton;
if (ma != null) {
for (int i=0; i < ma.slabs.length; i++) {
@@ -686,21 +663,6 @@ public final class SimpleMemoryAllocatorImpl implements MemoryAllocator, MemoryI
}
@Override
- public List<MemoryBlock> getDeallocatedBlocks() {
- return null;
- }
-
- @Override
- public List<MemoryBlock> getUnusedBlocks() {
- return null;
- }
-
- @Override
- public MemoryBlock getBlockContaining(long memoryAddress) {
- return null;
- }
-
- @Override
public MemoryBlock getBlockAfter(MemoryBlock block) {
if (block == null) {
return null;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f9744623/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/UnsafeMemoryChunk.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/UnsafeMemoryChunk.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/UnsafeMemoryChunk.java
index 06fee7b..4f0e86d 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/UnsafeMemoryChunk.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/offheap/UnsafeMemoryChunk.java
@@ -265,4 +265,14 @@ public class UnsafeMemoryChunk implements MemoryChunk {
sb.append("}");
return sb.toString();
}
+
+ /**
+ * Used to create UnsafeMemoryChunk instances.
+ */
+ public interface Factory {
+ /** Create and return an UnsafeMemoryChunk.
+ * @throws OutOfMemoryError if the create fails
+ */
+ public UnsafeMemoryChunk create(int size);
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f9744623/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/NullOffHeapMemoryStats.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/NullOffHeapMemoryStats.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/NullOffHeapMemoryStats.java
index 7c668f1..88bab77 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/NullOffHeapMemoryStats.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/NullOffHeapMemoryStats.java
@@ -24,6 +24,7 @@ import com.gemstone.gemfire.Statistics;
* @author Kirk Lund
*/
public class NullOffHeapMemoryStats implements OffHeapMemoryStats {
+ private boolean isClosed;
public void incFreeMemory(long value) {
}
@@ -100,9 +101,14 @@ public class NullOffHeapMemoryStats implements OffHeapMemoryStats {
}
@Override
public void close() {
+ this.isClosed = true;
}
@Override
public void initialize(OffHeapMemoryStats stats) {
stats.close();
}
+
+ public boolean isClosed() {
+ return this.isClosed;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f9744623/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/NullOutOfOffHeapMemoryListener.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/NullOutOfOffHeapMemoryListener.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/NullOutOfOffHeapMemoryListener.java
index caa913a..7d02c9f 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/NullOutOfOffHeapMemoryListener.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/NullOutOfOffHeapMemoryListener.java
@@ -24,10 +24,16 @@ import com.gemstone.gemfire.OutOfOffHeapMemoryException;
* @author Kirk Lund
*/
public class NullOutOfOffHeapMemoryListener implements OutOfOffHeapMemoryListener {
+ private boolean isClosed;
@Override
public void outOfOffHeapMemory(OutOfOffHeapMemoryException cause) {
}
@Override
public void close() {
+ this.isClosed = true;
+ }
+
+ public boolean isClosed() {
+ return this.isClosed;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f9744623/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorJUnitTest.java
index 19dfebb..1477764 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorJUnitTest.java
@@ -16,21 +16,21 @@
*/
package com.gemstone.gemfire.internal.offheap;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.*;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.concurrent.atomic.AtomicReference;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import com.gemstone.gemfire.OutOfOffHeapMemoryException;
+import com.gemstone.gemfire.cache.CacheClosedException;
+import com.gemstone.gemfire.internal.logging.NullLogWriter;
+import com.gemstone.gemfire.internal.offheap.UnsafeMemoryChunk.Factory;
import com.gemstone.gemfire.test.junit.categories.UnitTest;
@Category(UnitTest.class)
@@ -40,15 +40,198 @@ public class SimpleMemoryAllocatorJUnitTest {
return ((v+multiple-1)/multiple)*multiple;
}
@Test
+ public void testNullGetAllocator() {
+ try {
+ SimpleMemoryAllocatorImpl.getAllocator();
+ fail("expected CacheClosedException");
+ } catch (CacheClosedException expected) {
+ }
+ }
+ @Test
+ public void testConstructor() {
+ try {
+ SimpleMemoryAllocatorImpl.create(null, null, null);
+ fail("expected IllegalArgumentException");
+ } catch (IllegalArgumentException expected) {
+ }
+ try {
+ SimpleMemoryAllocatorImpl.create(new NullOutOfOffHeapMemoryListener(), null, null, -1, 0, 0, 0);
+ fail("expected IllegalStateException");
+ } catch (IllegalStateException expected) {
+ assertEquals(true, expected.getMessage().contains("gemfire.OFF_HEAP_ALIGNMENT must be a multiple of 8"));
+ }
+ try {
+ SimpleMemoryAllocatorImpl.create(new NullOutOfOffHeapMemoryListener(), null, null, 9, 0, 0, 0);
+ fail("expected IllegalStateException");
+ } catch (IllegalStateException expected) {
+ assertEquals(true, expected.getMessage().contains("gemfire.OFF_HEAP_ALIGNMENT must be a multiple of 8"));
+ }
+ try {
+ SimpleMemoryAllocatorImpl.create(new NullOutOfOffHeapMemoryListener(), null, null, 256+8, 0, 0, 0);
+ fail("expected IllegalStateException");
+ } catch (IllegalStateException expected) {
+ assertEquals(true, expected.getMessage().contains("gemfire.OFF_HEAP_ALIGNMENT must be <= 256"));
+ }
+ try {
+ SimpleMemoryAllocatorImpl.create(new NullOutOfOffHeapMemoryListener(), null, null, 8, 0, 0, 0);
+ fail("expected IllegalStateException");
+ } catch (IllegalStateException expected) {
+ assertEquals(true, expected.getMessage().contains("gemfire.OFF_HEAP_BATCH_ALLOCATION_SIZE must be >= 1."));
+ }
+ try {
+ SimpleMemoryAllocatorImpl.create(new NullOutOfOffHeapMemoryListener(), null, null, 8, 1, 0, 0);
+ fail("expected IllegalStateException");
+ } catch (IllegalStateException expected) {
+ assertEquals(true, expected.getMessage().contains("gemfire.OFF_HEAP_FREE_LIST_COUNT must be >= 1."));
+ }
+ try {
+ SimpleMemoryAllocatorImpl.create(new NullOutOfOffHeapMemoryListener(), null, null, 8, 1, 1, -1);
+ fail("expected IllegalStateException");
+ } catch (IllegalStateException expected) {
+ assertEquals(true, expected.getMessage().contains("HUGE_MULTIPLE must be >= 0 and <= 256 but it was -1"));
+ }
+ try {
+ SimpleMemoryAllocatorImpl.create(new NullOutOfOffHeapMemoryListener(), null, null, 8, 1, 1, 257);
+ fail("expected IllegalStateException");
+ } catch (IllegalStateException expected) {
+ assertEquals(true, expected.getMessage().contains("HUGE_MULTIPLE must be >= 0 and <= 256 but it was 257"));
+ }
+
+ }
+ /**
+ * Logger that remembers the last severe message
+ */
+ private static class LastSevereLogger extends NullLogWriter {
+ private String lastSevereMessage;
+ private Throwable lastSevereThrowable;
+
+ private void setLastSevere(String msg, Throwable ex) {
+ this.lastSevereMessage = msg;
+ this.lastSevereThrowable = ex;
+ }
+ public String getLastSevereMessage() {
+ return this.lastSevereMessage;
+ }
+ public Throwable getLastSevereThrowable() {
+ return this.lastSevereThrowable;
+ }
+ @Override
+ public void severe(String msg, Throwable ex) {
+ setLastSevere(msg, ex);
+ }
+ @Override
+ public void severe(String msg) {
+ setLastSevere(msg, null);
+ }
+ @Override
+ public void severe(Throwable ex) {
+ setLastSevere(null, ex);
+ }
+ }
+ @Test
+ public void testCreate() {
+ {
+ NullOutOfOffHeapMemoryListener listener = new NullOutOfOffHeapMemoryListener();
+ NullOffHeapMemoryStats stats = new NullOffHeapMemoryStats();
+ LastSevereLogger logger = new LastSevereLogger();
+ try {
+ SimpleMemoryAllocatorImpl.create(listener, stats, logger, 10, 950, 100,
+ new UnsafeMemoryChunk.Factory() {
+ @Override
+ public UnsafeMemoryChunk create(int size) {
+ throw new OutOfMemoryError("expected");
+ }
+ });
+ } catch (OutOfMemoryError expected) {
+ }
+ assertTrue(listener.isClosed());
+ assertTrue(stats.isClosed());
+ assertEquals(null, logger.getLastSevereThrowable());
+ assertEquals(null, logger.getLastSevereMessage());
+ }
+ {
+ NullOutOfOffHeapMemoryListener listener = new NullOutOfOffHeapMemoryListener();
+ NullOffHeapMemoryStats stats = new NullOffHeapMemoryStats();
+ LastSevereLogger logger = new LastSevereLogger();
+ int MAX_SLAB_SIZE = 100;
+ try {
+ Factory factory = new UnsafeMemoryChunk.Factory() {
+ private int createCount = 0;
+ @Override
+ public UnsafeMemoryChunk create(int size) {
+ createCount++;
+ if (createCount == 1) {
+ return new UnsafeMemoryChunk(size);
+ } else {
+ throw new OutOfMemoryError("expected");
+ }
+ }
+ };
+ SimpleMemoryAllocatorImpl.create(listener, stats, logger, 10, 950, MAX_SLAB_SIZE, factory);
+ } catch (OutOfMemoryError expected) {
+ }
+ assertTrue(listener.isClosed());
+ assertTrue(stats.isClosed());
+ assertEquals(null, logger.getLastSevereThrowable());
+ assertEquals("Off-heap memory creation failed after successfully allocating " + MAX_SLAB_SIZE + " bytes of off-heap memory.", logger.getLastSevereMessage());
+ }
+ {
+ NullOutOfOffHeapMemoryListener listener = new NullOutOfOffHeapMemoryListener();
+ NullOffHeapMemoryStats stats = new NullOffHeapMemoryStats();
+ Factory factory = new UnsafeMemoryChunk.Factory() {
+ @Override
+ public UnsafeMemoryChunk create(int size) {
+ return new UnsafeMemoryChunk(size);
+ }
+ };
+ MemoryAllocator ma =
+ SimpleMemoryAllocatorImpl.create(listener, stats, new NullLogWriter(), 10, 950, 100, factory);
+ try {
+ assertFalse(listener.isClosed());
+ assertFalse(stats.isClosed());
+ ma.close();
+ assertTrue(listener.isClosed());
+ assertFalse(stats.isClosed());
+ listener = new NullOutOfOffHeapMemoryListener();
+ NullOffHeapMemoryStats stats2 = new NullOffHeapMemoryStats();
+ {
+ UnsafeMemoryChunk slab = new UnsafeMemoryChunk(1024);
+ try {
+ SimpleMemoryAllocatorImpl.create(listener, stats2, new UnsafeMemoryChunk[]{slab});
+ } catch (IllegalStateException expected) {
+ assertTrue("unexpected message: " + expected.getMessage(),
+ expected.getMessage().equals("attempted to reuse existing off-heap memory even though new off-heap memory was allocated"));
+ } finally {
+ slab.release();
+ }
+ assertFalse(stats.isClosed());
+ assertTrue(listener.isClosed());
+ assertTrue(stats2.isClosed());
+ }
+ listener = new NullOutOfOffHeapMemoryListener();
+ stats2 = new NullOffHeapMemoryStats();
+ MemoryAllocator ma2 = SimpleMemoryAllocatorImpl.create(listener, stats2, new NullLogWriter(), 10, 950, 100, factory);
+ assertSame(ma, ma2);
+ assertTrue(stats.isClosed());
+ assertFalse(listener.isClosed());
+ assertFalse(stats2.isClosed());
+ stats = stats2;
+ } finally {
+ ma.close();
+ assertTrue(listener.isClosed());
+ assertFalse(stats.isClosed());
+ SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+ assertTrue(stats.isClosed());
+ }
+ }
+ }
+ @Test
public void testBasics() {
int BATCH_SIZE = com.gemstone.gemfire.internal.offheap.SimpleMemoryAllocatorImpl.BATCH_SIZE;
int TINY_MULTIPLE = com.gemstone.gemfire.internal.offheap.SimpleMemoryAllocatorImpl.TINY_MULTIPLE;
-// int BIG_MULTIPLE = com.gemstone.gemfire.internal.offheap.SimpleMemoryAllocatorImpl.FreeListManager.BIG_MULTIPLE;
int HUGE_MULTIPLE = com.gemstone.gemfire.internal.offheap.SimpleMemoryAllocatorImpl.HUGE_MULTIPLE;
int perObjectOverhead = com.gemstone.gemfire.internal.offheap.Chunk.OFF_HEAP_HEADER_SIZE;
int maxTiny = com.gemstone.gemfire.internal.offheap.SimpleMemoryAllocatorImpl.MAX_TINY-perObjectOverhead;
-// int MIN_BIG_SIZE = round(BIG_MULTIPLE, maxTiny+perObjectOverhead+1)-perObjectOverhead;
-// int maxBig = com.gemstone.gemfire.internal.offheap.SimpleMemoryAllocatorImpl.FreeListManager.MAX_BIG-perObjectOverhead;
int minHuge = maxTiny+1;
int TOTAL_MEM = (maxTiny+perObjectOverhead)*BATCH_SIZE /*+ (maxBig+perObjectOverhead)*BATCH_SIZE*/ + round(TINY_MULTIPLE, minHuge+1+perObjectOverhead)*BATCH_SIZE + (TINY_MULTIPLE+perObjectOverhead)*BATCH_SIZE /*+ (MIN_BIG_SIZE+perObjectOverhead)*BATCH_SIZE*/ + round(TINY_MULTIPLE, minHuge+perObjectOverhead+1);
UnsafeMemoryChunk slab = new UnsafeMemoryChunk(TOTAL_MEM);
@@ -57,14 +240,10 @@ public class SimpleMemoryAllocatorJUnitTest {
assertEquals(TOTAL_MEM, ma.getFreeMemory());
assertEquals(TOTAL_MEM, ma.freeList.getFreeFragmentMemory());
assertEquals(0, ma.freeList.getFreeTinyMemory());
-// assertEquals(0, ma.freeList.getFreeBigMemory());
assertEquals(0, ma.freeList.getFreeHugeMemory());
MemoryChunk tinymc = ma.allocate(maxTiny, null);
assertEquals(TOTAL_MEM-round(TINY_MULTIPLE, maxTiny+perObjectOverhead), ma.getFreeMemory());
assertEquals(round(TINY_MULTIPLE, maxTiny+perObjectOverhead)*(BATCH_SIZE-1), ma.freeList.getFreeTinyMemory());
-// MemoryChunk bigmc = ma.allocate(maxBig);
-// assertEquals(TOTAL_MEM-round(BIG_MULTIPLE, maxBig+perObjectOverhead)-round(TINY_MULTIPLE, maxTiny+perObjectOverhead), ma.getFreeMemory());
-// assertEquals(round(BIG_MULTIPLE, maxBig+perObjectOverhead)*(BATCH_SIZE-1), ma.getFreeList().getFreeBigMemory());
MemoryChunk hugemc = ma.allocate(minHuge, null);
assertEquals(TOTAL_MEM-round(TINY_MULTIPLE, minHuge+perObjectOverhead)/*-round(BIG_MULTIPLE, maxBig+perObjectOverhead)*/-round(TINY_MULTIPLE, maxTiny+perObjectOverhead), ma.getFreeMemory());
long freeSlab = ma.freeList.getFreeFragmentMemory();
@@ -73,9 +252,6 @@ public class SimpleMemoryAllocatorJUnitTest {
hugemc.release();
assertEquals(round(TINY_MULTIPLE, minHuge+perObjectOverhead), ma.freeList.getFreeHugeMemory()-oldFreeHugeMemory);
assertEquals(TOTAL_MEM/*-round(BIG_MULTIPLE, maxBig+perObjectOverhead)*/-round(TINY_MULTIPLE, maxTiny+perObjectOverhead), ma.getFreeMemory());
-// long oldFreeBigMemory = ma.freeList.getFreeBigMemory();
-// bigmc.free();
-// assertEquals(round(BIG_MULTIPLE, maxBig+perObjectOverhead), ma.freeList.getFreeBigMemory()-oldFreeBigMemory);
assertEquals(TOTAL_MEM-round(TINY_MULTIPLE, maxTiny+perObjectOverhead), ma.getFreeMemory());
long oldFreeTinyMemory = ma.freeList.getFreeTinyMemory();
tinymc.release();
@@ -85,17 +261,12 @@ public class SimpleMemoryAllocatorJUnitTest {
tinymc = ma.allocate(maxTiny, null);
assertEquals(oldFreeTinyMemory, ma.freeList.getFreeTinyMemory());
assertEquals(TOTAL_MEM-round(TINY_MULTIPLE, maxTiny+perObjectOverhead), ma.getFreeMemory());
-// bigmc = ma.allocate(maxBig);
-// assertEquals(oldFreeBigMemory, ma.freeList.getFreeBigMemory());
-// assertEquals(TOTAL_MEM-round(BIG_MULTIPLE, maxBig+perObjectOverhead)-round(TINY_MULTIPLE, maxTiny+perObjectOverhead), ma.getFreeMemory());
hugemc = ma.allocate(minHuge, null);
assertEquals(oldFreeHugeMemory, ma.freeList.getFreeHugeMemory());
assertEquals(TOTAL_MEM-round(TINY_MULTIPLE, minHuge+perObjectOverhead)/*-round(BIG_MULTIPLE, maxBig+perObjectOverhead)*/-round(TINY_MULTIPLE, maxTiny+perObjectOverhead), ma.getFreeMemory());
hugemc.release();
assertEquals(round(TINY_MULTIPLE, minHuge+perObjectOverhead), ma.freeList.getFreeHugeMemory()-oldFreeHugeMemory);
assertEquals(TOTAL_MEM/*-round(BIG_MULTIPLE, maxBig+perObjectOverhead)*/-round(TINY_MULTIPLE, maxTiny+perObjectOverhead), ma.getFreeMemory());
-// bigmc.free();
-// assertEquals(round(BIG_MULTIPLE, maxBig+perObjectOverhead), ma.freeList.getFreeBigMemory()-oldFreeBigMemory);
assertEquals(TOTAL_MEM-round(TINY_MULTIPLE, maxTiny+perObjectOverhead), ma.getFreeMemory());
tinymc.release();
assertEquals(round(TINY_MULTIPLE, maxTiny+perObjectOverhead), ma.freeList.getFreeTinyMemory()-oldFreeTinyMemory);
@@ -108,9 +279,6 @@ public class SimpleMemoryAllocatorJUnitTest {
freeSlab = ma.freeList.getFreeFragmentMemory();
tinymc.release();
assertEquals(round(TINY_MULTIPLE, maxTiny+perObjectOverhead)+(round(TINY_MULTIPLE, 1+perObjectOverhead)*BATCH_SIZE), ma.freeList.getFreeTinyMemory()-oldFreeTinyMemory);
-// bigmc = ma.allocate(MIN_BIG_SIZE);
-// assertEquals(MIN_BIG_SIZE+perObjectOverhead, bigmc.getSize());
-// assertEquals(freeSlab-((MIN_BIG_SIZE+perObjectOverhead)*BATCH_SIZE), ma.freeList.getFreeFragmentMemory());
hugemc = ma.allocate(minHuge+1, null);
assertEquals(round(TINY_MULTIPLE, minHuge+1+perObjectOverhead), hugemc.getSize());
@@ -129,13 +297,6 @@ public class SimpleMemoryAllocatorJUnitTest {
assertEquals(round(TINY_MULTIPLE, minHuge+perObjectOverhead)*BATCH_SIZE, ma.freeList.getFreeHugeMemory());
// now that we do compaction the following allocate works.
hugemc = ma.allocate(minHuge + HUGE_MULTIPLE + HUGE_MULTIPLE-1, null);
-
- // assertEquals(minHuge+minHuge+1, ma.freeList.getFreeHugeMemory());
-// hugemc.free();
-// assertEquals(minHuge+minHuge+1+minHuge + HUGE_MULTIPLE + HUGE_MULTIPLE-1, ma.freeList.getFreeHugeMemory());
-// hugemc = ma.allocate(minHuge + HUGE_MULTIPLE);
-// assertEquals(minHuge + HUGE_MULTIPLE + HUGE_MULTIPLE-1, hugemc.getSize());
-// assertEquals(minHuge+minHuge+1, ma.freeList.getFreeHugeMemory());
} finally {
SimpleMemoryAllocatorImpl.freeOffHeapMemory();
}
@@ -165,6 +326,144 @@ public class SimpleMemoryAllocatorJUnitTest {
}
@Test
+ public void testDebugLog() {
+ SimpleMemoryAllocatorImpl.debugLog("test debug log", false);
+ SimpleMemoryAllocatorImpl.debugLog("test debug log", true);
+ }
+ @Test
+ public void testGetLostChunks() {
+ UnsafeMemoryChunk slab = new UnsafeMemoryChunk(1024*1024);
+ try {
+ SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.create(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
+ assertEquals(Collections.emptyList(), ma.getLostChunks());
+ } finally {
+ SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+ }
+ }
+ @Test
+ public void testFindSlab() {
+ final int SLAB_SIZE = 1024*1024;
+ UnsafeMemoryChunk slab = new UnsafeMemoryChunk(SLAB_SIZE);
+ try {
+ SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.create(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
+ assertEquals(0, ma.findSlab(slab.getMemoryAddress()));
+ assertEquals(0, ma.findSlab(slab.getMemoryAddress()+SLAB_SIZE-1));
+ try {
+ ma.findSlab(slab.getMemoryAddress()-1);
+ fail("expected IllegalStateException");
+ } catch (IllegalStateException expected) {
+ }
+ try {
+ ma.findSlab(slab.getMemoryAddress()+SLAB_SIZE);
+ fail("expected IllegalStateException");
+ } catch (IllegalStateException expected) {
+ }
+ } finally {
+ SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+ }
+ }
+ @Test
+ public void testValidateAddressAndSize() {
+ final int SLAB_SIZE = 1024*1024;
+ UnsafeMemoryChunk slab = new UnsafeMemoryChunk(SLAB_SIZE);
+ try {
+ SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.create(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
+ try {
+ SimpleMemoryAllocatorImpl.validateAddress(0L);
+ fail("expected IllegalStateException");
+ } catch (IllegalStateException expected) {
+ assertEquals("Unexpected exception message: " + expected.getMessage(), true, expected.getMessage().contains("addr was smaller than expected"));
+ }
+ try {
+ SimpleMemoryAllocatorImpl.validateAddress(1L);
+ fail("expected IllegalStateException");
+ } catch (IllegalStateException expected) {
+ assertEquals("Unexpected exception message: " + expected.getMessage(), true, expected.getMessage().contains("Valid addresses must be in one of the following ranges:"));
+ }
+ SimpleMemoryAllocatorImpl.validateAddressAndSizeWithinSlab(slab.getMemoryAddress(), SLAB_SIZE, false);
+ SimpleMemoryAllocatorImpl.validateAddressAndSizeWithinSlab(slab.getMemoryAddress(), SLAB_SIZE, true);
+ SimpleMemoryAllocatorImpl.validateAddressAndSizeWithinSlab(slab.getMemoryAddress(), -1, true);
+ try {
+ SimpleMemoryAllocatorImpl.validateAddressAndSizeWithinSlab(slab.getMemoryAddress()-1, SLAB_SIZE, true);
+ fail("expected IllegalStateException");
+ } catch (IllegalStateException expected) {
+ assertEquals("Unexpected exception message: " + expected.getMessage(), true, expected.getMessage().equals(" address 0x" + Long.toString(slab.getMemoryAddress()-1, 16) + " does not address the original slab memory"));
+ }
+ try {
+ SimpleMemoryAllocatorImpl.validateAddressAndSizeWithinSlab(slab.getMemoryAddress(), SLAB_SIZE+1, true);
+ fail("expected IllegalStateException");
+ } catch (IllegalStateException expected) {
+ assertEquals("Unexpected exception message: " + expected.getMessage(), true, expected.getMessage().equals(" address 0x" + Long.toString(slab.getMemoryAddress()+SLAB_SIZE, 16) + " does not address the original slab memory"));
+ }
+ } finally {
+ SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+ }
+ }
+ @Test
+ public void testMemoryInspection() {
+ final int SLAB_SIZE = 1024*1024;
+ UnsafeMemoryChunk slab = new UnsafeMemoryChunk(SLAB_SIZE);
+ try {
+ SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.create(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab});
+ MemoryInspector inspector = ma.getMemoryInspector();
+ assertNotNull(inspector);
+ assertEquals(null, inspector.getFirstBlock());
+ assertEquals(Collections.emptyList(), ma.getInspectionSnapshot());
+ assertEquals(Collections.emptyList(), ma.getAllocatedBlocks());
+ assertEquals(null, ma.getBlockAfter(null));
+ inspector.createInspectionSnapshot();
+ // call this twice for code coverage
+ inspector.createInspectionSnapshot();
+ try {
+ assertEquals(ma.getAllBlocks(), ma.getInspectionSnapshot());
+ MemoryBlock firstBlock = inspector.getFirstBlock();
+ assertNotNull(firstBlock);
+ assertEquals(1024*1024, firstBlock.getBlockSize());
+ assertEquals("N/A", firstBlock.getDataType());
+ assertEquals(-1, firstBlock.getFreeListId());
+ assertTrue(firstBlock.getMemoryAddress() > 0);
+ assertNull(firstBlock.getNextBlock());
+ assertEquals(0, firstBlock.getRefCount());
+ assertEquals(0, firstBlock.getSlabId());
+ assertEquals(MemoryBlock.State.UNUSED, firstBlock.getState());
+ assertFalse(firstBlock.isCompressed());
+ assertFalse(firstBlock.isSerialized());
+ assertEquals(null, ma.getBlockAfter(firstBlock));
+ } finally {
+ inspector.clearInspectionSnapshot();
+ }
+ } finally {
+ SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+ }
+ }
+
+ @Test
+ public void testClose() {
+ UnsafeMemoryChunk slab = new UnsafeMemoryChunk(1024*1024);
+ boolean freeSlab = true;
+ UnsafeMemoryChunk[] slabs = new UnsafeMemoryChunk[]{slab};
+ try {
+ SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.create(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), slabs);
+ ma.close();
+ ma.close();
+ System.setProperty(SimpleMemoryAllocatorImpl.FREE_OFF_HEAP_MEMORY_PROPERTY, "true");
+ try {
+ ma = SimpleMemoryAllocatorImpl.create(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), slabs);
+ ma.close();
+ freeSlab = false;
+ ma.close();
+ } finally {
+ System.clearProperty(SimpleMemoryAllocatorImpl.FREE_OFF_HEAP_MEMORY_PROPERTY);
+ }
+ } finally {
+ if (freeSlab) {
+ SimpleMemoryAllocatorImpl.freeOffHeapMemory();
+ }
+ }
+
+ }
+
+ @Test
public void testCompaction() {
final int perObjectOverhead = com.gemstone.gemfire.internal.offheap.Chunk.OFF_HEAP_HEADER_SIZE;
final int BIG_ALLOC_SIZE = 150000;
@@ -306,8 +605,18 @@ public class SimpleMemoryAllocatorJUnitTest {
smc = ma.allocate(SMALL_ALLOC_SIZE-perObjectOverhead, null);
assertEquals(true, this.memoryUsageEventReceived);
+ MemoryUsageListener unaddedListener = new MemoryUsageListener() {
+ @Override
+ public void updateMemoryUsed(final long bytesUsed) {
+ throw new IllegalStateException("Should never be called");
+ }
+ };
+ ma.removeMemoryUsageListener(unaddedListener);
+
ma.removeMemoryUsageListener(listener);
+ ma.removeMemoryUsageListener(unaddedListener);
+
this.expectedMemoryUsage = SMALL_ALLOC_SIZE * 2;
this.memoryUsageEventReceived = false;
smc = ma.allocate(SMALL_ALLOC_SIZE-perObjectOverhead, null);
[10/13] incubator-geode git commit: Adding additional unit tests for
GMSHealthMonitor and GMSJoinLeave Moved GMSHealthMonitorJUnitTest to package
level of GMSHealthMonitor Minor refactoring to allow testing
Posted by kl...@apache.org.
Adding additional unit tests for GMSHealthMonitor and GMSJoinLeave
Moved GMSHealthMonitorJUnitTest to package level of GMSHealthMonitor
Minor refactoring to allow testing
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/3259c023
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/3259c023
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/3259c023
Branch: refs/heads/feature/GEODE-291
Commit: 3259c0238a97413268297b663219d72bf8b130c9
Parents: e0bf685
Author: Jason Huynh <hu...@gmail.com>
Authored: Wed Dec 2 15:11:40 2015 -0800
Committer: Jason Huynh <hu...@gmail.com>
Committed: Fri Dec 4 10:40:52 2015 -0800
----------------------------------------------------------------------
.../membership/InternalDistributedMember.java | 16 +-
.../membership/gms/fd/GMSHealthMonitor.java | 60 +-
.../membership/gms/membership/GMSJoinLeave.java | 8 +
.../gms/fd/GMSHealthMonitorJUnitTest.java | 576 +++++++++++++++++++
.../gms/membership/GMSJoinLeaveJUnitTest.java | 31 +-
.../fd/GMSHealthMonitorJUnitTest.java | 461 ---------------
6 files changed, 666 insertions(+), 486 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3259c023/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/InternalDistributedMember.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/InternalDistributedMember.java b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/InternalDistributedMember.java
index 10478b7..b112b92 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/InternalDistributedMember.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/InternalDistributedMember.java
@@ -292,7 +292,21 @@ public final class InternalDistributedMember
* @throws UnknownHostException if the given hostname cannot be resolved
*/
public InternalDistributedMember(String i, int p, Version version) throws UnknownHostException {
- netMbr = MemberFactory.newNetMember(i, p);
+ this (i, p, version, MemberFactory.newNetMember(i, p));
+ }
+
+ /**
+ * Create a InternalDistributedMember referring to the current host (as defined by the given
+ * string).<p>
+ *
+ * <b>
+ * THIS METHOD IS FOR TESTING ONLY. DO NOT USE IT TO CREATE IDs FOR
+ * USE IN THE PRODUCT. IT DOES NOT PROPERLY INITIALIZE ATTRIBUTES NEEDED
+ * FOR P2P FUNCTIONALITY.
+ * </b>
+ **/
+ public InternalDistributedMember(String i, int p, Version version, NetMember netMember) throws UnknownHostException {
+ netMbr = netMember;
defaultToCurrentHost();
this.vmKind = DistributionManager.NORMAL_DM_TYPE;
this.versionObj = version;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3259c023/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/fd/GMSHealthMonitor.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/fd/GMSHealthMonitor.java b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/fd/GMSHealthMonitor.java
index fcda1a0..cc64f9b 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/fd/GMSHealthMonitor.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/fd/GMSHealthMonitor.java
@@ -56,6 +56,7 @@ import org.jgroups.util.UUID;
import com.gemstone.gemfire.CancelException;
import com.gemstone.gemfire.GemFireConfigException;
+import com.gemstone.gemfire.SystemConnectException;
import com.gemstone.gemfire.distributed.DistributedMember;
import com.gemstone.gemfire.distributed.DistributedSystemDisconnectedException;
import com.gemstone.gemfire.distributed.internal.DistributionMessage;
@@ -173,9 +174,8 @@ public class GMSHealthMonitor implements HealthMonitor, MessageHandler {
// For TCP check
private ExecutorService serverSocketExecutor;
- private static final int OK = 0x7B;
- private static final int ERROR = 0x00;
- private InetAddress socketAddress;
+ static final int OK = 0x7B;
+ static final int ERROR = 0x00;
private volatile int socketPort;
private volatile ServerSocket serverSocket;
@@ -491,11 +491,7 @@ public class GMSHealthMonitor implements HealthMonitor, MessageHandler {
InputStream in = clientSocket.getInputStream();
DataOutputStream out = new DataOutputStream(clientSocket.getOutputStream());
GMSMember gmbr = (GMSMember) suspectMember.getNetMember();
- out.writeShort(Version.CURRENT_ORDINAL);
- out.writeInt(gmbr.getVmViewId());
- out.writeLong(gmbr.getUuidLSBs());
- out.writeLong(gmbr.getUuidMSBs());
- out.flush();
+ writeMemberToStream(gmbr, out);
clientSocket.shutdownOutput();
logger.debug("Connected - reading response", suspectMember);
int b = in.read();
@@ -531,6 +527,14 @@ public class GMSHealthMonitor implements HealthMonitor, MessageHandler {
return false;
}
+ void writeMemberToStream(GMSMember gmbr, DataOutputStream out) throws IOException {
+ out.writeShort(Version.CURRENT_ORDINAL);
+ out.writeInt(gmbr.getVmViewId());
+ out.writeLong(gmbr.getUuidLSBs());
+ out.writeLong(gmbr.getUuidMSBs());
+ out.flush();
+ }
+
/*
* (non-Javadoc)
*
@@ -610,32 +614,37 @@ public class GMSHealthMonitor implements HealthMonitor, MessageHandler {
}
- /**
- * start the thread that listens for tcp/ip connections and responds
- * to connection attempts
- */
- private void startTcpServer() {
- // allocate a socket here so there are no race conditions between knowing the FD
- // socket port and joining the system
- socketAddress = localAddress.getInetAddress();
- int[] portRange = services.getConfig().getMembershipPortRange();
+ ServerSocket createServerSocket(InetAddress socketAddress, int[] portRange) {
+ ServerSocket serverSocket = null;
try {
serverSocket = SocketCreator.getDefaultInstance().createServerSocketUsingPortRange(socketAddress, 50/*backlog*/, true/*isBindAddress*/, false/*useNIO*/, 65536/*tcpBufferSize*/, portRange);
socketPort = serverSocket.getLocalPort();
} catch (IOException e) {
throw new GemFireConfigException("Unable to allocate a failure detection port in the membership-port range", e);
+ } catch (SystemConnectException e) {
+ throw new GemFireConfigException("Unable to allocate a failure detection port in the membership-port range", e);
}
+ return serverSocket;
+ }
+
+ /**
+ * start the thread that listens for tcp/ip connections and responds
+ * to connection attempts
+ */
+ private void startTcpServer(ServerSocket ssocket) {
+ // allocate a socket here so there are no race conditions between knowing the FD
+ // socket port and joining the system
serverSocketExecutor.execute(new Runnable() {
@Override
public void run() {
- logger.info("Started failure detection server thread on {}:{}.", socketAddress, socketPort);
+ logger.info("Started failure detection server thread on {}:{}.", ssocket.getInetAddress(), socketPort);
Socket socket = null;
try {
while (!services.getCancelCriterion().isCancelInProgress()
&& !GMSHealthMonitor.this.isStopping) {
try {
- socket = serverSocket.accept();
+ socket = ssocket.accept();
if (GMSHealthMonitor.this.playingDead) {
continue;
}
@@ -658,9 +667,9 @@ public class GMSHealthMonitor implements HealthMonitor, MessageHandler {
logger.info("GMSHealthMonitor server thread exiting");
} finally {
// close the server socket
- if (serverSocket != null && !serverSocket.isClosed()) {
+ if (ssocket != null && !ssocket.isClosed()) {
try {
- serverSocket.close();
+ ssocket.close();
serverSocket = null;
logger.info("GMSHealthMonitor server socket closed.");
} catch (IOException e) {
@@ -841,8 +850,9 @@ public class GMSHealthMonitor implements HealthMonitor, MessageHandler {
@Override
public void started() {
- this.localAddress = services.getMessenger().getMemberID();
- startTcpServer();
+ setLocalAddress( services.getMessenger().getMemberID());
+ serverSocket = createServerSocket(localAddress.getInetAddress(), services.getConfig().getMembershipPortRange());
+ startTcpServer(serverSocket);
startHeartbeatThread();
}
@@ -941,6 +951,10 @@ public class GMSHealthMonitor implements HealthMonitor, MessageHandler {
public void emergencyClose() {
stopServices();
}
+
+ void setLocalAddress(InternalDistributedMember idm) {
+ this.localAddress = idm;
+ }
@Override
public void processMessage(DistributionMessage m) {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3259c023/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
index 2986238..84a0bd7 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
@@ -1058,6 +1058,14 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
joinResponse.notify();
}
}
+
+ /**
+ * for testing, do not use in any other case as it is not thread safe
+ * @param req
+ */
+ JoinResponseMessage[] getJoinResponseMessage() {
+ return joinResponse;
+ }
private void processFindCoordinatorRequest(FindCoordinatorRequest req) {
FindCoordinatorResponse resp;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3259c023/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/fd/GMSHealthMonitorJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/fd/GMSHealthMonitorJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/fd/GMSHealthMonitorJUnitTest.java
new file mode 100644
index 0000000..86205b9
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/fd/GMSHealthMonitorJUnitTest.java
@@ -0,0 +1,576 @@
+/*
+ * 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.distributed.internal.membership.gms.fd;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.isA;
+import static org.mockito.Mockito.atLeastOnce;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+
+import org.jgroups.util.UUID;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.distributed.internal.DistributionManager;
+import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember;
+import com.gemstone.gemfire.distributed.internal.membership.NetView;
+import com.gemstone.gemfire.distributed.internal.membership.gms.GMSMember;
+import com.gemstone.gemfire.distributed.internal.membership.gms.ServiceConfig;
+import com.gemstone.gemfire.distributed.internal.membership.gms.Services;
+import com.gemstone.gemfire.distributed.internal.membership.gms.Services.Stopper;
+import com.gemstone.gemfire.distributed.internal.membership.gms.fd.GMSHealthMonitor.ClientSocketHandler;
+import com.gemstone.gemfire.distributed.internal.membership.gms.interfaces.JoinLeave;
+import com.gemstone.gemfire.distributed.internal.membership.gms.interfaces.Manager;
+import com.gemstone.gemfire.distributed.internal.membership.gms.interfaces.Messenger;
+import com.gemstone.gemfire.distributed.internal.membership.gms.messages.HeartbeatMessage;
+import com.gemstone.gemfire.distributed.internal.membership.gms.messages.HeartbeatRequestMessage;
+import com.gemstone.gemfire.distributed.internal.membership.gms.messages.SuspectMembersMessage;
+import com.gemstone.gemfire.distributed.internal.membership.gms.messages.SuspectRequest;
+import com.gemstone.gemfire.internal.SocketCreator;
+import com.gemstone.gemfire.internal.Version;
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
+
+@Category(UnitTest.class)
+public class GMSHealthMonitorJUnitTest {
+
+ private Services services;
+ private ServiceConfig mockConfig;
+ private DistributionConfig mockDistConfig;
+ private List<InternalDistributedMember> mockMembers;
+ private Messenger messenger;
+ private JoinLeave joinLeave;
+ private GMSHealthMonitor gmsHealthMonitor;
+ private Manager manager;
+ final long memberTimeout = 1000l;
+ private int[] portRange= new int[]{0, 65535};
+
+ @Before
+ public void initMocks() throws UnknownHostException {
+ System.setProperty("gemfire.bind-address", "localhost");
+ mockDistConfig = mock(DistributionConfig.class);
+ mockConfig = mock(ServiceConfig.class);
+ messenger = mock(Messenger.class);
+ joinLeave = mock(JoinLeave.class);
+ manager = mock(Manager.class);
+ services = mock(Services.class);
+ Stopper stopper = mock(Stopper.class);
+
+ when(mockConfig.getDistributionConfig()).thenReturn(mockDistConfig);
+ when(mockConfig.getMemberTimeout()).thenReturn(memberTimeout);
+ when(mockConfig.getMembershipPortRange()).thenReturn(portRange);
+ when(services.getConfig()).thenReturn(mockConfig);
+ when(services.getMessenger()).thenReturn(messenger);
+ when(services.getJoinLeave()).thenReturn(joinLeave);
+ when(services.getCancelCriterion()).thenReturn(stopper);
+ when(services.getManager()).thenReturn(manager);
+ when(stopper.isCancelInProgress()).thenReturn(false);
+
+
+ if (mockMembers == null) {
+ mockMembers = new ArrayList<InternalDistributedMember>();
+ for (int i = 0; i < 7; i++) {
+ InternalDistributedMember mbr = new InternalDistributedMember("localhost", 8888 + i);
+
+ if (i == 0 || i == 1) {
+ mbr.setVmKind(DistributionManager.LOCATOR_DM_TYPE);
+ mbr.getNetMember().setPreferredForCoordinator(true);
+ }
+ mockMembers.add(mbr);
+ }
+ }
+ when(joinLeave.getMemberID()).thenReturn(mockMembers.get(3));
+ when(messenger.getMemberID()).thenReturn(mockMembers.get(3));
+ gmsHealthMonitor = new GMSHealthMonitor();
+ gmsHealthMonitor.init(services);
+ gmsHealthMonitor.start();
+ }
+
+ @After
+ public void tearDown() {
+ gmsHealthMonitor.stop();
+ }
+
+ @Test
+ public void testHMServiceStarted() throws IOException {
+
+ InternalDistributedMember mbr = new InternalDistributedMember(SocketCreator.getLocalHost(), 12345);
+ mbr.setVmViewId(1);
+ when(messenger.getMemberID()).thenReturn(mbr);
+ gmsHealthMonitor.started();
+
+ NetView v = new NetView(mbr, 1, mockMembers, new HashSet<InternalDistributedMember>(), new HashSet<InternalDistributedMember>());
+
+ gmsHealthMonitor.processMessage(new HeartbeatRequestMessage(mbr, 1));
+ verify(messenger, atLeastOnce()).send(any(HeartbeatMessage.class));
+ }
+
+ /**
+ * checks who is next neighbor
+ */
+ @Test
+ public void testHMNextNeighborVerify() throws IOException {
+
+ NetView v = new NetView(mockMembers.get(0), 2, mockMembers, new HashSet<InternalDistributedMember>(), new HashSet<InternalDistributedMember>());
+
+ when(messenger.getMemberID()).thenReturn(mockMembers.get(3));
+ gmsHealthMonitor.started();
+
+ gmsHealthMonitor.installView(v);
+
+ Assert.assertEquals(mockMembers.get(4), gmsHealthMonitor.getNextNeighbor());
+
+ }
+
+ @Test
+ public void testHMNextNeighborAfterTimeout() throws Exception {
+ System.out.println("testHMNextNeighborAfterTimeout starting");
+ NetView v = new NetView(mockMembers.get(0), 2, mockMembers, new HashSet<InternalDistributedMember>(), new HashSet<InternalDistributedMember>());
+
+// System.out.printf("memberID is %s view is %s\n", mockMembers.get(3), v);
+
+ // 3rd is current member
+ when(messenger.getMemberID()).thenReturn(mockMembers.get(3));
+ gmsHealthMonitor.started();
+
+ gmsHealthMonitor.installView(v);
+
+ // allow the monitor to give up on the initial "next neighbor" and
+ // move on to the one after it
+ long giveup = System.currentTimeMillis() + memberTimeout + 500;
+ InternalDistributedMember expected = mockMembers.get(5);
+ InternalDistributedMember neighbor = gmsHealthMonitor.getNextNeighbor();
+ while (System.currentTimeMillis() < giveup && neighbor != expected) {
+ Thread.sleep(5);
+ neighbor = gmsHealthMonitor.getNextNeighbor();
+ }
+
+ // neighbor should change to 5th
+ System.out.println("testHMNextNeighborAfterTimeout ending");
+ Assert.assertEquals("expected " + expected + " but found " + neighbor
+ + ". view="+v, expected, neighbor);
+ }
+
+ /**
+ * it checks neighbor before member-timeout, it should be same
+ */
+
+ @Test
+ public void testHMNextNeighborBeforeTimeout() throws IOException {
+ NetView v = new NetView(mockMembers.get(0), 2, mockMembers, new HashSet<InternalDistributedMember>(), new HashSet<InternalDistributedMember>());
+
+ // 3rd is current member
+ when(messenger.getMemberID()).thenReturn(mockMembers.get(3));
+ gmsHealthMonitor.started();
+
+ gmsHealthMonitor.installView(v);
+
+ //Should we remove these sleeps and force the checkmember directly instead of waiting?
+ try {
+ // member-timeout is 1000 ms. We initiate a check and choose
+ // a new neighbor at 500 ms
+ Thread.sleep(memberTimeout/GMSHealthMonitor.LOGICAL_INTERVAL - 100);
+ } catch (InterruptedException e) {
+ }
+ // neighbor should be same
+ System.out.println("next neighbor is " + gmsHealthMonitor.getNextNeighbor() +
+ "\nmy address is " + mockMembers.get(3) +
+ "\nview is " + v);
+
+ Assert.assertEquals(mockMembers.get(4), gmsHealthMonitor.getNextNeighbor());
+ }
+
+ /***
+ * checks whether member-check thread sends suspectMembers message
+ */
+ @Test
+ public void testSuspectMembersCalledThroughMemberCheckThread() throws Exception {
+ System.out.println("testSuspectMembersCalledThroughMemberCheckThread starting");
+ NetView v = new NetView(mockMembers.get(0), 2, mockMembers, new HashSet<InternalDistributedMember>(), new HashSet<InternalDistributedMember>());
+
+ // 3rd is current member
+ when(messenger.getMemberID()).thenReturn(mockMembers.get(3));
+ gmsHealthMonitor.started();
+
+ gmsHealthMonitor.installView(v);
+
+ // when the view is installed we start a heartbeat timeout. After
+ // that expires we request a heartbeat
+ Thread.sleep(3*memberTimeout + 100);
+
+ System.out.println("testSuspectMembersCalledThroughMemberCheckThread ending");
+ assertTrue(gmsHealthMonitor.isSuspectMember(mockMembers.get(4)));
+ }
+
+ /***
+ * checks ping thread didn't sends suspectMembers message before timeout
+ */
+ @Test
+ public void testSuspectMembersNotCalledThroughPingThreadBeforeTimeout() {
+ NetView v = new NetView(mockMembers.get(0), 2, mockMembers, new HashSet<InternalDistributedMember>(), new HashSet<InternalDistributedMember>());
+
+ // 3rd is current member
+ when(messenger.getMemberID()).thenReturn(mockMembers.get(3));
+ gmsHealthMonitor.started();
+
+ gmsHealthMonitor.installView(v);
+ InternalDistributedMember neighbor = gmsHealthMonitor.getNextNeighbor();
+
+ try {
+ // member-timeout is 1000 ms
+ // plus 100 ms for ack
+ Thread.sleep(memberTimeout - 200);
+ } catch (InterruptedException e) {
+ }
+
+ assertFalse(gmsHealthMonitor.isSuspectMember(neighbor));
+ }
+
+ /***
+ * Checks whether suspect thread sends suspectMembers message
+ */
+ @Test
+ public void testSuspectMembersCalledThroughSuspectThread() throws Exception {
+ NetView v = new NetView(mockMembers.get(0), 2, mockMembers, new HashSet<InternalDistributedMember>(), new HashSet<InternalDistributedMember>());
+
+ // 3rd is current member
+ when(messenger.getMemberID()).thenReturn(mockMembers.get(3));
+
+ gmsHealthMonitor.installView(v);
+
+ gmsHealthMonitor.suspect(mockMembers.get(1), "Not responding");
+
+ Thread.sleep(GMSHealthMonitor.MEMBER_SUSPECT_COLLECTION_INTERVAL + 1000);
+
+ verify(messenger, atLeastOnce()).send(any(SuspectMembersMessage.class));
+ }
+
+ /***
+ * Checks suspect thread doesn't sends suspectMembers message before timeout
+ */
+ @Test
+ public void testSuspectMembersNotCalledThroughSuspectThreadBeforeTimeout() {
+
+ NetView v = new NetView(mockMembers.get(0), 2, mockMembers, new HashSet<InternalDistributedMember>(), new HashSet<InternalDistributedMember>());
+
+ MethodExecuted messageSent = new MethodExecuted();
+ // 3rd is current member
+ when(messenger.getMemberID()).thenReturn(mockMembers.get(3));
+
+ gmsHealthMonitor.installView(v);
+
+ gmsHealthMonitor.suspect(mockMembers.get(1), "Not responding");
+
+ when(messenger.send(isA(SuspectMembersMessage.class))).thenAnswer(messageSent);
+
+ try {
+ // suspect thread timeout is 200 ms
+ Thread.sleep(100l);
+ } catch (InterruptedException e) {
+ }
+
+ assertTrue("SuspectMembersMessage shouldn't have sent", !messageSent.isMethodExecuted());
+ }
+
+ /***
+ * Send remove member message after doing final check, ping Timeout
+ */
+ @Test
+ public void testRemoveMemberCalled() throws Exception {
+ System.out.println("testRemoveMemberCalled starting");
+ NetView v = new NetView(mockMembers.get(0), 2, mockMembers, new HashSet<InternalDistributedMember>(), new HashSet<InternalDistributedMember>());
+
+ // 3rd is current member
+ when(messenger.getMemberID()).thenReturn(mockMembers.get(0)); // coordinator and local member
+ gmsHealthMonitor.started();
+
+ gmsHealthMonitor.installView(v);
+
+ Thread.sleep(memberTimeout/GMSHealthMonitor.LOGICAL_INTERVAL);
+
+ ArrayList<InternalDistributedMember> recipient = new ArrayList<InternalDistributedMember>();
+ recipient.add(mockMembers.get(0));
+ ArrayList<SuspectRequest> as = new ArrayList<SuspectRequest>();
+ SuspectRequest sr = new SuspectRequest(mockMembers.get(1), "Not Responding");// removing member 1
+ as.add(sr);
+ SuspectMembersMessage sm = new SuspectMembersMessage(recipient, as);
+ sm.setSender(mockMembers.get(0));
+
+ gmsHealthMonitor.processMessage(sm);
+
+ Thread.sleep(2*memberTimeout + 200);
+
+ System.out.println("testRemoveMemberCalled ending");
+ verify(joinLeave, atLeastOnce()).remove(any(InternalDistributedMember.class), any(String.class));
+ }
+
+ /***
+ * Shouldn't send remove member message before doing final check, or before ping Timeout
+ */
+ @Test
+ public void testRemoveMemberNotCalledBeforeTimeout() {
+ System.out.println("testRemoveMemberNotCalledBeforeTimeout starting");
+ NetView v = new NetView(mockMembers.get(0), 2, mockMembers, new HashSet<InternalDistributedMember>(), new HashSet<InternalDistributedMember>());
+
+ // 3rd is current member
+ when(messenger.getMemberID()).thenReturn(mockMembers.get(0)); // coordinator and local member
+ when(joinLeave.getMemberID()).thenReturn(mockMembers.get(0)); // coordinator and local member
+ gmsHealthMonitor.started();
+
+ gmsHealthMonitor.installView(v);
+
+ ArrayList<InternalDistributedMember> recipient = new ArrayList<InternalDistributedMember>();
+ recipient.add(mockMembers.get(0));
+ ArrayList<SuspectRequest> as = new ArrayList<SuspectRequest>();
+ SuspectRequest sr = new SuspectRequest(mockMembers.get(1), "Not Responding");// removing member 1
+ as.add(sr);
+ SuspectMembersMessage sm = new SuspectMembersMessage(recipient, as);
+ sm.setSender(mockMembers.get(0));
+
+ gmsHealthMonitor.processMessage(sm);
+
+ try {
+ // this happens after final check, ping timeout
+ Thread.sleep(memberTimeout-100);
+ } catch (InterruptedException e) {
+ }
+
+ System.out.println("testRemoveMemberNotCalledBeforeTimeout ending");
+ verify(joinLeave, never()).remove(any(InternalDistributedMember.class), any(String.class));
+ }
+
+ /***
+ * Send remove member message after doing final check for coordinator, ping timeout
+ * This test trying to remove coordinator
+ */
+ @Test
+ public void testRemoveMemberCalledAfterDoingFinalCheckOnCoordinator() throws Exception {
+
+ NetView v = new NetView(mockMembers.get(0), 2, mockMembers, new HashSet<InternalDistributedMember>(), new HashSet<InternalDistributedMember>());
+
+ // preferred coordinators are 0 and 1
+ when(messenger.getMemberID()).thenReturn(mockMembers.get(1));// next preferred coordinator
+ gmsHealthMonitor.started();
+
+ gmsHealthMonitor.installView(v);
+
+ Thread.sleep(memberTimeout/GMSHealthMonitor.LOGICAL_INTERVAL);
+
+ ArrayList<InternalDistributedMember> recipient = new ArrayList<InternalDistributedMember>();
+ recipient.add(mockMembers.get(0));
+ recipient.add(mockMembers.get(1));
+ ArrayList<SuspectRequest> as = new ArrayList<SuspectRequest>();
+ SuspectRequest sr = new SuspectRequest(mockMembers.get(0), "Not Responding");// removing coordinator
+ as.add(sr);
+ SuspectMembersMessage sm = new SuspectMembersMessage(recipient, as);
+ sm.setSender(mockMembers.get(4));// member 4 sends suspect message
+
+ gmsHealthMonitor.processMessage(sm);
+
+ // this happens after final check, ping timeout = 1000 ms
+ Thread.sleep(memberTimeout + 200);
+
+ verify(joinLeave, atLeastOnce()).remove(any(InternalDistributedMember.class), any(String.class));
+ }
+
+ /***
+ * validates HealthMonitor.CheckIfAvailable api
+ */
+ @Test
+ public void testCheckIfAvailable() {
+
+ NetView v = new NetView(mockMembers.get(0), 2, mockMembers, new HashSet<InternalDistributedMember>(), new HashSet<InternalDistributedMember>());
+
+ // 3rd is current member
+ when(messenger.getMemberID()).thenReturn(mockMembers.get(3));
+
+ gmsHealthMonitor.installView(v);
+
+ long startTime = System.currentTimeMillis();
+
+ boolean retVal = gmsHealthMonitor.checkIfAvailable(mockMembers.get(1), "Not responding", false);
+
+ long timeTaken = System.currentTimeMillis() - startTime;
+
+ assertTrue("This should have taken member ping timeout 100ms ", timeTaken > 90);
+ assertTrue("CheckIfAvailable should have return false", !retVal);
+ }
+
+ @Test
+ public void testShutdown() {
+
+ NetView v = new NetView(mockMembers.get(0), 2, mockMembers, new HashSet<InternalDistributedMember>(), new HashSet<InternalDistributedMember>());
+
+ // 3rd is current member
+ when(messenger.getMemberID()).thenReturn(mockMembers.get(3));
+
+ gmsHealthMonitor.installView(v);
+
+ gmsHealthMonitor.stop();
+
+ try {
+ // this happens after final check, membertimeout = 1000
+ Thread.sleep(100l);
+ } catch (InterruptedException e) {
+ }
+
+ assertTrue("HeathMonitor should have shutdown", gmsHealthMonitor.isShutdown());
+
+ }
+
+ @Test
+ public void testCreateServerSocket() throws Exception {
+ try (ServerSocket socket = gmsHealthMonitor.createServerSocket(InetAddress.getLocalHost(), portRange)) {
+ Assert.assertTrue( portRange[0] <= socket.getLocalPort() && socket.getLocalPort() <= portRange[1]);
+ }
+ }
+
+ @Test
+ public void testCreateServerSocketPortRangeInvalid() throws Exception {
+ try (ServerSocket socket = gmsHealthMonitor.createServerSocket(InetAddress.getLocalHost(), new int[]{-1, -1})) {
+ Assert.fail("socket was created with invalid port range");
+ }
+ catch (IllegalArgumentException e) {
+
+ }
+ }
+
+ @Test
+ public void testClientSocketHandler() throws Exception {
+ int viewId = 2;
+ long msb = 3;
+ long lsb = 4;
+ GMSMember otherMember = createGMSMember(Version.CURRENT_ORDINAL, viewId, msb, lsb);
+ GMSMember gmsMember = createGMSMember(Version.CURRENT_ORDINAL, viewId, msb, lsb);
+ executeTestClientSocketHandler(gmsMember, otherMember, GMSHealthMonitor.OK);
+ }
+
+ @Test
+ public void testClientSocketHandlerWhenMsbDoNotMatch() throws Exception {
+ int viewId = 2;
+ long msb = 3;
+ long lsb = 4;
+ GMSMember otherMember = createGMSMember(Version.CURRENT_ORDINAL, viewId, msb + 1, lsb);
+ GMSMember gmsMember = createGMSMember(Version.CURRENT_ORDINAL, viewId, msb, lsb);
+ executeTestClientSocketHandler(gmsMember, otherMember, GMSHealthMonitor.ERROR);
+ }
+
+ @Test
+ public void testClientSocketHandlerWhenLsbDoNotMatch() throws Exception {
+ int viewId = 2;
+ long msb = 3;
+ long lsb = 4;
+ GMSMember otherMember = createGMSMember(Version.CURRENT_ORDINAL, viewId, msb, lsb + 1);
+ GMSMember gmsMember = createGMSMember(Version.CURRENT_ORDINAL, viewId, msb, lsb);
+ executeTestClientSocketHandler(gmsMember, otherMember, GMSHealthMonitor.ERROR);
+ }
+
+ @Test
+ public void testClientSocketHandlerWhenViewIdDoNotMatch() throws Exception {
+ int viewId = 2;
+ long msb = 3;
+ long lsb = 4;
+ GMSMember otherMember = createGMSMember(Version.CURRENT_ORDINAL, viewId + 1, msb, lsb);
+ GMSMember gmsMember = createGMSMember(Version.CURRENT_ORDINAL, viewId, msb, lsb);
+ executeTestClientSocketHandler(gmsMember, otherMember, GMSHealthMonitor.ERROR);
+ }
+
+ public void executeTestClientSocketHandler(GMSMember gmsMember, GMSMember otherMember, int expectedResult) throws Exception {
+ //We have already set the view id in the member but when creating the IDM it resets it to -1 for some reason
+ int viewId = gmsMember.getVmViewId();
+
+ InternalDistributedMember testMember = new InternalDistributedMember("localhost", 9000, Version.CURRENT, gmsMember);
+ //We set to our expected test viewId in the IDM as well as reseting the gms member
+ testMember.setVmViewId(viewId);
+ gmsMember.setBirthViewId(viewId);
+
+
+ //Set up the incoming/received bytes. We just wrap output streams and write out the gms member information
+ byte[] receivedBytes = writeMemberToBytes(otherMember);
+ InputStream mockInputStream = new ByteArrayInputStream(receivedBytes);
+
+ //configure the mock to return the mocked incoming bytes and provide an outputstream that we will check
+ Socket fakeSocket = mock(Socket.class);
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ when(fakeSocket.getInputStream()).thenReturn(mockInputStream);
+ when(fakeSocket.getOutputStream()).thenReturn(outputStream);
+
+ //run the socket handler
+ gmsHealthMonitor.setLocalAddress(testMember);
+ ClientSocketHandler handler = gmsHealthMonitor.new ClientSocketHandler(fakeSocket);
+ handler.run();
+
+ //verify the written bytes are as expected
+ DataInputStream dis = new DataInputStream(new ByteArrayInputStream(outputStream.toByteArray()));
+ int byteReply = dis.read();
+ Assert.assertEquals(expectedResult, byteReply);
+ }
+
+ private GMSMember createGMSMember(short version, int viewId, long msb, long lsb) {
+ GMSMember gmsMember = new GMSMember();
+ gmsMember.setVersionOrdinal(version);
+ gmsMember.setBirthViewId(viewId);
+ gmsMember.setUUID(new UUID(msb, lsb));
+ return gmsMember;
+ }
+
+ private byte[] writeMemberToBytes(GMSMember gmsMember) throws IOException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ DataOutputStream dataReceive = new DataOutputStream(baos);
+ gmsHealthMonitor.writeMemberToStream(gmsMember, dataReceive);
+ return baos.toByteArray();
+ }
+
+
+ private class MethodExecuted implements Answer {
+ private boolean methodExecuted = false;
+
+ public boolean isMethodExecuted() {
+ return methodExecuted;
+ }
+
+ @Override
+ public Object answer(InvocationOnMock invocation) throws Throwable {
+ methodExecuted = true;
+ return null;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3259c023/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java
index abc7a2f..9895f68 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java
@@ -19,7 +19,7 @@ package com.gemstone.gemfire.distributed.internal.membership.gms.membership;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.isA;
+import static org.mockito.Matchers.isA;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
@@ -244,6 +244,21 @@ public class GMSJoinLeaveJUnitTest {
verify(messenger).send(any(JoinResponseMessage.class));
}
+ //This test does not test the actual join process but rather that the join response gets loggedß
+ @Test
+ public void testProcessJoinResponseIsRecorded() throws IOException {
+ initMocks();
+ when(services.getAuthenticator()).thenReturn(authenticator);
+ when(authenticator.authenticate(mockMembers[0], null)).thenThrow(new AuthenticationFailedException("we want to fail auth here"));
+ when(services.getMessenger()).thenReturn(messenger);
+
+ JoinResponseMessage[] joinResponse = gmsJoinLeave.getJoinResponseMessage();
+
+ JoinResponseMessage jrm = new JoinResponseMessage();
+ gmsJoinLeave.processMessage(jrm);
+ Assert.assertEquals(jrm, joinResponse[0]);
+ }
+
/**
* prepares and install a view
* @throws IOException
@@ -635,6 +650,20 @@ public class GMSJoinLeaveJUnitTest {
verify(manager).quorumLost(crashes, newView);
}
+ //Possibly modify test to check for network partition message in the force disconnect
+ @Test
+ public void testNetworkPartitionMessageReceived() throws Exception {
+ initMocks();
+ gmsJoinLeave.becomeCoordinatorForTest();
+ List<InternalDistributedMember> members = Arrays.asList(mockMembers);
+ Set<InternalDistributedMember> empty = Collections.<InternalDistributedMember>emptySet();
+ NetView v = new NetView(mockMembers[0], 2, members, empty, empty);
+ NetworkPartitionMessage message = new NetworkPartitionMessage();
+ gmsJoinLeave.processMessage(message);
+ verify(manager).forceDisconnect(any(String.class));
+ }
+
+
@Test
public void testQuorumLossNotificationWithNetworkPartitionDetectionDisabled() throws IOException {
initMocks(false);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3259c023/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/fd/GMSHealthMonitorJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/fd/GMSHealthMonitorJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/fd/GMSHealthMonitorJUnitTest.java
deleted file mode 100644
index 41a99a6..0000000
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/fd/GMSHealthMonitorJUnitTest.java
+++ /dev/null
@@ -1,461 +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.distributed.internal.membership.gms.membership.fd;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.isA;
-import static org.mockito.Mockito.atLeastOnce;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.io.IOException;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-
-import com.gemstone.gemfire.distributed.internal.DistributionConfig;
-import com.gemstone.gemfire.distributed.internal.DistributionManager;
-import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember;
-import com.gemstone.gemfire.distributed.internal.membership.NetView;
-import com.gemstone.gemfire.distributed.internal.membership.gms.ServiceConfig;
-import com.gemstone.gemfire.distributed.internal.membership.gms.Services;
-import com.gemstone.gemfire.distributed.internal.membership.gms.Services.Stopper;
-import com.gemstone.gemfire.distributed.internal.membership.gms.fd.GMSHealthMonitor;
-import com.gemstone.gemfire.distributed.internal.membership.gms.interfaces.JoinLeave;
-import com.gemstone.gemfire.distributed.internal.membership.gms.interfaces.Manager;
-import com.gemstone.gemfire.distributed.internal.membership.gms.interfaces.Messenger;
-import com.gemstone.gemfire.distributed.internal.membership.gms.messages.HeartbeatMessage;
-import com.gemstone.gemfire.distributed.internal.membership.gms.messages.HeartbeatRequestMessage;
-import com.gemstone.gemfire.distributed.internal.membership.gms.messages.SuspectMembersMessage;
-import com.gemstone.gemfire.distributed.internal.membership.gms.messages.SuspectRequest;
-import com.gemstone.gemfire.internal.SocketCreator;
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
-
-@Category(UnitTest.class)
-public class GMSHealthMonitorJUnitTest {
-
- private Services services;
- private ServiceConfig mockConfig;
- private DistributionConfig mockDistConfig;
- private List<InternalDistributedMember> mockMembers;
- private Messenger messenger;
- private JoinLeave joinLeave;
- private GMSHealthMonitor gmsHealthMonitor;
- private Manager manager;
- final long memberTimeout = 1000l;
- private int[] portRange= new int[]{0, 65535};
-
- @Before
- public void initMocks() throws UnknownHostException {
- System.setProperty("gemfire.bind-address", "localhost");
- mockDistConfig = mock(DistributionConfig.class);
- mockConfig = mock(ServiceConfig.class);
- messenger = mock(Messenger.class);
- joinLeave = mock(JoinLeave.class);
- manager = mock(Manager.class);
- services = mock(Services.class);
- Stopper stopper = mock(Stopper.class);
-
- when(mockConfig.getDistributionConfig()).thenReturn(mockDistConfig);
- when(mockConfig.getMemberTimeout()).thenReturn(memberTimeout);
- when(mockConfig.getMembershipPortRange()).thenReturn(portRange);
- when(services.getConfig()).thenReturn(mockConfig);
- when(services.getMessenger()).thenReturn(messenger);
- when(services.getJoinLeave()).thenReturn(joinLeave);
- when(services.getCancelCriterion()).thenReturn(stopper);
- when(services.getManager()).thenReturn(manager);
- when(stopper.isCancelInProgress()).thenReturn(false);
-
-
- if (mockMembers == null) {
- mockMembers = new ArrayList<InternalDistributedMember>();
- for (int i = 0; i < 7; i++) {
- InternalDistributedMember mbr = new InternalDistributedMember("localhost", 8888 + i);
-
- if (i == 0 || i == 1) {
- mbr.setVmKind(DistributionManager.LOCATOR_DM_TYPE);
- mbr.getNetMember().setPreferredForCoordinator(true);
- }
- mockMembers.add(mbr);
- }
- }
- when(joinLeave.getMemberID()).thenReturn(mockMembers.get(3));
- when(messenger.getMemberID()).thenReturn(mockMembers.get(3));
- gmsHealthMonitor = new GMSHealthMonitor();
- gmsHealthMonitor.init(services);
- gmsHealthMonitor.start();
- }
-
- @After
- public void tearDown() {
- gmsHealthMonitor.stop();
- System.getProperties().remove("gemfire.bind-address");
- }
-
- @Test
- public void testHMServiceStarted() throws IOException {
-
- InternalDistributedMember mbr = new InternalDistributedMember(SocketCreator.getLocalHost(), 12345);
- mbr.setVmViewId(1);
- when(messenger.getMemberID()).thenReturn(mbr);
- gmsHealthMonitor.started();
-
- NetView v = new NetView(mbr, 1, mockMembers, new HashSet<InternalDistributedMember>(), new HashSet<InternalDistributedMember>());
-
- gmsHealthMonitor.processMessage(new HeartbeatRequestMessage(mbr, 1));
- verify(messenger, atLeastOnce()).send(any(HeartbeatMessage.class));
- }
-
- /**
- * checks who is next neighbor
- */
- @Test
- public void testHMNextNeighborVerify() throws IOException {
-
- NetView v = new NetView(mockMembers.get(0), 2, mockMembers, new HashSet<InternalDistributedMember>(), new HashSet<InternalDistributedMember>());
-
- when(messenger.getMemberID()).thenReturn(mockMembers.get(3));
- gmsHealthMonitor.started();
-
- gmsHealthMonitor.installView(v);
-
- Assert.assertEquals(mockMembers.get(4), gmsHealthMonitor.getNextNeighbor());
-
- }
-
- @Test
- public void testHMNextNeighborAfterTimeout() throws Exception {
- System.out.println("testHMNextNeighborAfterTimeout starting");
- NetView v = new NetView(mockMembers.get(0), 2, mockMembers, new HashSet<InternalDistributedMember>(), new HashSet<InternalDistributedMember>());
-
-// System.out.printf("memberID is %s view is %s\n", mockMembers.get(3), v);
-
- // 3rd is current member
- when(messenger.getMemberID()).thenReturn(mockMembers.get(3));
- gmsHealthMonitor.started();
-
- gmsHealthMonitor.installView(v);
-
- // allow the monitor to give up on the initial "next neighbor" and
- // move on to the one after it
- long giveup = System.currentTimeMillis() + memberTimeout + 600;
- InternalDistributedMember expected = mockMembers.get(5);
- InternalDistributedMember neighbor = gmsHealthMonitor.getNextNeighbor();
- while (System.currentTimeMillis() < giveup && neighbor != expected) {
- Thread.sleep(5);
- neighbor = gmsHealthMonitor.getNextNeighbor();
- }
-
- // neighbor should change to 5th
- System.out.println("testHMNextNeighborAfterTimeout ending");
- Assert.assertEquals("expected " + expected + " but found " + neighbor
- + ". view="+v, expected, neighbor);
- }
-
- /**
- * it checks neighbor before member-timeout, it should be same
- */
-
- @Test
- public void testHMNextNeighborBeforeTimeout() throws IOException {
- NetView v = new NetView(mockMembers.get(0), 2, mockMembers, new HashSet<InternalDistributedMember>(), new HashSet<InternalDistributedMember>());
-
- // 3rd is current member
- when(messenger.getMemberID()).thenReturn(mockMembers.get(3));
- gmsHealthMonitor.started();
-
- gmsHealthMonitor.installView(v);
-
- try {
- // member-timeout is 1000 ms. We initiate a check and choose
- // a new neighbor at 500 ms
- Thread.sleep(memberTimeout/GMSHealthMonitor.LOGICAL_INTERVAL - 100);
- } catch (InterruptedException e) {
- }
- // neighbor should be same
- System.out.println("next neighbor is " + gmsHealthMonitor.getNextNeighbor() +
- "\nmy address is " + mockMembers.get(3) +
- "\nview is " + v);
-
- Assert.assertEquals(mockMembers.get(4), gmsHealthMonitor.getNextNeighbor());
- }
-
- /***
- * checks whether member-check thread sends suspectMembers message
- */
- @Test
- public void testSuspectMembersCalledThroughMemberCheckThread() throws Exception {
- System.out.println("testSuspectMembersCalledThroughMemberCheckThread starting");
- NetView v = new NetView(mockMembers.get(0), 2, mockMembers, new HashSet<InternalDistributedMember>(), new HashSet<InternalDistributedMember>());
-
- // 3rd is current member
- when(messenger.getMemberID()).thenReturn(mockMembers.get(3));
- gmsHealthMonitor.started();
-
- gmsHealthMonitor.installView(v);
-
- // when the view is installed we start a heartbeat timeout. After
- // that expires we request a heartbeat
- Thread.sleep(3*memberTimeout + 100);
-
- System.out.println("testSuspectMembersCalledThroughMemberCheckThread ending");
- assertTrue(gmsHealthMonitor.isSuspectMember(mockMembers.get(4)));
- }
-
- /***
- * checks ping thread didn't sends suspectMembers message before timeout
- */
- @Test
- public void testSuspectMembersNotCalledThroughPingThreadBeforeTimeout() {
- NetView v = new NetView(mockMembers.get(0), 2, mockMembers, new HashSet<InternalDistributedMember>(), new HashSet<InternalDistributedMember>());
-
- // 3rd is current member
- when(messenger.getMemberID()).thenReturn(mockMembers.get(3));
- gmsHealthMonitor.started();
-
- gmsHealthMonitor.installView(v);
- InternalDistributedMember neighbor = gmsHealthMonitor.getNextNeighbor();
-
- try {
- // member-timeout is 1000 ms
- // plus 100 ms for ack
- Thread.sleep(memberTimeout - 200);
- } catch (InterruptedException e) {
- }
-
- assertFalse(gmsHealthMonitor.isSuspectMember(neighbor));
- }
-
- /***
- * Checks whether suspect thread sends suspectMembers message
- */
- @Test
- public void testSuspectMembersCalledThroughSuspectThread() throws Exception {
- NetView v = new NetView(mockMembers.get(0), 2, mockMembers, new HashSet<InternalDistributedMember>(), new HashSet<InternalDistributedMember>());
-
- // 3rd is current member
- when(messenger.getMemberID()).thenReturn(mockMembers.get(3));
-
- gmsHealthMonitor.installView(v);
-
- gmsHealthMonitor.suspect(mockMembers.get(1), "Not responding");
-
- Thread.sleep(GMSHealthMonitor.MEMBER_SUSPECT_COLLECTION_INTERVAL + 1000);
-
- verify(messenger, atLeastOnce()).send(any(SuspectMembersMessage.class));
- }
-
- /***
- * Checks suspect thread doesn't sends suspectMembers message before timeout
- */
- @Test
- public void testSuspectMembersNotCalledThroughSuspectThreadBeforeTimeout() {
-
- NetView v = new NetView(mockMembers.get(0), 2, mockMembers, new HashSet<InternalDistributedMember>(), new HashSet<InternalDistributedMember>());
-
- MethodExecuted messageSent = new MethodExecuted();
- // 3rd is current member
- when(messenger.getMemberID()).thenReturn(mockMembers.get(3));
-
- gmsHealthMonitor.installView(v);
-
- gmsHealthMonitor.suspect(mockMembers.get(1), "Not responding");
-
- when(messenger.send(isA(SuspectMembersMessage.class))).thenAnswer(messageSent);
-
- try {
- // suspect thread timeout is 200 ms
- Thread.sleep(100l);
- } catch (InterruptedException e) {
- }
-
- assertTrue("SuspectMembersMessage shouldn't have sent", !messageSent.isMethodExecuted());
- }
-
- /***
- * Send remove member message after doing final check, ping Timeout
- */
- @Test
- public void testRemoveMemberCalled() throws Exception {
- System.out.println("testRemoveMemberCalled starting");
- NetView v = new NetView(mockMembers.get(0), 2, mockMembers, new HashSet<InternalDistributedMember>(), new HashSet<InternalDistributedMember>());
-
- // 3rd is current member
- when(messenger.getMemberID()).thenReturn(mockMembers.get(0)); // coordinator and local member
- gmsHealthMonitor.started();
-
- gmsHealthMonitor.installView(v);
-
- Thread.sleep(memberTimeout/GMSHealthMonitor.LOGICAL_INTERVAL);
-
- ArrayList<InternalDistributedMember> recipient = new ArrayList<InternalDistributedMember>();
- recipient.add(mockMembers.get(0));
- ArrayList<SuspectRequest> as = new ArrayList<SuspectRequest>();
- SuspectRequest sr = new SuspectRequest(mockMembers.get(1), "Not Responding");// removing member 1
- as.add(sr);
- SuspectMembersMessage sm = new SuspectMembersMessage(recipient, as);
- sm.setSender(mockMembers.get(0));
-
- gmsHealthMonitor.processMessage(sm);
-
- Thread.sleep(2*memberTimeout + 200);
-
- System.out.println("testRemoveMemberCalled ending");
- verify(joinLeave, atLeastOnce()).remove(any(InternalDistributedMember.class), any(String.class));
- }
-
- /***
- * Shouldn't send remove member message before doing final check, or before ping Timeout
- */
- @Test
- public void testRemoveMemberNotCalledBeforeTimeout() {
- System.out.println("testRemoveMemberNotCalledBeforeTimeout starting");
- NetView v = new NetView(mockMembers.get(0), 2, mockMembers, new HashSet<InternalDistributedMember>(), new HashSet<InternalDistributedMember>());
-
- // 3rd is current member
- when(messenger.getMemberID()).thenReturn(mockMembers.get(0)); // coordinator and local member
- when(joinLeave.getMemberID()).thenReturn(mockMembers.get(0)); // coordinator and local member
- gmsHealthMonitor.started();
-
- gmsHealthMonitor.installView(v);
-
- ArrayList<InternalDistributedMember> recipient = new ArrayList<InternalDistributedMember>();
- recipient.add(mockMembers.get(0));
- ArrayList<SuspectRequest> as = new ArrayList<SuspectRequest>();
- SuspectRequest sr = new SuspectRequest(mockMembers.get(1), "Not Responding");// removing member 1
- as.add(sr);
- SuspectMembersMessage sm = new SuspectMembersMessage(recipient, as);
- sm.setSender(mockMembers.get(0));
-
- gmsHealthMonitor.processMessage(sm);
-
- try {
- // this happens after final check, ping timeout
- Thread.sleep(memberTimeout-100);
- } catch (InterruptedException e) {
- }
-
- System.out.println("testRemoveMemberNotCalledBeforeTimeout ending");
- verify(joinLeave, never()).remove(any(InternalDistributedMember.class), any(String.class));
- }
-
- /***
- * Send remove member message after doing final check for coordinator, ping timeout
- * This test trying to remove coordinator
- */
- @Test
- public void testRemoveMemberCalledAfterDoingFinalCheckOnCoordinator() throws Exception {
-
- NetView v = new NetView(mockMembers.get(0), 2, mockMembers, new HashSet<InternalDistributedMember>(), new HashSet<InternalDistributedMember>());
-
- // preferred coordinators are 0 and 1
- when(messenger.getMemberID()).thenReturn(mockMembers.get(1));// next preferred coordinator
- gmsHealthMonitor.started();
-
- gmsHealthMonitor.installView(v);
-
- Thread.sleep(memberTimeout/GMSHealthMonitor.LOGICAL_INTERVAL);
-
- ArrayList<InternalDistributedMember> recipient = new ArrayList<InternalDistributedMember>();
- recipient.add(mockMembers.get(0));
- recipient.add(mockMembers.get(1));
- ArrayList<SuspectRequest> as = new ArrayList<SuspectRequest>();
- SuspectRequest sr = new SuspectRequest(mockMembers.get(0), "Not Responding");// removing coordinator
- as.add(sr);
- SuspectMembersMessage sm = new SuspectMembersMessage(recipient, as);
- sm.setSender(mockMembers.get(4));// member 4 sends suspect message
-
- gmsHealthMonitor.processMessage(sm);
-
- // this happens after final check, ping timeout = 1000 ms
- Thread.sleep(memberTimeout + 200);
-
- verify(joinLeave, atLeastOnce()).remove(any(InternalDistributedMember.class), any(String.class));
- }
-
- /***
- * validates HealthMonitor.CheckIfAvailable api
- */
- @Test
- public void testCheckIfAvailable() {
-
- NetView v = new NetView(mockMembers.get(0), 2, mockMembers, new HashSet<InternalDistributedMember>(), new HashSet<InternalDistributedMember>());
-
- // 3rd is current member
- when(messenger.getMemberID()).thenReturn(mockMembers.get(3));
-
- gmsHealthMonitor.installView(v);
-
- long startTime = System.currentTimeMillis();
-
- boolean retVal = gmsHealthMonitor.checkIfAvailable(mockMembers.get(1), "Not responding", false);
-
- long timeTaken = System.currentTimeMillis() - startTime;
-
- assertTrue("This should have taken member ping timeout 100ms ", timeTaken > 90);
- assertTrue("CheckIfAvailable should have return false", !retVal);
- }
-
- @Test
- public void testShutdown() {
-
- NetView v = new NetView(mockMembers.get(0), 2, mockMembers, new HashSet<InternalDistributedMember>(), new HashSet<InternalDistributedMember>());
-
- // 3rd is current member
- when(messenger.getMemberID()).thenReturn(mockMembers.get(3));
-
- gmsHealthMonitor.installView(v);
-
- gmsHealthMonitor.stop();
-
- try {
- // this happens after final check, membertimeout = 1000
- Thread.sleep(100l);
- } catch (InterruptedException e) {
- }
-
- assertTrue("HeathMonitor should have shutdown", gmsHealthMonitor.isShutdown());
-
- }
-
- private class MethodExecuted implements Answer {
- private boolean methodExecuted = false;
-
- public boolean isMethodExecuted() {
- return methodExecuted;
- }
-
- @Override
- public Object answer(InvocationOnMock invocation) throws Throwable {
- methodExecuted = true;
- return null;
- }
- }
-}
[08/13] incubator-geode git commit: With disable tcp(udp) now we
don't throttle serial executor queue
Posted by kl...@apache.org.
With disable tcp(udp) now we don't throttle serial executor queue
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/fba68678
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/fba68678
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/fba68678
Branch: refs/heads/feature/GEODE-291
Commit: fba68678d268cf6c142d2f9dc275a54c0d6974af
Parents: 74e1364
Author: Hitesh Khamesra <hi...@yahoo.com>
Authored: Fri Dec 4 09:02:17 2015 -0800
Committer: Hitesh Khamesra <hi...@yahoo.com>
Committed: Fri Dec 4 09:05:40 2015 -0800
----------------------------------------------------------------------
.../distributed/internal/DistributionManager.java | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fba68678/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionManager.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionManager.java b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionManager.java
index 5d3bdce..7a9f7c0 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionManager.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionManager.java
@@ -842,7 +842,10 @@ public class DistributionManager
" SERIAL_QUEUE_SIZE_THROTTLE :" + SERIAL_QUEUE_SIZE_THROTTLE
);
}
- this.serialQueuedExecutorPool = new SerialQueuedExecutorPool(this.threadGroup, this.stats);
+ // when TCP/IP is disabled we can't throttle the serial queue or we run the risk of
+ // distributed deadlock when we block the UDP reader thread
+ boolean throttlingDisabled = system.getConfig().getDisableTcp();
+ this.serialQueuedExecutorPool = new SerialQueuedExecutorPool(this.threadGroup, this.stats, throttlingDisabled);
}
{
@@ -4119,14 +4122,17 @@ public class DistributionManager
DistributionStats stats;
ThreadGroup threadGroup;
+ final boolean throttlingDisabled;
+
/**
* Constructor.
* @param group thread group to which the threads will belog to.
* @param stats
*/
- SerialQueuedExecutorPool(ThreadGroup group, DistributionStats stats) {
+ SerialQueuedExecutorPool(ThreadGroup group, DistributionStats stats, boolean throttlingDisabled) {
this.threadGroup = group;
this.stats = stats;
+ this.throttlingDisabled = throttlingDisabled;
}
/*
@@ -4250,7 +4256,7 @@ public class DistributionManager
BlockingQueue poolQueue;
- if (SERIAL_QUEUE_BYTE_LIMIT == 0) {
+ if (SERIAL_QUEUE_BYTE_LIMIT == 0 || this.throttlingDisabled) {
poolQueue = new OverflowQueueWithDMStats(stats.getSerialQueueHelper());
} else {
poolQueue = new ThrottlingMemLinkedQueueWithDMStats(SERIAL_QUEUE_BYTE_LIMIT, SERIAL_QUEUE_THROTTLE, SERIAL_QUEUE_SIZE_LIMIT, SERIAL_QUEUE_SIZE_THROTTLE, this.stats.getSerialQueueHelper());
[05/13] incubator-geode git commit: Fixing a find-bugs issue
Posted by kl...@apache.org.
Fixing a find-bugs issue
GMSJoinLeave had a static variable that should have been final but
was not.
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/e19fa40c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/e19fa40c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/e19fa40c
Branch: refs/heads/feature/GEODE-291
Commit: e19fa40ca5079e0ce6930d60b04245dbfa07d6dd
Parents: ae8c475
Author: Bruce Schuchardt <bs...@pivotal.io>
Authored: Wed Dec 2 10:12:04 2015 -0800
Committer: Bruce Schuchardt <bs...@pivotal.io>
Committed: Wed Dec 2 10:13:08 2015 -0800
----------------------------------------------------------------------
.../internal/membership/gms/membership/GMSJoinLeave.java | 4 ++--
.../distributed/internal/membership/MembershipJUnitTest.java | 4 ++--
gemfire-core/src/test/java/dunit/standalone/DUnitLauncher.java | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e19fa40c/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
index 2f8d734..2f9c514 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
@@ -88,7 +88,7 @@ import com.gemstone.gemfire.security.AuthenticationFailedException;
*/
public class GMSJoinLeave implements JoinLeave, MessageHandler {
- public static String BYPASS_DISCOVERY = "gemfire.bypass-discovery";
+ public static final String BYPASS_DISCOVERY_PROPERTY = "gemfire.bypass-discovery";
/** amount of time to wait for responses to FindCoordinatorRequests */
private static final int DISCOVERY_TIMEOUT = Integer.getInteger("gemfire.discovery-timeout", 3000);
@@ -221,7 +221,7 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
public boolean join() {
try {
- if (Boolean.getBoolean(BYPASS_DISCOVERY)) {
+ if (Boolean.getBoolean(BYPASS_DISCOVERY_PROPERTY)) {
synchronized(viewInstallationLock) {
becomeCoordinator();
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e19fa40c/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/MembershipJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/MembershipJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/MembershipJUnitTest.java
index 91889df..2ce1ca7 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/MembershipJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/MembershipJUnitTest.java
@@ -185,14 +185,14 @@ public class MembershipJUnitTest {
// start the first membership manager
try {
- System.setProperty(GMSJoinLeave.BYPASS_DISCOVERY, "true");
+ System.setProperty(GMSJoinLeave.BYPASS_DISCOVERY_PROPERTY, "true");
DistributedMembershipListener listener1 = mock(DistributedMembershipListener.class);
DMStats stats1 = mock(DMStats.class);
System.out.println("creating 1st membership manager");
m1 = MemberFactory.newMembershipManager(listener1, config, transport, stats1);
m1.startEventProcessing();
} finally {
- System.getProperties().remove(GMSJoinLeave.BYPASS_DISCOVERY);
+ System.getProperties().remove(GMSJoinLeave.BYPASS_DISCOVERY_PROPERTY);
}
// start the second membership manager
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e19fa40c/gemfire-core/src/test/java/dunit/standalone/DUnitLauncher.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/dunit/standalone/DUnitLauncher.java b/gemfire-core/src/test/java/dunit/standalone/DUnitLauncher.java
index ad437c9..f3109f3 100644
--- a/gemfire-core/src/test/java/dunit/standalone/DUnitLauncher.java
+++ b/gemfire-core/src/test/java/dunit/standalone/DUnitLauncher.java
@@ -245,11 +245,11 @@ public class DUnitLauncher {
//Tell the locator it's the first in the system for
//faster boot-up
- System.setProperty(GMSJoinLeave.BYPASS_DISCOVERY, "true");
+ System.setProperty(GMSJoinLeave.BYPASS_DISCOVERY_PROPERTY, "true");
try {
Locator.startLocatorAndDS(locatorPort, locatorLogFile, p);
} finally {
- System.getProperties().remove(GMSJoinLeave.BYPASS_DISCOVERY);
+ System.getProperties().remove(GMSJoinLeave.BYPASS_DISCOVERY_PROPERTY);
}
return null;
[11/13] incubator-geode git commit: GEODE-626: add unit tests for
MemoryChunk
Posted by kl...@apache.org.
GEODE-626: add unit tests for MemoryChunk
Added testGetSize and testCopyBytes.
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/9283282c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/9283282c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/9283282c
Branch: refs/heads/feature/GEODE-291
Commit: 9283282c64076c5f8e599f3d47895f3c48e205e8
Parents: 3259c02
Author: Darrel Schneider <ds...@pivotal.io>
Authored: Fri Dec 4 16:33:50 2015 -0800
Committer: Darrel Schneider <ds...@pivotal.io>
Committed: Fri Dec 4 16:47:24 2015 -0800
----------------------------------------------------------------------
.../offheap/MemoryChunkJUnitTestBase.java | 47 ++++++++++++++++++++
1 file changed, 47 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9283282c/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/MemoryChunkJUnitTestBase.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/MemoryChunkJUnitTestBase.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/MemoryChunkJUnitTestBase.java
index 2e4eabb..c8c0b2b 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/MemoryChunkJUnitTestBase.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/MemoryChunkJUnitTestBase.java
@@ -50,6 +50,53 @@ public abstract class MemoryChunkJUnitTestBase {
}
@Test
+ public void testGetSize() {
+ MemoryChunk mc = createChunk(5);
+ try {
+ assertEquals(5, mc.getSize());
+ } finally {
+ mc.release();
+ }
+ mc = createChunk(0);
+ try {
+ assertEquals(0, mc.getSize());
+ } finally {
+ mc.release();
+ }
+ mc = createChunk(1024);
+ try {
+ assertEquals(1024, mc.getSize());
+ } finally {
+ mc.release();
+ }
+ }
+
+ @Test
+ public void testCopyBytes() {
+ int CHUNK_SIZE = 1024;
+ MemoryChunk mc = createChunk(CHUNK_SIZE*2);
+ try {
+ for (int i=0; i<CHUNK_SIZE; i++) {
+ mc.writeByte(i, (byte)(i%128));
+ }
+ for (int i=0; i<CHUNK_SIZE; i++) {
+ assertEquals(i%128, mc.readByte(i));
+ }
+ mc.copyBytes(0, CHUNK_SIZE, CHUNK_SIZE);
+ for (int i=0; i<CHUNK_SIZE; i++) {
+ assertEquals(i%128, mc.readByte(CHUNK_SIZE+i));
+ }
+ mc.copyBytes(0, 1, CHUNK_SIZE);
+ for (int i=0; i<CHUNK_SIZE; i++) {
+ assertEquals(i%128, mc.readByte(1+i));
+ }
+ } finally {
+ mc.release();
+ }
+ }
+
+
+ @Test
public void testByteArrayReadWrite() {
byte[] writeBytes = new byte[256];
int v = Byte.MIN_VALUE;
[13/13] incubator-geode git commit: Merge remote-tracking branch
'origin/develop' into feature/GEODE-291
Posted by kl...@apache.org.
Merge remote-tracking branch 'origin/develop' into feature/GEODE-291
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/998206b2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/998206b2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/998206b2
Branch: refs/heads/feature/GEODE-291
Commit: 998206b217ac552e0393283372b88f7b76d3abad
Parents: 3884684 dec83b4
Author: Kirk Lund <kl...@pivotal.io>
Authored: Mon Dec 7 09:14:07 2015 -0800
Committer: Kirk Lund <kl...@pivotal.io>
Committed: Mon Dec 7 09:14:07 2015 -0800
----------------------------------------------------------------------
.../internal/DistributionManager.java | 12 +-
.../membership/InternalDistributedMember.java | 16 +-
.../internal/membership/gms/GMSMember.java | 20 +-
.../membership/gms/fd/GMSHealthMonitor.java | 60 +-
.../membership/gms/membership/GMSJoinLeave.java | 29 +-
.../gms/messenger/JGroupsMessenger.java | 2 +-
.../internal/offheap/AbstractStoredObject.java | 107 ++++
.../gemfire/internal/offheap/Chunk.java | 1 -
.../gemfire/internal/offheap/ChunkType.java | 14 +-
.../gemfire/internal/offheap/DataAsAddress.java | 87 +--
.../gemfire/internal/offheap/Fragment.java | 14 +
.../internal/offheap/FreeListManager.java | 14 +
.../gemfire/internal/offheap/GemFireChunk.java | 8 -
.../internal/offheap/MemoryAllocator.java | 2 -
.../internal/offheap/MemoryBlockNode.java | 14 +-
.../internal/offheap/MemoryInspector.java | 6 -
.../offheap/OffHeapCachedDeserializable.java | 85 +--
.../internal/offheap/OffHeapStorage.java | 1 -
.../offheap/SimpleMemoryAllocatorImpl.java | 284 ++++-----
.../internal/offheap/UnsafeMemoryChunk.java | 10 +
.../cli/functions/DataCommandFunction.java | 6 +-
.../membership/MembershipJUnitTest.java | 4 +-
.../membership/gms/GMSMemberJUnitTest.java | 148 +++++
.../gms/fd/GMSHealthMonitorJUnitTest.java | 576 +++++++++++++++++++
.../locator/GMSLocatorRecoveryJUnitTest.java | 4 +-
.../gms/membership/GMSJoinLeaveJUnitTest.java | 180 +++++-
.../fd/GMSHealthMonitorJUnitTest.java | 461 ---------------
.../offheap/MemoryChunkJUnitTestBase.java | 47 ++
.../offheap/NullOffHeapMemoryStats.java | 6 +
.../offheap/NullOutOfOffHeapMemoryListener.java | 6 +
.../offheap/SimpleMemoryAllocatorJUnitTest.java | 369 +++++++++++-
.../functions/DataCommandFunctionJUnitTest.java | 132 +++++
.../java/dunit/standalone/DUnitLauncher.java | 4 +-
.../sanctionedDataSerializables.txt | 10 +-
34 files changed, 1840 insertions(+), 899 deletions(-)
----------------------------------------------------------------------
[09/13] incubator-geode git commit: Added GMSJoinLeave tests
Posted by kl...@apache.org.
Added GMSJoinLeave tests
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/e0bf6858
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/e0bf6858
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/e0bf6858
Branch: refs/heads/feature/GEODE-291
Commit: e0bf6858ab3db9c043853cef32cba0cffc1f1b68
Parents: fba6867
Author: Hitesh Khamesra <hi...@yahoo.com>
Authored: Fri Dec 4 09:04:18 2015 -0800
Committer: Hitesh Khamesra <hi...@yahoo.com>
Committed: Fri Dec 4 09:05:41 2015 -0800
----------------------------------------------------------------------
.../membership/gms/membership/GMSJoinLeave.java | 17 ++-
.../gms/membership/GMSJoinLeaveJUnitTest.java | 149 +++++++++++++++++++
2 files changed, 165 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e0bf6858/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
index 2f9c514..2986238 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeave.java
@@ -1476,12 +1476,24 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
return result;
}
+ /***
+ * test method
+ * @return ViewReplyProcessor
+ */
+ protected ViewReplyProcessor getPrepareViewReplyProcessor() {
+ return prepareProcessor;
+ }
+
+ protected boolean testPrepareProcessorWaiting(){
+ return prepareProcessor.isWaiting();
+ }
+
class ViewReplyProcessor {
volatile int viewId = -1;
final Set<InternalDistributedMember> notRepliedYet = new HashSet<>();
NetView conflictingView;
InternalDistributedMember conflictingViewSender;
- boolean waiting;
+ volatile boolean waiting;
final boolean isPrepareViewProcessor;
final Set<InternalDistributedMember> pendingRemovals = new HashSet<>();
@@ -1498,6 +1510,9 @@ public class GMSJoinLeave implements JoinLeave, MessageHandler {
pendingRemovals.clear();
}
+ boolean isWaiting(){
+ return waiting;
+ }
synchronized void processPendingRequests(Set<InternalDistributedMember> pendingLeaves, Set<InternalDistributedMember> pendingRemovals) {
// there's no point in waiting for members who have already
// requested to leave or who have been declared crashed.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e0bf6858/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java
index e49e4ae..abc7a2f 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/membership/GMSJoinLeaveJUnitTest.java
@@ -41,8 +41,14 @@ import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.junit.experimental.categories.Category;
+import org.mockito.ArgumentCaptor;
+import org.mockito.internal.verification.Times;
+import org.mockito.internal.verification.api.VerificationData;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
+import org.mockito.verification.Timeout;
+import org.mockito.verification.VerificationMode;
+import org.mockito.verification.VerificationWithTimeout;
import com.gemstone.gemfire.distributed.internal.DistributionConfig;
import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember;
@@ -57,13 +63,17 @@ import com.gemstone.gemfire.distributed.internal.membership.gms.interfaces.Manag
import com.gemstone.gemfire.distributed.internal.membership.gms.interfaces.Messenger;
import com.gemstone.gemfire.distributed.internal.membership.gms.locator.FindCoordinatorResponse;
import com.gemstone.gemfire.distributed.internal.membership.gms.membership.GMSJoinLeave.SearchState;
+import com.gemstone.gemfire.distributed.internal.membership.gms.membership.GMSJoinLeave.ViewReplyProcessor;
import com.gemstone.gemfire.distributed.internal.membership.gms.messages.InstallViewMessage;
import com.gemstone.gemfire.distributed.internal.membership.gms.messages.JoinRequestMessage;
import com.gemstone.gemfire.distributed.internal.membership.gms.messages.JoinResponseMessage;
import com.gemstone.gemfire.distributed.internal.membership.gms.messages.LeaveRequestMessage;
+import com.gemstone.gemfire.distributed.internal.membership.gms.messages.NetworkPartitionMessage;
import com.gemstone.gemfire.distributed.internal.membership.gms.messages.RemoveMemberMessage;
import com.gemstone.gemfire.distributed.internal.membership.gms.messages.ViewAckMessage;
import com.gemstone.gemfire.internal.Version;
+import com.gemstone.gemfire.internal.admin.remote.AddStatListenerResponse;
+import com.gemstone.gemfire.internal.admin.remote.StatListenerMessage;
import com.gemstone.gemfire.security.AuthenticationFailedException;
import com.gemstone.gemfire.test.junit.categories.UnitTest;
@@ -793,5 +803,144 @@ public class GMSJoinLeaveJUnitTest {
b.run();
verify(messenger).sendUnreliably(isA(InstallViewMessage.class));
}
+
+ private void installView(int viewId,InternalDistributedMember coordinator, List<InternalDistributedMember> members) throws IOException {
+ Set<InternalDistributedMember> shutdowns = new HashSet<>();
+ Set<InternalDistributedMember> crashes = new HashSet<>();
+
+ when(services.getMessenger()).thenReturn(messenger);
+
+ //prepare the view
+ NetView netView = new NetView(coordinator, viewId, members, shutdowns, crashes);
+ InstallViewMessage installViewMessage = new InstallViewMessage(netView, credentials, false);
+ gmsJoinLeave.processMessage(installViewMessage);
+ // verify(messenger).send(any(ViewAckMessage.class));
+ }
+
+ @Test
+ public void testIgnoreoldView() throws Exception {
+ initMocks(false);
+ installView(3, mockMembers[0], createMemberList(mockMembers[0], mockMembers[1], mockMembers[2], gmsJoinLeaveMemberId, mockMembers[3]));
+ //now try to intall old view..
+ installView(1, mockMembers[0], createMemberList(mockMembers[0], mockMembers[1], mockMembers[2], gmsJoinLeaveMemberId, mockMembers[3]));
+
+ assertFalse("Expected view id is 3 but found " + gmsJoinLeave.getView().getViewId(), gmsJoinLeave.getView().getViewId() == 1);
+ }
+
+ @Test
+ public void testClearViewRequests() throws Exception {
+ try {
+ initMocks(false);
+ System.setProperty(GMSJoinLeave.BYPASS_DISCOVERY_PROPERTY, "true");
+ gmsJoinLeave.join();
+ gmsJoinLeave.processMessage(new JoinRequestMessage(mockMembers[0], mockMembers[0], credentials, -1));
+ int viewRequests = gmsJoinLeave.getViewRequests().size();
+
+ assertTrue( "There should be 1 viewRequest but found " + viewRequests, viewRequests == 1);
+ Thread.sleep(2 * GMSJoinLeave.MEMBER_REQUEST_COLLECTION_INTERVAL);
+
+ viewRequests = gmsJoinLeave.getViewRequests().size();
+ assertTrue( "There should be 0 viewRequest but found " + viewRequests, viewRequests == 0);
+ }finally {
+ System.getProperties().remove(GMSJoinLeave.BYPASS_DISCOVERY_PROPERTY);
+ }
+ }
+
+ /***
+ * validating ViewReplyProcessor's memberSuspected,
+ * processLeaveRequest, processRemoveRequest, processViewResponse method
+ */
+ @Test
+ public void testViewReplyProcessor() throws Exception {
+ try {
+ initMocks(false);
+ System.setProperty(GMSJoinLeave.BYPASS_DISCOVERY_PROPERTY, "true");
+ gmsJoinLeave.join();
+ Set<InternalDistributedMember> recips = new HashSet<>();
+ recips.add(mockMembers[0]);
+ recips.add(mockMembers[1]);
+ recips.add(mockMembers[2]);
+ recips.add(mockMembers[3]);
+ ViewReplyProcessor prepareProcessor = gmsJoinLeave.getPrepareViewReplyProcessor();
+ prepareProcessor.initialize( 1, recips);
+ assertTrue("Prepare processor should be waiting ", gmsJoinLeave.testPrepareProcessorWaiting());
+
+ prepareProcessor.memberSuspected(gmsJoinLeaveMemberId, mockMembers[0]);
+ prepareProcessor.processLeaveRequest(mockMembers[1]);
+ prepareProcessor.processRemoveRequest(mockMembers[2]);
+ prepareProcessor.processViewResponse(1, mockMembers[3], null);
+
+ assertFalse("Prepare processor should not be waiting ", gmsJoinLeave.testPrepareProcessorWaiting());
+ }finally {
+ System.getProperties().remove(GMSJoinLeave.BYPASS_DISCOVERY_PROPERTY);
+ }
+ }
+
+ /***
+ * validating ViewReplyProcessor's processPendingRequests method
+ */
+ @Test
+ public void testViewReplyProcessor2() throws Exception {
+ try {
+ initMocks(false);
+ System.setProperty(GMSJoinLeave.BYPASS_DISCOVERY_PROPERTY, "true");
+ gmsJoinLeave.join();
+ Set<InternalDistributedMember> recips = new HashSet<>();
+ recips.add(mockMembers[0]);
+ recips.add(mockMembers[1]);
+ recips.add(mockMembers[2]);
+ recips.add(mockMembers[3]);
+ ViewReplyProcessor prepareProcessor = gmsJoinLeave.getPrepareViewReplyProcessor();
+ prepareProcessor.initialize(1, recips);
+ assertTrue("Prepare processor should be waiting ", gmsJoinLeave.testPrepareProcessorWaiting());
+ Set<InternalDistributedMember> pendingLeaves = new HashSet<>();
+ pendingLeaves.add(mockMembers[0]);
+ Set<InternalDistributedMember> pendingRemovals = new HashSet<>();
+ pendingRemovals.add(mockMembers[1]);
+
+ prepareProcessor.processPendingRequests(pendingLeaves, pendingRemovals);
+
+ prepareProcessor.processViewResponse(1, mockMembers[2], null);
+ prepareProcessor.processViewResponse(1, mockMembers[3], null);
+
+ assertFalse("Prepare processor should not be waiting ", gmsJoinLeave.testPrepareProcessorWaiting());
+ }finally {
+ System.getProperties().remove(GMSJoinLeave.BYPASS_DISCOVERY_PROPERTY);
+ }
+ }
+
+ @Test
+ public void testJoinResponseMsgWithBecomeCoordinator() throws Exception {
+ initMocks(false);
+ gmsJoinLeaveMemberId.getNetMember().setPreferredForCoordinator(false);
+ JoinRequestMessage reqMsg = new JoinRequestMessage(gmsJoinLeaveMemberId, mockMembers[0], null, 56734);
+ InternalDistributedMember ids = new InternalDistributedMember("localhost", 97898);
+ ids.getNetMember().setPreferredForCoordinator(true);
+ gmsJoinLeave.processMessage(reqMsg);
+ ArgumentCaptor<JoinResponseMessage> ac = new ArgumentCaptor<>();
+ verify(messenger).send(ac.capture());
+
+ assertTrue("Should have asked for becoming a coordinator", ac.getValue().getBecomeCoordinator());
+ }
+
+ @Test
+ public void testNetworkPartionMessage() throws Exception {
+ try {
+ initMocks(true);
+ System.setProperty(GMSJoinLeave.BYPASS_DISCOVERY_PROPERTY, "true");
+ gmsJoinLeave.join();
+ installView(1, gmsJoinLeaveMemberId, createMemberList(mockMembers[0], mockMembers[1], mockMembers[2], gmsJoinLeaveMemberId, mockMembers[3]));
+ for(int i = 1; i < 4; i++) {
+ RemoveMemberMessage msg = new RemoveMemberMessage(gmsJoinLeaveMemberId, mockMembers[i], "crashed");
+ msg.setSender(gmsJoinLeaveMemberId);
+ gmsJoinLeave.processMessage(msg);
+ }
+ Timeout to = new Timeout(2 * GMSJoinLeave.MEMBER_REQUEST_COLLECTION_INTERVAL, new Times(1));
+ verify(messenger, to).send( isA(NetworkPartitionMessage.class));
+
+ }finally {
+ System.getProperties().remove(GMSJoinLeave.BYPASS_DISCOVERY_PROPERTY);
+ }
+ }
}
[12/13] incubator-geode git commit: fixing merge error from 38dd3ed
that caused this test to start failing again
Posted by kl...@apache.org.
fixing merge error from 38dd3ed that caused this test to start failing again
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/dec83b4e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/dec83b4e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/dec83b4e
Branch: refs/heads/feature/GEODE-291
Commit: dec83b4ebcc75a9425101985f34d2b9afe650f0d
Parents: 9283282
Author: Bruce Schuchardt <bs...@pivotal.io>
Authored: Mon Dec 7 08:43:12 2015 -0800
Committer: Bruce Schuchardt <bs...@pivotal.io>
Committed: Mon Dec 7 08:43:12 2015 -0800
----------------------------------------------------------------------
.../membership/gms/locator/GMSLocatorRecoveryJUnitTest.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/dec83b4e/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/GMSLocatorRecoveryJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/GMSLocatorRecoveryJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/GMSLocatorRecoveryJUnitTest.java
index 7badce6..2d042fc 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/GMSLocatorRecoveryJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/GMSLocatorRecoveryJUnitTest.java
@@ -152,8 +152,8 @@ public class GMSLocatorRecoveryJUnitTest {
nonDefault.put(DistributionConfig.MCAST_PORT_NAME, "0");
nonDefault.put(DistributionConfig.LOG_FILE_NAME, "");
nonDefault.put(DistributionConfig.LOG_LEVEL_NAME, "fine");
- nonDefault.put(DistributionConfig.LOCATORS_NAME, localHost.getHostName()+'['+port+']');
- nonDefault.put(DistributionConfig.BIND_ADDRESS_NAME, localHost.getHostName());
+ nonDefault.put(DistributionConfig.LOCATORS_NAME, localHost.getHostAddress()+'['+port+']');
+ nonDefault.put(DistributionConfig.BIND_ADDRESS_NAME, localHost.getHostAddress());
DistributionConfigImpl config = new DistributionConfigImpl(nonDefault);
RemoteTransportConfig transport = new RemoteTransportConfig(config,
DistributionManager.NORMAL_DM_TYPE);
[03/13] incubator-geode git commit: GEODE-621: failure in
AnalyzeSerializablesJUnitTest
Posted by kl...@apache.org.
GEODE-621: failure in AnalyzeSerializablesJUnitTest
fixed the entry for StartupMessage
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/b7030d1c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/b7030d1c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/b7030d1c
Branch: refs/heads/feature/GEODE-291
Commit: b7030d1cd7bf5461889a8a2a0eb400796021c307
Parents: dce479e
Author: Bruce Schuchardt <bs...@pivotal.io>
Authored: Tue Dec 1 16:55:36 2015 -0800
Committer: Bruce Schuchardt <bs...@pivotal.io>
Committed: Tue Dec 1 16:58:03 2015 -0800
----------------------------------------------------------------------
.../gemfire/codeAnalysis/sanctionedDataSerializables.txt | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b7030d1c/gemfire-core/src/test/resources/com/gemstone/gemfire/codeAnalysis/sanctionedDataSerializables.txt
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/resources/com/gemstone/gemfire/codeAnalysis/sanctionedDataSerializables.txt b/gemfire-core/src/test/resources/com/gemstone/gemfire/codeAnalysis/sanctionedDataSerializables.txt
index 137850f..af0ee36 100644
--- a/gemfire-core/src/test/resources/com/gemstone/gemfire/codeAnalysis/sanctionedDataSerializables.txt
+++ b/gemfire-core/src/test/resources/com/gemstone/gemfire/codeAnalysis/sanctionedDataSerializables.txt
@@ -243,9 +243,9 @@ fromData,27,2a2bb7000c2a2bb9000d0100b500032a2bb8000ec0000fb50002b1
toData,24,2a2bb700092b2ab40003b9000a02002ab400022bb8000bb1
com/gemstone/gemfire/distributed/internal/StartupMessage,3
-fromDataProblem,38,2ab4003ac7000e2abb006d59b7006eb5003a2ab4003a2bb6006f572ab4003a1270b6006f57b1
-fromData,354,2a2bb700712bb9007201003d1c99000e2a2bb80073b5000ca700082a01b5000c2bb80074b20051b600529c000704a70004033e1d9900082bb80075572a2bb80076b500092a2bb900770100b5000d2a2bb900720100b5000e2a2bb900720100b500122bb900770100360403360515051504a2003e2bb800783a062bb90077010036071906c6000d19060301011507b80079a700183a082ab2007a04bd00235903190853b60027b7007b840501a7ffc12bb900770100360503360615061505a200492bb800783a072bb800783a082bb90077010036091907c600121908c6000d19071908150903b8007ca700183a0a2ab2007d04bd00235903190a53b60027b7007b840601a7ffb62a2bb80075c0007eb500132a2bb900770100b500182a2bb80076b500192a2bb900720100b5001abb006659b700673a0619062bb6007f2a1906b60080b5000a2a1906b60081b5000b2a1906b60082b5000f2a1906b60083b50010b1
-toData,399,2a2bb7004d2b2ab4000cc6000704a7000403b9004e02002ab4000cc6000b2ab4000c2bb8004f2bb80050b20051b600529c000704a70004033d1c99000ebb005359b700542bb800552ab400092bb800562b2ab4000db9005702002b2ab4000eb9004e02002b2ab40012b9004e0200b800584e2b2dbeb90057020003360415042dbea200212d150432b600592bb8005a2b2d150432b6005bb900570200840401a7ffdeb8005c3a042b1904beb90057020003360515051904bea2007f1904150532c1005d9900331904150532c0005db6005eb6005f3a061904150532c0005db60060b6005f3a071904150532c0005db600613608a7002a1904150532c00062b600633a061904150532c00062b600643a071904150532c00062b60065360819062bb8005a19072bb8005a2b1508b900570200840501a7ff7f2ab400132bb800552b2ab40018b9005702002ab400192bb800562b2ab4001ab9004e0200bb006659b700673a0519052ab4000ab6006819052ab4000bb6006919052ab4000fb6006a19052ab40010b6006b19052bb6006cb1
+fromDataProblem,38,2ab40039c7000e2abb006b59b7006cb500392ab400392bb6006d572ab40039126eb6006d57b1
+fromData,325,2a2bb7006f2bb80070b2004eb6004f9c000704a70004033d1c9900082bb80071572a2bb80072b500092a2bb900730100b5000c2a2bb900740100b5000d2a2bb900740100b500112bb9007301003e03360415041da2003e2bb800753a052bb90073010036061905c6000d19050301011506b80076a700183a072ab2007704bd00225903190753b60026b70078840401a7ffc22bb900730100360403360515051504a200492bb800753a062bb800753a072bb90073010036081906c600121907c6000d19061907150803b80079a700183a092ab2007a04bd00225903190953b60026b70078840501a7ffb62a2bb80071c0007bb500122a2bb900730100b500172a2bb80072b500182a2bb900740100b50019bb006459b700653a0519052bb6007c2a1905b6007db5000a2a1905b6007eb5000b2a1905b6007fb5000e2a1905b60080b5000fb1
+toData,366,2a2bb7004c2bb8004db2004eb6004f9c000704a70004033d1c99000ebb005059b700512bb800522ab400092bb800532b2ab4000cb9005402002b2ab4000db9005502002b2ab40011b900550200b800564e2b2dbeb90054020003360415042dbea200212d150432b600572bb800582b2d150432b60059b900540200840401a7ffdeb8005a3a042b1904beb90054020003360515051904bea2007f1904150532c1005b9900331904150532c0005bb6005cb6005d3a061904150532c0005bb6005eb6005d3a071904150532c0005bb6005f3608a7002a1904150532c00060b600613a061904150532c00060b600623a071904150532c00060b60063360819062bb8005819072bb800582b1508b900540200840501a7ff7f2ab400122bb800522b2ab40017b9005402002ab400182bb800532b2ab40019b900550200bb006459b700653a0519052ab4000ab6006619052ab4000bb6006719052ab4000eb6006819052ab4000fb6006919052bb6006ab1
com/gemstone/gemfire/distributed/internal/StartupResponseMessage,3
fromDataProblem,43,2ab40026c7000e2abb003959b7003ab500262ab400262bb6003b572ab40026123c123db8003eb6003b57b1
[04/13] incubator-geode git commit: GEODE-621: Added
BucketCountLoadProbe to sanctionedDataSerializables
Posted by kl...@apache.org.
GEODE-621: Added BucketCountLoadProbe to sanctionedDataSerializables
Fixing a failing in AnalyzeSerializables due to the changes for
GEODE-581
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/ae8c475d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/ae8c475d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/ae8c475d
Branch: refs/heads/feature/GEODE-291
Commit: ae8c475de698e87305092aa711be953ee2daafb0
Parents: b7030d1
Author: Dan Smith <up...@apache.org>
Authored: Wed Dec 2 10:07:33 2015 -0800
Committer: Dan Smith <up...@apache.org>
Committed: Wed Dec 2 10:07:33 2015 -0800
----------------------------------------------------------------------
.../gemfire/codeAnalysis/sanctionedDataSerializables.txt | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ae8c475d/gemfire-core/src/test/resources/com/gemstone/gemfire/codeAnalysis/sanctionedDataSerializables.txt
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/resources/com/gemstone/gemfire/codeAnalysis/sanctionedDataSerializables.txt b/gemfire-core/src/test/resources/com/gemstone/gemfire/codeAnalysis/sanctionedDataSerializables.txt
index af0ee36..d553ad9 100644
--- a/gemfire-core/src/test/resources/com/gemstone/gemfire/codeAnalysis/sanctionedDataSerializables.txt
+++ b/gemfire-core/src/test/resources/com/gemstone/gemfire/codeAnalysis/sanctionedDataSerializables.txt
@@ -1569,6 +1569,10 @@ com/gemstone/gemfire/internal/cache/partitioned/BucketBackupMessage,2
fromData,16,2a2bb7001d2a2bb9001e0100b50003b1
toData,16,2a2bb7001f2b2ab40003b900200200b1
+com/gemstone/gemfire/internal/cache/partitioned/BucketCountLoadProbe,2
+fromData,1,b1
+toData,1,b1
+
com/gemstone/gemfire/internal/cache/partitioned/BucketProfileUpdateMessage,2
fromData,47,2a2bb700232a2bb900240100b500052a2bb900240100b500062a2bb900240100b500022a2bb80025c00026b50007b1
toData,44,2a2bb700272b2ab40005b9002802002b2ab40006b9002802002b2ab40002b9002802002ab400072bb80029b1