mivanac commented on a change in pull request #6909:
URL: https://github.com/apache/geode/pull/6909#discussion_r728394334



##########
File path: 
geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/CreateMissingBucketsTask.java
##########
@@ -58,4 +74,44 @@ protected void createMissingBuckets(PartitionedRegion 
region) {
       }
     }
   }
+
+  /**
+   * Wait for Colocation to complete. Wait all nodes to Register this 
PartitionedRegion.
+   */
+  protected boolean waitForColocationCompleted(PartitionedRegion 
partitionedRegion) {
+    int retryCount = 0;
+    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 {
+        Thread.sleep(sleepInterval);
+      } catch (InterruptedException ignore) {
+        interrupted = true;
+      } finally {
+        if (interrupted) {
+          Thread.currentThread().interrupt();
+        }
+      }
+
+      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);

Review comment:
       I think that it would be better to leave current behavior, in case 
something is stack, then fail initialization of region, since this seams to 
have variable duration, depending on number of servers in cluster, and other 
variables. Maybe we can introduce configuration parameter, which user can set 
depending on cluster size.




-- 
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]


Reply via email to