Search in sources :

Example 1 with DaemonStopEvent

use of org.gradle.launcher.daemon.registry.DaemonStopEvent in project gradle by gradle.

the class DefaultDaemonConnector method handleStopEvents.

private void handleStopEvents(Collection<DaemonInfo> idleDaemons, Collection<DaemonInfo> busyDaemons) {
    final List<DaemonStopEvent> stopEvents = daemonRegistry.getStopEvents();
    // Clean up old stop events
    daemonRegistry.removeStopEvents(DaemonStopEvents.oldStopEvents(stopEvents));
    final List<DaemonStopEvent> recentStopEvents = DaemonStopEvents.uniqueRecentDaemonStopEvents(stopEvents);
    for (DaemonStopEvent stopEvent : recentStopEvents) {
        Long pid = stopEvent.getPid();
        LOGGER.info("Previous Daemon (" + (pid == null ? "PID unknown" : pid) + ") stopped at " + stopEvent.getTimestamp() + " " + stopEvent.getReason());
    }
    LOGGER.lifecycle(DaemonStartupMessage.generate(busyDaemons.size(), idleDaemons.size(), recentStopEvents.size()));
}
Also used : DaemonStopEvent(org.gradle.launcher.daemon.registry.DaemonStopEvent)

Example 2 with DaemonStopEvent

use of org.gradle.launcher.daemon.registry.DaemonStopEvent 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 3 with DaemonStopEvent

use of org.gradle.launcher.daemon.registry.DaemonStopEvent in project gradle by gradle.

the class ReportDaemonStatusClient method printStoppedDaemons.

@VisibleForTesting
void printStoppedDaemons(final List<DaemonStopEvent> stopEvents) {
    if (!stopEvents.isEmpty()) {
        for (DaemonStopEvent event : stopEvents) {
            Long pid = event.getPid();
            LOGGER.quiet(String.format(STATUS_FORMAT, pid == null ? "PID unknown" : pid, "STOPPED", "(" + event.getReason() + ")"));
        }
    }
}
Also used : DaemonStopEvent(org.gradle.launcher.daemon.registry.DaemonStopEvent) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 4 with DaemonStopEvent

use of org.gradle.launcher.daemon.registry.DaemonStopEvent in project gradle by gradle.

the class DaemonRegistryUpdater method onExpire.

public void onExpire(String reason, DaemonExpirationStatus status) {
    LOGGER.debug("Storing daemon stop event: {}", reason);
    final Date timestamp = new Date(System.currentTimeMillis());
    daemonRegistry.storeStopEvent(new DaemonStopEvent(timestamp, daemonContext.getPid(), status, reason));
}
Also used : DaemonStopEvent(org.gradle.launcher.daemon.registry.DaemonStopEvent) Date(java.util.Date)

Aggregations

DaemonStopEvent (org.gradle.launcher.daemon.registry.DaemonStopEvent)4 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Date (java.util.Date)1 ReportStatus (org.gradle.launcher.daemon.protocol.ReportStatus)1 Status (org.gradle.launcher.daemon.protocol.Status)1 DaemonInfo (org.gradle.launcher.daemon.registry.DaemonInfo)1