use of org.jenkinsci.test.acceptance.controller.JenkinsController in project acceptance-test-harness by jenkinsci.
the class JenkinsControllerPoolProcess method processServerSocket.
/**
* Accepts connection to Unix domain socket and hand it off to a connection handling thread.
*/
private void processServerSocket() throws IOException, InterruptedException {
socket.deleteOnExit();
socket.delete();
try (UnixServerSocketChannel channel = UnixServerSocketChannel.open()) {
channel.configureBlocking(true);
channel.socket().bind(new UnixSocketAddress(socket));
System.out.println("JUT Server is ready and listening at " + socket.getAbsolutePath());
while (true) {
final UnixSocketChannel c = channel.accept();
System.out.println("Accepted");
final QueueItem qi = queue.take();
final JenkinsController j = qi.controller;
System.out.println("Handed out " + j.getUrl());
new Thread("Connection handling thread") {
@Override
public void run() {
lifecycle.import_(qi.testScope);
try {
processConnection(c, j);
} finally {
TestCleaner scope = injector.getInstance(TestCleaner.class);
if (scope != null)
scope.performCleanUp();
lifecycle.endTestScope();
}
}
}.start();
}
}
}
Aggregations