YarnTwillRunnerService yarnRunner = (YarnTwillRunnerService) runner;
prevJVMOptions = yarnRunner.getJVMOptions() != null ? yarnRunner.getJVMOptions() : "";
yarnRunner.setJVMOptions(prevJVMOptions + " -verbose:gc -Xloggc:gc.log -XX:+PrintGCDetails");
}
TwillController controller = runner.prepare(new LocalFileApplication())
.withApplicationArguments("local")
.withArguments("LocalFileSocketServer", "local2")
.addLogHandler(new PrinterLogHandler(new PrintWriter(System.out, true)))
.start();
if (runner instanceof YarnTwillRunnerService) {
((YarnTwillRunnerService) runner).setJVMOptions(prevJVMOptions);
}
Iterable<Discoverable> discoverables = controller.discoverService("local");
Assert.assertTrue(YarnTestUtils.waitForSize(discoverables, 1, 60));
InetSocketAddress socketAddress = discoverables.iterator().next().getSocketAddress();
Socket socket = new Socket(socketAddress.getAddress(), socketAddress.getPort());
try {
PrintWriter writer = new PrintWriter(new OutputStreamWriter(socket.getOutputStream(), Charsets.UTF_8), true);
LineReader reader = new LineReader(new InputStreamReader(socket.getInputStream(), Charsets.UTF_8));
String msg = "Local file test";
writer.println(msg);
Assert.assertEquals(header, reader.readLine());
Assert.assertEquals(msg, reader.readLine());
} finally {
socket.close();
}
controller.stopAndWait();
Assert.assertTrue(YarnTestUtils.waitForSize(discoverables, 0, 60));
TimeUnit.SECONDS.sleep(2);
}