goiri commented on code in PR #6055:
URL: https://github.com/apache/hadoop/pull/6055#discussion_r1327796374


##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/Router.java:
##########
@@ -362,6 +363,72 @@ public FedAppReportFetcher getFetcher() {
     return fetcher;
   }
 
+  @VisibleForTesting
+  public static void removeApplication(Configuration conf, String 
applicationId)
+      throws Exception {
+    FederationStateStoreFacade facade = 
FederationStateStoreFacade.getInstance(conf);
+    ApplicationId removeAppId = ApplicationId.fromString(applicationId);
+    LOG.info("Deleting application {} from state store.", removeAppId);
+    facade.deleteApplicationHomeSubCluster(removeAppId);
+    LOG.info("Application is deleted from state store");
+  }
+
+  private static void handFormatStateStore() {
+    // TODO: YARN-11548. [Federation] Router Supports Format 
FederationStateStore.
+    System.err.println("format-state-store is not yet supported.");
+  }
+
+  private static void handRemoveApplicationFromStateStore(Configuration conf,
+      String applicationId) {
+    try {
+      removeApplication(conf, applicationId);
+      System.out.println("Application " + applicationId + " is deleted from 
state store");
+    } catch (Exception e) {
+      System.err.println("Application " + applicationId + " error, exception = 
" + e);
+    }
+  }
+
+  private static void executeRouterCommand(Configuration conf, String[] args) {
+    Options opts = new Options();
+    Option formatStateStoreOpt = new Option("format-state-store",  false,
+        " Formats the FederationStateStore. " +
+        "This will clear the FederationStateStore and " +
+        "is useful if past applications are no longer needed. " +
+        "This should be run only when the Router is not running.");
+    Option removeApplicationFromStateStoreOpt = new 
Option("remove-application-from-state-store",
+        false, " Remove the application from FederationStateStore. " +
+         " This should be run only when the Router is not running. ");
+    opts.addOption(formatStateStoreOpt);
+    opts.addOption(removeApplicationFromStateStoreOpt);
+
+    String cmd = args[0];
+
+    CommandLine cliParser = null;

Review Comment:
   Move the definition inside of the try.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to