Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GEODE-9463: Add SerializableRegionRedundancyStatusImpl to accept list #6753

Merged
merged 1 commit into from
Aug 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class RestoreRedundancyManagementDUnitTest {
@Rule
public ClusterStartupRule cluster = new ClusterStartupRule();

private MemberVM locator;
private MemberVM locator1;
private List<MemberVM> servers;
private static final int SERVERS_TO_START = 3;
private static final String HIGH_REDUNDANCY_REGION_NAME = "highRedundancy";
Expand All @@ -70,24 +70,33 @@ public class RestoreRedundancyManagementDUnitTest {
private static final String NO_CONFIGURED_REDUNDANCY_REGION_NAME = "noConfiguredRedundancy";

private ClusterManagementService client1;
private ClusterManagementService client2;

@Before
public void setup() {
locator = cluster.startLocatorVM(0, MemberStarterRule::withHttpService);
locator1 = cluster.startLocatorVM(0, MemberStarterRule::withHttpService);
int locator1Port = locator1.getPort();
MemberVM locator2 = cluster.startLocatorVM(1,
l -> l.withHttpService().withConnectionToLocator(locator1Port));
servers = new ArrayList<>();
int locatorPort = locator.getPort();
int locatorPort = locator1.getPort();
IntStream.range(0, SERVERS_TO_START)
.forEach(i -> servers.add(cluster.startServerVM(i + 1, locatorPort)));
.forEach(i -> servers.add(cluster.startServerVM(i + 2, locatorPort)));

client1 = new ClusterManagementServiceBuilder()
.setHost("localhost")
.setPort(locator.getHttpPort())
.setPort(locator1.getHttpPort())
.build();
client2 = new ClusterManagementServiceBuilder()
.setHost("localhost")
.setPort(locator2.getHttpPort())
.build();
}

@After
public void tearDown() {
client1.close();
client2.close();
}

@Test
Expand All @@ -98,14 +107,42 @@ public void restoreRedundancyWithNoArgumentsRestoresRedundancyForAllRegions()
createAndPopulateRegions(regionNames);

int numberOfServers = servers.size();
regionNames.forEach(region -> locator
regionNames.forEach(region -> locator1
.waitUntilRegionIsReadyOnExactlyThisManyServers(SEPARATOR + region, numberOfServers));

RestoreRedundancyRequest restoreRedundancyRequest = new RestoreRedundancyRequest();

restoreRedundancyRequest.setIncludeRegions(regionNames);

verifyClusterManagementOperationRequestAndResponse(restoreRedundancyRequest, client1, client1);

// Confirm all regions have their configured redundancy and that primaries were balanced
int numberOfActiveServers = servers.size();
servers.get(0).invoke(() -> {
for (String regionName : regionNames) {
assertRedundancyStatusForRegion(regionName, true);
assertPrimariesBalanced(regionName, numberOfActiveServers, true);
}
});
}

@Test
public void canReadRestoreRedundancyResultFromDifferentLocator()
throws ExecutionException, InterruptedException {

List<String> regionNames = getAllRegionNames();
createAndPopulateRegions(regionNames);

int numberOfServers = servers.size();
regionNames.forEach(region -> locator1
.waitUntilRegionIsReadyOnExactlyThisManyServers(SEPARATOR + region, numberOfServers));

RestoreRedundancyRequest restoreRedundancyRequest = new RestoreRedundancyRequest();

restoreRedundancyRequest.setIncludeRegions(regionNames);

verifyClusterManagementOperationRequestAndResponse(restoreRedundancyRequest);
// Perform the operation on locator1 and use a client connected to locator2 to get the result
verifyClusterManagementOperationRequestAndResponse(restoreRedundancyRequest, client1, client2);

// Confirm all regions have their configured redundancy and that primaries were balanced
int numberOfActiveServers = servers.size();
Expand All @@ -119,15 +156,16 @@ public void restoreRedundancyWithNoArgumentsRestoresRedundancyForAllRegions()

// Helper methods
private void verifyClusterManagementOperationRequestAndResponse(
RestoreRedundancyRequest restoreRedundancyRequest)
RestoreRedundancyRequest restoreRedundancyRequest, ClusterManagementService startClient,
ClusterManagementService readResultClient)
throws InterruptedException, ExecutionException {
ClusterManagementOperationResult<RestoreRedundancyRequest, RestoreRedundancyResults> startResult =
client1.start(restoreRedundancyRequest);
startClient.start(restoreRedundancyRequest);

assertThat(startResult.isSuccessful()).isTrue();

ClusterManagementOperationResult<RestoreRedundancyRequest, RestoreRedundancyResults> endResult =
client1.getFuture(restoreRedundancyRequest, startResult.getOperationId()).get();
readResultClient.getFuture(restoreRedundancyRequest, startResult.getOperationId()).get();
RestoreRedundancyResults restoreRedundancyResult = endResult.getOperationResult();

assertThat(restoreRedundancyResult.getSuccess()).isTrue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ public class SerializableRegionRedundancyStatusImpl extends
/**
* Default constructor used for serialization
*/
public SerializableRegionRedundancyStatusImpl() {}
public SerializableRegionRedundancyStatusImpl() {
status = RedundancyStatus.NOT_SATISFIED;
}

public SerializableRegionRedundancyStatusImpl(PartitionedRegion region) {
regionName = region.getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ org/apache/geode/internal/cache/control/InternalResourceManager$ResourceType,fal
org/apache/geode/internal/cache/control/MemoryThresholds$MemoryState,false
org/apache/geode/internal/cache/control/PartitionRebalanceDetailsImpl,true,5880667005758250156,bucketCreateBytes:long,bucketCreateTime:long,bucketCreatesCompleted:int,bucketRemoveBytes:long,bucketRemoveTime:long,bucketRemovesCompleted:int,bucketTransferBytes:long,bucketTransferTime:long,bucketTransfersCompleted:int,numOfMembers:int,partitionMemberDetailsAfter:java/util/Set,partitionMemberDetailsBefore:java/util/Set,primaryTransferTime:long,primaryTransfersCompleted:int,time:long
org/apache/geode/internal/cache/control/RebalanceResultsImpl,false,detailSet:java/util/Set,totalBucketCreateBytes:long,totalBucketCreateTime:long,totalBucketCreatesCompleted:int,totalBucketTransferBytes:long,totalBucketTransferTime:long,totalBucketTransfersCompleted:int,totalNumOfMembers:int,totalPrimaryTransferTime:long,totalPrimaryTransfersCompleted:int,totalTime:long
org/apache/geode/internal/cache/control/SerializableRegionRedundancyStatusImpl,false
org/apache/geode/internal/cache/control/SerializableRestoreRedundancyResultsImpl,true,-6385537590999520662
org/apache/geode/internal/cache/execute/BucketMovedException,true,4893171227542647452
org/apache/geode/internal/cache/execute/InternalFunctionException,true,3532698050312820319
org/apache/geode/internal/cache/execute/InternalFunctionInvocationTargetException,true,-6063507496829271815,failedIds:java/util/Set
Expand Down