use of org.apache.geode.cache.util.AutoBalancer.SizeBasedOOBAuditor in project geode by apache.
the class AutoBalancerJUnitTest method testOOBAuditorInit.
@Test
public void testOOBAuditorInit() {
AutoBalancer balancer = new AutoBalancer();
balancer.init(getBasicConfig());
SizeBasedOOBAuditor auditor = (SizeBasedOOBAuditor) balancer.getOOBAuditor();
assertEquals(AutoBalancer.DEFAULT_SIZE_THRESHOLD_PERCENT, auditor.getSizeThreshold());
assertEquals(AutoBalancer.DEFAULT_MINIMUM_SIZE, auditor.getSizeMinimum());
Properties props = getBasicConfig();
props.put(AutoBalancer.SIZE_THRESHOLD_PERCENT, "17");
props.put(AutoBalancer.MINIMUM_SIZE, "10");
balancer = new AutoBalancer();
balancer.init(props);
auditor = (SizeBasedOOBAuditor) balancer.getOOBAuditor();
assertEquals(17, auditor.getSizeThreshold());
assertEquals(10, auditor.getSizeMinimum());
}
use of org.apache.geode.cache.util.AutoBalancer.SizeBasedOOBAuditor in project geode by apache.
the class AutoBalancerJUnitTest method testOOBWhenAboveThresholdButBelowMin.
@Test
public void testOOBWhenAboveThresholdButBelowMin() {
final long totalSize = 1000L;
mockContext.checking(new Expectations() {
{
// first run
oneOf(mockCacheFacade).getTotalTransferSize();
// twice threshold
will(returnValue((AutoBalancer.DEFAULT_SIZE_THRESHOLD_PERCENT * totalSize / 100) * 2));
// second run
oneOf(mockCacheFacade).getTotalTransferSize();
// more than total size
will(returnValue(2 * totalSize));
}
});
AutoBalancer balancer = new AutoBalancer(null, null, null, mockCacheFacade);
Properties config = getBasicConfig();
config.put(AutoBalancer.MINIMUM_SIZE, "" + (totalSize * 5));
balancer.init(config);
SizeBasedOOBAuditor auditor = (SizeBasedOOBAuditor) balancer.getOOBAuditor();
// first run
assertFalse(auditor.needsRebalancing());
// second run
assertFalse(auditor.needsRebalancing());
}
use of org.apache.geode.cache.util.AutoBalancer.SizeBasedOOBAuditor in project geode by apache.
the class AutoBalancerJUnitTest method testOOBWhenBelowSizeThreshold.
@Test
public void testOOBWhenBelowSizeThreshold() {
final long totalSize = 1000L;
final Map<PartitionedRegion, InternalPRInfo> details = new HashMap<>();
mockContext.checking(new Expectations() {
{
allowing(mockCacheFacade).getRegionMemberDetails();
will(returnValue(details));
// first run
oneOf(mockCacheFacade).getTotalDataSize(details);
will(returnValue(totalSize));
oneOf(mockCacheFacade).getTotalTransferSize();
// half of threshold limit
will(returnValue((AutoBalancer.DEFAULT_SIZE_THRESHOLD_PERCENT * totalSize / 100) / 2));
// second run
oneOf(mockCacheFacade).getTotalTransferSize();
// nothing to transfer
will(returnValue(0L));
}
});
AutoBalancer balancer = new AutoBalancer(null, null, null, mockCacheFacade);
Properties config = getBasicConfig();
config.put(AutoBalancer.MINIMUM_SIZE, "10");
balancer.init(config);
SizeBasedOOBAuditor auditor = (SizeBasedOOBAuditor) balancer.getOOBAuditor();
// first run
assertFalse(auditor.needsRebalancing());
// second run
assertFalse(auditor.needsRebalancing());
}
use of org.apache.geode.cache.util.AutoBalancer.SizeBasedOOBAuditor in project geode by apache.
the class AutoBalancerJUnitTest method testOOBWhenAboveThresholdAndMin.
@Test
public void testOOBWhenAboveThresholdAndMin() {
final long totalSize = 1000L;
final Map<PartitionedRegion, InternalPRInfo> details = new HashMap<>();
mockContext.checking(new Expectations() {
{
allowing(mockCacheFacade).getRegionMemberDetails();
will(returnValue(details));
// first run
oneOf(mockCacheFacade).getTotalDataSize(details);
will(returnValue(totalSize));
oneOf(mockCacheFacade).getTotalTransferSize();
// twice threshold
will(returnValue((AutoBalancer.DEFAULT_SIZE_THRESHOLD_PERCENT * totalSize / 100) * 2));
// second run
oneOf(mockCacheFacade).getTotalDataSize(details);
will(returnValue(totalSize));
oneOf(mockCacheFacade).getTotalTransferSize();
// more than total size
will(returnValue(2 * totalSize));
}
});
AutoBalancer balancer = new AutoBalancer(null, null, null, mockCacheFacade);
Properties config = getBasicConfig();
config.put(AutoBalancer.MINIMUM_SIZE, "10");
balancer.init(config);
SizeBasedOOBAuditor auditor = (SizeBasedOOBAuditor) balancer.getOOBAuditor();
// first run
assertTrue(auditor.needsRebalancing());
// second run
assertTrue(auditor.needsRebalancing());
}
Aggregations