You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by as...@apache.org on 2015/07/27 21:17:33 UTC
[1/2] incubator-geode git commit: GEODE-124: Address review comments
Repository: incubator-geode
Updated Branches:
refs/heads/feature/GEODE-124 dad71e90f -> d307eda92
GEODE-124: Address review comments
* Fix spelling mistakes
* Add more details in logs
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/a0ada760
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/a0ada760
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/a0ada760
Branch: refs/heads/feature/GEODE-124
Commit: a0ada7603d2447c7b70d791a8ae1fa75a4bd413f
Parents: dad71e9
Author: Ashvin Agrawal <as...@apache.org>
Authored: Fri Jul 24 14:44:31 2015 -0700
Committer: Ashvin Agrawal <as...@apache.org>
Committed: Fri Jul 24 15:10:03 2015 -0700
----------------------------------------------------------------------
.../gemfire/cache/util/AutoBalancer.java | 24 +++++++++++---------
1 file changed, 13 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a0ada760/gemfire-rebalancer/src/main/java/com/gemstone/gemfire/cache/util/AutoBalancer.java
----------------------------------------------------------------------
diff --git a/gemfire-rebalancer/src/main/java/com/gemstone/gemfire/cache/util/AutoBalancer.java b/gemfire-rebalancer/src/main/java/com/gemstone/gemfire/cache/util/AutoBalancer.java
index 19c028f..decbd89 100644
--- a/gemfire-rebalancer/src/main/java/com/gemstone/gemfire/cache/util/AutoBalancer.java
+++ b/gemfire-rebalancer/src/main/java/com/gemstone/gemfire/cache/util/AutoBalancer.java
@@ -101,7 +101,7 @@ public class AutoBalancer implements Declarable {
@Override
public void init(Properties props) {
if (logger.isDebugEnabled()) {
- logger.debug("Initiazing " + this.getClass().getSimpleName() + " with " + props);
+ logger.debug("Initializing " + this.getClass().getSimpleName() + " with " + props);
}
auditor.init(props);
@@ -140,7 +140,7 @@ public class AutoBalancer implements Declarable {
@Override
public void init(String schedule) {
if (logger.isDebugEnabled()) {
- logger.debug("Initiazing " + this.getClass().getSimpleName() + " with " + schedule);
+ logger.debug("Initializing " + this.getClass().getSimpleName() + " with " + schedule);
}
if (schedule == null || schedule.isEmpty()) {
@@ -192,7 +192,7 @@ public class AutoBalancer implements Declarable {
@Override
public void init(Properties props) {
if (logger.isDebugEnabled()) {
- logger.debug("Initiazing " + this.getClass().getSimpleName());
+ logger.debug("Initializing " + this.getClass().getSimpleName());
}
if (props != null) {
@@ -303,7 +303,7 @@ public class AutoBalancer implements Declarable {
try {
cache.getResourceManager().getStats().incAutoRebalanceAttempts();
} catch (Exception e) {
- logger.warn("Failed ot increment AutoBalanceAttempts counter");
+ logger.warn("Failed to increment AutoBalanceAttempts counter");
}
}
@@ -312,12 +312,14 @@ public class AutoBalancer implements Declarable {
try {
RebalanceOperation operation = getCache().getResourceManager().createRebalanceFactory().start();
RebalanceResults result = operation.getResults();
- logger.info("Rebalance result: RebalanceResultsImpl [TotalBucketCreateBytes="
- + result.getTotalBucketCreateBytes() + ", TotalBucketCreatesCompleted="
+ logger.info("Rebalance result: [TotalBucketCreateBytes=" + result.getTotalBucketCreateBytes()
+ + ", TotalBucketCreateTime=" + result.getTotalBucketCreateTime() + ", TotalBucketCreatesCompleted="
+ result.getTotalBucketCreatesCompleted() + ", TotalBucketTransferBytes="
- + result.getTotalBucketTransferBytes() + ", TotalBucketTransfersCompleted="
- + result.getTotalBucketTransfersCompleted() + ", TotalPrimaryTransfersCompleted="
- + result.getTotalPrimaryTransfersCompleted() + "]");
+ + result.getTotalBucketTransferBytes() + ", TotalBucketTransferTime=" + result.getTotalBucketTransferTime()
+ + ", TotalBucketTransfersCompleted=" + +result.getTotalBucketTransfersCompleted()
+ + ", TotalPrimaryTransferTime=" + result.getTotalPrimaryTransferTime()
+ + ", TotalPrimaryTransfersCompleted=" + result.getTotalPrimaryTransfersCompleted() + ", TotalTime="
+ + result.getTotalTime() + "]");
} catch (CancellationException e) {
logger.info("Error rebalancing the cluster", e);
} catch (InterruptedException e) {
@@ -338,7 +340,7 @@ public class AutoBalancer implements Declarable {
boolean result = dls.lock(AUTO_BALANCER_LOCK, 0, -1);
if (logger.isDebugEnabled()) {
- logger.debug("Grabed AutoBalancer lock? " + result);
+ logger.debug("Grabbed AutoBalancer lock? " + result);
}
return result;
}
@@ -347,7 +349,7 @@ public class AutoBalancer implements Declarable {
DistributedLockService dls = getDLS();
dls.unlock(AUTO_BALANCER_LOCK);
if (logger.isDebugEnabled()) {
- logger.debug("Successfully release auto-balance ownership");
+ logger.debug("Successfully released auto-balance ownership");
}
}
[2/2] incubator-geode git commit: GEODE-124: Add logic to compute
getTotalSize
Posted by as...@apache.org.
GEODE-124: Add logic to compute getTotalSize
getTotalSize collects current size of a partitioned region on all members. The
sum of these sizes is used to check if rebalance is needed.
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/d307eda9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/d307eda9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/d307eda9
Branch: refs/heads/feature/GEODE-124
Commit: d307eda9253e9d8929806f5421ef12059eed71eb
Parents: a0ada76
Author: Ashvin Agrawal <as...@apache.org>
Authored: Mon Jul 27 10:02:24 2015 -0700
Committer: Ashvin Agrawal <as...@apache.org>
Committed: Mon Jul 27 10:02:24 2015 -0700
----------------------------------------------------------------------
.../gemfire/cache/util/AutoBalancer.java | 21 +++-
.../cache/util/AutoBalancerJUnitTest.java | 103 ++++++++++++++++++-
2 files changed, 117 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d307eda9/gemfire-rebalancer/src/main/java/com/gemstone/gemfire/cache/util/AutoBalancer.java
----------------------------------------------------------------------
diff --git a/gemfire-rebalancer/src/main/java/com/gemstone/gemfire/cache/util/AutoBalancer.java b/gemfire-rebalancer/src/main/java/com/gemstone/gemfire/cache/util/AutoBalancer.java
index decbd89..1de7031 100644
--- a/gemfire-rebalancer/src/main/java/com/gemstone/gemfire/cache/util/AutoBalancer.java
+++ b/gemfire-rebalancer/src/main/java/com/gemstone/gemfire/cache/util/AutoBalancer.java
@@ -2,6 +2,7 @@ package com.gemstone.gemfire.cache.util;
import java.util.Date;
import java.util.Properties;
+import java.util.Set;
import java.util.concurrent.CancellationException;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
@@ -17,9 +18,13 @@ import com.gemstone.gemfire.cache.Declarable;
import com.gemstone.gemfire.cache.GemFireCache;
import com.gemstone.gemfire.cache.control.RebalanceOperation;
import com.gemstone.gemfire.cache.control.RebalanceResults;
+import com.gemstone.gemfire.cache.partition.PartitionMemberInfo;
import com.gemstone.gemfire.distributed.DistributedLockService;
import com.gemstone.gemfire.distributed.internal.locks.DLockService;
import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
+import com.gemstone.gemfire.internal.cache.PartitionedRegion;
+import com.gemstone.gemfire.internal.cache.partitioned.InternalPRInfo;
+import com.gemstone.gemfire.internal.cache.partitioned.LoadProbe;
import com.gemstone.gemfire.internal.logging.LogService;
/**
@@ -271,8 +276,20 @@ public class AutoBalancer implements Declarable {
static class GeodeCacheFacade implements CacheOperationFacade {
@Override
public long getTotalDataSize() {
- // TODO Auto-generated method stub
- return getTotalTransferSize();
+ long totalSize = 0;
+ GemFireCacheImpl cache = getCache();
+ for (PartitionedRegion region : cache.getPartitionedRegions()) {
+ LoadProbe probe = cache.getResourceManager().getLoadProbe();
+ InternalPRInfo info = region.getRedundancyProvider().buildPartitionedRegionInfo(true, probe);
+ Set<PartitionMemberInfo> membersInfo = info.getPartitionMemberInfo();
+ for (PartitionMemberInfo member : membersInfo) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Region:{}, Member: {}, Size: {}", region.getFullPath(), member, member.getSize());
+ }
+ totalSize += member.getSize();
+ }
+ }
+ return totalSize;
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d307eda9/gemfire-rebalancer/src/test/java/com/gemstone/gemfire/cache/util/AutoBalancerJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-rebalancer/src/test/java/com/gemstone/gemfire/cache/util/AutoBalancerJUnitTest.java b/gemfire-rebalancer/src/test/java/com/gemstone/gemfire/cache/util/AutoBalancerJUnitTest.java
index 90ddbc3..888ea20 100644
--- a/gemfire-rebalancer/src/test/java/com/gemstone/gemfire/cache/util/AutoBalancerJUnitTest.java
+++ b/gemfire-rebalancer/src/test/java/com/gemstone/gemfire/cache/util/AutoBalancerJUnitTest.java
@@ -6,6 +6,7 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.ByteArrayInputStream;
+import java.util.HashSet;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -27,6 +28,7 @@ import com.gemstone.gemfire.cache.CacheFactory;
import com.gemstone.gemfire.cache.control.RebalanceFactory;
import com.gemstone.gemfire.cache.control.RebalanceOperation;
import com.gemstone.gemfire.cache.control.RebalanceResults;
+import com.gemstone.gemfire.cache.partition.PartitionMemberInfo;
import com.gemstone.gemfire.cache.util.AutoBalancer.AuditScheduler;
import com.gemstone.gemfire.cache.util.AutoBalancer.CacheOperationFacade;
import com.gemstone.gemfire.cache.util.AutoBalancer.GeodeCacheFacade;
@@ -36,7 +38,11 @@ import com.gemstone.gemfire.cache.util.AutoBalancer.TimeProvider;
import com.gemstone.gemfire.distributed.DistributedLockService;
import com.gemstone.gemfire.distributed.internal.locks.DLockService;
import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
+import com.gemstone.gemfire.internal.cache.PRHARedundancyProvider;
+import com.gemstone.gemfire.internal.cache.PartitionedRegion;
import com.gemstone.gemfire.internal.cache.control.InternalResourceManager;
+import com.gemstone.gemfire.internal.cache.partitioned.InternalPRInfo;
+import com.gemstone.gemfire.internal.cache.partitioned.LoadProbe;
import com.gemstone.gemfire.test.junit.categories.UnitTest;
@Category(UnitTest.class)
@@ -570,7 +576,7 @@ public class AutoBalancerJUnitTest {
public void testFacadeTotalTransferSize() throws Exception {
assertEquals(12345, getFacadeForResourceManagerOps(true).getTotalTransferSize());
}
-
+
@Test
public void testFacadeRebalance() throws Exception {
getFacadeForResourceManagerOps(false).rebalance();
@@ -582,7 +588,7 @@ public class AutoBalancerJUnitTest {
final RebalanceFactory mockRebalanceFactory = mockContext.mock(RebalanceFactory.class);
final RebalanceOperation mockRebalanceOperation = mockContext.mock(RebalanceOperation.class);
final RebalanceResults mockRebalanceResults = mockContext.mock(RebalanceResults.class);
-
+
mockContext.checking(new Expectations() {
{
oneOf(mockCache).getResourceManager();
@@ -604,17 +610,104 @@ public class AutoBalancerJUnitTest {
allowing(mockRebalanceResults);
}
});
-
+
GeodeCacheFacade facade = new GeodeCacheFacade() {
@Override
GemFireCacheImpl getCache() {
return mockCache;
}
};
-
+
return facade;
}
-
+
+ @Test
+ public void testFacadeTotalBytesNoRegion() {
+ final GemFireCacheImpl mockCache = mockContext.mock(GemFireCacheImpl.class);
+ mockContext.checking(new Expectations() {
+ {
+ oneOf(mockCache).getPartitionedRegions();
+ will(returnValue(new HashSet<PartitionedRegion>()));
+ }
+ });
+
+ GeodeCacheFacade facade = new GeodeCacheFacade() {
+ @Override
+ GemFireCacheImpl getCache() {
+ return mockCache;
+ }
+ };
+
+ assertEquals(0, facade.getTotalDataSize());
+ }
+
+ @Test
+ public void testFacadeTotalBytes2Regions() {
+ cache = createBasicCache();
+
+ final GemFireCacheImpl mockCache = mockContext.mock(GemFireCacheImpl.class);
+
+ final PartitionedRegion mockR1 = mockContext.mock(PartitionedRegion.class, "r1");
+ final PartitionedRegion mockR2 = mockContext.mock(PartitionedRegion.class, "r2");
+ final HashSet<PartitionedRegion> regions = new HashSet<>();
+ regions.add(mockR1);
+ regions.add(mockR2);
+
+ final PRHARedundancyProvider mockRedundancyProviderR1 = mockContext.mock(PRHARedundancyProvider.class, "prhaR1");
+ final InternalPRInfo mockR1PRInfo = mockContext.mock(InternalPRInfo.class, "prInforR1");
+ final PartitionMemberInfo mockR1M1Info = mockContext.mock(PartitionMemberInfo.class, "r1M1");
+ final PartitionMemberInfo mockR1M2Info = mockContext.mock(PartitionMemberInfo.class, "r1M2");
+ final HashSet<PartitionMemberInfo> r1Members = new HashSet<>();
+ r1Members.add(mockR1M1Info);
+ r1Members.add(mockR1M2Info);
+
+ final PRHARedundancyProvider mockRedundancyProviderR2 = mockContext.mock(PRHARedundancyProvider.class, "prhaR2");
+ final InternalPRInfo mockR2PRInfo = mockContext.mock(InternalPRInfo.class, "prInforR2");
+ final PartitionMemberInfo mockR2M1Info = mockContext.mock(PartitionMemberInfo.class, "r2M1");
+ final HashSet<PartitionMemberInfo> r2Members = new HashSet<>();
+ r2Members.add(mockR2M1Info);
+
+ mockContext.checking(new Expectations() {
+ {
+ oneOf(mockCache).getPartitionedRegions();
+ will(returnValue(regions));
+ exactly(2).of(mockCache).getResourceManager();
+ will(returnValue(cache.getResourceManager()));
+ allowing(mockR1).getFullPath();
+ oneOf(mockR1).getRedundancyProvider();
+ will(returnValue(mockRedundancyProviderR1));
+ allowing(mockR2).getFullPath();
+ oneOf(mockR2).getRedundancyProvider();
+ will(returnValue(mockRedundancyProviderR2));
+
+ oneOf(mockRedundancyProviderR1).buildPartitionedRegionInfo(with(true), with(any(LoadProbe.class)));
+ will(returnValue(mockR1PRInfo));
+ oneOf(mockR1PRInfo).getPartitionMemberInfo();
+ will(returnValue(r1Members));
+ atLeast(1).of(mockR1M1Info).getSize();
+ will(returnValue(123L));
+ atLeast(1).of(mockR1M2Info).getSize();
+ will(returnValue(74L));
+
+ oneOf(mockRedundancyProviderR2).buildPartitionedRegionInfo(with(true), with(any(LoadProbe.class)));
+ will(returnValue(mockR2PRInfo));
+ oneOf(mockR2PRInfo).getPartitionMemberInfo();
+ will(returnValue(r2Members));
+ atLeast(1).of(mockR2M1Info).getSize();
+ will(returnValue(3475L));
+ }
+ });
+
+ GeodeCacheFacade facade = new GeodeCacheFacade() {
+ @Override
+ GemFireCacheImpl getCache() {
+ return mockCache;
+ }
+ };
+
+ assertEquals(123 + 74 + 3475, facade.getTotalDataSize());
+ }
+
private Properties getBasicConfig() {
Properties props = new Properties();
// every second schedule