use of org.gradle.launcher.daemon.protocol.ReportStatus in project gradle by gradle.
the class ReportDaemonStatusClient method listAll.
public void listAll() {
final List<DaemonInfo> daemons = daemonRegistry.getAll();
final List<Status> statuses = Lists.newArrayList();
for (DaemonInfo daemon : daemons) {
DaemonClientConnection connection = connector.maybeConnect(daemon);
if (connection != null) {
try {
final ReportStatus statusCommand = new ReportStatus(idGenerator.generateId(), daemon.getToken());
final Status status = reportStatusDispatcher.dispatch(connection, statusCommand);
if (status != null) {
statuses.add(status);
} else {
// Handle failure
statuses.add(new Status(connection.getDaemon().getPid(), "UNKNOWN", "UNKNOWN"));
}
} finally {
connection.stop();
}
}
}
final List<DaemonStopEvent> stopEvents = DaemonStopEvents.uniqueRecentDaemonStopEvents(daemonRegistry.getStopEvents());
if (statuses.isEmpty()) {
LOGGER.quiet(DaemonMessages.NO_DAEMONS_RUNNING);
}
if (!(statuses.isEmpty() && stopEvents.isEmpty())) {
LOGGER.quiet(String.format(STATUS_FORMAT, "PID", "STATUS", "INFO"));
}
printRunningDaemons(statuses);
printStoppedDaemons(stopEvents);
LOGGER.quiet("");
LOGGER.quiet(STATUS_FOOTER + " See " + documentationRegistry.getDocumentationFor("gradle_daemon", "sec:status"));
}
use of org.gradle.launcher.daemon.protocol.ReportStatus in project gradle by gradle.
the class HandleReportStatus method execute.
@Override
public void execute(DaemonCommandExecution execution) {
if (execution.getCommand() instanceof ReportStatus) {
String version = GradleVersion.current().getVersion();
String status = execution.getDaemonStateControl().getState().toString().toUpperCase();
Status message = new Status(execution.getDaemonContext().getPid(), version, status);
execution.getConnection().completed(new Success(message));
} else {
execution.proceed();
}
}
Aggregations