mivanac commented on a change in pull request #6909:
URL: https://github.com/apache/geode/pull/6909#discussion_r738671616
##########
File path:
geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/CreateMissingBucketsTask.java
##########
@@ -43,19 +71,70 @@ public void run2() {
protected void createMissingBuckets(PartitionedRegion region) {
PartitionedRegion parentRegion =
ColocationHelper.getColocatedRegion(region);
- if (parentRegion == null) {
+ if (parentRegion == null)
return;
- }
+
// 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 (region.isClosed || region.isLocallyDestroyed)
+ return;
if
(parentRegion.getRegionAdvisor().getBucketAdvisor(i).getBucketRedundancy() !=
region
.getRegionAdvisor().getBucketAdvisor(i).getBucketRedundancy()) {
region.getRedundancyProvider().createBucketAtomically(i, 0, true,
null);
}
}
}
+
+ /**
+ * Wait for Colocation to complete. Wait all nodes to Register this
PartitionedRegion.
+ */
+ protected boolean waitForColocationCompleted(PartitionedRegion
partitionedRegion) {
+ int sleepInterval =
PartitionedRegionHelper.DEFAULT_WAIT_PER_RETRY_ITERATION;
+
+ while (!ColocationHelper.isColocationComplete(partitionedRegion)
+ && (retryCount < MAX_NUMBER_INTERVALS)) {
+
+ // Didn't time out. Sleep a bit and then continue
+ boolean interrupted = Thread.interrupted();
+ try {
+ logger.info("Waiting for collocation to complete, retry number {}",
retryCount);
+ Thread.sleep(sleepInterval);
+ } catch (InterruptedException ignore) {
+ interrupted = true;
+ } finally {
+ if (interrupted) {
+ Thread.currentThread().interrupt();
+ }
+ }
+
+ if (partitionedRegion.isLocallyDestroyed || partitionedRegion.isClosed)
+ return false;
+
+ retryCount++;
+ if (retryCount == SMALL_200MS_INTERVALS) {
+ sleepInterval = 2 *
PartitionedRegionHelper.DEFAULT_WAIT_PER_RETRY_ITERATION;
+ } else if (retryCount == SMALL_500MS_INTERVALS) {
+ sleepInterval = 5 *
PartitionedRegionHelper.DEFAULT_WAIT_PER_RETRY_ITERATION;
+ } else if (retryCount == MEDIUM_1SEC_INTERVALS) {
+ sleepInterval = 10 *
PartitionedRegionHelper.DEFAULT_WAIT_PER_RETRY_ITERATION;
+ } else if (retryCount == MEDIUM_2SEC_INTERVALS) {
+ sleepInterval = 20 *
PartitionedRegionHelper.DEFAULT_WAIT_PER_RETRY_ITERATION;
+ } else if (retryCount == LARGE_5SEC_INTERVALS) {
+ sleepInterval = 50 *
PartitionedRegionHelper.DEFAULT_WAIT_PER_RETRY_ITERATION;
+ }
+
+ }
+ return ColocationHelper.isColocationComplete(partitionedRegion);
+
+ }
+
+ @VisibleForTesting
+ public int getRetryCount() {
+ return retryCount;
+ }
Review comment:
updated
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]