use of org.gradle.internal.remote.ConnectionAcceptor in project gradle by gradle.
the class DefaultWorkerProcessBuilder method build.
@Override
public WorkerProcess build() {
final WorkerJvmMemoryStatus memoryStatus = shouldPublishJvmMemoryInfo ? new WorkerJvmMemoryStatus() : null;
final DefaultWorkerProcess workerProcess = new DefaultWorkerProcess(connectTimeoutSeconds, TimeUnit.SECONDS, memoryStatus);
ConnectionAcceptor acceptor = server.accept(new Action<ObjectConnection>() {
public void execute(final ObjectConnection connection) {
workerProcess.onConnect(connection, new Runnable() {
@Override
public void run() {
DefaultWorkerLoggingProtocol defaultWorkerLoggingProtocol = new DefaultWorkerLoggingProtocol(outputEventListener);
connection.useParameterSerializers(WorkerLoggingSerializer.create());
connection.addIncoming(WorkerLoggingProtocol.class, defaultWorkerLoggingProtocol);
if (shouldPublishJvmMemoryInfo) {
connection.useParameterSerializers(WorkerJvmMemoryInfoSerializer.create());
connection.addIncoming(WorkerJvmMemoryInfoProtocol.class, memoryStatus);
}
}
});
}
});
workerProcess.startAccepting(acceptor);
Address localAddress = acceptor.getAddress();
// Build configuration for GradleWorkerMain
Object id = idGenerator.generateId();
String displayName = getBaseName() + " " + id;
LOGGER.debug("Creating {}", displayName);
LOGGER.debug("Using application classpath {}", applicationClasspath);
LOGGER.debug("Using implementation classpath {}", implementationClassPath);
JavaExecHandleBuilder javaCommand = getJavaCommand();
javaCommand.setDisplayName(displayName);
workerImplementationFactory.prepareJavaCommand(id, displayName, this, implementationClassPath, localAddress, javaCommand, shouldPublishJvmMemoryInfo);
javaCommand.args("'" + displayName + "'");
ExecHandle execHandle = javaCommand.build();
workerProcess.setExecHandle(execHandle);
return new MemoryRequestingWorkerProcess(workerProcess, memoryManager, MemoryAmount.parseNotation(javaCommand.getMinHeapSize()));
}
use of org.gradle.internal.remote.ConnectionAcceptor in project gradle by gradle.
the class TcpIncomingConnector method accept.
public ConnectionAcceptor accept(Action<ConnectCompletion> action, boolean allowRemote) {
final ServerSocketChannel serverSocket;
int localPort;
try {
serverSocket = ServerSocketChannel.open();
serverSocket.socket().bind(new InetSocketAddress(addressFactory.getLocalBindingAddress(), 0));
localPort = serverSocket.socket().getLocalPort();
} catch (Exception e) {
throw UncheckedException.throwAsUncheckedException(e);
}
UUID id = idGenerator.generateId();
List<InetAddress> addresses = addressFactory.getCommunicationAddresses();
final Address address = new MultiChoiceAddress(id, localPort, addresses);
LOGGER.debug("Listening on {}.", address);
final StoppableExecutor executor = executorFactory.create("Incoming " + (allowRemote ? "remote" : "local") + " TCP Connector on port " + localPort);
executor.execute(new Receiver(serverSocket, action, allowRemote));
return new ConnectionAcceptor() {
public Address getAddress() {
return address;
}
public void requestStop() {
CompositeStoppable.stoppable(serverSocket).stop();
}
public void stop() {
requestStop();
executor.stop();
}
};
}
Aggregations