-
Notifications
You must be signed in to change notification settings - Fork 588
HDDS-12060. Replace System.currentTimeMillis() with Time.monotonicNow() for duration calculation #8096
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HDDS-12060. Replace System.currentTimeMillis() with Time.monotonicNow() for duration calculation #8096
Changes from 4 commits
491603c
5d73fb3
6913762
caf69c1
1ee2db4
00a3473
efa19ce
d0e80f7
5ff7659
09adbcb
21494f0
b9eff9e
86b7505
2496e09
8288a48
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,6 +51,7 @@ | |
| import org.apache.hadoop.hdds.scm.ha.SCMContext; | ||
| import org.apache.hadoop.hdds.scm.node.states.NodeNotFoundException; | ||
| import org.apache.hadoop.hdds.server.events.EventPublisher; | ||
| import org.apache.hadoop.util.Time; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
|
|
@@ -527,7 +528,7 @@ public synchronized void startMaintenance(DatanodeDetails dn, int endInHours) | |
| long maintenanceEnd = 0; | ||
| if (endInHours != 0) { | ||
| maintenanceEnd = | ||
| (System.currentTimeMillis() / 1000L) + (endInHours * 60L * 60L); | ||
| (Time.monotonicNow() / 1000L) + (endInHours * 60L * 60L); | ||
|
||
| } | ||
| if (opState == NodeOperationalState.IN_SERVICE) { | ||
| nodeManager.setNodeOperationalState( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ | |
| import java.util.Objects; | ||
| import java.util.Set; | ||
| import org.apache.hadoop.hdds.protocol.proto.HddsProtos; | ||
| import org.apache.hadoop.util.Time; | ||
|
|
||
| /** | ||
| * This class is used to capture the current status of a datanode. This | ||
|
|
@@ -123,7 +124,7 @@ public boolean operationalStateExpired() { | |
| if (0 == opStateExpiryEpochSeconds) { | ||
| return false; | ||
| } | ||
| return System.currentTimeMillis() / 1000 >= opStateExpiryEpochSeconds; | ||
| return Time.monotonicNow() / 1000 >= opStateExpiryEpochSeconds; | ||
|
||
| } | ||
|
|
||
| public boolean isInService() { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -637,7 +637,7 @@ public void testSetNodeOpStateAndCommandFired() | |
| DatanodeDetails dn = HddsTestUtils.createRandomDatanodeAndRegister( | ||
| nodeManager); | ||
|
|
||
| long expiry = System.currentTimeMillis() / 1000 + 1000; | ||
| long expiry = Time.monotonicNow() / 1000 + 1000; | ||
|
||
| nodeManager.setNodeOperationalState(dn, | ||
| HddsProtos.NodeOperationalState.ENTERING_MAINTENANCE, expiry); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unused import