use of org.apache.geode.internal.cache.partitioned.rebalance.BucketOperator.Completion in project geode by apache.
the class BucketOperatorWrapperTest method bucketWrapperShouldInvokeOnSuccessWhenCreateBucketSucceeds.
@Test
public void bucketWrapperShouldInvokeOnSuccessWhenCreateBucketSucceeds() {
doAnswer(new Answer<Object>() {
public Object answer(InvocationOnMock invocation) {
// 3rd argument is Completion object sent to BucketOperatorImpl.createRedundantBucket
((Completion) invocation.getArguments()[3]).onSuccess();
return null;
}
}).when(delegate).createRedundantBucket(eq(targetMember), eq(bucketId), eq(colocatedRegionBytes), any(Completion.class));
Completion completionSentToWrapper = mock(Completion.class);
wrapper.createRedundantBucket(targetMember, bucketId, colocatedRegionBytes, completionSentToWrapper);
verify(completionSentToWrapper, times(1)).onSuccess();
}
use of org.apache.geode.internal.cache.partitioned.rebalance.BucketOperator.Completion in project geode by apache.
the class BucketOperatorWrapperTest method bucketWrapperShouldNotRecordNumberOfBucketsCreatedIfCreateBucketFails.
@Test
public void bucketWrapperShouldNotRecordNumberOfBucketsCreatedIfCreateBucketFails() {
doAnswer(new Answer<Object>() {
public Object answer(InvocationOnMock invocation) {
// 3rd argument is Completion object sent to BucketOperatorImpl.createRedundantBucket
((Completion) invocation.getArguments()[3]).onFailure();
return null;
}
}).when(delegate).createRedundantBucket(eq(targetMember), eq(bucketId), eq(colocatedRegionBytes), any(Completion.class));
Completion completionSentToWrapper = mock(Completion.class);
wrapper.createRedundantBucket(targetMember, bucketId, colocatedRegionBytes, completionSentToWrapper);
// verify create buckets is not recorded
for (PartitionRebalanceDetailsImpl details : rebalanceDetails) {
verify(details, times(0)).incTransfers(anyLong(), anyLong());
}
}
use of org.apache.geode.internal.cache.partitioned.rebalance.BucketOperator.Completion in project geode by apache.
the class BucketOperatorWrapperTest method bucketWrapperShouldRecordNumberOfBucketsCreatedIfCreateBucketSucceeds.
@Test
public void bucketWrapperShouldRecordNumberOfBucketsCreatedIfCreateBucketSucceeds() {
doAnswer(new Answer<Object>() {
public Object answer(InvocationOnMock invocation) {
// 3rd argument is Completion object sent to BucketOperatorImpl.createRedundantBucket
((Completion) invocation.getArguments()[3]).onSuccess();
return null;
}
}).when(delegate).createRedundantBucket(eq(targetMember), eq(bucketId), eq(colocatedRegionBytes), any(Completion.class));
Completion completionSentToWrapper = mock(Completion.class);
wrapper.createRedundantBucket(targetMember, bucketId, colocatedRegionBytes, completionSentToWrapper);
// verify create buckets is recorded
for (PartitionRebalanceDetailsImpl details : rebalanceDetails) {
if (details.getRegionPath().equalsIgnoreCase(PR_LEADER_REGION_NAME))
verify(details, times(1)).incCreates(eq(colocatedRegionBytes.get(PR_LEADER_REGION_NAME)), anyLong());
else if (details.getRegionPath().equals(PR_COLOCATED_REGION_NAME))
verify(details, times(1)).incTransfers(colocatedRegionBytes.get(PR_COLOCATED_REGION_NAME), // elapsed is recorded only if its leader
0);
}
}
use of org.apache.geode.internal.cache.partitioned.rebalance.BucketOperator.Completion in project geode by apache.
the class BucketOperatorWrapperTest method bucketWrapperShouldDelegateCreateBucketToEnclosedOperator.
@Test
public void bucketWrapperShouldDelegateCreateBucketToEnclosedOperator() {
Completion completionSentToWrapper = mock(Completion.class);
doNothing().when(delegate).createRedundantBucket(targetMember, bucketId, colocatedRegionBytes, completionSentToWrapper);
wrapper.createRedundantBucket(targetMember, bucketId, colocatedRegionBytes, completionSentToWrapper);
verify(delegate, times(1)).createRedundantBucket(eq(targetMember), eq(bucketId), eq(colocatedRegionBytes), any(Completion.class));
}
use of org.apache.geode.internal.cache.partitioned.rebalance.BucketOperator.Completion in project geode by apache.
the class PartitionedRegionLoadModelJUnitTest method testRedundancySatisfactionWithAsyncFailures.
/**
* Test that redundancy satisfation can handle asynchronous failures and complete the job
* correctly.
*/
@Test
public void testRedundancySatisfactionWithAsyncFailures() throws Exception {
InternalDistributedMember member1 = new InternalDistributedMember(InetAddress.getByName("127.0.0.1"), 1);
InternalDistributedMember member2 = new InternalDistributedMember(InetAddress.getByName("127.0.0.1"), 2);
InternalDistributedMember member3 = new InternalDistributedMember(InetAddress.getByName("127.0.0.1"), 3);
BucketOperatorWithFailures operator = new BucketOperatorWithFailures();
operator.addBadMember(member2);
bucketOperator = operator;
PartitionedRegionLoadModel model = new PartitionedRegionLoadModel(bucketOperator, 1, 6, getAddressComparor(false), Collections.<InternalDistributedMember>emptySet(), null);
PartitionMemberInfoImpl details1 = buildDetails(member1, 500, 500, new long[] { 1, 1, 1, 1, 1, 1 }, new long[] { 1, 1, 1, 1, 1, 1 });
PartitionMemberInfoImpl details2 = buildDetails(member2, 500, 500, new long[] { 0, 0, 0, 0, 0, 0 }, new long[] { 0, 0, 0, 0, 0, 0 });
PartitionMemberInfoImpl details3 = buildDetails(member3, 500, 500, new long[] { 0, 0, 0, 0, 0, 0 }, new long[] { 0, 0, 0, 0, 0, 0 });
model.addRegion("a", Arrays.asList(details1, details2, details3), new FakeOfflineDetails(), true);
Set<PartitionMemberInfo> details = model.getPartitionedMemberDetails("a");
assertEquals(3, details.size());
// TODO - make some assertions about what's in the details
// we expect 6 moves (3 of these will fail)
assertEquals(6, doMoves(new CompositeDirector(true, true, false, false), model));
assertEquals(3, bucketOperator.creates.size());
for (Completion completion : operator.pendingSuccesses) {
completion.onSuccess();
}
for (Completion completion : operator.pendingFailures) {
completion.onFailure();
}
// Now the last two moves will get reattempted to a new location (because the last location
// failed)
assertEquals(3, doMoves(new CompositeDirector(true, true, false, false), model));
List<Create> expectedCreates = new ArrayList<Create>();
expectedCreates.add(new Create(member3, 1));
expectedCreates.add(new Create(member3, 3));
expectedCreates.add(new Create(member3, 5));
expectedCreates.add(new Create(member3, 0));
expectedCreates.add(new Create(member3, 2));
expectedCreates.add(new Create(member3, 4));
assertEquals(expectedCreates, bucketOperator.creates);
}
Aggregations