Fixup 143f4f13 Display the daemon id and shorten it a bit #314

This commit is contained in:
Peter Palaga
2021-01-08 23:19:40 +01:00
parent 143f4f13ab
commit ddea5d8ea8
22 changed files with 114 additions and 113 deletions

View File

@@ -666,7 +666,7 @@ public class DaemonMavenCli {
eventSpyDispatcher.onEvent(request);
slf4jLogger.info(buffer().a("Processing build on daemon ")
.strong(Environment.MVND_UID.asString()).toString());
.strong(Environment.MVND_ID.asString()).toString());
MavenExecutionResult result = maven.execute(request);

View File

@@ -100,7 +100,7 @@ public class DaemonExpiration {
static DaemonExpirationStrategy notMostRecentlyUsed() {
return daemon -> daemon.getRegistry().getIdle().stream()
.max(Comparator.comparingLong(DaemonInfo::getLastBusy))
.map(d -> Objects.equals(d.getUid(), daemon.getUid()))
.map(d -> Objects.equals(d.getId(), daemon.getDaemonId()))
.orElse(false)
? new DaemonExpirationResult(GRACEFUL_EXPIRE, "not recently used")
: NOT_TRIGGERED;
@@ -111,7 +111,7 @@ public class DaemonExpiration {
try {
if (!Files.isReadable(daemon.getRegistry().getRegistryFile())) {
return new DaemonExpirationResult(GRACEFUL_EXPIRE, "after the daemon registry became unreadable");
} else if (daemon.getRegistry().get(daemon.getUid()) == null) {
} else if (daemon.getRegistry().get(daemon.getDaemonId()) == null) {
return new DaemonExpirationResult(GRACEFUL_EXPIRE,
"after the daemon was no longer found in the daemon registry");
} else {

View File

@@ -73,7 +73,7 @@ public class Server implements AutoCloseable, Runnable {
private static final Logger LOGGER = LoggerFactory.getLogger(Server.class);
public static final int CANCEL_TIMEOUT = 10 * 1000;
private final String uid;
private final String daemonId;
private final boolean noDaemon;
private final ServerSocketChannel socket;
private final DaemonMavenCli cli;
@@ -105,7 +105,7 @@ public class Server implements AutoCloseable, Runnable {
} catch (Throwable t) {
LOGGER.warn("Unable to ignore INT and TSTP signals", t);
}
this.uid = Environment.MVND_UID.asString();
this.daemonId = Environment.MVND_ID.asString();
this.noDaemon = Environment.MVND_NO_DAEMON.asBoolean();
this.keepAliveMs = Environment.MVND_KEEP_ALIVE.asDuration().toMillis();
@@ -126,7 +126,7 @@ public class Server implements AutoCloseable, Runnable {
"\n ", "Initializing daemon with properties:\n ", "\n")));
}
long cur = System.currentTimeMillis();
info = new DaemonInfo(uid,
info = new DaemonInfo(daemonId,
Environment.MVND_JAVA_HOME.asString(),
Environment.MVND_HOME.asString(),
DaemonRegistry.getProcessId(),
@@ -200,7 +200,7 @@ public class Server implements AutoCloseable, Runnable {
} catch (Throwable t) {
LOGGER.error("Error running daemon loop", t);
} finally {
registry.remove(uid);
registry.remove(daemonId);
}
}
@@ -283,7 +283,7 @@ public class Server implements AutoCloseable, Runnable {
private void onExpire(String reason, DaemonExpirationStatus status) {
LOGGER.debug("Storing daemon stop event: {}", reason);
registry.storeStopEvent(new DaemonStopEvent(uid, System.currentTimeMillis(), status, reason));
registry.storeStopEvent(new DaemonStopEvent(daemonId, System.currentTimeMillis(), status, reason));
}
boolean awaitStop() {
@@ -616,8 +616,8 @@ public class Server implements AutoCloseable, Runnable {
return info;
}
public String getUid() {
return info.getUid();
public String getDaemonId() {
return info.getId();
}
public DaemonState getState() {