taking checkpoint:
git-svn-id: https://asterixdb.googlecode.com/svn/branches/asterix_stabilization_ioc_installer@1307 eaa15691-b419-025a-1212-ee371bd00084
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/AlterCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/AlterCommand.java
index cbea918..7cb15d9 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/AlterCommand.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/AlterCommand.java
@@ -59,7 +59,7 @@
@Option(name = "-h", required = false, usage = "Help")
public boolean help = false;
- @Option(name = "-n", required = false, usage = "Name of Asterix Instance")
+ @Option(name = "-n", required = true, usage = "Name of Asterix Instance")
public String name;
@Option(name = "-conf", required = false, usage = "Path to instance configuration")
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/CommandHandler.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/CommandHandler.java
index 3f07e71..8a9347a 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/CommandHandler.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/CommandHandler.java
@@ -49,8 +49,11 @@
case VALIDATE:
cmd = new ValidateCommand();
break;
- case INIT:
- cmd = new InitializeCommand();
+ case CONFIGURE:
+ cmd = new ConfigureCommand();
+ break;
+ case SHUTDOWN:
+ cmd = new ShutdownCommand();
break;
}
cmd.execute(args);
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/InitializeCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ConfigureCommand.java
similarity index 90%
rename from asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/InitializeCommand.java
rename to asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ConfigureCommand.java
index c175410..597824f 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/InitializeCommand.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ConfigureCommand.java
@@ -14,7 +14,7 @@
import edu.uci.ics.asterix.installer.driver.InstallerDriver;
import edu.uci.ics.asterix.installer.schema.conf.Configuration;
-public class InitializeCommand extends AbstractCommand {
+public class ConfigureCommand extends AbstractCommand {
@Override
protected void execCommand() throws Exception {
@@ -56,15 +56,12 @@
@Override
protected CommandConfig getCommandConfig() {
- return new InitializeConfig();
+ return new ConfigureConfig();
}
- public static void main(String args[]) throws Exception {
- new InitializeCommand().execCommand();
- }
}
-class InitializeConfig implements CommandConfig {
+class ConfigureConfig implements CommandConfig {
@Option(name = "-h", required = false, usage = "Help")
public boolean help = false;
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ICommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ICommand.java
index 0c13db6..5d6d9ac 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ICommand.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ICommand.java
@@ -17,7 +17,7 @@
public interface ICommand {
public enum CommandType {
- CREATE, DELETE, START, STOP, BACKUP, RESTORE, DESCRIBE, ALTER, VALIDATE, INIT
+ CREATE, DELETE, START, STOP, BACKUP, RESTORE, DESCRIBE, ALTER, VALIDATE, CONFIGURE, SHUTDOWN
}
public void execute(String args[]) throws Exception;
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ShutdownCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ShutdownCommand.java
new file mode 100644
index 0000000..a897516
--- /dev/null
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ShutdownCommand.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.installer.command;
+
+import org.kohsuke.args4j.Option;
+
+import edu.uci.ics.asterix.installer.driver.InstallerDriver;
+import edu.uci.ics.asterix.installer.service.ILookupService;
+import edu.uci.ics.asterix.installer.service.ServiceProvider;
+
+public class ShutdownCommand extends AbstractCommand {
+
+ @Override
+ protected void execCommand() throws Exception {
+ ILookupService lookupService = ServiceProvider.INSTANCE.getLookupService();
+ lookupService.stopService(InstallerDriver.getConfiguration());
+ }
+
+ @Override
+ protected CommandConfig getCommandConfig() {
+ return new ShutdownConfig();
+ }
+
+ @Override
+ protected String getUsageDescription() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
+
+class ShutdownConfig implements CommandConfig {
+
+ @Option(name = "-h", required = false, usage = "Help")
+ public boolean help = false;
+
+}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ValidateCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ValidateCommand.java
index 574bfc7..426e1b2 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ValidateCommand.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ValidateCommand.java
@@ -107,7 +107,7 @@
MasterNode masterNode = cluster.getMasterNode();
Node master = new Node(masterNode.getId(), masterNode.getIp(), masterNode.getRam(),
- masterNode.getJavaHome(), masterNode.getLogdir(), null);
+ masterNode.getJavaHome(), masterNode.getLogdir(), null, masterNode.getDebug());
valid = valid & validateNodeConfiguration(master, cluster);
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/driver/InstallerDriver.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/driver/InstallerDriver.java
index 1c2f8fd..d22e9b2 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/driver/InstallerDriver.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/driver/InstallerDriver.java
@@ -102,7 +102,7 @@
if (args.length != 0) {
managixHome = System.getenv(ENV_MANAGIX_HOME);
CommandType cmdType = CommandType.valueOf(args[0].toUpperCase());
- if (!cmdType.equals(CommandType.VALIDATE)) {
+ if (!cmdType.equals(CommandType.VALIDATE) && !cmdType.equals(CommandType.CONFIGURE)) {
initConfig();
}
CommandHandler cmdHandler = new CommandHandler();
@@ -119,7 +119,7 @@
}
private static void printUsage() {
- StringBuffer buffer = new StringBuffer("managix <command> <args>" + "\n");
+ StringBuffer buffer = new StringBuffer("managix <command> <options>" + "\n");
buffer.append("Commands" + "\n");
buffer.append("create " + ":" + " Creates a new asterix instance" + "\n");
buffer.append("delete " + ":" + " Deletes an asterix instance" + "\n");
@@ -130,8 +130,9 @@
buffer.append("alter " + ":" + " Alters the configuration for an existing asterix instance" + "\n");
buffer.append("describe " + ":" + " Describes an existing asterix instance" + "\n");
buffer.append("validate " + ":" + " Validates the installer/cluster configuration" + "\n");
- buffer.append("init " + ":"
- + " Initialize the installer/cluster configuration for local psedu-distributed cluster." + "\n");
+ buffer.append("configure" + ":" + " Auto generate configuration for a local psedu-distributed Asterix instance"
+ + "\n");
+ buffer.append("shutdown " + ":" + " Shutdown the installer service" + "\n");
LOGGER.info(buffer.toString());
}
}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/error/VerificationUtil.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/error/VerificationUtil.java
index 48988e8..7c7a792 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/error/VerificationUtil.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/error/VerificationUtil.java
@@ -101,4 +101,21 @@
instance.setAsterixRuntimeStates(state);
}
+ public static void verifyBackupRestoreConfiguration(String hdfsUrl, String hadoopVersion, String hdfsBackupDir)
+ throws Exception {
+ StringBuffer errorCheck = new StringBuffer();
+ if (hdfsUrl == null || hdfsUrl.length() == 0) {
+ errorCheck.append("\n HDFS Url not configured");
+ }
+ if (hadoopVersion == null || hadoopVersion.length() == 0) {
+ errorCheck.append("\n HDFS version not configured");
+ }
+ if (hdfsBackupDir == null || hdfsBackupDir.length() == 0) {
+ errorCheck.append("\n HDFS backup directory not configured");
+ }
+ if (errorCheck.length() > 0) {
+ throw new Exception("Incomplete hdfs configuration in " + InstallerDriver.getManagixHome() + File.separator
+ + InstallerDriver.MANAGIX_CONF_XML + errorCheck);
+ }
+ }
}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/events/PatternCreator.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/events/PatternCreator.java
index 9db74b0..695a8d6 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/events/PatternCreator.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/events/PatternCreator.java
@@ -30,6 +30,7 @@
import edu.uci.ics.asterix.event.schema.pattern.Value;
import edu.uci.ics.asterix.installer.command.StopCommand;
import edu.uci.ics.asterix.installer.driver.InstallerDriver;
+import edu.uci.ics.asterix.installer.error.VerificationUtil;
import edu.uci.ics.asterix.installer.model.AsterixInstance;
import edu.uci.ics.asterix.installer.service.ILookupService;
import edu.uci.ics.asterix.installer.service.ServiceProvider;
@@ -103,6 +104,7 @@
String hdfsUrl = InstallerDriver.getConfiguration().getBackup().getHdfs().getUrl();
String hadoopVersion = InstallerDriver.getConfiguration().getBackup().getHdfs().getVersion();
String hdfsBackupDir = InstallerDriver.getConfiguration().getBackup().getHdfs().getBackupDir();
+ VerificationUtil.verifyBackupRestoreConfiguration(hdfsUrl, hadoopVersion, hdfsBackupDir);
String workingDir = cluster.getWorkingDir().getDir();
String backupId = "" + instance.getBackupInfo().size();
String nodeStore;
@@ -125,6 +127,7 @@
String hdfsUrl = InstallerDriver.getConfiguration().getBackup().getHdfs().getUrl();
String hadoopVersion = InstallerDriver.getConfiguration().getBackup().getHdfs().getVersion();
String hdfsBackupDir = InstallerDriver.getConfiguration().getBackup().getHdfs().getBackupDir();
+ VerificationUtil.verifyBackupRestoreConfiguration(hdfsUrl, hadoopVersion, hdfsBackupDir);
String workingDir = cluster.getWorkingDir().getDir();
String nodeStore;
String pargs;
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/service/ILookupService.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/service/ILookupService.java
index f258e66..aad963f 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/service/ILookupService.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/service/ILookupService.java
@@ -29,6 +29,8 @@
public void startService(Configuration conf) throws Exception;
+ public void stopService(Configuration conf) throws Exception;
+
public boolean exists(String name) throws Exception;
public void removeAsterixInstance(String name) throws Exception;
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/service/ZooKeeperService.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/service/ZooKeeperService.java
index cbd9a7f..1bd8772 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/service/ZooKeeperService.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/service/ZooKeeperService.java
@@ -114,6 +114,24 @@
createRootIfNotExist();
}
+ public void stopService(Configuration conf) throws Exception {
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug("Stopping ZooKeeper running at " + zkConnectionString);
+ }
+ String stopScript = ZOOKEEPER_HOME + File.separator + "bin" + File.separator + "stop_zk";
+ StringBuffer cmdBuffer = new StringBuffer();
+ cmdBuffer.append(stopScript + " ");
+ cmdBuffer.append(conf.getZookeeper().getHomeDir() + " ");
+ List<String> zkServers = conf.getZookeeper().getServers().getServer();
+ for (String zkServer : zkServers) {
+ cmdBuffer.append(zkServer + " ");
+ }
+ Runtime.getRuntime().exec(cmdBuffer.toString());
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug("Stopped ZooKeeper service at " + zkConnectionString);
+ }
+ }
+
public void writeAsterixInstance(AsterixInstance asterixInstance) throws Exception {
String instanceBasePath = ASTERIX_INSTANCE_BASE_PATH + File.separator + asterixInstance.getName();
ByteArrayOutputStream b = new ByteArrayOutputStream();
diff --git a/asterix-installer/src/main/resources/zookeeper/stop_zk b/asterix-installer/src/main/resources/zookeeper/stop_zk
new file mode 100755
index 0000000..d8615d9
--- /dev/null
+++ b/asterix-installer/src/main/resources/zookeeper/stop_zk
@@ -0,0 +1,6 @@
+ZK_HOME=$1
+shift 1
+for zk_host in $@
+do
+ ssh $zk_host "kill -9 `jps | grep QuorumPeerMain | cut -d " " -f1`" &
+done