Merge pull request #1 from mikewalch/999-review
Changes from review
diff --git a/modules/api/src/main/java/org/apache/fluo/api/client/FluoAdmin.java b/modules/api/src/main/java/org/apache/fluo/api/client/FluoAdmin.java
index 12f43f7..d1a0db4 100644
--- a/modules/api/src/main/java/org/apache/fluo/api/client/FluoAdmin.java
+++ b/modules/api/src/main/java/org/apache/fluo/api/client/FluoAdmin.java
@@ -120,12 +120,11 @@
throws AlreadyInitializedException, TableExistsException;
/**
- * Removes Fluo application and shared configuration in Zookeeper. Shared configuration
+ * Removes Fluo application, Accumulo table and shared configuration in Zookeeper. Shared configuration
* consists of all properties except those with
* {@value org.apache.fluo.api.config.FluoConfiguration#CONNECTION_PREFIX} prefix.
*/
- void remove(InitializationOptions opts)
- throws AlreadyInitializedException, TableExistsException;
+ void remove();
/**
* Updates shared configuration in Zookeeper. Shared configuration consists of all properties
diff --git a/modules/command/src/main/java/org/apache/fluo/command/FluoRemove.java b/modules/command/src/main/java/org/apache/fluo/command/FluoRemove.java
index 2feb0e7..0c337d2 100644
--- a/modules/command/src/main/java/org/apache/fluo/command/FluoRemove.java
+++ b/modules/command/src/main/java/org/apache/fluo/command/FluoRemove.java
@@ -15,71 +15,30 @@
package org.apache.fluo.command;
-import java.io.File;
-
-import com.beust.jcommander.Parameter;
-import com.google.common.base.Preconditions;
-import org.apache.fluo.api.client.FluoAdmin;
import org.apache.fluo.api.config.FluoConfiguration;
import org.apache.fluo.core.client.FluoAdminImpl;
public class FluoRemove {
- public static class RemoveOptions extends CommonOpts {
-
- @Parameter(names = "-p", required = true, description = "Path to application properties file")
- private String appPropsPath;
-
- String getAppPropsPath() {
- return appPropsPath;
- }
-
- public static RemoveOptions parse(String[] args) {
- RemoveOptions opts = new RemoveOptions();
- parse("fluo remove", opts, args);
- return opts;
- }
- }
-
public static void main(String[] args) {
- RemoveOptions opts = RemoveOptions.parse(args);
- File applicationPropsFile = new File(opts.getAppPropsPath());
- Preconditions.checkArgument(applicationPropsFile.exists(),
- opts.getAppPropsPath() + " does not exist");
+
+ CommonOpts opts = CommonOpts.parse("fluo remove", args);
FluoConfiguration config = CommandUtil.resolveFluoConfig();
- config.load(applicationPropsFile);
config.setApplicationName(opts.getApplicationName());
opts.overrideFluoConfig(config);
-
- if (!config.hasRequiredAdminProps()) {
- System.err.println("Error - Required properties are not set in " + opts.getAppPropsPath());
- System.exit(-1);
- }
- try {
- config.validate();
- } catch (Exception e) {
- System.err.println("Error - Invalid configuration due to " + e.getMessage());
- System.exit(-1);
- }
+ config = FluoAdminImpl.mergeZookeeperConfig(config);
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 remove'. "
+ " Aborted remove.");
System.exit(-1);
}
-
- FluoAdmin.InitializationOptions initOpts = new FluoAdmin.InitializationOptions();
- initOpts.setClearZookeeper(true).setClearTable(true);
- initOpts.setClearTable(true);
-
- System.out.println("Removing Fluo '" + config.getApplicationName() + "' application using "
- + opts.getAppPropsPath());
+ System.out.println("Removing Fluo '" + config.getApplicationName());
try {
- admin.remove(initOpts);
+ admin.remove();
} catch (Exception e) {
System.out.println("Remove failed due to the following exception:");
e.printStackTrace();
diff --git a/modules/core/src/main/java/org/apache/fluo/core/client/FluoAdminImpl.java b/modules/core/src/main/java/org/apache/fluo/core/client/FluoAdminImpl.java
index 25bb839..5d29cdb 100644
--- a/modules/core/src/main/java/org/apache/fluo/core/client/FluoAdminImpl.java
+++ b/modules/core/src/main/java/org/apache/fluo/core/client/FluoAdminImpl.java
@@ -202,8 +202,7 @@
}
@Override
- public void remove(InitializationOptions opts)
- throws AlreadyInitializedException, TableExistsException {
+ public void remove() {
if (!config.hasRequiredAdminProps()) {
throw new IllegalArgumentException("Admin configuration is missing required properties");
}
diff --git a/modules/distribution/src/main/scripts/fluo b/modules/distribution/src/main/scripts/fluo
index 7239159..03f6d13 100755
--- a/modules/distribution/src/main/scripts/fluo
+++ b/modules/distribution/src/main/scripts/fluo
@@ -66,7 +66,7 @@
echo -e "Usage: fluo <command> (<argument> ...)\n"
echo -e "Possible commands:\n"
echo " init -a <app> -p <appProps> Initializes Fluo application for <app> using <appProps>. Run with -h to see additional args."
- echo " remove -a <app> -p <appProps> Removes Fluo application for <app> using <appProps>."
+ echo " remove -a <app> Removes Fluo application for <app>"
echo " classpath Prints the classpath setup in fluo-env.sh"
echo " config -a <app> Prints application configuration stored in Zookeeper for <app>"
echo " get-jars -a <app> -d <dir> Copies <app> jars from DFS to local <dir>"
@@ -186,23 +186,11 @@
fi
;;
remove)
- if [ -f "$FLUO_CONN_PROPS" ]; then
- if [[ $2 = *"-h"* ]]; then
- $JAVA org.apache.fluo.command.FluoRemove -h
- exit 0
- fi
- init_dir=$($JAVA org.apache.fluo.command.FluoInit "${@:2}" --retrieveProperty fluo.observer.init.dir)
- if [ -d "$init_dir" ]; then
- echo "Adding $init_dir/* to CLASSPATH"
- export CLASSPATH="$init_dir/*:$CLASSPATH"
- fi
- $JAVA org.apache.fluo.command.FluoRemove "${@:2}"
- else
- deprecated_verify_full "$2"
- check_hadoop
- export CLASSPATH="$APP_LIB_DIR/*:$CLASSPATH"
- java org.apache.fluo.cluster.command.FluoCommand "$basedir" "$HADOOP_PREFIX" "$@"
+ if [[ $2 = *"-h"* ]]; then
+ $JAVA org.apache.fluo.command.FluoRemove -h
+ exit 0
fi
+ $JAVA org.apache.fluo.command.FluoRemove "${@:2}"
;;
oracle)
if [[ $2 = *"-h"* ]]; then