Search in sources :

Example 1 with ReportStatus

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"));
}
Also used : ReportStatus(org.gradle.launcher.daemon.protocol.ReportStatus) Status(org.gradle.launcher.daemon.protocol.Status) DaemonStopEvent(org.gradle.launcher.daemon.registry.DaemonStopEvent) DaemonInfo(org.gradle.launcher.daemon.registry.DaemonInfo) ReportStatus(org.gradle.launcher.daemon.protocol.ReportStatus)

Example 2 with ReportStatus

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();
    }
}
Also used : ReportStatus(org.gradle.launcher.daemon.protocol.ReportStatus) Status(org.gradle.launcher.daemon.protocol.Status) ReportStatus(org.gradle.launcher.daemon.protocol.ReportStatus) Success(org.gradle.launcher.daemon.protocol.Success)

Aggregations

ReportStatus (org.gradle.launcher.daemon.protocol.ReportStatus)2 Status (org.gradle.launcher.daemon.protocol.Status)2 Success (org.gradle.launcher.daemon.protocol.Success)1 DaemonInfo (org.gradle.launcher.daemon.registry.DaemonInfo)1 DaemonStopEvent (org.gradle.launcher.daemon.registry.DaemonStopEvent)1