Skip to content

Conversation

@sodonnel
Copy link
Contributor

Replication Manager currently uses Time.monotonicNow() in a few places to check if a pending command should be timed out.

This is difficult to test without adding sleeps in the tests.

We should inject a Clock object to use rather than making calls to SystemTime directly to allow tests more flexibility.

What changes were proposed in this pull request?

(Please fill in changes proposed in this fix)

What is the link to the Apache JIRA

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

How was this patch tested?

New Unit test

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 @sodonnel for the improvement, LGTM, except minor (theoretical) comment on equals.

serviceManager,
scmNodeManager);
scmNodeManager,
new MonotonicClock(ZoneId.of("UTC")));
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any reason not to use ZoneOffset.UTC?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No reason, except I didn't know about it :-) I will change it.

Comment on lines +65 to +66
if (obj instanceof MonotonicClock) {
return zoneId.equals(((MonotonicClock) obj).zoneId);
Copy link
Contributor

Choose a reason for hiding this comment

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

MonotonicClock should be final or equals should check class equality instead of instanceof. Otherwise equality of instances of a subclass and MonotonicClock would not be symmetric.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing this out. I will make it final to avoid this problem. I basically copied this code from the Java SystemClock class, and it was a final class, so that explains why this code is that way.

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 @sodonnel for updating the patch.

@sodonnel sodonnel merged commit d404339 into apache:master Jul 18, 2021
@sodonnel
Copy link
Contributor Author

Thanks for the review @adoroszlai. I have merged the change to master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants