[
https://issues.apache.org/jira/browse/TWILL-137?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14596597#comment-14596597
]
ASF GitHub Bot commented on TWILL-137:
--------------------------------------
Github user chtyim commented on a diff in the pull request:
https://github.com/apache/incubator-twill/pull/46#discussion_r32979605
--- Diff:
twill-yarn/src/test/java/org/apache/twill/yarn/LogLevelTestRun.java ---
@@ -68,17 +74,73 @@ public void stop() {
}
}
+ /**
+ * A test TwillApplication to test setting log level to DEBUG.
+ */
+ public static final class LogLevelTestApplication implements
TwillApplication {
+
+ @Override
+ public TwillSpecification configure() {
+ return TwillSpecification.Builder.with()
+ .setName(LogLevelTestApplication.class.getSimpleName())
+ .withRunnable()
+ .add(LogLevelTestRunnable.class.getSimpleName(), new
LogLevelTestRunnable()).noLocalFiles()
+ .anyOrder()
+ .build();
+ }
+ }
+
@Test
public void testDebugLogLevel()throws Exception {
YarnTwillRunnerService runner = getTwillRunner();
runner.start();
- TwillController controller = runner.prepare(new LogLevelTestRunnable())
+ // Set log level to DEBUG
+ TwillController controller = runner.prepare(new
LogLevelTestApplication())
.setLogLevel(LogEntry.Level.DEBUG)
.addLogHandler(new PrinterLogHandler(new PrintWriter(System.out)))
.start();
+ // Lets wait until the service is running
+ final CountDownLatch running = new CountDownLatch(1);
+ controller.onRunning(new Runnable() {
+ @Override
+ public void run() {
+ running.countDown();
+ }
+ }, Threads.SAME_THREAD_EXECUTOR);
+ Assert.assertTrue(running.await(200, TimeUnit.SECONDS));
+
+ String logLevel = waitForLogLevel(controller,
LogLevelTestRunnable.class.getSimpleName(), 30);
+
+ // Verify we got DEBUG log level.
+ Assert.assertEquals(LogEntry.Level.DEBUG.toString(), logLevel);
+
controller.terminate().get(120, TimeUnit.SECONDS);
+
+ // Sleep a bit for full cleanup
+ TimeUnit.SECONDS.sleep(2);
}
+ // Need helper method here to wait for getting resource report because
{@link TwillController#getResourceReport()}
+ // could return null if the application has not fully started.
+ private String waitForLogLevel(TwillController controller, String
runnable, int timeLimit)
--- End diff --
better to take a `long, TimeUnit` for the timeout. Also, you can use guava
`Stopwatch` to help tracking time elapse easier.
> Be able to get log level for each runnable via
> TwillController.getResourceReport
> --------------------------------------------------------------------------------
>
> Key: TWILL-137
> URL: https://issues.apache.org/jira/browse/TWILL-137
> Project: Apache Twill
> Issue Type: Improvement
> Components: api, core
> Reporter: Henry Saputra
> Assignee: Henry Saputra
> Priority: Minor
>
> With TWILL-24 resolved, the client should be able to get the log level for an
> application broken down by each runnable.
> This would involve adding log level to TwillRunResources interface and its
> implementations.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)