Skip to content

HDDS-5847. Make OM Retry Policy configurable for different protocols#2964

Closed
hanishakoneru wants to merge 1 commit intoapache:masterfrom
hanishakoneru:HDDS-5847
Closed

HDDS-5847. Make OM Retry Policy configurable for different protocols#2964
hanishakoneru wants to merge 1 commit intoapache:masterfrom
hanishakoneru:HDDS-5847

Conversation

@hanishakoneru
Copy link
Contributor

@hanishakoneru hanishakoneru commented Jan 5, 2022

What changes were proposed in this pull request?

Currently we reuse the retry policy in OMFailoverProxyProvider formulated for OM client communication for the Inter Service Protocol and the OM Admin protocol (HDDS-5490). This does not take into account the retry policy required when a ReconfigurationInProgressException is encountered while bootstrapping or decommissioning an OM (please refer to Bharat Viswanadham's comment here). It would be good to separate out the retry policy based on the protocol.

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-5847

How was this patch tested?

Existing unit tests

Copy link
Contributor

@adoroszlai adoroszlai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @hanishakoneru for working on this, and sorry for forgetting to review.

Some trivial code improvements can be made in OMRetryPolicy, but otherwise looks good. Especially OMFailoverProxyProvider looks much cleaner now.

One question: what is the reason for adding ExceptionType-based mapping in addition to the exception class-based one?

Comment on lines +40 to +42
private final HashMap<ExceptionType, RetryAction> defaultRetryRulesMap;
private HashMap<ExceptionType, RetryAction> retryRulesMapByType;
private HashMap<Class, RetryAction> retryRulesMapByClass;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could improve it in the following ways:

  • defaults do not need to be instance-specific
  • variables can be declared using Map interface
  • specify type parameter for Class
  • variables can be final
Suggested change
private final HashMap<ExceptionType, RetryAction> defaultRetryRulesMap;
private HashMap<ExceptionType, RetryAction> retryRulesMapByType;
private HashMap<Class, RetryAction> retryRulesMapByClass;
private static final Map<ExceptionType, RetryAction> DEFAULT_RETRY_RULES;
private final Map<ExceptionType, RetryAction> retryRulesByType;
private final Map<Class<? extends Exception>, RetryAction> retryRulesByClass;

(Needs corresponding changes where these are used.)

Comment on lines +61 to +62
this.defaultRetryRulesMap = new HashMap<>();
this.retryRulesMapByType = new HashMap<>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two can be created as EnumMap.

Comment on lines +64 to +67
this.defaultRetryRulesMap.put(ExceptionType.NOT_LEADER,
RetryAction.FAILOVER_AND_RETRY);
this.defaultRetryRulesMap.put(ExceptionType.LEADER_NOT_READY,
RetryAction.RETRY_ON_SAME_OM);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If variable changed to static, these can be in static {} block.

Comment on lines +83 to +85
if (retryRulesMapByClass == null) {
retryRulesMapByClass = new HashMap<>();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary, already created in constructor.

/**
* Add a Retry rule based on Exception Class.
*/
public void addRetryRule(Class exceptionClass,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public void addRetryRule(Class exceptionClass,
public void addRetryRule(Class<? extends Exception> exceptionClass,

}

/**
* Get the ExceptioType for the given Exception.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Get the ExceptioType for the given Exception.
* Get the ExceptionType for the given Exception.

Comment on lines +43 to +44

public enum ExceptionType {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checkstyle insists on javadoc for these enums.

@adoroszlai
Copy link
Contributor

@hanishakoneru I think this is a useful change, so I would like to wrap this up. If you agree, I would like to apply the improvements I had suggested (and resolve merge conflict). Then we could either merge it, or ask someone else for another round of review.

@kerneltime kerneltime requested review from fapifta and kerneltime and removed request for bharatviswa504 and fapifta November 14, 2022 17:23
@kerneltime
Copy link
Contributor

@duongkame

@kerneltime
Copy link
Contributor

@neils-dev @GeorgeJahad

@neils-dev
Copy link
Contributor

@kerneltime , Thanks for bringing up this older PR. General comment: it needs to be rebased and updated for the refactored OmFailoverProxyProvider that was introduced, HDDS-6433 #3389.

@adoroszlai
Copy link
Contributor

/pending

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marking this issue as un-mergeable as requested.

Please use /ready comment when it's resolved.

Please note that the PR will be closed after 21 days of inactivity from now. (But can be re-opened anytime later...)

/pending

@neils-dev
Copy link
Contributor

@kerneltime , this PR needs some attention to resolve conflicts with the master.

@kerneltime
Copy link
Contributor

@neils-dev I think one will have to adopt this Jira and work on the fix. Let me know if you want to take that up. I am closing this issue for now as even if works is continued on this Jira it would make sense to start a new PR.

@kerneltime kerneltime closed this Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants