[GitHub] twill pull request #53: (TWILL-230) Get resource report based on the caller ...

2017-04-03 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/twill/pull/53


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] twill pull request #53: (TWILL-230) Get resource report based on the caller ...

2017-04-03 Thread chtyim
Github user chtyim commented on a diff in the pull request:

https://github.com/apache/twill/pull/53#discussion_r109553180
  
--- Diff: 
twill-yarn/src/main/java/org/apache/twill/yarn/YarnTwillController.java ---
@@ -322,7 +314,46 @@ private boolean hasRun(YarnApplicationState state) {
 
   @Override
   public ResourceReport getResourceReport() {
-// in case the user calls this before starting, return null
+// Only has resource report if the app is running.
+if (state() != State.RUNNING) {
+  return null;
+}
+ResourceReportClient resourcesClient = getResourcesClient();
 return (resourcesClient == null) ? null : resourcesClient.get();
   }
+
+  /**
+   * Returns the {@link ResourceReportClient} for fetching resource report 
from the AM.
+   * It first consults the RM for the tracking URL and get the resource 
report from there.
+   */
+  @Nullable
+  private ResourceReportClient getResourcesClient() {
+YarnApplicationReport report = processController.getReport();
+List urls = new ArrayList<>(2);
--- End diff --

Because we store the tracking URL and the original tracking URL.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] twill pull request #53: (TWILL-230) Get resource report based on the caller ...

2017-04-03 Thread yaojiefeng
Github user yaojiefeng commented on a diff in the pull request:

https://github.com/apache/twill/pull/53#discussion_r109552373
  
--- Diff: 
twill-yarn/src/main/java/org/apache/twill/yarn/YarnTwillController.java ---
@@ -322,7 +314,46 @@ private boolean hasRun(YarnApplicationState state) {
 
   @Override
   public ResourceReport getResourceReport() {
-// in case the user calls this before starting, return null
+// Only has resource report if the app is running.
+if (state() != State.RUNNING) {
+  return null;
+}
+ResourceReportClient resourcesClient = getResourcesClient();
 return (resourcesClient == null) ? null : resourcesClient.get();
   }
+
+  /**
+   * Returns the {@link ResourceReportClient} for fetching resource report 
from the AM.
+   * It first consults the RM for the tracking URL and get the resource 
report from there.
+   */
+  @Nullable
+  private ResourceReportClient getResourcesClient() {
+YarnApplicationReport report = processController.getReport();
+List urls = new ArrayList<>(2);
--- End diff --

Why will this url list has initial capacity of 2?


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---