bharatviswa504 commented on a change in pull request #2266:
URL: https://github.com/apache/ozone/pull/2266#discussion_r635151585
##########
File path:
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/HAUtils.java
##########
@@ -413,47 +418,44 @@ public static File getMetaDir(DBDefinition definition,
return caCertPemList;
}
+ /**
+ * Retry for ever until CA list matches expected count.
+ * @param task - task to get CA list.
+ * @return CA list.
+ * @throws IOException
+ */
+ private static List<String> getCAListWithRetry(Callable task,
+ long waitDuration) throws IOException {
+ RetryPolicy retryPolicy = RetryPolicies.retryForeverWithFixedSleep(
+ waitDuration, TimeUnit.SECONDS);
+ RetriableTask<List<String>> retriableTask =
+ new RetriableTask(retryPolicy, "getCAList", task);
+ try {
+ return retriableTask.call();
+ } catch (Exception ex) {
+ throw new SCMSecurityException("Unable to obtain complete CA " +
+ "list", ex);
+ }
+ }
+
private static List<String> waitForCACerts(
final SupplierWithIOException<List<String>> applyFunction,
int expectedCount) throws IOException {
- //TODO: make wait time and sleep time configurable if needed.
// TODO: If SCMs are bootstrapped later, then listCA need to be
// refetched if listCA size is less than scm ha config node list size.
// For now when Client of SCM's are started we compare their node list
// size and ca list size if it is as expected, we return the ca list.
boolean caListUpToDate;
Review comment:
Done
##########
File path:
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/HAUtils.java
##########
@@ -413,47 +418,44 @@ public static File getMetaDir(DBDefinition definition,
return caCertPemList;
}
+ /**
+ * Retry for ever until CA list matches expected count.
+ * @param task - task to get CA list.
+ * @return CA list.
+ * @throws IOException
+ */
+ private static List<String> getCAListWithRetry(Callable task,
+ long waitDuration) throws IOException {
+ RetryPolicy retryPolicy = RetryPolicies.retryForeverWithFixedSleep(
+ waitDuration, TimeUnit.SECONDS);
+ RetriableTask<List<String>> retriableTask =
+ new RetriableTask(retryPolicy, "getCAList", task);
+ try {
+ return retriableTask.call();
+ } catch (Exception ex) {
+ throw new SCMSecurityException("Unable to obtain complete CA " +
+ "list", ex);
+ }
+ }
+
private static List<String> waitForCACerts(
final SupplierWithIOException<List<String>> applyFunction,
int expectedCount) throws IOException {
- //TODO: make wait time and sleep time configurable if needed.
// TODO: If SCMs are bootstrapped later, then listCA need to be
// refetched if listCA size is less than scm ha config node list size.
// For now when Client of SCM's are started we compare their node list
// size and ca list size if it is as expected, we return the ca list.
boolean caListUpToDate;
- long waitTime = 5 * 60 * 1000L;
- long retryTime = 10 * 1000L;
- long currentTime = Time.monotonicNow();
List<String> caCertPemList;
- do {
- caCertPemList = applyFunction.get();
- caListUpToDate =
- caCertPemList.size() == expectedCount ? true : false;
- if (!caListUpToDate) {
- LOG.info("Expected CA list size {}, where as received CA List size " +
- "{}. Retry to fetch CA List after {} seconds", expectedCount,
- caCertPemList.size(), retryTime);
- try {
- Thread.sleep(retryTime);
- } catch (InterruptedException ex) {
- Thread.currentThread().interrupt();
- }
- }
- } while (!caListUpToDate &&
- Time.monotonicNow() - currentTime < waitTime);
- return caCertPemList;
- }
-
-
- private static void checkCertCount(int certCount, int expectedCount)
- throws SCMSecurityException{
- if (certCount != expectedCount) {
- LOG.error("Unable to obtain CA list for SCM cluster, obtained CA list " +
- "size is {}, where as expected list size is {}",
- certCount, expectedCount);
- throw new SCMSecurityException("Unable to obtain complete CA list");
+ caCertPemList = applyFunction.get();
Review comment:
Done
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]