jkosh44 commented on a change in pull request #1052: Issue 1003 - Refactor 
remove and init apis to check if running
URL: https://github.com/apache/fluo/pull/1052#discussion_r223162166
 
 

 ##########
 File path: modules/command/src/main/java/org/apache/fluo/command/FluoInit.java
 ##########
 @@ -134,65 +135,60 @@ public static void main(String[] args) {
 
     try (FluoAdminImpl admin = new FluoAdminImpl(config)) {
 
-      if (admin.applicationRunning()) {
-        System.err.println("Error - The Fluo '" + config.getApplicationName() 
+ "' application"
-            + " is already running and must be stopped before running 'fluo 
init'. "
-            + " Aborted initialization.");
-        System.exit(-1);
-      }
-
       FluoAdmin.InitializationOptions initOpts = new 
FluoAdmin.InitializationOptions();
 
       if (opts.getUpdate()) {
         System.out.println("Updating configuration for the Fluo '" + 
config.getApplicationName()
             + "' application in Zookeeper using " + opts.getAppPropsPath());
-        admin.updateSharedConfig();
-        System.out.println("Update is complete.");
-        System.exit(0);
-      }
-
-      if (opts.getForce()) {
-        initOpts.setClearZookeeper(true).setClearTable(true);
+        initOpts.setUpdateWithoutInitializing(true);
 
 Review comment:
   I don't see any explicit check in `updateSharedConfig()` to see if the 
application is already running. I ran the following test in `FluoAdminImplIT` 
to see
   ```
   @Test
     public void test() throws Exception {
   
       FluoConfiguration localConfig = new FluoConfiguration(config);
       localConfig.setProperty("fluo.test123", 
"${fluo.connection.application.name}");
       Assert.assertEquals(localConfig.getApplicationName(), 
localConfig.getString("fluo.test123"));
   
       try (FluoAdmin admin = new FluoAdminImpl(localConfig)) {
   
         InitializationOptions opts =
             new 
InitializationOptions().setClearZookeeper(true).setClearTable(true);
         // admin.initialize(opts);
         Thread.sleep(20000);
   
         admin.updateSharedConfig();
       }
     }
   ```
   With `admin.initialize(opts);` commented out it passes, but with that line 
not commented out it fails due to an `AlreadyInitializedException` (from within 
`admin.initialize()`).
   
   I can add an `applicationRunning()` check to the beginning of 
`updateSharedConfiguration()`. Do we want to limit calling that method on only 
stopped applications?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to