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-events/src/main/java/edu/uci/ics/asterix/event/driver/EventDriver.java b/asterix-events/src/main/java/edu/uci/ics/asterix/event/driver/EventDriver.java
index 17d6647..d3c338d 100644
--- a/asterix-events/src/main/java/edu/uci/ics/asterix/event/driver/EventDriver.java
+++ b/asterix-events/src/main/java/edu/uci/ics/asterix/event/driver/EventDriver.java
@@ -40,134 +40,124 @@
public class EventDriver {
- public static final String CLIENT_NODE_ID = "client_node";
- public static final Node CLIENT_NODE = new Node(CLIENT_NODE_ID,
- "127.0.0.1", null, null, null, null);
+ public static final String CLIENT_NODE_ID = "client_node";
+ public static final Node CLIENT_NODE = new Node(CLIENT_NODE_ID, "127.0.0.1", null, null, null, null, null);
- private static String eventsDir;
- private static Events events;
- private static Map<String, String> env = new HashMap<String, String>();
- private static String scriptDirSuffix;
+ private static String eventsDir;
+ private static Events events;
+ private static Map<String, String> env = new HashMap<String, String>();
+ private static String scriptDirSuffix;
- public static String getEventsDir() {
- return eventsDir;
- }
+ public static String getEventsDir() {
+ return eventsDir;
+ }
- public static Events getEvents() {
- return events;
- }
+ public static Events getEvents() {
+ return events;
+ }
- public static Map<String, String> getEnvironment() {
- return env;
- }
+ public static Map<String, String> getEnvironment() {
+ return env;
+ }
- public static String getStringifiedEnv(Cluster cluster) {
- StringBuffer buffer = new StringBuffer();
- for (Property p : cluster.getEnv().getProperty()) {
- buffer.append(p.getKey() + "=" + p.getValue() + " ");
- }
- return buffer.toString();
- }
+ public static String getStringifiedEnv(Cluster cluster) {
+ StringBuffer buffer = new StringBuffer();
+ for (Property p : cluster.getEnv().getProperty()) {
+ buffer.append(p.getKey() + "=" + p.getValue() + " ");
+ }
+ return buffer.toString();
+ }
- public static Cluster initializeCluster(String path) throws JAXBException,
- IOException {
- File file = new File(path);
- JAXBContext ctx = JAXBContext.newInstance(Cluster.class);
- Unmarshaller unmarshaller = ctx.createUnmarshaller();
- Cluster cluster = (Cluster) unmarshaller.unmarshal(file);
- for (Property p : cluster.getEnv().getProperty()) {
- env.put(p.getKey(), p.getValue());
- }
- return cluster;
- }
+ public static Cluster initializeCluster(String path) throws JAXBException, IOException {
+ File file = new File(path);
+ JAXBContext ctx = JAXBContext.newInstance(Cluster.class);
+ Unmarshaller unmarshaller = ctx.createUnmarshaller();
+ Cluster cluster = (Cluster) unmarshaller.unmarshal(file);
+ for (Property p : cluster.getEnv().getProperty()) {
+ env.put(p.getKey(), p.getValue());
+ }
+ return cluster;
+ }
- public static Patterns initializePatterns(String path)
- throws JAXBException, IOException {
- File file = new File(path);
- JAXBContext ctx = JAXBContext.newInstance(Patterns.class);
- Unmarshaller unmarshaller = ctx.createUnmarshaller();
- return (Patterns) unmarshaller.unmarshal(file);
- }
+ public static Patterns initializePatterns(String path) throws JAXBException, IOException {
+ File file = new File(path);
+ JAXBContext ctx = JAXBContext.newInstance(Patterns.class);
+ Unmarshaller unmarshaller = ctx.createUnmarshaller();
+ return (Patterns) unmarshaller.unmarshal(file);
+ }
- private static void initialize(EventConfig eventConfig) throws IOException,
- JAXBException {
+ private static void initialize(EventConfig eventConfig) throws IOException, JAXBException {
- }
+ }
- public static EventrixClient getClient(String eventsDir, Cluster cluster,
- boolean dryRun) throws Exception {
- return new EventrixClient(eventsDir, cluster, dryRun,
- new DefaultOutputHandler());
- }
+ public static EventrixClient getClient(String eventsDir, Cluster cluster, boolean dryRun) throws Exception {
+ return new EventrixClient(eventsDir, cluster, dryRun, new DefaultOutputHandler());
+ }
- public static EventrixClient getClient(String eventsDir, Cluster cluster,
- boolean dryRun, IOutputHandler outputHandler) throws Exception {
- return new EventrixClient(eventsDir, cluster, dryRun, outputHandler);
- }
+ public static EventrixClient getClient(String eventsDir, Cluster cluster, boolean dryRun,
+ IOutputHandler outputHandler) throws Exception {
+ return new EventrixClient(eventsDir, cluster, dryRun, outputHandler);
+ }
- public static void main(String[] args) throws Exception {
- String eventsHome = System.getenv("EVENT_HOME");
- if (eventsHome == null) {
- throw new IllegalStateException("EVENT_HOME is not set");
- }
- eventsDir = eventsHome + File.separator + EventUtil.EVENTS_DIR;
- EventConfig eventConfig = new EventConfig();
- CmdLineParser parser = new CmdLineParser(eventConfig);
- try {
- parser.parseArgument(args);
- if (eventConfig.help) {
- parser.printUsage(System.out);
- }
- if (eventConfig.seed > 0) {
- Randomizer.getInstance(eventConfig.seed);
- }
- Cluster cluster = initializeCluster(eventConfig.clusterPath);
- Patterns patterns = initializePatterns(eventConfig.patternPath);
- initialize(eventConfig);
+ public static void main(String[] args) throws Exception {
+ String eventsHome = System.getenv("EVENT_HOME");
+ if (eventsHome == null) {
+ throw new IllegalStateException("EVENT_HOME is not set");
+ }
+ eventsDir = eventsHome + File.separator + EventUtil.EVENTS_DIR;
+ EventConfig eventConfig = new EventConfig();
+ CmdLineParser parser = new CmdLineParser(eventConfig);
+ try {
+ parser.parseArgument(args);
+ if (eventConfig.help) {
+ parser.printUsage(System.out);
+ }
+ if (eventConfig.seed > 0) {
+ Randomizer.getInstance(eventConfig.seed);
+ }
+ Cluster cluster = initializeCluster(eventConfig.clusterPath);
+ Patterns patterns = initializePatterns(eventConfig.patternPath);
+ initialize(eventConfig);
- if (!eventConfig.dryRun) {
- prepare(cluster);
- }
- EventrixClient client = new EventrixClient(eventsDir, cluster,
- eventConfig.dryRun, new DefaultOutputHandler());
- client.submit(patterns);
- if (!eventConfig.dryRun) {
- cleanup(cluster);
- }
- } catch (Exception e) {
- e.printStackTrace();
- parser.printUsage(System.err);
- }
- }
+ if (!eventConfig.dryRun) {
+ prepare(cluster);
+ }
+ EventrixClient client = new EventrixClient(eventsDir, cluster, eventConfig.dryRun,
+ new DefaultOutputHandler());
+ client.submit(patterns);
+ if (!eventConfig.dryRun) {
+ cleanup(cluster);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ parser.printUsage(System.err);
+ }
+ }
- private static void prepare(Cluster cluster) throws IOException,
- InterruptedException {
+ private static void prepare(Cluster cluster) throws IOException, InterruptedException {
- scriptDirSuffix = "" + System.nanoTime();
- List<String> args = new ArrayList<String>();
- args.add(scriptDirSuffix);
- Node clientNode = new Node();
- clientNode.setId("client");
- clientNode.setIp("127.0.0.1");
- for (Node node : cluster.getNode()) {
- args.add(node.getIp());
- }
- EventUtil.executeLocalScript(clientNode, eventsDir + "/" + "events"
- + "/" + "prepare.sh", args);
- }
+ scriptDirSuffix = "" + System.nanoTime();
+ List<String> args = new ArrayList<String>();
+ args.add(scriptDirSuffix);
+ Node clientNode = new Node();
+ clientNode.setId("client");
+ clientNode.setIp("127.0.0.1");
+ for (Node node : cluster.getNode()) {
+ args.add(node.getIp());
+ }
+ EventUtil.executeLocalScript(clientNode, eventsDir + "/" + "events" + "/" + "prepare.sh", args);
+ }
- private static void cleanup(Cluster cluster) throws IOException,
- InterruptedException {
- List<String> args = new ArrayList<String>();
- args.add(scriptDirSuffix);
- Node clientNode = new Node();
- clientNode.setId("client");
- clientNode.setIp("127.0.0.1");
- for (Node node : cluster.getNode()) {
- args.add(node.getIp());
- }
- EventUtil.executeLocalScript(clientNode, eventsDir + "/" + "events"
- + "/" + "cleanup.sh", args);
- }
+ private static void cleanup(Cluster cluster) throws IOException, InterruptedException {
+ List<String> args = new ArrayList<String>();
+ args.add(scriptDirSuffix);
+ Node clientNode = new Node();
+ clientNode.setId("client");
+ clientNode.setIp("127.0.0.1");
+ for (Node node : cluster.getNode()) {
+ args.add(node.getIp());
+ }
+ EventUtil.executeLocalScript(clientNode, eventsDir + "/" + "events" + "/" + "cleanup.sh", args);
+ }
}
diff --git a/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventExecutor.java b/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventExecutor.java
index 1dd257e..34da06e 100644
--- a/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventExecutor.java
+++ b/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventExecutor.java
@@ -31,68 +31,64 @@
public class EventExecutor {
- public static final String EVENTS_DIR = "events";
- private static final String EXECUTE_SCRIPT = "execute.sh";
- private static final String IP_LOCATION = "IP_LOCATION";
- private static final String CLUSTER_ENV = "ENV";
- private static final String SCRIPT = "SCRIPT";
- private static final String ARGS = "ARGS";
- private static final String DAEMON = "DAEMON";
+ public static final String EVENTS_DIR = "events";
+ private static final String EXECUTE_SCRIPT = "execute.sh";
+ private static final String IP_LOCATION = "IP_LOCATION";
+ private static final String CLUSTER_ENV = "ENV";
+ private static final String SCRIPT = "SCRIPT";
+ private static final String ARGS = "ARGS";
+ private static final String DAEMON = "DAEMON";
- public void executeEvent(Node node, String script, List<String> args,
- boolean isDaemon, Cluster cluster, Pattern pattern,
- IOutputHandler outputHandler, EventrixClient client)
- throws IOException {
- List<String> pargs = new ArrayList<String>();
- pargs.add("/bin/bash");
- pargs.add(client.getEventsDir() + File.separator + "scripts"
- + File.separator + EXECUTE_SCRIPT);
- StringBuffer envBuffer = new StringBuffer(IP_LOCATION + "="
- + node.getIp() + " ");
- if (!node.getId().equals(EventDriver.CLIENT_NODE_ID)) {
- for (Property p : cluster.getEnv().getProperty()) {
- if (p.getKey().equals("JAVA_HOME")) {
- String val = node.getJavaHome() == null ? p.getValue()
- : node.getJavaHome();
- envBuffer.append(p.getKey() + "=" + val + " ");
- } else if (p.getKey().equals("JAVA_OPTS")) {
- String val = "-Xmx" + (node.getRam() == null ? cluster.getRam()
- : node.getRam());
- envBuffer.append(p.getKey() + "=" + val + " ");
- } else {
- envBuffer.append(p.getKey() + "=" + p.getValue() + " ");
- }
+ public void executeEvent(Node node, String script, List<String> args, boolean isDaemon, Cluster cluster,
+ Pattern pattern, IOutputHandler outputHandler, EventrixClient client) throws IOException {
+ List<String> pargs = new ArrayList<String>();
+ pargs.add("/bin/bash");
+ pargs.add(client.getEventsDir() + File.separator + "scripts" + File.separator + EXECUTE_SCRIPT);
+ StringBuffer envBuffer = new StringBuffer(IP_LOCATION + "=" + node.getIp() + " ");
+ if (!node.getId().equals(EventDriver.CLIENT_NODE_ID)) {
+ for (Property p : cluster.getEnv().getProperty()) {
+ if (p.getKey().equals("JAVA_HOME")) {
+ String val = node.getJavaHome() == null ? p.getValue() : node.getJavaHome();
+ envBuffer.append(p.getKey() + "=" + val + " ");
+ } else if (p.getKey().equals("JAVA_OPTS")) {
+ String val = "\"" + "-Xmx" + (node.getRam() == null ? cluster.getRam() : node.getRam());
+ if (node.getDebug() != null) {
+ val = val + " " + "-Xdebug -Xrunjdwp:transport=dt_socket,address=" + node.getDebug().intValue()
+ + "," + "server=y,suspend=n";
+ }
+ val = val + "\"";
+ envBuffer.append(p.getKey() + "=" + val + " ");
+ } else {
+ envBuffer.append(p.getKey() + "=" + p.getValue() + " ");
+ }
- }
- pargs.add(cluster.getUsername() == null ? System
- .getProperty("user.name") : cluster.getUsername());
- }
- StringBuffer argBuffer = new StringBuffer();
- if (args != null && args.size() > 0) {
- for (String arg : args) {
- argBuffer.append(arg + " ");
- }
- }
+ }
+ pargs.add(cluster.getUsername() == null ? System.getProperty("user.name") : cluster.getUsername());
+ }
+ StringBuffer argBuffer = new StringBuffer();
+ if (args != null && args.size() > 0) {
+ for (String arg : args) {
+ argBuffer.append(arg + " ");
+ }
+ }
- ProcessBuilder pb = new ProcessBuilder(pargs);
- pb.environment().put(IP_LOCATION, node.getIp());
- pb.environment().put(CLUSTER_ENV, envBuffer.toString());
- pb.environment().put(SCRIPT, script);
- pb.environment().put(ARGS, argBuffer.toString());
- pb.environment().put(DAEMON, isDaemon ? "true" : "false");
+ ProcessBuilder pb = new ProcessBuilder(pargs);
+ pb.environment().put(IP_LOCATION, node.getIp());
+ pb.environment().put(CLUSTER_ENV, envBuffer.toString());
+ pb.environment().put(SCRIPT, script);
+ pb.environment().put(ARGS, argBuffer.toString());
+ pb.environment().put(DAEMON, isDaemon ? "true" : "false");
- Process p = pb.start();
- if (!isDaemon) {
- BufferedInputStream bis = new BufferedInputStream(
- p.getInputStream());
- StringWriter writer = new StringWriter();
- IOUtils.copy(bis, writer, "UTF-8");
- String result = writer.getBuffer().toString();
- OutputAnalysis analysis = outputHandler.reportEventOutput(
- pattern.getEvent(), result);
- if (!analysis.isExpected()) {
- throw new IOException(analysis.getErrorMessage() + result);
- }
- }
- }
+ Process p = pb.start();
+ if (!isDaemon) {
+ BufferedInputStream bis = new BufferedInputStream(p.getInputStream());
+ StringWriter writer = new StringWriter();
+ IOUtils.copy(bis, writer, "UTF-8");
+ String result = writer.getBuffer().toString();
+ OutputAnalysis analysis = outputHandler.reportEventOutput(pattern.getEvent(), result);
+ if (!analysis.isExpected()) {
+ throw new IOException(analysis.getErrorMessage() + result);
+ }
+ }
+ }
}
diff --git a/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventUtil.java b/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventUtil.java
index 7fe0d7c..e3de560 100644
--- a/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventUtil.java
+++ b/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventUtil.java
@@ -15,6 +15,7 @@
package edu.uci.ics.asterix.event.management;
import java.io.IOException;
+import java.math.BigInteger;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -186,8 +187,10 @@
.getLogdir() : cluster.getMasterNode().getLogdir();
String javaHome = cluster.getMasterNode().getJavaHome() == null ? cluster
.getJavaHome() : cluster.getMasterNode().getJavaHome();
+ BigInteger debug = cluster.getMasterNode().getDebug();
return new Node(cluster.getMasterNode().getId(), cluster
- .getMasterNode().getIp(), ram, javaHome, logDir, null);
+ .getMasterNode().getIp(), ram, javaHome, logDir, null,
+ debug);
}
List<Node> nodeList = cluster.getNode();
diff --git a/asterix-events/src/main/resources/schema/cluster.xsd b/asterix-events/src/main/resources/schema/cluster.xsd
index edfe220..eaf343d 100644
--- a/asterix-events/src/main/resources/schema/cluster.xsd
+++ b/asterix-events/src/main/resources/schema/cluster.xsd
@@ -15,6 +15,7 @@
<xs:element name="store" type="xs:string"/>
<xs:element name="java_home" type="xs:string"/>
<xs:element name="username" type="xs:string"/>
+<xs:element name="debug" type="xs:integer"/>
<!-- definition of complex elements -->
<xs:element name="workingDir">
@@ -35,6 +36,7 @@
<xs:element ref="cl:java_home" minOccurs="0"/>
<xs:element ref="cl:ram" minOccurs="0"/>
<xs:element ref="cl:logdir" minOccurs="0"/>
+ <xs:element ref="cl:debug" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
@@ -65,6 +67,7 @@
<xs:element ref="cl:java_home" minOccurs="0"/>
<xs:element ref="cl:logdir" minOccurs="0"/>
<xs:element ref="cl:store" minOccurs="0"/>
+ <xs:element ref="cl:debug" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
diff --git a/asterix-events/src/main/resources/scripts/execute.sh b/asterix-events/src/main/resources/scripts/execute.sh
index 72234c1..30f6c2f 100755
--- a/asterix-events/src/main/resources/scripts/execute.sh
+++ b/asterix-events/src/main/resources/scripts/execute.sh
@@ -1,22 +1,27 @@
USERNAME=$1
+if [ ! -d $MANAGIX_HOME/logs ];
+then
+ mkdir -p $MANAGIX_HOME/logs
+fi
+LOGDIR=$MANAGIX_HOME/logs
if [ $DAEMON == "false" ]; then
if [ -z $USERNAME ]
then
cmd_output=$(ssh $IP_LOCATION "$ENV $SCRIPT $ARGS" 2>&1 >/dev/null)
- echo "ssh $IP_LOCATION $ENV $SCRIPT $ARGS" >> ./execute.log
+ echo "ssh $IP_LOCATION $ENV $SCRIPT $ARGS" >> $LOGDIR/execute.log
echo "$cmd_output"
else
- echo "ssh -l $USERNAME $IP_LOCATION $ENV $SCRIPT $ARGS" >> ./execute.log
+ echo "ssh -l $USERNAME $IP_LOCATION $ENV $SCRIPT $ARGS" >> $LOGDIR/execute.log
cmd_output=$(ssh -l $USERNAME $IP_LOCATION "$ENV $SCRIPT $ARGS" 2>&1 >/dev/null)
echo "$cmd_output"
fi
else
if [ -z $USERNAME ];
then
- echo "ssh $IP_LOCATION $ENV $SCRIPT $ARGS &" >> ./execute.log
+ echo "ssh $IP_LOCATION $ENV $SCRIPT $ARGS &" >> $LOGDIR/execute.log
ssh $IP_LOCATION "$ENV $SCRIPT $ARGS" &
else
- echo "ssh -l $USERNAME $IP_LOCATION $ENV $SCRIPT $ARGS &" >> ./execute.log
+ echo "ssh -l $USERNAME $IP_LOCATION $ENV $SCRIPT $ARGS &" >> $LOGDIR/execute.log
ssh -l $USERNAME $IP_LOCATION "$ENV $SCRIPT $ARGS" &
fi
fi
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