Search in sources :

Example 1 with DaemonStartupInfo

use of org.gradle.launcher.daemon.diagnostics.DaemonStartupInfo in project gradle by gradle.

the class DaemonStartupCommunication method readDiagnostics.

public DaemonStartupInfo readDiagnostics(String message) {
    //Assuming the message has correct format. Not bullet proof, but seems to work ok for now.
    if (!message.startsWith(daemonGreeting())) {
        throw new IllegalArgumentException(String.format("Unexpected daemon startup message: %s", message));
    }
    try {
        String encoded = message.substring(daemonGreeting().length()).trim();
        InputStream inputStream = new EncodedStream.EncodedInput(new ByteArrayInputStream(encoded.getBytes()));
        Decoder decoder = new InputStreamBackedDecoder(inputStream);
        String pidString = decoder.readNullableString();
        String uid = decoder.readString();
        Long pid = pidString == null ? null : Long.valueOf(pidString);
        Address address = new MultiChoiceAddressSerializer().read(decoder);
        File daemonLog = new File(decoder.readString());
        return new DaemonStartupInfo(uid, address, new DaemonDiagnostics(daemonLog, pid));
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
Also used : InputStreamBackedDecoder(org.gradle.internal.serialize.InputStreamBackedDecoder) Address(org.gradle.internal.remote.Address) MultiChoiceAddress(org.gradle.internal.remote.internal.inet.MultiChoiceAddress) UncheckedIOException(org.gradle.api.UncheckedIOException) UncheckedIOException(org.gradle.api.UncheckedIOException) Decoder(org.gradle.internal.serialize.Decoder) InputStreamBackedDecoder(org.gradle.internal.serialize.InputStreamBackedDecoder) DaemonStartupInfo(org.gradle.launcher.daemon.diagnostics.DaemonStartupInfo) DaemonDiagnostics(org.gradle.launcher.daemon.diagnostics.DaemonDiagnostics) MultiChoiceAddressSerializer(org.gradle.internal.remote.internal.inet.MultiChoiceAddressSerializer)

Example 2 with DaemonStartupInfo

use of org.gradle.launcher.daemon.diagnostics.DaemonStartupInfo in project gradle by gradle.

the class DefaultDaemonConnector method startDaemon.

public DaemonClientConnection startDaemon(ExplainingSpec<DaemonContext> constraint) {
    ProgressLogger progressLogger = progressLoggerFactory.newOperation(DefaultDaemonConnector.class).start("Starting Gradle Daemon", "Starting Daemon");
    final DaemonStartupInfo startupInfo = daemonStarter.startDaemon();
    LOGGER.debug("Started Gradle daemon {}", startupInfo);
    CountdownTimer timer = Timers.startTimer(connectTimeout);
    try {
        do {
            DaemonClientConnection daemonConnection = connectToDaemonWithId(startupInfo, constraint);
            if (daemonConnection != null) {
                startListener.daemonStarted(daemonConnection.getDaemon());
                return daemonConnection;
            }
            try {
                sleep(200L);
            } catch (InterruptedException e) {
                throw UncheckedException.throwAsUncheckedException(e);
            }
        } while (!timer.hasExpired());
    } finally {
        progressLogger.completed();
    }
    throw new DaemonConnectionException("Timeout waiting to connect to the Gradle daemon.\n" + startupInfo.describe());
}
Also used : CountdownTimer(org.gradle.internal.time.CountdownTimer) DaemonStartupInfo(org.gradle.launcher.daemon.diagnostics.DaemonStartupInfo) ProgressLogger(org.gradle.internal.logging.progress.ProgressLogger)

Aggregations

DaemonStartupInfo (org.gradle.launcher.daemon.diagnostics.DaemonStartupInfo)2 UncheckedIOException (org.gradle.api.UncheckedIOException)1 ProgressLogger (org.gradle.internal.logging.progress.ProgressLogger)1 Address (org.gradle.internal.remote.Address)1 MultiChoiceAddress (org.gradle.internal.remote.internal.inet.MultiChoiceAddress)1 MultiChoiceAddressSerializer (org.gradle.internal.remote.internal.inet.MultiChoiceAddressSerializer)1 Decoder (org.gradle.internal.serialize.Decoder)1 InputStreamBackedDecoder (org.gradle.internal.serialize.InputStreamBackedDecoder)1 CountdownTimer (org.gradle.internal.time.CountdownTimer)1 DaemonDiagnostics (org.gradle.launcher.daemon.diagnostics.DaemonDiagnostics)1