/** * Create a redundant bucket on the target member * * @param target the member on which to create the redundant bucket * @param bucketId the identifier of the bucket * @return true if the redundant bucket was created */ public boolean createRedundantBucketForRegion(InternalDistributedMember target, int bucketId) { return getLeaderRegion().getRedundancyProvider().createBackupBucketOnMember(bucketId, target, isRebalance, replaceOfflineData, null, true); }
private Map<PartitionedRegion, InternalPRInfo> fetchDetails(InternalCache cache) { LoadProbe probe = cache.getInternalResourceManager().getLoadProbe(); Map<PartitionedRegion, InternalPRInfo> detailsMap = new LinkedHashMap<PartitionedRegion, InternalPRInfo>(colocatedRegions.size()); for (PartitionedRegion colocatedRegion : colocatedRegions) { if (ColocationHelper.isColocationComplete(colocatedRegion)) { InternalPRInfo info = colocatedRegion.getRedundancyProvider().buildPartitionedRegionInfo(true, probe); detailsMap.put(colocatedRegion, info); } } return detailsMap; }
public boolean isPersistentRecoveryComplete() { if (!ColocationHelper.checkMembersColocation(this.prRegion, this.prRegion.getMyId())) { return false; } if (allBucketsRecoveredFromDisk != null && allBucketsRecoveredFromDisk.getCount() > 0) { return false; } Map<String, PartitionedRegion> colocatedRegions = ColocationHelper.getAllColocationRegions(this.prRegion); for (PartitionedRegion region : colocatedRegions.values()) { PRHARedundancyProvider redundancyProvider = region.getRedundancyProvider(); if (redundancyProvider.allBucketsRecoveredFromDisk != null && redundancyProvider.allBucketsRecoveredFromDisk.getCount() > 0) { return false; } } return true; }
@Override protected boolean operateOnPartitionedRegion(ClusterDistributionManager dm, PartitionedRegion region, long startTime) throws ForceReattemptException { // this is executing in the WAITING_POOL_EXECUTOR try { region.getRedundancyProvider().endBucketCreationLocally(bucketId, newPrimary); } finally { region.getPrStats().endPartitionMessagesProcessing(startTime); } return false; }
@Override public Map<PartitionedRegion, InternalPRInfo> getRegionMemberDetails() { InternalCache cache = getCache(); Map<PartitionedRegion, InternalPRInfo> detailsMap = new HashMap<>(); for (PartitionedRegion region : cache.getPartitionedRegions()) { LoadProbe probe = cache.getInternalResourceManager().getLoadProbe(); InternalPRInfo info = region.getRedundancyProvider().buildPartitionedRegionInfo(true, probe); detailsMap.put(region, info); } return detailsMap; }
/** * Check that sender is still a participant in the partitioned region. If not, notify other nodes * to create backup buckets */ private void checkSenderStillAlive(PartitionedRegion r, InternalDistributedMember sender) { if (!r.getDistributionAdvisor().containsId(sender)) { r.getRedundancyProvider().finishIncompleteBucketCreation(this.bucketId); } }
private static void fillInPartitionedRegionInfo(final InternalCache cache, final Set prDetailsSet, final boolean internal) { // TODO: optimize by fetching all PR details from each member at once Set<PartitionedRegion> partitionedRegions = cache.getPartitionedRegions(); if (partitionedRegions.isEmpty()) { return; } for (PartitionedRegion partitionedRegion : partitionedRegions) { PartitionRegionInfo prDetails = partitionedRegion.getRedundancyProvider() .buildPartitionedRegionInfo(internal, cache.getInternalResourceManager().getLoadProbe()); if (prDetails != null) { prDetailsSet.add(prDetails); } } }
@Override public void run() { getBucket().getPartitionedRegion().getRedundancyProvider() .finishIncompleteBucketCreation(getBucket().getId()); } });
/** * Writes a log entry every SLEEP_PERIOD when there are missing colocated child regions for this * region. * */ private void run2() throws InterruptedException { boolean firstLogIteration = true; synchronized (loggerLock) { while (true) { int sleepMillis = getLogInterval(); // delay for first log message is half the time of the interval between subsequent log // messages if (firstLogIteration) { firstLogIteration = false; sleepMillis /= 2; } loggerLock.wait(sleepMillis); PRHARedundancyProvider rp = region.getRedundancyProvider(); if (rp != null && rp.isPersistentRecoveryComplete()) { // Terminate the logging thread, recoverycomplete is only true when there are no missing // colocated regions break; } if (missingChildren.isEmpty()) { break; } logMissingRegions(region); } } }
/** * Wait for all persistent buckets to be recovered from disk, or for the region to be closed, * whichever happens first. */ protected void waitForPersistentBucketRecoveryOrClose() { CountDownLatch recoveryLatch = allBucketsRecoveredFromDisk; if (recoveryLatch != null) { boolean interrupted = false; while (true) { try { this.prRegion.getCancelCriterion().checkCancelInProgress(null); boolean done = recoveryLatch.await( PartitionedRegionHelper.DEFAULT_WAIT_PER_RETRY_ITERATION, TimeUnit.MILLISECONDS); if (done) { break; } } catch (InterruptedException e) { interrupted = true; } } if (interrupted) { Thread.currentThread().interrupt(); } } List<PartitionedRegion> colocatedRegions = ColocationHelper.getColocatedChildRegions(this.prRegion); for (PartitionedRegion child : colocatedRegions) { child.getRedundancyProvider().waitForPersistentBucketRecoveryOrClose(); } }
private boolean isRebalanceNecessary() { // Fixed partitions will always be rebalanced. // Persistent partitions that have recovered from disk will // also need to rebalance primaries return isRebalance || director.isRebalanceNecessary( leaderRegion.getRedundancyProvider().isRedundancyImpaired(), leaderRegion.getDataPolicy().withPersistence()); }
@Override protected boolean operateOnPartitionedRegion(ClusterDistributionManager dm, PartitionedRegion region, long startTime) throws ForceReattemptException { PartitionMemberInfoImpl details = (PartitionMemberInfoImpl) region.getRedundancyProvider() .buildPartitionMemberDetails(this.internal, this.loadProbe); OfflineMemberDetails offlineDetails; if (this.internal && this.fetchOfflineMembers) { offlineDetails = region.getRedundancyProvider().fetchOfflineMembers(); } else { offlineDetails = new OfflineMemberDetailsImpl(new Set[0]); } region.getPrStats().endPartitionMessagesProcessing(startTime); FetchPartitionDetailsReplyMessage.send(getSender(), getProcessorId(), details, dm, offlineDetails, null); // Unless there was an exception thrown, this message handles sending the // response return false; }
@Override protected boolean operateOnPartitionedRegion(ClusterDistributionManager dm, PartitionedRegion pr, long startTime) throws CacheException { // This call has come to an uninitialized region. // This can occur as bucket grab Op is done outside the // d-lock. if (pr == null || !pr.isInitialized()) { return false; } if (logger.isTraceEnabled(LogMarker.DM_VERBOSE)) { logger.trace(LogMarker.DM_VERBOSE, "BucketBackupMessage operateOnRegion: {}", pr.getFullPath()); } PartitionedRegionDataStore ds = pr.getDataStore(); if (ds != null) { pr.getRedundancyProvider().finishIncompleteBucketCreation(bucketId); } else { logger.warn("BucketBackupMessage: data store not configured for this member"); } pr.getPrStats().endPartitionMessagesProcessing(startTime); return false; }
when(mockCache.getInternalResourceManager()).thenReturn(mockRM); when(mockRM.getLoadProbe()).thenReturn(mockProbe); when(mockR1.getRedundancyProvider()).thenReturn(mockRedundancyProviderR1); when(mockR2.getRedundancyProvider()).thenReturn(mockRedundancyProviderR2); when(mockRedundancyProviderR1.buildPartitionedRegionInfo(eq(true), any(LoadProbe.class))) .thenReturn(mockR1PRInfo);
/** * Gathers details about the specified partitioned region. Returns null if the partitioned region * is not locally defined. * * @param region the region to get info about * @return details about the specified partitioned region * @since GemFire 6.0 */ public static PartitionRegionInfo getPartitionRegionInfo(final Region<?, ?> region) { try { PartitionedRegion partitionedRegion = isPartitionedCheck(region); InternalCache cache = (InternalCache) region.getCache(); return partitionedRegion.getRedundancyProvider().buildPartitionedRegionInfo(false, cache.getInternalResourceManager().getLoadProbe()); } catch (ClassCastException ignore) { // not a PR so return null } return null; }
&& !this.partitionedRegion.getRedundancyProvider().isPersistentRecoveryComplete()) { if (logger.isDebugEnabled()) { logger.debug(
protected void createMissingBuckets(PartitionedRegion region) { PartitionedRegion parentRegion = ColocationHelper.getColocatedRegion(region); if (parentRegion == null) { return; } // Fix for 48954 - Make sure the parent region has created missing buckets // before we create missing buckets for this child region. createMissingBuckets(parentRegion); for (int i = 0; i < region.getTotalNumberOfBuckets(); i++) { if (parentRegion.getRegionAdvisor().getBucketAdvisor(i).getBucketRedundancy() != region .getRegionAdvisor().getBucketAdvisor(i).getBucketRedundancy()) { /* if (leaderRegion.getRegionAdvisor().isStorageAssignedForBucket(i)) { */ final long startTime = PartitionedRegionStats.startTime(); region.getRedundancyProvider().createBucketAtomically(i, 0, startTime, true, null); } } } }
acquiredLock = true; synchronized (partitionedRegion.getRedundancyProvider()) { if (partitionedRegion.isDataStore() && partitionedRegion.getDataStore() != null && partitionedRegion.getDataPolicy() == DataPolicy.PERSISTENT_PARTITION) {
InternalDistributedMember primary = r.getRedundancyProvider().createBucketAtomically(bucketId, bucketSize, startTime, false, partitionName); r.getPrStats().endPartitionMessagesProcessing(startTime);
for (PartitionedRegion child : colocatedWithList) { if (child.getRegionAdvisor().isBucketLocal(bucketId)) { child.getRedundancyProvider().endBucketCreationLocally(bucketId, newPrimary);