Skip to content
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

Use monotonic clocks for Q2. #419

Open
wants to merge 1 commit into
base: tail
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions jpos/src/main/java/org/jpos/q2/Q2.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
import java.nio.file.WatchService;
import java.security.GeneralSecurityException;
import java.time.Duration;
import java.time.Instant;
import java.util.*;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -116,7 +115,7 @@ public class Q2 implements FileFilter, Runnable {
private String[] args;
private boolean hasSystemLogger;
private boolean exit;
private Instant startTime;
private Duration startTime;
private CLI cli;
private boolean recursive;
private ConfigDecorationProvider decorator=null;
Expand All @@ -126,7 +125,7 @@ public class Q2 implements FileFilter, Runnable {
private BundleContext bundleContext;
private String pidFile;
private String name = JMX_NAME;
private long lastVersionLog;
private Duration lastVersionLog = Duration.ZERO;
private String watchServiceClassname;
private boolean enableSsh;
private boolean disableDeployScan;
Expand All @@ -142,7 +141,7 @@ public class Q2 implements FileFilter, Runnable {
public Q2 (String[] args, BundleContext bundleContext) {
super();
this.args = args;
startTime = Instant.now();
startTime = Duration.ofNanos(System.nanoTime());
instanceId = UUID.randomUUID();
parseCmdLine (args);
libDir = new File (deployDir, "lib");
Expand Down Expand Up @@ -673,7 +672,7 @@ public MBeanServer getMBeanServer () {
return server;
}
public long getUptime() {
return Duration.between(startTime, Instant.now()).toMillis();
return Duration.ofNanos(System.nanoTime()).minus(startTime).toMillis();
}
public void displayVersion () {
System.out.println(getVersionString());
Expand Down Expand Up @@ -985,8 +984,8 @@ private void initConfigDecorator()
}
}
private void logVersion () {
long now = System.currentTimeMillis();
if (now - lastVersionLog > 86400000L) {
Duration now = Duration.ofNanos(System.nanoTime());
if (now.minus(lastVersionLog).compareTo(Duration.ofDays(1)) > 0) {
LogEvent evt = getLog().createLogEvent("version");
evt.addMessage(getVersionString());
Logger.log(evt);
Expand Down