PRHARedundancyProvider { public InternalPRInfo buildPartitionedRegionInfo(boolean internal, LoadProbe loadProbe) { PartitionedRegion pr = partitionedRegion; if (pr == null) { return null; } int configuredBucketCount = pr.getTotalNumberOfBuckets(); int createdBucketCount = pr.getRegionAdvisor().getCreatedBucketsCount(); int lowRedundancyBucketCount = pr.getRedundancyTracker().getLowRedundancyBuckets(); int configuredRedundantCopies = pr.getRedundantCopies(); int actualRedundantCopies = pr.getRedundancyTracker().getActualRedundancy(); PartitionedRegionDataStore dataStore = pr.getDataStore(); Set<InternalDistributedMember> datastores = pr.getRegionAdvisor().adviseDataStore(); Set<InternalPartitionDetails> memberDetails = new TreeSet<>(); OfflineMemberDetails offlineMembers = null; boolean fetchOfflineMembers = false; if (dataStore != null) { memberDetails.add(buildPartitionMemberDetails(internal, loadProbe)); offlineMembers = fetchOfflineMembers(); } else { fetchOfflineMembers = true; } if (!datastores.isEmpty()) { FetchPartitionDetailsResponse response = FetchPartitionDetailsMessage.send(datastores, pr, internal, fetchOfflineMembers, loadProbe); memberDetails.addAll(response.waitForResponse()); if (fetchOfflineMembers) { offlineMembers = response.getOfflineMembers(); } } String colocatedWithPath = pr.getColocatedWith(); return new PartitionRegionInfoImpl(pr.getFullPath(), configuredBucketCount, createdBucketCount, lowRedundancyBucketCount, configuredRedundantCopies, actualRedundantCopies, memberDetails, colocatedWithPath, offlineMembers); } PRHARedundancyProvider(PartitionedRegion partitionedRegion,
      InternalResourceManager resourceManager); @VisibleForTesting  PRHARedundancyProvider(PartitionedRegion partitionedRegion,
      InternalResourceManager resourceManager,
      BiFunction<PRHARedundancyProvider, Integer, PersistentBucketRecoverer> persistentBucketRecovererFunction); @VisibleForTesting  PRHARedundancyProvider(PartitionedRegion partitionedRegion,
      InternalResourceManager resourceManager,
      BiFunction<PRHARedundancyProvider, Integer, PersistentBucketRecoverer> persistentBucketRecovererFunction,
      PartitionedRegionRebalanceOpFactory rebalanceOpFactory,
      CompletableFuture<Void> providerStartupTask); static void timedOut(PartitionedRegion partitionedRegion,
      Set<InternalDistributedMember> allStores,
      Collection<InternalDistributedMember> alreadyUsed, String opString, long timeOut); PartitionedRegion getPartitionedRegion(); InternalDistributedMember createBucketAtomically(int bucketId, int newBucketSize,
      boolean finishIncompleteCreation, String partitionName); void endBucketCreationLocally(int bucketId, InternalDistributedMember newPrimary); void finishIncompleteBucketCreation(int bucketId); boolean createBackupBucketOnMember(int bucketId, InternalDistributedMember targetMember,
      boolean isRebalance, boolean replaceOfflineData, InternalDistributedMember fromMember,
      boolean forceCreation); boolean isRedundancyImpaired(); void shutdown(); InternalPRInfo buildPartitionedRegionInfo(boolean internal, LoadProbe loadProbe); OfflineMemberDetailsImpl fetchOfflineMembers(); InternalPartitionDetails buildPartitionMemberDetails(boolean internal,
      LoadProbe loadProbe); boolean isPersistentRecoveryComplete(); static final String TIMEOUT_MSG; static final String INSUFFICIENT_STORES_MSG; }
@Test public void buildPartitionedRegionInfo() { prHaRedundancyProvider = new PRHARedundancyProvider(partitionedRegion, resourceManager, (a, b) -> mock(PersistentBucketRecoverer.class)); when(partitionedRegion.getRedundancyTracker()) .thenReturn(mock(PartitionedRegionRedundancyTracker.class)); when(partitionedRegion.getRedundancyTracker().getActualRedundancy()).thenReturn(33); when(partitionedRegion.getRedundancyTracker().getLowRedundancyBuckets()).thenReturn(3); when(partitionedRegion.getRedundantCopies()).thenReturn(12); when(partitionedRegion.getRegionAdvisor()).thenReturn(mock(RegionAdvisor.class)); when(partitionedRegion.getRegionAdvisor().adviseDataStore()).thenReturn(new HashSet<>()); when(partitionedRegion.getRegionAdvisor().getCreatedBucketsCount()).thenReturn(17); when(partitionedRegion.getTotalNumberOfBuckets()).thenReturn(42); InternalPRInfo internalPRInfo = prHaRedundancyProvider.buildPartitionedRegionInfo(false, mock(LoadProbe.class)); assertThat(internalPRInfo.getConfiguredBucketCount()).isEqualTo(42); assertThat(internalPRInfo.getCreatedBucketCount()).isEqualTo(17); assertThat(internalPRInfo.getLowRedundancyBucketCount()).isEqualTo(3); assertThat(internalPRInfo.getConfiguredRedundantCopies()).isEqualTo(12); assertThat(internalPRInfo.getActualRedundantCopies()).isEqualTo(33); }