Github user hsaputra commented on a diff in the pull request:
https://github.com/apache/incubator-twill/pull/52#discussion_r34516532
--- Diff:
twill-yarn/src/test/java/org/apache/twill/yarn/EchoServerTestRun.java ---
@@ -132,4 +156,51 @@ public void run() {
// Sleep a bit before exiting.
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.
+ *
+ * This method helps validate restart scenario.
+ *
+ * To avoid long sleep if instanceIdToContainerId is passed, then
compare the container ids to ones before.
+ * Otherwise just return the valid resource report.
+ */
+ @Nullable
+ private ResourceReport waitForAfterRestartResourceReport(TwillController
controller, String runnable, long timeout,
+ TimeUnit
timeoutUnit, int numOfResources,
+ @Nullable
Map<Integer, String> instanceIdToContainerId) {
+ Stopwatch stopwatch = new Stopwatch();
+ stopwatch.start();
+ do {
+ ResourceReport report = controller.getResourceReport();
+ if (report == null || report.getRunnableResources(runnable) == null)
{
+ Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
+ } else if (report.getRunnableResources(runnable) == null ||
+ report.getRunnableResources(runnable).size() != numOfResources) {
+ Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
+ } else {
+ if (instanceIdToContainerId == null) {
+ return report;
+ } else {
--- End diff --
Sure, will update the PR
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---