use of org.gradle.launcher.daemon.registry.DaemonDir in project gradle by gradle.
the class DaemonRegistryUnavailableExpirationStrategy method checkExpiration.
@Override
public DaemonExpirationResult checkExpiration() {
try {
final DaemonContext daemonContext = daemon.getDaemonContext();
final File daemonRegistryDir = daemonContext.getDaemonRegistryDir();
if (!new DaemonDir(daemonRegistryDir).getRegistry().canRead()) {
LOG.warn("Daemon registry {} became unreadable. Expiring daemon.", daemonRegistryDir);
return new DaemonExpirationResult(GRACEFUL_EXPIRE, REGISTRY_BECAME_UNREADABLE);
} else {
// Check that given daemon still exists in registry - a daemon registry could be removed and recreated between checks
List<Long> allDaemonPids = Lists.transform(daemon.getDaemonRegistry().getAll(), new Function<DaemonInfo, Long>() {
public Long apply(DaemonInfo info) {
return info.getPid();
}
});
if (!allDaemonPids.contains(daemonContext.getPid())) {
return new DaemonExpirationResult(GRACEFUL_EXPIRE, REGISTRY_ENTRY_UNEXPECTEDLY_LOST);
}
}
} catch (SecurityException se) {
LOG.warn("Daemon registry became inaccessible. Expiring daemon. Error message is '{}'", se.getMessage());
return new DaemonExpirationResult(GRACEFUL_EXPIRE, REGISTRY_BECAME_INACCESSIBLE);
}
return DaemonExpirationResult.NOT_TRIGGERED;
}
Aggregations