use of org.gradle.internal.remote.internal.inet.MultiChoiceAddress in project gradle by gradle.
the class SystemApplicationClassLoaderWorker method call.
public Void call() throws Exception {
if (System.getProperty("org.gradle.worker.test.stuck") != null) {
// Simulate a stuck worker. There's probably a way to inject this failure...
Thread.sleep(30000);
return null;
}
Decoder decoder = new InputStreamBackedDecoder(configInputStream);
// Read logging config and setup logging
int logLevel = decoder.readSmallInt();
LoggingManagerInternal loggingManager = createLoggingManager();
loggingManager.setLevelInternal(LogLevel.values()[logLevel]).start();
// Read whether process info should be published
boolean shouldPublishJvmMemoryInfo = decoder.readBoolean();
// Read path to Gradle user home
String gradleUserHomeDirPath = decoder.readString();
File gradleUserHomeDir = new File(gradleUserHomeDirPath);
// Read server address and start connecting
MultiChoiceAddress serverAddress = new MultiChoiceAddressSerializer().read(decoder);
MessagingServices messagingServices = new MessagingServices();
final WorkerServices workerServices = new WorkerServices(messagingServices, gradleUserHomeDir);
ObjectConnection connection = null;
WorkerLogEventListener workerLogEventListener = null;
try {
// Read serialized worker
byte[] serializedWorker = decoder.readBinary();
// Deserialize the worker action
Action<WorkerContext> action;
try {
ObjectInputStream instr = new ClassLoaderObjectInputStream(new ByteArrayInputStream(serializedWorker), getClass().getClassLoader());
action = (Action<WorkerContext>) instr.readObject();
} catch (Exception e) {
throw UncheckedException.throwAsUncheckedException(e);
}
connection = messagingServices.get(MessagingClient.class).getConnection(serverAddress);
workerLogEventListener = configureLogging(loggingManager, connection);
if (shouldPublishJvmMemoryInfo) {
configureWorkerJvmMemoryInfoEvents(workerServices, connection);
}
final ObjectConnection serverConnection = connection;
action.execute(new WorkerContext() {
public ClassLoader getApplicationClassLoader() {
return ClassLoader.getSystemClassLoader();
}
@Override
public ObjectConnection getServerConnection() {
return serverConnection;
}
@Override
public ServiceRegistry getServiceRegistry() {
return workerServices;
}
});
} finally {
if (workerLogEventListener != null) {
loggingManager.removeOutputEventListener(workerLogEventListener);
}
if (connection != null) {
connection.stop();
}
messagingServices.close();
loggingManager.stop();
}
return null;
}
use of org.gradle.internal.remote.internal.inet.MultiChoiceAddress in project gradle by gradle.
the class DaemonStartupCommunication method printDaemonStarted.
public void printDaemonStarted(PrintStream target, Long pid, String uid, Address address, File daemonLog) {
target.print(daemonGreeting());
// Encode as ascii
try {
OutputStream outputStream = new EncodedStream.EncodedOutput(target);
FlushableEncoder encoder = new OutputStreamBackedEncoder(outputStream);
encoder.writeNullableString(pid == null ? null : pid.toString());
encoder.writeString(uid);
MultiChoiceAddress multiChoiceAddress = (MultiChoiceAddress) address;
new MultiChoiceAddressSerializer().write(encoder, multiChoiceAddress);
encoder.writeString(daemonLog.getPath());
encoder.flush();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
target.println();
// ibm vm 1.6 + windows XP gotchas:
// we need to print something else to the stream after we print the daemon greeting.
// without it, the parent hangs without receiving the message above (flushing does not help).
LOGGER.debug("Completed writing the daemon greeting. Closing streams...");
// btw. the ibm vm+winXP also has some issues detecting closed streams by the child but we handle this problem differently.
}
Aggregations