merge from asterix_stabilization_ioc_installer r1260:1314
git-svn-id: https://asterixdb.googlecode.com/svn/branches/asterix_stabilization_ioc@1315 eaa15691-b419-025a-1212-ee371bd00084
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java b/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java
index a8bd499..cee5b7f 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java
@@ -2,6 +2,7 @@
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
+import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -21,6 +22,7 @@
private AsterixAppRuntimeContext runtimeContext;
private String nodeId;
private boolean isMetadataNode = false;
+ private boolean stopInitiated = false;
@Override
public void start(INCApplicationContext ncAppCtx, String[] args) throws Exception {
@@ -33,19 +35,28 @@
runtimeContext = new AsterixAppRuntimeContext(ncApplicationContext);
runtimeContext.initialize();
ncApplicationContext.setApplicationObject(runtimeContext);
+ JVMShutdownHook sHook = new JVMShutdownHook(this);
+ Runtime.getRuntime().addShutdownHook(sHook);
}
@Override
public void stop() throws Exception {
- if (LOGGER.isLoggable(Level.INFO)) {
- LOGGER.info("Stopping Asterix node controller: " + nodeId);
- }
+ if (!stopInitiated) {
+ stopInitiated = true;
+ if (LOGGER.isLoggable(Level.INFO)) {
+ LOGGER.info("Stopping Asterix node controller: " + nodeId);
+ }
- if (isMetadataNode) {
- MetadataBootstrap.stopUniverse();
+ if (isMetadataNode) {
+ MetadataBootstrap.stopUniverse();
+ }
+ runtimeContext.deinitialize();
+ } else {
+ if (LOGGER.isLoggable(Level.INFO)) {
+ LOGGER.info("Duplicate attempt to stop ignored: " + nodeId);
+ }
}
- runtimeContext.deinitialize();
}
@Override
@@ -74,4 +85,30 @@
LOGGER.info("Metadata node bound");
}
}
+
+ /**
+ * Shutdown hook that invokes {@link NCApplicationEntryPoint#stop() stop} method.
+ */
+ private static class JVMShutdownHook extends Thread {
+
+ private final NCApplicationEntryPoint ncAppEntryPoint;
+
+ public JVMShutdownHook(NCApplicationEntryPoint ncAppEntryPoint) {
+ this.ncAppEntryPoint = ncAppEntryPoint;
+ }
+
+ public void run() {
+ if (LOGGER.isLoggable(Level.INFO)) {
+ LOGGER.info("Shutdown hook in progress");
+ }
+ try {
+ ncAppEntryPoint.stop();
+ } catch (Exception e) {
+ if (LOGGER.isLoggable(Level.WARNING)) {
+ LOGGER.warning("Exception in executing shutdown hook" + e);
+ }
+ }
+ }
+ }
+
}
\ No newline at end of file
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..04c6333 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) && cluster.getEnv() != null) {
+ 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/events/backup/backup.sh b/asterix-events/src/main/resources/events/backup/backup.sh
index cff37df..e10a4c9 100755
--- a/asterix-events/src/main/resources/events/backup/backup.sh
+++ b/asterix-events/src/main/resources/events/backup/backup.sh
@@ -2,18 +2,34 @@
ASTERIX_INSTANCE_NAME=$2
ASTERIX_DATA_DIR=$3
BACKUP_ID=$4
-HDFS_URL=$5
-HADOOP_VERSION=$6
-HDFS_BACKUP_DIR=$7
-NODE_ID=$8
-
-export HADOOP_HOME=$WORKING_DIR/hadoop-$HADOOP_VERSION
+BACKUP_DIR=$5
+BACKUP_TYPE=$6
+NODE_ID=$7
nodeStores=$(echo $ASTERIX_DATA_DIR | tr "," "\n")
-for nodeStore in $nodeStores
-do
- NODE_BACKUP_DIR=$HDFS_BACKUP_DIR/$ASTERIX_INSTANCE_NAME/$BACKUP_ID/$NODE_ID/$nodeStore
- $HADOOP_HOME/bin/hadoop fs -mkdir $HDFS_URL/$NODE_BACKUP_DIR
- echo "$HADOOP_HOME/bin/hadoop fs -copyFromLocal $nodeStore/$NODE_ID $HDFS_URL/$NODE_BACKUP_DIR" >> ~/backup.log
- $HADOOP_HOME/bin/hadoop fs -copyFromLocal $nodeStore/$NODE_ID/$ASTERIX_INSTANCE_NAME/* $HDFS_URL/$NODE_BACKUP_DIR/
-done
+
+if [ $BACKUP_TYPE == "hdfs" ];
+then
+ HDFS_URL=$8
+ HADOOP_VERSION=$9
+ export HADOOP_HOME=$WORKING_DIR/hadoop-$HADOOP_VERSION
+ for nodeStore in $nodeStores
+ do
+ MANGLED_DIR_NAME=`echo $nodeStores | tr / _`
+ NODE_BACKUP_DIR=$BACKUP_DIR/$ASTERIX_INSTANCE_NAME/$BACKUP_ID/$NODE_ID/$MANGLED_DIR_NAME
+ echo "$HADOOP_HOME/bin/hadoop fs -copyFromLocal $nodeStore/$NODE_ID/$ASTERIX_INSTANCE_NAME/ $HDFS_URL/$NODE_BACKUP_DIR/" >> ~/backup.log
+ $HADOOP_HOME/bin/hadoop fs -copyFromLocal $nodeStore/$NODE_ID/$ASTERIX_INSTANCE_NAME/ $HDFS_URL/$NODE_BACKUP_DIR/
+ done
+else
+ for nodeStore in $nodeStores
+ do
+ MANGLED_DIR_NAME=`echo $nodeStores | tr / _`
+ NODE_BACKUP_DIR=$BACKUP_DIR/$ASTERIX_INSTANCE_NAME/$BACKUP_ID/$NODE_ID/$MANGLED_DIR_NAME
+ if [ ! -d $NODE_BACKUP_DIR ];
+ then
+ mkdir -p $NODE_BACKUP_DIR
+ fi
+ echo "cp -r $nodeStore/$NODE_ID/$ASTERIX_INSTANCE_NAME/* $NODE_BACKUP_DIR/" >> ~/backup.log
+ cp -r $nodeStore/$NODE_ID/$ASTERIX_INSTANCE_NAME/* $NODE_BACKUP_DIR/
+ done
+fi
diff --git a/asterix-events/src/main/resources/events/events.xml b/asterix-events/src/main/resources/events/events.xml
index 857ee5a..f85e3ea1 100644
--- a/asterix-events/src/main/resources/events/events.xml
+++ b/asterix-events/src/main/resources/events/events.xml
@@ -97,4 +97,10 @@
<args>WorkingDir HadoopVersion HDFSUrl Path_to_Delete</args>
<daemon>false</daemon>
</event>
+ <event>
+ <type>node_info</type>
+ <script>node_info/node_info.sh</script>
+ <description>Retrieved environment information for a node</description>
+ <daemon>false</daemon>
+ </event>
</events>
diff --git a/asterix-events/src/main/resources/events/node_failure/nc_failure.sh b/asterix-events/src/main/resources/events/node_failure/nc_failure.sh
index fc4a0be..3ca083c 100755
--- a/asterix-events/src/main/resources/events/node_failure/nc_failure.sh
+++ b/asterix-events/src/main/resources/events/node_failure/nc_failure.sh
@@ -4,4 +4,4 @@
PARENT_ID=`echo $INFO | cut -d " " -f2`
PID_INFO=`ps -ef | grep asterix | grep -v grep | grep -v nc_join | grep $PARENT_ID`
PID=`echo $PID_INFO | cut -d " " -f2`
-kill -9 $PID
+kill -15 $PID
diff --git a/asterix-events/src/main/resources/events/node_info/node_info.sh b/asterix-events/src/main/resources/events/node_info/node_info.sh
new file mode 100755
index 0000000..ae72490
--- /dev/null
+++ b/asterix-events/src/main/resources/events/node_info/node_info.sh
@@ -0,0 +1,4 @@
+JAVA_VERSION=`java -version 2>&1 |awk 'NR==1{ gsub(/"/,""); print $3 }'`
+HOME_DIR=`echo ~`
+echo JAVA_VERSION=$JAVA_VERSION
+echo HOME_DIR=$HOME_DIR
diff --git a/asterix-events/src/main/resources/events/restore/restore.sh b/asterix-events/src/main/resources/events/restore/restore.sh
index 96f3db4..515efc1 100755
--- a/asterix-events/src/main/resources/events/restore/restore.sh
+++ b/asterix-events/src/main/resources/events/restore/restore.sh
@@ -2,17 +2,19 @@
ASTERIX_INSTANCE_NAME=$2
ASTERIX_DATA_DIR=$3
BACKUP_ID=$4
-HDFS_URL=$5
-HADOOP_VERSION=$6
-HDFS_BACKUP_DIR=$7
-NODE_ID=$8
+BACKUP_DIR=$5
+BACKUP_TYPE=$6
+NODE_ID=$7
+HDFS_URL=$8
+HADOOP_VERSION=$9
export HADOOP_HOME=$WORKING_DIR/hadoop-$HADOOP_VERSION
-
nodeStores=$(echo $ASTERIX_DATA_DIR | tr "," "\n")
+
for nodeStore in $nodeStores
do
- NODE_BACKUP_DIR=$HDFS_BACKUP_DIR/$ASTERIX_INSTANCE_NAME/$BACKUP_ID/$NODE_ID/$nodeStore
+ MANGLED_BACKUP_DIR=`echo $nodeStore | tr / _`
+ NODE_BACKUP_DIR=$BACKUP_DIR/$ASTERIX_INSTANCE_NAME/$BACKUP_ID/$NODE_ID/$MANGLED_BACKUP_DIR
DEST_DIR=$nodeStore/$NODE_ID/$ASTERIX_INSTANCE_NAME
if [ ! -d $DEST_DIR ]
then
@@ -20,6 +22,11 @@
else
rm -rf $DEST_DIR/*
fi
- echo "$HADOOP_HOME/bin/hadoop fs -copyToLocal $HDFS_URL/$NODE_BACKUP_DIR/ $DEST_DIR/" >> ~/restore.log
- $HADOOP_HOME/bin/hadoop fs -copyToLocal $HDFS_URL/$NODE_BACKUP_DIR/* $DEST_DIR/
+
+ if [ $BACKUP_TYPE == "hdfs" ];
+ then
+ $HADOOP_HOME/bin/hadoop fs -copyToLocal $HDFS_URL/$NODE_BACKUP_DIR/* $DEST_DIR/
+ else
+ cp -r $NODE_BACKUP_DIR/* $DEST_DIR/
+ fi
done
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/pom.xml b/asterix-installer/pom.xml
index 22af412..28ad995 100644
--- a/asterix-installer/pom.xml
+++ b/asterix-installer/pom.xml
@@ -36,6 +36,22 @@
<goal>generate</goal>
</goals>
<configuration>
+ <args>
+ <arg>-Xsetters</arg>
+ <arg>-Xvalue-constructor</arg>
+ </args>
+ <plugins>
+ <plugin>
+ <groupId>org.jvnet.jaxb2_commons</groupId>
+ <artifactId>jaxb2-basics</artifactId>
+ <version>0.6.2</version>
+ </plugin>
+ <plugin>
+ <groupId>org.jvnet.jaxb2_commons</groupId>
+ <artifactId>jaxb2-value-constructor</artifactId>
+ <version>3.0</version>
+ </plugin>
+ </plugins>
<schemaDirectory>src/main/resources/schema</schemaDirectory>
<schemaIncludes>
<include>installer-conf.xsd</include>
@@ -55,6 +71,10 @@
<include>cluster.xsd</include>
</schemaIncludes>
<generatePackage>edu.uci.ics.asterix.installer.schema.cluster</generatePackage>
+ <bindingDirectory>src/main/resources/schema</bindingDirectory>
+ <bindingIncludes>
+ <bindingInclude>jaxb-bindings.xjb</bindingInclude>
+ </bindingIncludes>
<generateDirectory>${project.build.directory}/generated-sources/cluster</generateDirectory>
</configuration>
</execution>
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/AbstractCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/AbstractCommand.java
index 8ebdea5..af7dbb7 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/AbstractCommand.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/AbstractCommand.java
@@ -14,7 +14,6 @@
*/
package edu.uci.ics.asterix.installer.command;
-
import org.apache.log4j.Logger;
import org.kohsuke.args4j.CmdLineParser;
@@ -23,16 +22,20 @@
protected static final Logger LOGGER = Logger.getLogger(AbstractCommand.class.getName());
protected CommandConfig config;
-
+
protected String usageDescription;
public void execute(String[] args) throws Exception {
String[] cmdArgs = new String[args.length - 1];
System.arraycopy(args, 1, cmdArgs, 0, cmdArgs.length);
- config = getCommandConfig();
- CmdLineParser parser = new CmdLineParser(config);
- parser.parseArgument(cmdArgs);
- execCommand();
+ if (cmdArgs.length >= 1 && cmdArgs[0].equals("-help")) {
+ System.out.println(getUsageDescription());
+ } else {
+ config = getCommandConfig();
+ CmdLineParser parser = new CmdLineParser(config);
+ parser.parseArgument(cmdArgs);
+ execCommand();
+ }
}
abstract protected void execCommand() throws Exception;
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/AbstractCommandConfig.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/AbstractCommandConfig.java
new file mode 100644
index 0000000..f28dfd9
--- /dev/null
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/AbstractCommandConfig.java
@@ -0,0 +1,15 @@
+package edu.uci.ics.asterix.installer.command;
+
+import org.kohsuke.args4j.Option;
+
+public class AbstractCommandConfig implements CommandConfig {
+
+ @Option(name = "-help", required = false, usage = "Help")
+ public boolean help = false;
+
+ @Override
+ public boolean helpMode() {
+ return help;
+ }
+
+}
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..e52308e 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
@@ -19,6 +19,7 @@
import org.kohsuke.args4j.Option;
+import edu.uci.ics.asterix.installer.driver.InstallerDriver;
import edu.uci.ics.asterix.installer.driver.InstallerUtil;
import edu.uci.ics.asterix.installer.model.AsterixInstance;
import edu.uci.ics.asterix.installer.model.AsterixInstance.State;
@@ -29,6 +30,7 @@
@Override
protected void execCommand() throws Exception {
+ InstallerDriver.initConfig();
String instanceName = ((AlterConfig) config).name;
InstallerUtil.validateAsterixInstanceExists(instanceName, State.INACTIVE);
ILookupService lookupService = ServiceProvider.INSTANCE.getLookupService();
@@ -48,21 +50,21 @@
@Override
protected String getUsageDescription() {
- // TODO Auto-generated method stub
- return null;
+ return "\nAlter the instance's configuration settings."
+ + "\nPrior to running this command, the instance is required to be INACTIVE state."
+ + "\n\nAvailable arguments/options"
+ + "\n-n name of the ASTERIX instance"
+ + "\n-conf path to the ASTERIX configuration file.";
}
}
-class AlterConfig implements CommandConfig {
+class AlterConfig extends AbstractCommandConfig {
- @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")
+ @Option(name = "-conf", required = true, usage = "Path to instance configuration")
public String confPath;
}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/BackupCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/BackupCommand.java
index 58c309a..cd4cc5c 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/BackupCommand.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/BackupCommand.java
@@ -20,25 +20,29 @@
import org.kohsuke.args4j.Option;
import edu.uci.ics.asterix.event.schema.pattern.Patterns;
+import edu.uci.ics.asterix.installer.driver.InstallerDriver;
import edu.uci.ics.asterix.installer.driver.InstallerUtil;
import edu.uci.ics.asterix.installer.events.PatternCreator;
import edu.uci.ics.asterix.installer.model.AsterixInstance;
import edu.uci.ics.asterix.installer.model.AsterixInstance.State;
import edu.uci.ics.asterix.installer.model.BackupInfo;
+import edu.uci.ics.asterix.installer.schema.conf.Backup;
import edu.uci.ics.asterix.installer.service.ServiceProvider;
public class BackupCommand extends AbstractCommand {
@Override
protected void execCommand() throws Exception {
+ InstallerDriver.initConfig();
String asterixInstanceName = ((BackupConfig) config).name;
AsterixInstance instance = InstallerUtil.validateAsterixInstanceExists(asterixInstanceName, State.INACTIVE);
List<BackupInfo> backupInfo = instance.getBackupInfo();
PatternCreator pc = new PatternCreator();
- Patterns patterns = pc.getBackUpAsterixPattern(instance, ((BackupConfig) config).localPath);
+ Backup backupConf = InstallerDriver.getConfiguration().getBackup();
+ Patterns patterns = pc.getBackUpAsterixPattern(instance, backupConf);
InstallerUtil.getEventrixClient(instance.getCluster()).submit(patterns);
int backupId = backupInfo.size();
- BackupInfo binfo = new BackupInfo(backupId, new Date());
+ BackupInfo binfo = new BackupInfo(backupId, new Date(), backupConf);
backupInfo.add(binfo);
LOGGER.info(asterixInstanceName + " backed up " + binfo);
ServiceProvider.INSTANCE.getLookupService().updateAsterixInstance(instance);
@@ -51,20 +55,21 @@
@Override
protected String getUsageDescription() {
- return null;
+ return "\nIn an undesirable event of data loss either due to a disk/system"
+ + "\nfailure or accidental execution of a DDL statement (drop dataverse/dataset),"
+ + "\nyou may need to recover the lost data. The backup command allows you to take a"
+ + "\nbackup of the data stored with an ASTERIX instance. "
+ + "\nThe backed up snapshot is stored in HDFS."
+ + "\n\nAvailable arguments/options:"
+ + "\n-n name of the Asterix instance";
+
}
}
-class BackupConfig implements CommandConfig {
-
- @Option(name = "-h", required = false, usage = "Help")
- public boolean help = false;
+class BackupConfig extends AbstractCommandConfig {
@Option(name = "-n", required = true, usage = "Name of the Asterix instance")
public String name;
- @Option(name = "-local", required = false, usage = "Path on the local file system for backup")
- public String localPath;
-
}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/CommandConfig.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/CommandConfig.java
index c0dd480..94aa935 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/CommandConfig.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/CommandConfig.java
@@ -16,4 +16,5 @@
public interface CommandConfig {
+ public boolean helpMode();
}
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 179412f..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
@@ -46,6 +46,15 @@
case STOP:
cmd = new StopCommand();
break;
+ case VALIDATE:
+ cmd = new ValidateCommand();
+ break;
+ 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/ConfigureCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ConfigureCommand.java
new file mode 100644
index 0000000..6b0b53d
--- /dev/null
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ConfigureCommand.java
@@ -0,0 +1,65 @@
+package edu.uci.ics.asterix.installer.command;
+
+import java.io.File;
+import java.io.FileOutputStream;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+
+import edu.uci.ics.asterix.event.schema.cluster.Cluster;
+import edu.uci.ics.asterix.event.schema.cluster.WorkingDir;
+import edu.uci.ics.asterix.installer.driver.InstallerDriver;
+import edu.uci.ics.asterix.installer.schema.conf.Configuration;
+
+public class ConfigureCommand extends AbstractCommand {
+
+ @Override
+ protected void execCommand() throws Exception {
+ String localClusterPath = InstallerDriver.getManagixHome() + File.separator + "clusters" + File.separator
+ + "local" + File.separator + "local.xml";
+
+ JAXBContext ctx = JAXBContext.newInstance(Cluster.class);
+ Unmarshaller unmarshaller = ctx.createUnmarshaller();
+ Cluster cluster = (Cluster) unmarshaller.unmarshal(new File(localClusterPath));
+
+ String workingDir = InstallerDriver.getManagixHome() + File.separator + "clusters" + File.separator + "local"
+ + File.separator + "working_dir";
+ cluster.setWorkingDir(new WorkingDir(workingDir, true));
+ cluster.setStore(workingDir + File.separator + "storage");
+ cluster.setLogdir(workingDir + File.separator + "logs");
+ cluster.setJavaHome(System.getenv("JAVA_HOME"));
+
+ Marshaller marshaller = ctx.createMarshaller();
+ marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+ marshaller.marshal(cluster, new FileOutputStream(localClusterPath));
+
+ String installerConfPath = InstallerDriver.getManagixHome() + File.separator + InstallerDriver.MANAGIX_CONF_XML;
+ ctx = JAXBContext.newInstance(Configuration.class);
+ unmarshaller = ctx.createUnmarshaller();
+ Configuration configuration = (Configuration) unmarshaller.unmarshal(new File(installerConfPath));
+
+ configuration.getBackup().setBackupDir(workingDir + File.separator + "backup");
+ configuration.getZookeeper().setHomeDir(workingDir + File.separator + "zookeeper");
+ marshaller = ctx.createMarshaller();
+ marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+ marshaller.marshal(configuration, new FileOutputStream(installerConfPath));
+
+ }
+
+ @Override
+ protected String getUsageDescription() {
+ return "\nAuto-generates the ASTERIX installer configruation settings and ASTERIX cluster "
+ + "\n configuration settings for a single node setup.";
+ }
+
+ @Override
+ protected CommandConfig getCommandConfig() {
+ return new ConfigureConfig();
+ }
+
+}
+
+class ConfigureConfig extends AbstractCommandConfig {
+
+}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/CreateCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/CreateCommand.java
index 48016a5..854ee8e 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/CreateCommand.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/CreateCommand.java
@@ -42,14 +42,19 @@
@Override
protected void execCommand() throws Exception {
+ InstallerDriver.initConfig();
+ ValidateCommand validateCommand = new ValidateCommand();
+ boolean valid = validateCommand.validateCluster(((CreateConfig) config).clusterPath);
+ if (!valid) {
+ throw new Exception("Cannot create an Asterix instance.");
+ }
asterixInstanceName = ((CreateConfig) config).name;
InstallerUtil.validateAsterixInstanceNotExists(asterixInstanceName);
CreateConfig createConfig = (CreateConfig) config;
JAXBContext ctx = JAXBContext.newInstance(Cluster.class);
Unmarshaller unmarshaller = ctx.createUnmarshaller();
cluster = (Cluster) unmarshaller.unmarshal(new File(createConfig.clusterPath));
- AsterixInstance asterixInstance = InstallerUtil.createAsterixInstance(asterixInstanceName, cluster,
- ((CreateConfig) config).asterixConf);
+ AsterixInstance asterixInstance = InstallerUtil.createAsterixInstance(asterixInstanceName, cluster);
InstallerUtil.evaluateConflictWithOtherInstances(asterixInstance);
InstallerUtil.createAsterixZip(asterixInstance, true);
List<Property> clusterProperties = new ArrayList<Property>();
@@ -90,14 +95,15 @@
@Override
protected String getUsageDescription() {
- return null;
+ return "\nCreates an ASTERIX instance with a specified name."
+ + "\n\nPost creation, the instance is in ACTIVE state, signifying its "
+ + "\navailability for executing statements/queries." + "\n\nUsage arguments/options:"
+ + "\n-n Name of the ASTERIX instance." + "\n-c Path to the cluster configuration file"
+ + "\n-a Path to the ASTERIX configuration file";
}
}
-class CreateConfig implements CommandConfig {
-
- @Option(name = "-h", required = false, usage = "Help")
- public boolean help = false;
+class CreateConfig extends AbstractCommandConfig {
@Option(name = "-n", required = true, usage = "Name of Asterix Instance")
public String name;
@@ -105,7 +111,4 @@
@Option(name = "-c", required = true, usage = "Path to cluster configuration")
public String clusterPath;
- @Option(name = "-a", required = true, usage = "Path to cluster configuration")
- public String asterixConf;
-
}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/DeleteCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/DeleteCommand.java
index dc4d53e..e97fe3f 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/DeleteCommand.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/DeleteCommand.java
@@ -17,6 +17,7 @@
import org.kohsuke.args4j.Option;
import edu.uci.ics.asterix.event.schema.pattern.Patterns;
+import edu.uci.ics.asterix.installer.driver.InstallerDriver;
import edu.uci.ics.asterix.installer.driver.InstallerUtil;
import edu.uci.ics.asterix.installer.events.PatternCreator;
import edu.uci.ics.asterix.installer.model.AsterixInstance;
@@ -27,6 +28,7 @@
@Override
protected void execCommand() throws Exception {
+ InstallerDriver.initConfig();
String asterixInstanceName = ((DeleteConfig) config).name;
AsterixInstance instance = InstallerUtil.validateAsterixInstanceExists(asterixInstanceName, State.INACTIVE);
PatternCreator pc = new PatternCreator();
@@ -43,18 +45,15 @@
@Override
protected String getUsageDescription() {
- // TODO Auto-generated method stub
- return null;
+ return "\nPermanently deletes an ASTERIX instance." + "\n" + "The instance must be in the INACTIVE state."
+ + "\n\nAvailable arguments/options" + "\n-n name of the ASTERIX instance.";
}
}
-class DeleteConfig implements CommandConfig {
+class DeleteConfig extends AbstractCommandConfig {
- @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;
}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/DescribeCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/DescribeCommand.java
index 977acaf..63dcc30 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/DescribeCommand.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/DescribeCommand.java
@@ -18,6 +18,7 @@
import org.kohsuke.args4j.Option;
+import edu.uci.ics.asterix.installer.driver.InstallerDriver;
import edu.uci.ics.asterix.installer.driver.InstallerUtil;
import edu.uci.ics.asterix.installer.error.InstallerException;
import edu.uci.ics.asterix.installer.error.VerificationUtil;
@@ -30,6 +31,7 @@
@Override
protected void execCommand() throws Exception {
+ InstallerDriver.initConfig();
String asterixInstanceName = ((DescribeConfig) config).name;
boolean adminView = ((DescribeConfig) config).admin;
if (asterixInstanceName != null) {
@@ -72,16 +74,13 @@
@Override
protected String getUsageDescription() {
- // TODO Auto-generated method stub
- return null;
+ return "\nProvides information about an ASTERIX instance." + "\n\nUsage arguments/options:-"
+ + "\n[-n] Name of the ASTERIX instance." + "\n[-admin] Provides a detailed description";
}
}
-class DescribeConfig implements CommandConfig {
-
- @Option(name = "-h", required = false, usage = "Help")
- public boolean help = false;
+class DescribeConfig extends AbstractCommandConfig {
@Option(name = "-n", required = false, usage = "Name of Asterix Instance")
public String name;
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 2822337..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
+ 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/RestoreCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/RestoreCommand.java
index 777d179..958ce6c 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/RestoreCommand.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/RestoreCommand.java
@@ -14,26 +14,34 @@
*/
package edu.uci.ics.asterix.installer.command;
+import java.util.List;
+
import org.kohsuke.args4j.Option;
import edu.uci.ics.asterix.event.schema.pattern.Patterns;
+import edu.uci.ics.asterix.installer.driver.InstallerDriver;
import edu.uci.ics.asterix.installer.driver.InstallerUtil;
import edu.uci.ics.asterix.installer.events.PatternCreator;
import edu.uci.ics.asterix.installer.model.AsterixInstance;
import edu.uci.ics.asterix.installer.model.AsterixInstance.State;
+import edu.uci.ics.asterix.installer.model.BackupInfo;
public class RestoreCommand extends AbstractCommand {
@Override
protected void execCommand() throws Exception {
+ InstallerDriver.initConfig();
String asterixInstanceName = ((RestoreConfig) config).name;
AsterixInstance instance = InstallerUtil.validateAsterixInstanceExists(asterixInstanceName, State.INACTIVE);
int backupId = ((RestoreConfig) config).backupId;
- if (instance.getBackupInfo().size() <= backupId || backupId < 0) {
+ List<BackupInfo> backupInfoList = instance.getBackupInfo();
+ if (backupInfoList.size() <= backupId || backupId < 0) {
throw new IllegalStateException("Invalid backup id");
}
+
+ BackupInfo backupInfo = backupInfoList.get(backupId);
PatternCreator pc = new PatternCreator();
- Patterns patterns = pc.getRestoreAsterixPattern(instance, backupId);
+ Patterns patterns = pc.getRestoreAsterixPattern(instance, backupInfo);
InstallerUtil.getEventrixClient(instance.getCluster()).submit(patterns);
LOGGER.info("Asterix instance: " + asterixInstanceName + " has been restored from backup");
}
@@ -45,16 +53,14 @@
@Override
protected String getUsageDescription() {
- // TODO Auto-generated method stub
- return null;
+ return "\nRestores an ASTERIX instance's data from a previously taken backup snapshot."
+ + "\n\nAvailable arguments/options" + "\n-n name of the ASTERIX instance"
+ + "\n-b id of the backed up snapshot ";
}
}
-class RestoreConfig implements CommandConfig {
-
- @Option(name = "-h", required = false, usage = "Help")
- public boolean help = false;
+class RestoreConfig extends AbstractCommandConfig {
@Option(name = "-n", required = true, usage = "Name of the Asterix instance")
public String name;
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..cbfd5c5
--- /dev/null
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ShutdownCommand.java
@@ -0,0 +1,44 @@
+/*
+ * 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 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 {
+ InstallerDriver.initConfig();
+ ILookupService lookupService = ServiceProvider.INSTANCE.getLookupService();
+ lookupService.stopService(InstallerDriver.getConfiguration());
+ }
+
+ @Override
+ protected CommandConfig getCommandConfig() {
+ return new ShutdownConfig();
+ }
+
+ @Override
+ protected String getUsageDescription() {
+ return "\nShuts down the installer's backgrouund processes";
+ }
+
+}
+
+class ShutdownConfig extends AbstractCommandConfig {
+
+}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/StartCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/StartCommand.java
index 99dfaa5..8004e9a 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/StartCommand.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/StartCommand.java
@@ -32,6 +32,7 @@
@Override
protected void execCommand() throws Exception {
+ InstallerDriver.initConfig();
String asterixInstanceName = ((StartConfig) config).name;
AsterixInstance instance = InstallerUtil.validateAsterixInstanceExists(asterixInstanceName, State.INACTIVE);
InstallerUtil.createAsterixZip(instance, false);
@@ -53,21 +54,18 @@
@Override
protected String getUsageDescription() {
- // TODO Auto-generated method stub
- return null;
+ return "\nStarts an ASTERIX instance that is in INACTIVE state."
+ + "\nAfter executing the start command, the ASTERIX instance transits to the ACTIVE state,"
+ + "\nindicating that it is now available for executing statements/queries."
+ + "\n\nAvailable arguments/options" + "\n-n name of the ASTERIX instance. ";
}
-
}
-class StartConfig implements CommandConfig {
+class StartConfig extends AbstractCommandConfig {
- @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")
- public String confPath;
+
}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/StopCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/StopCommand.java
index 81b147a..85fcb68 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/StopCommand.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/StopCommand.java
@@ -24,6 +24,7 @@
import edu.uci.ics.asterix.event.schema.cluster.Node;
import edu.uci.ics.asterix.event.schema.pattern.Pattern;
import edu.uci.ics.asterix.event.schema.pattern.Patterns;
+import edu.uci.ics.asterix.installer.driver.InstallerDriver;
import edu.uci.ics.asterix.installer.driver.InstallerUtil;
import edu.uci.ics.asterix.installer.events.PatternCreator;
import edu.uci.ics.asterix.installer.model.AsterixInstance;
@@ -34,6 +35,7 @@
@Override
protected void execCommand() throws Exception {
+ InstallerDriver.initConfig();
String asterixInstanceName = ((StopConfig) config).name;
AsterixInstance asterixInstance = InstallerUtil.validateAsterixInstanceExists(asterixInstanceName,
State.ACTIVE, State.UNUSABLE);
@@ -68,16 +70,17 @@
@Override
protected String getUsageDescription() {
- // TODO Auto-generated method stub
- return null;
+ return "\nShuts an ASTERIX instance that is in ACTIVE/UNUSABLE state."
+ + "\nAfter executing the stop command, the ASTERIX instance transits"
+ + "\nto the INACTIVE state, indicating that it is no longer available"
+ + "\nfor executing statements/queries." + "\n\nAvailable arguments/options"
+ + "\n-n name of the ASTERIX instance.";
+
}
}
-class StopConfig implements CommandConfig {
-
- @Option(name = "-h", required = false, usage = "Help")
- public boolean help = false;
+class StopConfig extends AbstractCommandConfig {
@Option(name = "-n", required = true, usage = "Name of Asterix Instance")
public String name;
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
new file mode 100644
index 0000000..9638ac6
--- /dev/null
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ValidateCommand.java
@@ -0,0 +1,242 @@
+/*
+ * 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 java.io.File;
+import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
+
+import org.kohsuke.args4j.Option;
+
+import edu.uci.ics.asterix.event.schema.cluster.Cluster;
+import edu.uci.ics.asterix.event.schema.cluster.MasterNode;
+import edu.uci.ics.asterix.event.schema.cluster.Node;
+import edu.uci.ics.asterix.installer.driver.InstallerDriver;
+import edu.uci.ics.asterix.installer.schema.conf.Configuration;
+import edu.uci.ics.asterix.installer.schema.conf.Zookeeper;
+
+public class ValidateCommand extends AbstractCommand {
+
+ private static final String OK = " [" + "\u2713" + "]";
+ private static final String ERROR = " [" + "x" + "]";
+ private static final String WARNING = " [" + "!" + "]";
+
+ @Override
+ protected void execCommand() throws Exception {
+ ValidateConfig vConfig = (ValidateConfig) config;
+ logValidationResult("Enviornment", validateEnvironment());
+ if (((ValidateConfig) config).cluster != null) {
+ logValidationResult("Cluster configuration", validateCluster(vConfig.cluster));
+ } else {
+ logValidationResult("Installer Configuration", validateConfiguration());
+ }
+ }
+
+ private void logValidationResult(String prefix, boolean isValid) {
+ if (!isValid) {
+ LOGGER.fatal(prefix + ERROR);
+ } else {
+ LOGGER.info(prefix + OK);
+ }
+ }
+
+ @Override
+ protected CommandConfig getCommandConfig() {
+ return new ValidateConfig();
+ }
+
+ @Override
+ protected String getUsageDescription() {
+ return "\nValidate the installer's configuration or a cluster configuration" + "\nUsage"
+ + "\nFor validating the installer configuration" + "\n use $ managix validate"
+ + "\n\nFor validating a cluster configuration"
+ + "\n$ use managix validate -c <path to the cluster configuration file>";
+ }
+
+ public boolean validateEnvironment() throws Exception {
+ boolean valid = true;
+ String managixHome = System.getenv(InstallerDriver.ENV_MANAGIX_HOME);
+ if (managixHome == null) {
+ valid = false;
+ LOGGER.fatal(InstallerDriver.ENV_MANAGIX_HOME + " not set " + ERROR);
+ } else {
+ File home = new File(managixHome);
+ if (!home.exists()) {
+ valid = false;
+ LOGGER.fatal(InstallerDriver.ENV_MANAGIX_HOME + ": " + home.getAbsolutePath() + " does not exist!"
+ + ERROR);
+ }
+ }
+ return valid;
+
+ }
+
+ public boolean validateCluster(String clusterPath) throws Exception {
+ boolean valid = true;
+ File f = new File(clusterPath);
+ if (!f.exists() || !f.isFile()) {
+ LOGGER.error(" Invalid path " + f.getAbsolutePath() + ERROR);
+ valid = false;
+ } else {
+ JAXBContext ctx = JAXBContext.newInstance(Cluster.class);
+ Unmarshaller unmarshaller = ctx.createUnmarshaller();
+ Cluster cluster = (Cluster) unmarshaller.unmarshal(new File(clusterPath));
+ validateClusterProperties(cluster);
+
+ Set<String> servers = new HashSet<String>();
+ Set<String> serverIds = new HashSet<String>();
+ servers.add(cluster.getMasterNode().getIp());
+ serverIds.add(cluster.getMasterNode().getId());
+
+ MasterNode masterNode = cluster.getMasterNode();
+ Node master = new Node(masterNode.getId(), masterNode.getIp(), masterNode.getRam(),
+ masterNode.getJavaHome(), masterNode.getLogdir(), null, masterNode.getDebug());
+
+ valid = valid & validateNodeConfiguration(master, cluster);
+
+ for (Node node : cluster.getNode()) {
+ servers.add(node.getIp());
+ if (serverIds.contains(node.getId())) {
+ valid = false;
+ LOGGER.error("Duplicate node id :" + node.getId() + ERROR);
+ } else {
+ valid = valid & validateNodeConfiguration(node, cluster);
+ }
+ }
+ }
+ return valid;
+ }
+
+ private void validateClusterProperties(Cluster cluster) {
+ List<String> tempDirs = new ArrayList<String>();
+ if (cluster.getLogdir() != null && checkTemporaryPath(cluster.getLogdir())) {
+ tempDirs.add("Log directory: " + cluster.getLogdir());
+ }
+ if (cluster.getStore() != null && checkTemporaryPath(cluster.getStore())) {
+ tempDirs.add("Store directory: " + cluster.getStore());
+ }
+
+ if (tempDirs.size() > 0) {
+ StringBuffer msg = new StringBuffer();
+ msg.append("The following paths are subject to be cleaned up by OS");
+ for (String tempDir : tempDirs) {
+ msg.append("\n" + tempDir + WARNING);
+ }
+ LOGGER.warn(msg);
+ }
+
+ }
+
+ private boolean validateNodeConfiguration(Node node, Cluster cluster) {
+ boolean valid = true;
+ valid = checkNodeReachability(node.getIp());
+ if (node.getJavaHome() == null || node.getJavaHome().length() == 0) {
+ if (cluster.getJavaHome() == null || cluster.getJavaHome().length() == 0) {
+ valid = false;
+ LOGGER.fatal("java_home not defined at cluster/node level for node: " + node.getId() + ERROR);
+ }
+ }
+
+ if (node.getLogdir() == null || node.getLogdir().length() == 0) {
+ if (cluster.getLogdir() == null || cluster.getLogdir().length() == 0) {
+ valid = false;
+ LOGGER.fatal("log_dir not defined at cluster/node level for node: " + node.getId() + ERROR);
+ }
+ }
+
+ if (node.getStore() == null || cluster.getStore().length() == 0) {
+ if (cluster.getMasterNode().getId().equals(node.getId())
+ && (cluster.getStore() == null || cluster.getStore().length() == 0)) {
+ valid = false;
+ LOGGER.fatal("store not defined at cluster/node level for node: " + node.getId() + ERROR);
+ }
+ }
+
+ if (node.getRam() == null || node.getRam().length() == 0) {
+ if (cluster.getRam() == null || cluster.getRam().length() == 0) {
+ valid = false;
+ LOGGER.fatal("ram not defined at cluster/node level for node: " + node.getId() + ERROR);
+ }
+ }
+ return valid;
+ }
+
+ private boolean checkTemporaryPath(String logdir) {
+ return logdir.startsWith("/tmp/");
+
+ }
+
+ public boolean validateConfiguration() throws Exception {
+ String managixHome = System.getenv(InstallerDriver.ENV_MANAGIX_HOME);
+ File configFile = new File(managixHome + File.separator + InstallerDriver.MANAGIX_CONF_XML);
+ JAXBContext configCtx = JAXBContext.newInstance(Configuration.class);
+ Unmarshaller unmarshaller = configCtx.createUnmarshaller();
+ Configuration conf = (Configuration) unmarshaller.unmarshal(configFile);
+ return validateZookeeperConfiguration(conf);
+ }
+
+ private boolean validateZookeeperConfiguration(Configuration conf) throws Exception {
+ boolean valid = true;
+ Zookeeper zk = conf.getZookeeper();
+
+ if (zk.getHomeDir() == null || zk.getHomeDir().length() == 0) {
+ valid = false;
+ LOGGER.fatal("Zookeeper home dir not configured" + ERROR);
+ } else if (checkTemporaryPath(zk.getHomeDir())) {
+ LOGGER.warn("Zookeeper home dir is subject to be cleaned up by OS" + WARNING);
+ }
+
+ if (zk.getServers().getServer().isEmpty()) {
+ valid = false;
+ LOGGER.fatal("Zookeeper servers not configured" + ERROR);
+ }
+
+ boolean validEnsemble = true;
+ for (String server : zk.getServers().getServer()) {
+ validEnsemble = validEnsemble && checkNodeReachability(server);
+ }
+
+ return valid;
+ }
+
+ private boolean checkNodeReachability(String server) {
+ boolean reachable = true;
+ try {
+ InetAddress address = InetAddress.getByName(server);
+ if (!address.isReachable(1000)) {
+ LOGGER.fatal("\n" + "Server: " + server + " unreachable" + ERROR);
+ reachable = false;
+ }
+ } catch (Exception e) {
+ reachable = false;
+ LOGGER.fatal("\n" + "Server: " + server + " Invalid address" + ERROR);
+ }
+ return reachable;
+ }
+
+}
+
+class ValidateConfig extends AbstractCommandConfig {
+
+ @Option(name = "-c", required = false, usage = "Path to the cluster configuration xml")
+ public String 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 f435b8d..bd8568f 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
@@ -24,6 +24,7 @@
import org.apache.log4j.Logger;
import edu.uci.ics.asterix.installer.command.CommandHandler;
+import edu.uci.ics.asterix.installer.command.ICommand.CommandType;
import edu.uci.ics.asterix.installer.schema.conf.Configuration;
import edu.uci.ics.asterix.installer.service.ILookupService;
import edu.uci.ics.asterix.installer.service.ServiceProvider;
@@ -38,8 +39,8 @@
public static final String EVENTS_DIR = "events";
private static final Logger LOGGER = Logger.getLogger(InstallerDriver.class.getName());
- private static final String ENV_MANAGIX_HOME = "MANAGIX_HOME";
- private static final String MANAGIX_CONF_XML = "conf" + File.separator + "installer-conf.xml";
+ public static final String ENV_MANAGIX_HOME = "INSTALLER_HOME";
+ public static final String MANAGIX_CONF_XML = "conf" + File.separator + "installer-conf.xml";
private static Configuration conf;
private static String managixHome;
@@ -53,8 +54,7 @@
return conf;
}
- private static void initConfig() throws Exception {
- managixHome = System.getenv(ENV_MANAGIX_HOME);
+ public static void initConfig() throws Exception {
File configFile = new File(managixHome + File.separator + MANAGIX_CONF_XML);
JAXBContext configCtx = JAXBContext.newInstance(Configuration.class);
Unmarshaller unmarshaller = configCtx.createUnmarshaller();
@@ -100,7 +100,7 @@
public static void main(String args[]) {
try {
if (args.length != 0) {
- initConfig();
+ managixHome = System.getenv(ENV_MANAGIX_HOME);
CommandHandler cmdHandler = new CommandHandler();
cmdHandler.processCommand(args);
} else {
@@ -110,12 +110,12 @@
LOGGER.error("Unknown command");
printUsage();
} catch (Exception e) {
- LOGGER.error(e.getMessage());
+ LOGGER.error(e);
}
}
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");
@@ -123,8 +123,11 @@
buffer.append("stop " + ":" + " Stops an asterix instance that is in ACTIVE state" + "\n");
buffer.append("backup " + ":" + " Creates a back up for an existing asterix instance" + "\n");
buffer.append("restore " + ":" + " Restores an asterix instance" + "\n");
- 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("configure" + ":" + " Auto-generate configuration for 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/driver/InstallerUtil.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/driver/InstallerUtil.java
index cd3ebdb..1007c01 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/driver/InstallerUtil.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/driver/InstallerUtil.java
@@ -51,9 +51,10 @@
public class InstallerUtil {
- public static AsterixInstance createAsterixInstance(String asterixInstanceName, Cluster cluster, String asterixConf)
+ public static AsterixInstance createAsterixInstance(String asterixInstanceName, Cluster cluster)
throws FileNotFoundException, IOException {
- Properties asterixConfProp = getAsterixConfiguration(asterixConf);
+ Properties asterixConfProp = new Properties();
+ asterixConfProp.put("output_dir", cluster.getWorkingDir().getDir() + File.separator + "asterix_output");
Node metadataNode = getMetadataNode(cluster);
String asterixZipName = InstallerDriver.getAsterixZip().substring(
InstallerDriver.getAsterixZip().lastIndexOf(File.separator) + 1);
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/error/OutputHandler.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/error/OutputHandler.java
index c5ad2a4..16b86df 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/error/OutputHandler.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/error/OutputHandler.java
@@ -14,6 +14,10 @@
*/
package edu.uci.ics.asterix.installer.error;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.Properties;
+
import edu.uci.ics.asterix.event.management.IOutputHandler;
import edu.uci.ics.asterix.event.management.OutputAnalysis;
import edu.uci.ics.asterix.event.schema.pattern.Event;
@@ -51,7 +55,8 @@
errorMessage.append("Insufficient permissions on HDFS back up directory");
ignore = false;
}
- if (output.contains("does not exist") || output.contains("File exist")) {
+ if (output.contains("does not exist") || output.contains("File exist")
+ || (output.contains("No such file or directory"))) {
ignore = true;
} else {
ignore = false;
@@ -65,7 +70,8 @@
errorMessage.append("Insufficient permissions on HDFS back up directory");
ignore = false;
}
- if (output.contains("does not exist") || output.contains("File exist")) {
+ if (output.contains("does not exist") || output.contains("File exist")
+ || output.contains("No such file or directory")) {
ignore = true;
} else {
ignore = false;
@@ -81,6 +87,22 @@
errorMessage.append("\nStop the instance to initiate a cleanup");
}
}
+ case NODE_INFO:
+ Properties p = new Properties();
+ try {
+ p.load(new ByteArrayInputStream(trimmedOutput.getBytes()));
+ } catch (IOException e) {
+ }
+ String javaVersion = (String) p.get("JAVA_VERSION");
+ if (p.get("JAVA_VERSION") == null) {
+ errorMessage.append("Java not installed on " + event.getNodeid().getValue().getAbsvalue());
+ ignore = false;
+ } else if (!javaVersion.contains("1.8")) {
+ errorMessage.append("Asterix requires Java 1.7.x. Incompatible version found on "
+ + event.getNodeid().getValue().getAbsvalue());
+ ignore = false;
+ }
+ break;
}
if (ignore) {
return new OutputAnalysis(true, null);
@@ -88,5 +110,4 @@
return new OutputAnalysis(false, errorMessage.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..1217c0b 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
@@ -17,7 +17,6 @@
import java.io.File;
import java.util.ArrayList;
import java.util.List;
-import java.util.logging.Logger;
import edu.uci.ics.asterix.event.driver.EventDriver;
import edu.uci.ics.asterix.event.schema.cluster.Cluster;
@@ -30,13 +29,16 @@
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.model.BackupInfo;
+import edu.uci.ics.asterix.installer.model.BackupInfo.BackupType;
+import edu.uci.ics.asterix.installer.schema.conf.Backup;
import edu.uci.ics.asterix.installer.service.ILookupService;
import edu.uci.ics.asterix.installer.service.ServiceProvider;
public class PatternCreator {
- private static final Logger LOGGER = Logger.getLogger(PatternCreator.class.getName());
private ILookupService lookupService = ServiceProvider.INSTANCE.getLookupService();
private void addInitialDelay(Pattern p, int delay, String unit) {
@@ -75,6 +77,20 @@
return patterns;
}
+ public Patterns getClusterInfoPattern(Cluster cluster) throws Exception {
+ List<Pattern> ps = new ArrayList<Pattern>();
+ String pargs = "";
+ List<Node> nodeList = cluster.getNode();
+ nodeList.add(new Node(cluster.getMasterNode().getId(), cluster.getMasterNode().getIp(), null, null, null, null,
+ null));
+ for (Node node : nodeList) {
+ Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
+ Event event = new Event("node_info", nodeid, pargs);
+ ps.add(new Pattern(null, 1, null, event));
+ }
+ return new Patterns(ps);
+ }
+
public Patterns getStopCommandPattern(StopCommand stopCommand) throws Exception {
List<Pattern> ps = new ArrayList<Pattern>();
AsterixInstance asterixInstance = lookupService.getAsterixInstance(stopCommand.getAsterixInstanceName());
@@ -97,12 +113,41 @@
return patterns;
}
- public Patterns getBackUpAsterixPattern(AsterixInstance instance, String backupPath) throws Exception {
+ public Patterns getBackUpAsterixPattern(AsterixInstance instance, Backup backupConf) throws Exception {
+ BackupType backupType = BackupInfo.getBackupType(backupConf);
+ Patterns patterns = null;
+ switch (backupType) {
+ case HDFS:
+ patterns = getHDFSBackUpAsterixPattern(instance, backupConf);
+ break;
+ case LOCAL:
+ patterns = getLocalBackUpAsterixPattern(instance, backupConf);
+ break;
+ }
+ return patterns;
+ }
+
+ public Patterns getRestoreAsterixPattern(AsterixInstance instance, BackupInfo backupInfo) throws Exception {
+ BackupType backupType = backupInfo.getBackupType();
+ Patterns patterns = null;
+ switch (backupType) {
+ case HDFS:
+ patterns = getHDFSRestoreAsterixPattern(instance, backupInfo);
+ break;
+ case LOCAL:
+ patterns = getLocalRestoreAsterixPattern(instance, backupInfo);
+ break;
+ }
+ return patterns;
+ }
+
+ private Patterns getHDFSBackUpAsterixPattern(AsterixInstance instance, Backup backupConf) throws Exception {
Cluster cluster = instance.getCluster();
String clusterStore = instance.getCluster().getStore();
- String hdfsUrl = InstallerDriver.getConfiguration().getBackup().getHdfs().getUrl();
- String hadoopVersion = InstallerDriver.getConfiguration().getBackup().getHdfs().getVersion();
- String hdfsBackupDir = InstallerDriver.getConfiguration().getBackup().getHdfs().getBackupDir();
+ String hdfsUrl = backupConf.getHdfs().getUrl();
+ String hadoopVersion = backupConf.getHdfs().getVersion();
+ String hdfsBackupDir = backupConf.getBackupDir();
+ VerificationUtil.verifyBackupRestoreConfiguration(hdfsUrl, hadoopVersion, hdfsBackupDir);
String workingDir = cluster.getWorkingDir().getDir();
String backupId = "" + instance.getBackupInfo().size();
String nodeStore;
@@ -111,29 +156,71 @@
for (Node node : cluster.getNode()) {
Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
nodeStore = node.getStore() == null ? clusterStore : node.getStore();
- pargs = workingDir + " " + instance.getName() + " " + nodeStore + " " + backupId + " " + hdfsUrl + " "
- + hadoopVersion + " " + hdfsBackupDir + " " + node.getId();
+ pargs = workingDir + " " + instance.getName() + " " + nodeStore + " " + backupId + " " + hdfsBackupDir
+ + " " + "hdfs" + " " + node.getId() + " " + hdfsUrl + " " + hadoopVersion;
Event event = new Event("backup", nodeid, pargs);
patternList.add(new Pattern(null, 1, null, event));
}
return new Patterns(patternList);
}
- public Patterns getRestoreAsterixPattern(AsterixInstance instance, int backupId) throws Exception {
+ private Patterns getLocalBackUpAsterixPattern(AsterixInstance instance, Backup backupConf) throws Exception {
Cluster cluster = instance.getCluster();
String clusterStore = instance.getCluster().getStore();
- String hdfsUrl = InstallerDriver.getConfiguration().getBackup().getHdfs().getUrl();
- String hadoopVersion = InstallerDriver.getConfiguration().getBackup().getHdfs().getVersion();
- String hdfsBackupDir = InstallerDriver.getConfiguration().getBackup().getHdfs().getBackupDir();
+ String backupDir = backupConf.getBackupDir();
String workingDir = cluster.getWorkingDir().getDir();
+ String backupId = "" + instance.getBackupInfo().size();
String nodeStore;
String pargs;
List<Pattern> patternList = new ArrayList<Pattern>();
for (Node node : cluster.getNode()) {
Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
nodeStore = node.getStore() == null ? clusterStore : node.getStore();
- pargs = workingDir + " " + instance.getName() + " " + nodeStore + " " + backupId + " " + hdfsUrl + " "
- + hadoopVersion + " " + hdfsBackupDir + " " + node.getId();
+ pargs = workingDir + " " + instance.getName() + " " + nodeStore + " " + backupId + " " + backupDir + " "
+ + "local" + " " + node.getId();
+ Event event = new Event("backup", nodeid, pargs);
+ patternList.add(new Pattern(null, 1, null, event));
+ }
+ return new Patterns(patternList);
+ }
+
+ public Patterns getHDFSRestoreAsterixPattern(AsterixInstance instance, BackupInfo backupInfo) throws Exception {
+ Cluster cluster = instance.getCluster();
+ String clusterStore = instance.getCluster().getStore();
+ String hdfsUrl = backupInfo.getBackupConf().getHdfs().getUrl();
+ String hadoopVersion = backupInfo.getBackupConf().getHdfs().getVersion();
+ String hdfsBackupDir = backupInfo.getBackupConf().getBackupDir();
+ VerificationUtil.verifyBackupRestoreConfiguration(hdfsUrl, hadoopVersion, hdfsBackupDir);
+ String workingDir = cluster.getWorkingDir().getDir();
+ int backupId = backupInfo.getId();
+ String nodeStore;
+ String pargs;
+ List<Pattern> patternList = new ArrayList<Pattern>();
+ for (Node node : cluster.getNode()) {
+ Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
+ nodeStore = node.getStore() == null ? clusterStore : node.getStore();
+ pargs = workingDir + " " + instance.getName() + " " + nodeStore + " " + backupId + " " + hdfsBackupDir
+ + " " + "hdfs" + " " + node.getId() + " " + hdfsUrl + " " + hadoopVersion;
+ Event event = new Event("restore", nodeid, pargs);
+ patternList.add(new Pattern(null, 1, null, event));
+ }
+ return new Patterns(patternList);
+ }
+
+ public Patterns getLocalRestoreAsterixPattern(AsterixInstance instance, BackupInfo backupInfo) throws Exception {
+ Cluster cluster = instance.getCluster();
+ String clusterStore = instance.getCluster().getStore();
+ String backupDir = backupInfo.getBackupConf().getBackupDir();
+ String workingDir = cluster.getWorkingDir().getDir();
+ int backupId = backupInfo.getId();
+ String nodeStore;
+ String pargs;
+ List<Pattern> patternList = new ArrayList<Pattern>();
+ for (Node node : cluster.getNode()) {
+ Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
+ nodeStore = node.getStore() == null ? clusterStore : node.getStore();
+ pargs = workingDir + " " + instance.getName() + " " + nodeStore + " " + backupId + " " + backupDir + " "
+ + "local" + " " + node.getId();
Event event = new Event("restore", nodeid, pargs);
patternList.add(new Pattern(null, 1, null, event));
}
@@ -190,7 +277,7 @@
Cluster cluster = instance.getCluster();
String hdfsUrl = InstallerDriver.getConfiguration().getBackup().getHdfs().getUrl();
String hadoopVersion = InstallerDriver.getConfiguration().getBackup().getHdfs().getVersion();
- String hdfsBackupDir = InstallerDriver.getConfiguration().getBackup().getHdfs().getBackupDir();
+ String hdfsBackupDir = InstallerDriver.getConfiguration().getBackup().getBackupDir();
String workingDir = cluster.getWorkingDir().getDir();
Node launchingNode = cluster.getNode().get(0);
Nodeid nodeid = new Nodeid(new Value(null, launchingNode.getId()));
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/AsterixInstance.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/AsterixInstance.java
index f020b6d..b0a7501 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/AsterixInstance.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/AsterixInstance.java
@@ -164,7 +164,7 @@
buffer.append("\n");
if (backupInfo != null && backupInfo.size() > 0) {
for (BackupInfo info : backupInfo) {
- buffer.append("Backup:" + info.getId() + " created at " + info.getDate() + "\n");
+ buffer.append(info + "\n");
}
}
buffer.append("\n");
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/BackupInfo.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/BackupInfo.java
index a5d2b36..cea8087 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/BackupInfo.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/BackupInfo.java
@@ -17,14 +17,24 @@
import java.io.Serializable;
import java.util.Date;
+import edu.uci.ics.asterix.installer.schema.conf.Backup;
+import edu.uci.ics.asterix.installer.schema.conf.Hdfs;
+
public class BackupInfo implements Serializable {
-
+
+ public static enum BackupType {
+ LOCAL,
+ HDFS
+ };
+
private final int id;
private final Date date;
+ private final Backup backupConf;
- public BackupInfo(int id, Date date) {
+ public BackupInfo(int id, Date date, Backup backupConf) {
this.id = id;
this.date = date;
+ this.backupConf = backupConf;
}
public int getId() {
@@ -34,10 +44,25 @@
public Date getDate() {
return date;
}
-
- @Override
- public String toString() {
- return id + "_" + date;
+
+ public Backup getBackupConf() {
+ return backupConf;
}
+ @Override
+ public String toString() {
+ return id + " " + date + " " + "(" + getBackupType() + ")" + " " + "[ " + this.getBackupConf().getBackupDir()
+ + " ]";
+
+ }
+
+ public BackupType getBackupType() {
+ return getBackupType(this.getBackupConf());
+ }
+
+ public static BackupType getBackupType(Backup backupConf) {
+ Hdfs hdfs = backupConf.getHdfs();
+ return (hdfs != null && hdfs.getUrl() != null && hdfs.getUrl().length() > 0) ? BackupType.HDFS
+ : BackupType.LOCAL;
+ }
}
\ No newline at end of file
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/EventList.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/EventList.java
index e7f7264..8ab6adc 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/EventList.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/EventList.java
@@ -27,6 +27,7 @@
FILE_DELETE,
HDFS_DELETE,
FILE_TRANSFER,
- DIRECTORY_TRANSFER
+ DIRECTORY_TRANSFER,
+ NODE_INFO
}
}
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 a35da73..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
@@ -23,6 +23,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
import org.apache.log4j.Logger;
import org.apache.zookeeper.CreateMode;
@@ -103,10 +104,34 @@
}
Runtime.getRuntime().exec(cmdBuffer.toString());
zk = new ZooKeeper(zkConnectionString, ZOOKEEPER_SESSION_TIME_OUT, watcher);
+ String head = msgQ.poll(10, TimeUnit.SECONDS);
+ if (head == null) {
+ String msg = "Unable to start Zookeeper Service. Please verify the configuration at "
+ + InstallerDriver.getManagixHome() + File.separator + InstallerDriver.MANAGIX_CONF_XML;
+ throw new Exception(msg);
+ }
msgQ.take();
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/conf/asterix.conf b/asterix-installer/src/main/resources/clusters/local/conf/asterix.conf
similarity index 100%
rename from asterix-installer/src/main/resources/conf/asterix.conf
rename to asterix-installer/src/main/resources/clusters/local/conf/asterix.conf
diff --git a/asterix-installer/src/main/resources/clusters/local.xml b/asterix-installer/src/main/resources/clusters/local/local.xml
similarity index 100%
rename from asterix-installer/src/main/resources/clusters/local.xml
rename to asterix-installer/src/main/resources/clusters/local/local.xml
diff --git a/asterix-installer/src/main/resources/conf/log4j.properties b/asterix-installer/src/main/resources/conf/log4j.properties
index b951c14..fedf941 100644
--- a/asterix-installer/src/main/resources/conf/log4j.properties
+++ b/asterix-installer/src/main/resources/conf/log4j.properties
@@ -3,7 +3,7 @@
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
# Print the date in ISO 8601 format
-log4j.appender.A1.layout.ConversionPattern=%d %-p: %n%m%n
+log4j.appender.A1.layout.ConversionPattern=%-p: %m%n
log4j.logger.edu.uci.ics.asterix.event.management=error
log4j.logger.org.apache.zookeeper=error
diff --git a/asterix-installer/src/main/resources/schema/installer-conf.xsd b/asterix-installer/src/main/resources/schema/installer-conf.xsd
index 489b024..318e7ce 100644
--- a/asterix-installer/src/main/resources/schema/installer-conf.xsd
+++ b/asterix-installer/src/main/resources/schema/installer-conf.xsd
@@ -18,7 +18,6 @@
<xs:sequence>
<xs:element ref="mg:version"/>
<xs:element ref="mg:url"/>
- <xs:element ref="mg:backupDir"/>
</xs:sequence>
</xs:complexType>
</xs:element>
@@ -26,7 +25,8 @@
<xs:element name="backup">
<xs:complexType>
<xs:sequence>
- <xs:element ref="mg:hdfs"/>
+ <xs:element ref="mg:hdfs" minOccurs="0"/>
+ <xs:element ref="mg:backupDir"/>
</xs:sequence>
</xs:complexType>
</xs:element>
diff --git a/asterix-installer/src/main/resources/schema/jaxb-bindings.xjb b/asterix-installer/src/main/resources/schema/jaxb-bindings.xjb
new file mode 100644
index 0000000..b5982e0
--- /dev/null
+++ b/asterix-installer/src/main/resources/schema/jaxb-bindings.xjb
@@ -0,0 +1,9 @@
+<jxb:bindings version="1.0"
+xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
+xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+<jxb:globalBindings>
+ <jxb:serializable uid="1"/>
+</jxb:globalBindings>
+
+</jxb:bindings>
diff --git a/asterix-installer/src/main/resources/scripts/managix b/asterix-installer/src/main/resources/scripts/managix
index cd0794e..11810ef 100755
--- a/asterix-installer/src/main/resources/scripts/managix
+++ b/asterix-installer/src/main/resources/scripts/managix
@@ -1,20 +1,20 @@
-if [ -z $MANAGIX_HOME ]
+if [ -z $INSTALLER_HOME ]
then
- echo "MANAGIX_HOME is not defined"
+ echo "INSTALLER_HOME is not defined"
exit 1
fi
VERSION=0.0.4-SNAPSHOT
-for jar in `ls $MANAGIX_HOME/lib/*.jar`
+for jar in `ls $INSTALLER_HOME/lib/*.jar`
do
- if [ -z $MANAGIX_CLASSPATH ]
+ if [ -z $INSTALLER_CLASSPATH ]
then
- MANAGIX_CLASSPATH=$jar
+ INSTALLER_CLASSPATH=$jar
else
- MANAGIX_CLASSPATH=$MANAGIX_CLASSPATH:$jar
+ INSTALLER_CLASSPATH=$INSTALLER_CLASSPATH:$jar
fi
done
-MANAGIX_CLASSPATH=$MANAGIX_CLASSPATH:$MANAGIX_HOME/conf/log4j.properties
-java $JAVA_OPTS -Dlog4j.configuration=file:$MANAGIX_HOME/conf/log4j.properties -cp $MANAGIX_CLASSPATH edu.uci.ics.asterix.installer.driver.InstallerDriver $@
+INSTALLER_CLASSPATH=$INSTALLER_CLASSPATH:$INSTALLER_HOME/conf/log4j.properties
+java $JAVA_OPTS -Dlog4j.configuration=file:$INSTALLER_HOME/conf/log4j.properties -cp $INSTALLER_CLASSPATH edu.uci.ics.asterix.installer.driver.InstallerDriver $@
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
diff --git a/asterix-installer/src/main/resources/zookeeper/zk.init b/asterix-installer/src/main/resources/zookeeper/zk.init
index 9b554b1..937d8b3 100755
--- a/asterix-installer/src/main/resources/zookeeper/zk.init
+++ b/asterix-installer/src/main/resources/zookeeper/zk.init
@@ -1,11 +1,11 @@
ZK_HOME=$1
shift 1
-cd $MANAGIX_HOME/.managix/zookeeper
+cd $MANAGIX_HOME/.installer/zookeeper
tar cf zk.pkg.tar *
zk_server_id=1
for zk_host in $@
do
- ssh $zk_host "mkdir $ZK_HOME"
+ ssh $zk_host "mkdir -p $ZK_HOME"
scp ./zk.pkg.tar $zk_host:$ZK_HOME/
ssh $zk_host "cd $ZK_HOME && tar xf $ZK_HOME/zk.pkg.tar && chmod +x $ZK_HOME/bin/start_zk.sh"
ssh $zk_host "$ZK_HOME/bin/start_zk.sh $ZK_HOME $zk_server_id" &