managix changes post feedback (taking checkpoint)
git-svn-id: https://asterixdb.googlecode.com/svn/branches/asterix_lsm_stabilization_installer@1446 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 4e5fde1..8d38b56 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
@@ -18,132 +18,152 @@
import edu.uci.ics.hyracks.api.application.INCApplicationEntryPoint;
public class NCApplicationEntryPoint implements INCApplicationEntryPoint {
- private static final Logger LOGGER = Logger.getLogger(NCApplicationEntryPoint.class.getName());
+ private static final Logger LOGGER = Logger
+ .getLogger(NCApplicationEntryPoint.class.getName());
- private INCApplicationContext ncApplicationContext = null;
- private AsterixAppRuntimeContext runtimeContext;
- private String nodeId;
- private boolean isMetadataNode = false;
- private boolean stopInitiated = false;
- private SystemState systemState = SystemState.NEW_UNIVERSE;
+ private INCApplicationContext ncApplicationContext = null;
+ private AsterixAppRuntimeContext runtimeContext;
+ private String nodeId;
+ private boolean isMetadataNode = false;
+ private boolean stopInitiated = false;
+ private SystemState systemState = SystemState.NEW_UNIVERSE;
- @Override
- public void start(INCApplicationContext ncAppCtx, String[] args) throws Exception {
- ncApplicationContext = ncAppCtx;
- nodeId = ncApplicationContext.getNodeId();
- if (LOGGER.isLoggable(Level.INFO)) {
- LOGGER.info("Starting Asterix node controller: " + nodeId);
- }
+ @Override
+ public void start(INCApplicationContext ncAppCtx, String[] args)
+ throws Exception {
+ ncApplicationContext = ncAppCtx;
+ nodeId = ncApplicationContext.getNodeId();
+ if (LOGGER.isLoggable(Level.INFO)) {
+ LOGGER.info("Starting Asterix node controller: " + nodeId);
+ }
- runtimeContext = new AsterixAppRuntimeContext(ncApplicationContext);
- runtimeContext.initialize();
- ncApplicationContext.setApplicationObject(runtimeContext);
- JVMShutdownHook sHook = new JVMShutdownHook(this);
- Runtime.getRuntime().addShutdownHook(sHook);
+ runtimeContext = new AsterixAppRuntimeContext(ncApplicationContext);
+ runtimeContext.initialize();
+ ncApplicationContext.setApplicationObject(runtimeContext);
+ JVMShutdownHook sHook = new JVMShutdownHook(this);
+ Runtime.getRuntime().addShutdownHook(sHook);
- //#. recover if the system is corrupted by checking system state.
- IRecoveryManager recoveryMgr = runtimeContext.getTransactionSubsystem().getRecoveryManager();
- systemState = recoveryMgr.getSystemState();
- if (systemState != SystemState.NEW_UNIVERSE) {
- PersistentLocalResourceRepository localResourceRepository = (PersistentLocalResourceRepository) runtimeContext
- .getLocalResourceRepository();
- localResourceRepository.initialize(nodeId, null, false, runtimeContext.getResourceIdFactory());
- }
- if (systemState == SystemState.CORRUPTED) {
- recoveryMgr.startRecovery(true);
- } else if (systemState == SystemState.NEW_UNIVERSE) {
- recoveryMgr.checkpoint(true);
- }
- }
+ // #. recover if the system is corrupted by checking system state.
+ IRecoveryManager recoveryMgr = runtimeContext.getTransactionSubsystem()
+ .getRecoveryManager();
+ systemState = recoveryMgr.getSystemState();
+ if (systemState != SystemState.NEW_UNIVERSE) {
+ PersistentLocalResourceRepository localResourceRepository = (PersistentLocalResourceRepository) runtimeContext
+ .getLocalResourceRepository();
+ localResourceRepository.initialize(nodeId, null, false,
+ runtimeContext.getResourceIdFactory());
+ }
+ if (systemState == SystemState.CORRUPTED) {
+ recoveryMgr.startRecovery(true);
+ } else if (systemState == SystemState.NEW_UNIVERSE) {
+ recoveryMgr.checkpoint(true);
+ }
+ }
- @Override
- public void stop() throws Exception {
- if (!stopInitiated) {
- stopInitiated = true;
- if (LOGGER.isLoggable(Level.INFO)) {
- LOGGER.info("Stopping Asterix node controller: " + nodeId);
- }
+ @Override
+ public void stop() throws Exception {
+ if (!stopInitiated) {
+ stopInitiated = true;
+ if (LOGGER.isLoggable(Level.INFO)) {
+ LOGGER.info("Stopping Asterix node controller: " + nodeId);
+ }
- IRecoveryManager recoveryMgr = runtimeContext.getTransactionSubsystem().getRecoveryManager();
- recoveryMgr.checkpoint(true);
+ IRecoveryManager recoveryMgr = runtimeContext
+ .getTransactionSubsystem().getRecoveryManager();
+ recoveryMgr.checkpoint(true);
- if (isMetadataNode) {
- MetadataBootstrap.stopUniverse();
- }
- runtimeContext.deinitialize();
- } else {
- if (LOGGER.isLoggable(Level.INFO)) {
- LOGGER.info("Duplicate attempt to stop ignored: " + nodeId);
- }
- }
- }
+ if (isMetadataNode) {
+ MetadataBootstrap.stopUniverse();
+ }
+ runtimeContext.deinitialize();
+ } else {
+ if (LOGGER.isLoggable(Level.INFO)) {
+ LOGGER.info("Duplicate attempt to stop ignored: " + nodeId);
+ }
+ }
+ }
- @Override
- public void notifyStartupComplete() throws Exception {
- IAsterixStateProxy proxy = (IAsterixStateProxy) ncApplicationContext.getDistributedState();
+ @Override
+ public void notifyStartupComplete() throws Exception {
+ IAsterixStateProxy proxy = (IAsterixStateProxy) ncApplicationContext
+ .getDistributedState();
- if (systemState == SystemState.NEW_UNIVERSE) {
- PersistentLocalResourceRepository localResourceRepository = (PersistentLocalResourceRepository) runtimeContext
- .getLocalResourceRepository();
- localResourceRepository.initialize(nodeId, proxy.getAsterixProperties().getStores().get(nodeId)[0], true,
- null);
- }
+ if (systemState == SystemState.NEW_UNIVERSE) {
+ PersistentLocalResourceRepository localResourceRepository = (PersistentLocalResourceRepository) runtimeContext
+ .getLocalResourceRepository();
+ System.out.println("nodeid" + nodeId);
+ System.out.println("proxy" + proxy);
+ System.out.println("stores"
+ + proxy.getAsterixProperties().getStores());
+ System.out.println("store"
+ + proxy.getAsterixProperties().getStores().get(nodeId)[0]);
- isMetadataNode = nodeId.equals(proxy.getAsterixProperties().getMetadataNodeName());
- if (isMetadataNode) {
- registerRemoteMetadataNode(proxy);
+ localResourceRepository.initialize(nodeId, proxy
+ .getAsterixProperties().getStores().get(nodeId)[0], true,
+ null);
+ }
- if (LOGGER.isLoggable(Level.INFO)) {
- LOGGER.info("Bootstrapping metadata");
- }
- MetadataManager.INSTANCE = new MetadataManager(proxy);
- MetadataManager.INSTANCE.init();
- MetadataBootstrap.startUniverse(proxy.getAsterixProperties(), ncApplicationContext,
- systemState == SystemState.NEW_UNIVERSE);
- MetadataBootstrap.startDDLRecovery();
- }
+ isMetadataNode = nodeId.equals(proxy.getAsterixProperties()
+ .getMetadataNodeName());
+ if (isMetadataNode) {
+ registerRemoteMetadataNode(proxy);
- IRecoveryManager recoveryMgr = runtimeContext.getTransactionSubsystem().getRecoveryManager();
- recoveryMgr.checkpoint(true);
+ if (LOGGER.isLoggable(Level.INFO)) {
+ LOGGER.info("Bootstrapping metadata");
+ }
+ MetadataManager.INSTANCE = new MetadataManager(proxy);
+ MetadataManager.INSTANCE.init();
+ MetadataBootstrap.startUniverse(proxy.getAsterixProperties(),
+ ncApplicationContext,
+ systemState == SystemState.NEW_UNIVERSE);
+ MetadataBootstrap.startDDLRecovery();
+ }
- //TODO
- //reclaim storage for orphaned index artifacts in NCs.
- }
+ IRecoveryManager recoveryMgr = runtimeContext.getTransactionSubsystem()
+ .getRecoveryManager();
+ recoveryMgr.checkpoint(true);
- public void registerRemoteMetadataNode(IAsterixStateProxy proxy) throws RemoteException {
- IMetadataNode stub = null;
- MetadataNode.INSTANCE.initialize(runtimeContext);
- stub = (IMetadataNode) UnicastRemoteObject.exportObject(MetadataNode.INSTANCE, 0);
- proxy.setMetadataNode(stub);
+ // TODO
+ // reclaim storage for orphaned index artifacts in NCs.
+ }
- if (LOGGER.isLoggable(Level.INFO)) {
- LOGGER.info("Metadata node bound");
- }
- }
+ public void registerRemoteMetadataNode(IAsterixStateProxy proxy)
+ throws RemoteException {
+ IMetadataNode stub = null;
+ MetadataNode.INSTANCE.initialize(runtimeContext);
+ stub = (IMetadataNode) UnicastRemoteObject.exportObject(
+ MetadataNode.INSTANCE, 0);
+ proxy.setMetadataNode(stub);
- /**
- * Shutdown hook that invokes {@link NCApplicationEntryPoint#stop() stop} method.
- */
- private static class JVMShutdownHook extends Thread {
+ if (LOGGER.isLoggable(Level.INFO)) {
+ LOGGER.info("Metadata node bound");
+ }
+ }
- private final NCApplicationEntryPoint ncAppEntryPoint;
+ /**
+ * Shutdown hook that invokes {@link NCApplicationEntryPoint#stop() stop}
+ * method.
+ */
+ private static class JVMShutdownHook extends Thread {
- public JVMShutdownHook(NCApplicationEntryPoint ncAppEntryPoint) {
- this.ncAppEntryPoint = ncAppEntryPoint;
- }
+ private final NCApplicationEntryPoint 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);
- }
- }
- }
- }
+ 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 d3c338d..66c0102 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
@@ -41,7 +41,7 @@
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, null);
+ public static final Node CLIENT_NODE = new Node(CLIENT_NODE_ID, "127.0.0.1", null, null, null, null, null, null);
private static String eventsDir;
private static Events events;
@@ -141,9 +141,9 @@
args.add(scriptDirSuffix);
Node clientNode = new Node();
clientNode.setId("client");
- clientNode.setIp("127.0.0.1");
+ clientNode.setClusterIp("127.0.0.1");
for (Node node : cluster.getNode()) {
- args.add(node.getIp());
+ args.add(node.getClusterIp());
}
EventUtil.executeLocalScript(clientNode, eventsDir + "/" + "events" + "/" + "prepare.sh", args);
}
@@ -153,11 +153,10 @@
args.add(scriptDirSuffix);
Node clientNode = new Node();
clientNode.setId("client");
- clientNode.setIp("127.0.0.1");
+ clientNode.setClusterIp("127.0.0.1");
for (Node node : cluster.getNode()) {
- args.add(node.getIp());
+ args.add(node.getClusterIp());
}
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 0157f65..6d89c88 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
@@ -18,6 +18,7 @@
import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
+import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
@@ -44,21 +45,28 @@
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() + " ");
+ StringBuffer envBuffer = new StringBuffer(IP_LOCATION + "=" + node.getClusterIp() + " ");
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.getJavaHeap() == null ? cluster.getJavaHeap() : node.getJavaHeap());
- if (node.getDebug() != null) {
- val = val + " " + "-Xdebug -Xrunjdwp:transport=dt_socket,address=" + node.getDebug().intValue()
- + "," + "server=y,suspend=n";
+ StringBuilder builder = new StringBuilder();
+ builder.append("\"");
+ String javaOpts = (node.getJavaOpts() == null ? cluster.getJavaOpts() : node.getJavaOpts());
+ if (javaOpts != null) {
+ builder.append(javaOpts);
}
- val = val + "\"";
- envBuffer.append(p.getKey() + "=" + val + " ");
+ if (cluster.isDebugEnabled() != null && cluster.isDebugEnabled().booleanValue()) {
+ BigInteger debugPort = node.getDebug() == null ? cluster.getDebug() : node.getDebug();
+ if (debugPort != null) {
+ builder.append("-Xdebug -Xrunjdwp:transport=dt_socket,address=" + debugPort.intValue()
+ + "," + "server=y,suspend=n");
+ }
+ }
+ builder.append("\"");
+ envBuffer.append(p.getKey() + "=" + builder + " ");
} else {
envBuffer.append(p.getKey() + "=" + p.getValue() + " ");
}
@@ -66,6 +74,7 @@
}
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) {
@@ -74,7 +83,7 @@
}
ProcessBuilder pb = new ProcessBuilder(pargs);
- pb.environment().put(IP_LOCATION, node.getIp());
+ pb.environment().put(IP_LOCATION, node.getClusterIp());
pb.environment().put(CLUSTER_ENV, envBuffer.toString());
pb.environment().put(SCRIPT, script);
pb.environment().put(ARGS, argBuffer.toString());
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 bf31e9f..d484947 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
@@ -31,232 +31,215 @@
public class EventUtil {
- public static final String EVENTS_DIR = "events";
- public static final String CLUSTER_CONF = "config/cluster.xml";
- public static final String PATTERN_CONF = "config/pattern.xml";
- public static final DateFormat dateFormat = new SimpleDateFormat(
- "yyyy/MM/dd HH:mm:ss");
+ public static final String EVENTS_DIR = "events";
+ public static final String CLUSTER_CONF = "config/cluster.xml";
+ public static final String PATTERN_CONF = "config/pattern.xml";
+ public static final DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
- 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 EXECUTE_SCRIPT = "events/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 EXECUTE_SCRIPT = "events/execute.sh";
- public static long parseTimeInterval(ValueType v, String unit)
- throws IllegalArgumentException {
- int val = 0;
- switch (v.getType()) {
- case ABS:
- val = Integer.parseInt(v.getAbsoluteValue());
- break;
- case RANDOM_MIN_MAX:
- val = Randomizer.getInstance().getRandomInt(v.getMin(), v.getMax());
- break;
- case RANDOM_RANGE:
- String[] values = v.getRangeSet();
- val = Integer.parseInt(values[Randomizer.getInstance()
- .getRandomInt(0, values.length - 1)]);
- break;
- }
- return computeInterval(val, unit);
- }
+ public static long parseTimeInterval(ValueType v, String unit) throws IllegalArgumentException {
+ int val = 0;
+ switch (v.getType()) {
+ case ABS:
+ val = Integer.parseInt(v.getAbsoluteValue());
+ break;
+ case RANDOM_MIN_MAX:
+ val = Randomizer.getInstance().getRandomInt(v.getMin(), v.getMax());
+ break;
+ case RANDOM_RANGE:
+ String[] values = v.getRangeSet();
+ val = Integer.parseInt(values[Randomizer.getInstance().getRandomInt(0, values.length - 1)]);
+ break;
+ }
+ return computeInterval(val, unit);
+ }
- public static long parseTimeInterval(String v, String unit)
- throws IllegalArgumentException {
- int value = Integer.parseInt(v);
- return computeInterval(value, unit);
- }
+ public static long parseTimeInterval(String v, String unit) throws IllegalArgumentException {
+ int value = Integer.parseInt(v);
+ return computeInterval(value, unit);
+ }
- private static long computeInterval(int val, String unit) {
- int vmult = 1;
- if ("hr".equalsIgnoreCase(unit)) {
- vmult = 3600 * 1000;
- } else if ("min".equalsIgnoreCase(unit)) {
- vmult = 60 * 1000;
- } else if ("sec".equalsIgnoreCase(unit)) {
- vmult = 1000;
- } else
- throw new IllegalArgumentException(
- " invalid unit value specified for frequency (hr,min,sec)");
- return val * vmult;
+ private static long computeInterval(int val, String unit) {
+ int vmult = 1;
+ if ("hr".equalsIgnoreCase(unit)) {
+ vmult = 3600 * 1000;
+ } else if ("min".equalsIgnoreCase(unit)) {
+ vmult = 60 * 1000;
+ } else if ("sec".equalsIgnoreCase(unit)) {
+ vmult = 1000;
+ } else
+ throw new IllegalArgumentException(" invalid unit value specified for frequency (hr,min,sec)");
+ return val * vmult;
- }
+ }
- public static Event getEvent(Pattern pattern, Events events) {
- for (Event event : events.getEvent()) {
- if (event.getType().equals(pattern.getEvent().getType())) {
- return event;
- }
- }
- throw new IllegalArgumentException(" Unknown event type"
- + pattern.getEvent().getType());
- }
+ public static Event getEvent(Pattern pattern, Events events) {
+ for (Event event : events.getEvent()) {
+ if (event.getType().equals(pattern.getEvent().getType())) {
+ return event;
+ }
+ }
+ throw new IllegalArgumentException(" Unknown event type" + pattern.getEvent().getType());
+ }
- public static Node getEventLocation(Pattern pattern,
- List<Node> candidateLocations, Cluster cluster) {
- ValueType value = new ValueType(pattern.getEvent().getNodeid()
- .getValue());
- Node location = null;
- Type vtype = value.getType();
+ public static Node getEventLocation(Pattern pattern, List<Node> candidateLocations, Cluster cluster) {
+ ValueType value = new ValueType(pattern.getEvent().getNodeid().getValue());
+ Node location = null;
+ Type vtype = value.getType();
- switch (vtype) {
- case ABS:
- location = getNodeFromId(value.getAbsoluteValue(), cluster);
- break;
- case RANDOM_RANGE:
- int nodeIndex = Randomizer.getInstance().getRandomInt(0,
- candidateLocations.size() - 1);
- location = candidateLocations.get(nodeIndex);
- break;
- case RANDOM_MIN_MAX:
- throw new IllegalStateException(
- " Canont configure a min max value range for location");
- }
- return location;
+ switch (vtype) {
+ case ABS:
+ location = getNodeFromId(value.getAbsoluteValue(), cluster);
+ break;
+ case RANDOM_RANGE:
+ int nodeIndex = Randomizer.getInstance().getRandomInt(0, candidateLocations.size() - 1);
+ location = candidateLocations.get(nodeIndex);
+ break;
+ case RANDOM_MIN_MAX:
+ throw new IllegalStateException(" Canont configure a min max value range for location");
+ }
+ return location;
- }
+ }
- public static List<Node> getCandidateLocations(Pattern pattern,
- Cluster cluster) {
- ValueType value = new ValueType(pattern.getEvent().getNodeid()
- .getValue());
- List<Node> candidateList = new ArrayList<Node>();
- switch (value.getType()) {
- case ABS:
- candidateList.add(getNodeFromId(value.getAbsoluteValue(), cluster));
- break;
- case RANDOM_RANGE:
- boolean anyOption = false;
- String[] values = value.getRangeSet();
- for (String v : values) {
- if (v.equalsIgnoreCase("ANY")) {
- anyOption = true;
- }
- }
- if (anyOption) {
- for (Node node : cluster.getNode()) {
- candidateList.add(node);
- }
- } else {
- boolean found = false;
- for (String v : values) {
- for (Node node : cluster.getNode()) {
- if (node.getId().equals(v)) {
- candidateList.add(node);
- found = true;
- break;
- }
- }
- if (!found) {
- throw new IllegalStateException("Unknonw nodeId : " + v);
- }
- found = false;
- }
+ public static List<Node> getCandidateLocations(Pattern pattern, Cluster cluster) {
+ ValueType value = new ValueType(pattern.getEvent().getNodeid().getValue());
+ List<Node> candidateList = new ArrayList<Node>();
+ switch (value.getType()) {
+ case ABS:
+ candidateList.add(getNodeFromId(value.getAbsoluteValue(), cluster));
+ break;
+ case RANDOM_RANGE:
+ boolean anyOption = false;
+ String[] values = value.getRangeSet();
+ for (String v : values) {
+ if (v.equalsIgnoreCase("ANY")) {
+ anyOption = true;
+ }
+ }
+ if (anyOption) {
+ for (Node node : cluster.getNode()) {
+ candidateList.add(node);
+ }
+ } else {
+ boolean found = false;
+ for (String v : values) {
+ for (Node node : cluster.getNode()) {
+ if (node.getId().equals(v)) {
+ candidateList.add(node);
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ throw new IllegalStateException("Unknonw nodeId : " + v);
+ }
+ found = false;
+ }
- }
- String[] excluded = value.getRangeExcluded();
- if (excluded != null && excluded.length > 0) {
- List<Node> markedForRemoval = new ArrayList<Node>();
- for (String exclusion : excluded) {
- for (Node node : candidateList) {
- if (node.getId().equals(exclusion)) {
- markedForRemoval.add(node);
- }
- }
- }
- candidateList.removeAll(markedForRemoval);
- }
- break;
- case RANDOM_MIN_MAX:
- throw new IllegalStateException(
- " Invalid value configured for location");
- }
- return candidateList;
- }
+ }
+ String[] excluded = value.getRangeExcluded();
+ if (excluded != null && excluded.length > 0) {
+ List<Node> markedForRemoval = new ArrayList<Node>();
+ for (String exclusion : excluded) {
+ for (Node node : candidateList) {
+ if (node.getId().equals(exclusion)) {
+ markedForRemoval.add(node);
+ }
+ }
+ }
+ candidateList.removeAll(markedForRemoval);
+ }
+ break;
+ case RANDOM_MIN_MAX:
+ throw new IllegalStateException(" Invalid value configured for location");
+ }
+ return candidateList;
+ }
- private static Node getNodeFromId(String nodeid, Cluster cluster) {
- if (nodeid.equals(EventDriver.CLIENT_NODE.getId())) {
- return EventDriver.CLIENT_NODE;
- }
+ private static Node getNodeFromId(String nodeid, Cluster cluster) {
+ if (nodeid.equals(EventDriver.CLIENT_NODE.getId())) {
+ return EventDriver.CLIENT_NODE;
+ }
- if (nodeid.equals(cluster.getMasterNode().getId())) {
- String ram = cluster.getMasterNode().getJavaHeap() == null ? cluster
- .getJavaHeap() : cluster.getMasterNode().getJavaHeap();
- String logDir = cluster.getMasterNode().getLogdir() == null ? cluster
- .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,
- debug);
- }
+ if (nodeid.equals(cluster.getMasterNode().getId())) {
+ String javaOpts = cluster.getMasterNode().getJavaOpts() == null ? cluster.getJavaOpts() : cluster
+ .getMasterNode().getJavaOpts();
+ String logDir = cluster.getMasterNode().getLogdir() == null ? cluster.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().getClusterIp(), javaHome,
+ javaOpts, logDir, null, null, debug);
+ }
- List<Node> nodeList = cluster.getNode();
- for (Node node : nodeList) {
- if (node.getId().equals(nodeid)) {
- return node;
- }
- }
- StringBuffer buffer = new StringBuffer();
- buffer.append(EventDriver.CLIENT_NODE.getId() + ",");
- buffer.append(cluster.getMasterNode().getId() + ",");
- for (Node v : cluster.getNode()) {
- buffer.append(v.getId() + ",");
- }
- buffer.deleteCharAt(buffer.length() - 1);
- throw new IllegalArgumentException("Unknown node id :" + nodeid
- + " valid ids:" + buffer);
- }
+ List<Node> nodeList = cluster.getNode();
+ for (Node node : nodeList) {
+ if (node.getId().equals(nodeid)) {
+ return node;
+ }
+ }
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(EventDriver.CLIENT_NODE.getId() + ",");
+ buffer.append(cluster.getMasterNode().getId() + ",");
+ for (Node v : cluster.getNode()) {
+ buffer.append(v.getId() + ",");
+ }
+ buffer.deleteCharAt(buffer.length() - 1);
+ throw new IllegalArgumentException("Unknown node id :" + nodeid + " valid ids:" + buffer);
+ }
- public static void executeEventScript(Node node, String script,
- List<String> args, Cluster cluster) throws IOException,
- InterruptedException {
- List<String> pargs = new ArrayList<String>();
- pargs.add("/bin/bash");
- pargs.add(EventDriver.getEventsDir() + "/" + EXECUTE_SCRIPT);
- StringBuffer argBuffer = new StringBuffer();
- String env = EventDriver.getStringifiedEnv(cluster) + " " + IP_LOCATION
- + "=" + node.getIp();
- if (args != null) {
- for (String arg : args) {
- argBuffer.append(arg + " ");
- }
- }
- ProcessBuilder pb = new ProcessBuilder(pargs);
- pb.environment().putAll(EventDriver.getEnvironment());
- pb.environment().put(IP_LOCATION, node.getIp());
- pb.environment().put(CLUSTER_ENV, env);
- pb.environment().put(SCRIPT, script);
- pb.environment().put(ARGS, argBuffer.toString());
- pb.start();
- }
+ public static void executeEventScript(Node node, String script, List<String> args, Cluster cluster)
+ throws IOException, InterruptedException {
+ List<String> pargs = new ArrayList<String>();
+ pargs.add("/bin/bash");
+ pargs.add(EventDriver.getEventsDir() + "/" + EXECUTE_SCRIPT);
+ StringBuffer argBuffer = new StringBuffer();
+ String env = EventDriver.getStringifiedEnv(cluster) + " " + IP_LOCATION + "=" + node.getClusterIp();
+ if (args != null) {
+ for (String arg : args) {
+ argBuffer.append(arg + " ");
+ }
+ }
+ ProcessBuilder pb = new ProcessBuilder(pargs);
+ pb.environment().putAll(EventDriver.getEnvironment());
+ pb.environment().put(IP_LOCATION, node.getClusterIp());
+ pb.environment().put(CLUSTER_ENV, env);
+ pb.environment().put(SCRIPT, script);
+ pb.environment().put(ARGS, argBuffer.toString());
+ pb.start();
+ }
- public static void executeLocalScript(Node node, String script,
- List<String> args) throws IOException, InterruptedException {
- List<String> pargs = new ArrayList<String>();
- pargs.add("/bin/bash");
- pargs.add(script);
- if (args != null) {
- pargs.addAll(args);
- }
- ProcessBuilder pb = new ProcessBuilder(pargs);
- pb.environment().putAll(EventDriver.getEnvironment());
- pb.environment().put(IP_LOCATION, node.getIp());
- pb.start();
- }
+ public static void executeLocalScript(Node node, String script, List<String> args) throws IOException,
+ InterruptedException {
+ List<String> pargs = new ArrayList<String>();
+ pargs.add("/bin/bash");
+ pargs.add(script);
+ if (args != null) {
+ pargs.addAll(args);
+ }
+ ProcessBuilder pb = new ProcessBuilder(pargs);
+ pb.environment().putAll(EventDriver.getEnvironment());
+ pb.environment().put(IP_LOCATION, node.getClusterIp());
+ pb.start();
+ }
- public static List<String> getEventArgs(Pattern pattern) {
- List<String> pargs = new ArrayList<String>();
- if (pattern.getEvent().getPargs() == null) {
- return pargs;
- }
- String[] args = pattern.getEvent().getPargs().split(" ");
- for (String arg : args) {
- pargs.add(arg.trim());
- }
- return pargs;
- }
+ public static List<String> getEventArgs(Pattern pattern) {
+ List<String> pargs = new ArrayList<String>();
+ if (pattern.getEvent().getPargs() == null) {
+ return pargs;
+ }
+ String[] args = pattern.getEvent().getPargs().split(" ");
+ for (String arg : args) {
+ pargs.add(arg.trim());
+ }
+ return pargs;
+ }
}
diff --git a/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventrixClient.java b/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventrixClient.java
index 4cd4b82..52d46c8 100644
--- a/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventrixClient.java
+++ b/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventrixClient.java
@@ -38,166 +38,159 @@
public class EventrixClient {
- private static final Logger LOGGER = Logger.getLogger(EventrixClient.class
- .getName());
+ private static final Logger LOGGER = Logger.getLogger(EventrixClient.class.getName());
- private EventTask[] tasks;
- private boolean dryRun = false;
- private LinkedBlockingQueue<EventTaskReport> msgInbox = new LinkedBlockingQueue<EventTaskReport>();
- private AtomicInteger pendingTasks = new AtomicInteger(0);
- private final Cluster cluster;
- private IPatternListener listener;
- private IOutputHandler outputHandler;
- private Events events;
- private String eventsDir;
+ private EventTask[] tasks;
+ private boolean dryRun = false;
+ private LinkedBlockingQueue<EventTaskReport> msgInbox = new LinkedBlockingQueue<EventTaskReport>();
+ private AtomicInteger pendingTasks = new AtomicInteger(0);
+ private final Cluster cluster;
+ private IPatternListener listener;
+ private IOutputHandler outputHandler;
+ private Events events;
+ private String eventsDir;
- public EventrixClient(String eventsDir, Cluster cluster, boolean dryRun,
- IOutputHandler outputHandler) throws Exception {
- this.eventsDir = eventsDir;
- this.events = initializeEvents();
- this.cluster = cluster;
- this.dryRun = dryRun;
- this.outputHandler = outputHandler;
- if (!dryRun) {
- initializeCluster(eventsDir);
- }
- }
+ public EventrixClient(String eventsDir, Cluster cluster, boolean dryRun, IOutputHandler outputHandler)
+ throws Exception {
+ this.eventsDir = eventsDir;
+ this.events = initializeEvents();
+ this.cluster = cluster;
+ this.dryRun = dryRun;
+ this.outputHandler = outputHandler;
+ if (!dryRun) {
+ initializeCluster(eventsDir);
+ }
+ }
- public void submit(Patterns patterns) throws Exception {
- initTasks(patterns);
- try {
- waitForCompletion();
- } catch (InterruptedException ie) {
- LOGGER.info("Interrupted exception :" + ie);
- } catch (Exception e) {
- throw e;
- }
+ public void submit(Patterns patterns) throws Exception {
+ initTasks(patterns);
+ try {
+ waitForCompletion();
+ } catch (InterruptedException ie) {
+ LOGGER.info("Interrupted exception :" + ie);
+ } catch (Exception e) {
+ throw e;
+ }
- }
+ }
- public void submit(Patterns patterns, IPatternListener listener)
- throws Exception {
- this.listener = listener;
- initTasks(patterns);
- }
+ public void submit(Patterns patterns, IPatternListener listener) throws Exception {
+ this.listener = listener;
+ initTasks(patterns);
+ }
- private void initTasks(Patterns patterns) {
- tasks = new EventTask[patterns.getPattern().size()];
- pendingTasks.set(tasks.length);
- int index = 0;
- for (Pattern pattern : patterns.getPattern()) {
- tasks[index] = new EventTask(pattern, this);
- tasks[index].start();
- index++;
- }
- }
+ private void initTasks(Patterns patterns) {
+ tasks = new EventTask[patterns.getPattern().size()];
+ pendingTasks.set(tasks.length);
+ int index = 0;
+ for (Pattern pattern : patterns.getPattern()) {
+ tasks[index] = new EventTask(pattern, this);
+ tasks[index].start();
+ index++;
+ }
+ }
- public Cluster getCluster() {
- return cluster;
- }
+ public Cluster getCluster() {
+ return cluster;
+ }
- public boolean isDryRun() {
- return dryRun;
- }
+ public boolean isDryRun() {
+ return dryRun;
+ }
- public Events getEvents() {
- return events;
- }
+ public Events getEvents() {
+ return events;
+ }
- public String getEventsDir() {
- return eventsDir;
- }
+ public String getEventsDir() {
+ return eventsDir;
+ }
- public synchronized void notifyCompletion(EventTaskReport report) {
+ public synchronized void notifyCompletion(EventTaskReport report) {
- if (report.isSuccess()) {
- if (listener != null) {
- pendingTasks.decrementAndGet();
- listener.eventCompleted(report);
- if (pendingTasks.get() == 0) {
- listener.jobCompleted();
- }
- } else {
- try {
- msgInbox.put(report);
- } catch (InterruptedException e) {
- }
- }
- } else {
- for (EventTask t : tasks) {
- if (t.getState() == EventTask.State.INITIALIZED
- || t.getState() == EventTask.State.IN_PROGRESS) {
- t.cancel();
- }
- }
- if (listener != null) {
- listener.jobFailed(report);
- } else {
- try {
- msgInbox.put(report);
- } catch (InterruptedException e) {
- }
- }
- }
- }
+ if (report.isSuccess()) {
+ if (listener != null) {
+ pendingTasks.decrementAndGet();
+ listener.eventCompleted(report);
+ if (pendingTasks.get() == 0) {
+ listener.jobCompleted();
+ }
+ } else {
+ try {
+ msgInbox.put(report);
+ } catch (InterruptedException e) {
+ }
+ }
+ } else {
+ for (EventTask t : tasks) {
+ if (t.getState() == EventTask.State.INITIALIZED || t.getState() == EventTask.State.IN_PROGRESS) {
+ t.cancel();
+ }
+ }
+ if (listener != null) {
+ listener.jobFailed(report);
+ } else {
+ try {
+ msgInbox.put(report);
+ } catch (InterruptedException e) {
+ }
+ }
+ }
+ }
- private void waitForCompletion() throws Exception {
- while (true) {
- EventTaskReport report = msgInbox.take();
- if (report.isSuccess()) {
- if (pendingTasks.decrementAndGet() == 0) {
- break;
- }
- } else {
- throw new RuntimeException(report.getException().getMessage());
- }
- }
- }
+ private void waitForCompletion() throws Exception {
+ while (true) {
+ EventTaskReport report = msgInbox.take();
+ if (report.isSuccess()) {
+ if (pendingTasks.decrementAndGet() == 0) {
+ break;
+ }
+ } else {
+ throw new RuntimeException(report.getException().getMessage());
+ }
+ }
+ }
- private void initializeCluster(String eventsDir) throws Exception {
- Patterns patterns = initPattern(eventsDir);
- submit(patterns);
- }
+ private void initializeCluster(String eventsDir) throws Exception {
+ Patterns patterns = initPattern(eventsDir);
+ submit(patterns);
+ }
- private Patterns initPattern(String eventsDir) {
- Nodeid nodeid = new Nodeid(new Value(null,
- EventDriver.CLIENT_NODE.getId()));
- List<Pattern> patternList = new ArrayList<Pattern>();
- String workingDir = cluster.getWorkingDir().getDir();
- String username = cluster.getUsername() == null ? System
- .getProperty("user.name") : cluster.getUsername();
- patternList.add(getDirectoryTransferPattern(username, eventsDir,
- nodeid, cluster.getMasterNode().getIp(), workingDir));
+ private Patterns initPattern(String eventsDir) {
+ Nodeid nodeid = new Nodeid(new Value(null, EventDriver.CLIENT_NODE.getId()));
+ List<Pattern> patternList = new ArrayList<Pattern>();
+ String workingDir = cluster.getWorkingDir().getDir();
+ String username = cluster.getUsername() == null ? System.getProperty("user.name") : cluster.getUsername();
+ patternList.add(getDirectoryTransferPattern(username, eventsDir, nodeid,
+ cluster.getMasterNode().getClusterIp(), workingDir));
- if (!cluster.getWorkingDir().isNFS()) {
- for (Node node : cluster.getNode()) {
- patternList.add(getDirectoryTransferPattern(username,
- eventsDir, nodeid, node.getIp(), workingDir));
- }
- }
- Patterns patterns = new Patterns(patternList);
- return patterns;
- }
+ if (!cluster.getWorkingDir().isNFS()) {
+ for (Node node : cluster.getNode()) {
+ patternList.add(getDirectoryTransferPattern(username, eventsDir, nodeid, node.getClusterIp(),
+ workingDir));
+ }
+ }
+ Patterns patterns = new Patterns(patternList);
+ return patterns;
+ }
- private Pattern getDirectoryTransferPattern(String username, String src,
- Nodeid srcNode, String destNodeIp, String destDir) {
- String pargs = username + " " + src + " " + destNodeIp + " " + destDir;
- Event event = new Event("directory_transfer", srcNode, pargs);
- return new Pattern(null, 1, null, event);
- }
+ private Pattern getDirectoryTransferPattern(String username, String src, Nodeid srcNode, String destNodeIp,
+ String destDir) {
+ String pargs = username + " " + src + " " + destNodeIp + " " + destDir;
+ Event event = new Event("directory_transfer", srcNode, pargs);
+ return new Pattern(null, 1, null, event);
+ }
- public IOutputHandler getErrorHandler() {
- return outputHandler;
- }
+ public IOutputHandler getErrorHandler() {
+ return outputHandler;
+ }
- private Events initializeEvents() throws JAXBException,
- FileNotFoundException {
- File file = new File(eventsDir + File.separator + "events"
- + File.separator + "events.xml");
- JAXBContext eventCtx = JAXBContext.newInstance(Events.class);
- Unmarshaller unmarshaller = eventCtx.createUnmarshaller();
- events = (Events) unmarshaller.unmarshal(file);
- return events;
- }
+ private Events initializeEvents() throws JAXBException, FileNotFoundException {
+ File file = new File(eventsDir + File.separator + "events" + File.separator + "events.xml");
+ JAXBContext eventCtx = JAXBContext.newInstance(Events.class);
+ Unmarshaller unmarshaller = eventCtx.createUnmarshaller();
+ events = (Events) unmarshaller.unmarshal(file);
+ return events;
+ }
}
diff --git a/asterix-events/src/main/resources/events/node_join/nc_join.sh b/asterix-events/src/main/resources/events/node_join/nc_join.sh
index 5aa86db..6b5280b 100755
--- a/asterix-events/src/main/resources/events/node_join/nc_join.sh
+++ b/asterix-events/src/main/resources/events/node_join/nc_join.sh
@@ -1,7 +1,8 @@
CC_HOST=$1
NC_ID=$2
+IO_DEVICES=$3
if [ ! -d $LOG_DIR ];
then
mkdir -p $LOG_DIR
fi
-$ASTERIX_HOME/bin/asterixnc -node-id $NC_ID -cc-host $CC_HOST -cc-port 1099 -cluster-net-ip-address $IP_LOCATION -data-ip-address $IP_LOCATION -result-ip-address $IP_LOCATION &> $LOG_DIR/${NC_ID}.log
+$ASTERIX_HOME/bin/asterixnc -node-id $NC_ID -cc-host $CC_HOST -cc-port 1099 -cluster-net-ip-address $IP_LOCATION -data-ip-address $IP_LOCATION -iodevices $IO_DEVICES -result-ip-address $IP_LOCATION &> $LOG_DIR/${NC_ID}.log
diff --git a/asterix-events/src/main/resources/schema/cluster.xsd b/asterix-events/src/main/resources/schema/cluster.xsd
index 38afda3..0e1adce 100644
--- a/asterix-events/src/main/resources/schema/cluster.xsd
+++ b/asterix-events/src/main/resources/schema/cluster.xsd
@@ -3,19 +3,21 @@
<!-- definition of simple types -->
<xs:element name="name" type="xs:string"/>
-<xs:element name="java_heap" type="xs:string"/>
+<xs:element name="java_opts" type="xs:string"/>
<xs:element name="logdir" type="xs:string"/>
<xs:element name="id" type="xs:string"/>
-<xs:element name="ip" type="xs:string"/>
+<xs:element name="client-ip" type="xs:string"/>
<xs:element name="cluster-ip" type="xs:string"/>
<xs:element name="key" type="xs:string"/>
<xs:element name="value" type="xs:string"/>
<xs:element name="dir" type="xs:string"/>
<xs:element name="NFS" type="xs:boolean"/>
<xs:element name="store" type="xs:string"/>
+<xs:element name="iodevices" 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"/>
+<xs:element name="debugEnabled" type="xs:boolean"/>
<!-- definition of complex elements -->
<xs:element name="workingDir">
@@ -31,10 +33,10 @@
<xs:complexType>
<xs:sequence>
<xs:element ref="cl:id"/>
- <xs:element ref="cl:ip"/>
+ <xs:element ref="cl:client-ip"/>
<xs:element ref="cl:cluster-ip"/>
<xs:element ref="cl:java_home" minOccurs="0"/>
- <xs:element ref="cl:java_heap" minOccurs="0"/>
+ <xs:element ref="cl:java_opts" minOccurs="0"/>
<xs:element ref="cl:logdir" minOccurs="0"/>
<xs:element ref="cl:debug" minOccurs="0"/>
</xs:sequence>
@@ -62,11 +64,12 @@
<xs:complexType>
<xs:sequence>
<xs:element ref="cl:id"/>
- <xs:element ref="cl:ip"/>
- <xs:element ref="cl:java_heap" minOccurs="0"/>
+ <xs:element ref="cl:cluster-ip"/>
<xs:element ref="cl:java_home" minOccurs="0"/>
+ <xs:element ref="cl:java_opts" minOccurs="0"/>
<xs:element ref="cl:logdir" minOccurs="0"/>
<xs:element ref="cl:store" minOccurs="0"/>
+ <xs:element ref="cl:iodevices" minOccurs="0"/>
<xs:element ref="cl:debug" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
@@ -78,11 +81,14 @@
<xs:element ref="cl:name"/>
<xs:element ref="cl:username"/>
<xs:element ref="cl:env" minOccurs="0"/>
- <xs:element ref="cl:java_heap" minOccurs="0"/>
<xs:element ref="cl:java_home" minOccurs="0"/>
+ <xs:element ref="cl:java_opts" minOccurs="0"/>
<xs:element ref="cl:logdir" minOccurs="0"/>
<xs:element ref="cl:store" minOccurs="0"/>
+ <xs:element ref="cl:iodevices" minOccurs="0"/>
<xs:element ref="cl:workingDir"/>
+ <xs:element ref="cl:debugEnabled" minOccurs="0"/>
+ <xs:element ref="cl:debug" minOccurs="0"/>
<xs:element ref="cl:master-node"/>
<xs:element ref="cl:node" maxOccurs="unbounded"/>
</xs:sequence>
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 af7dbb7..66a0697 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
@@ -28,14 +28,10 @@
public void execute(String[] args) throws Exception {
String[] cmdArgs = new String[args.length - 1];
System.arraycopy(args, 1, cmdArgs, 0, cmdArgs.length);
- if (cmdArgs.length >= 1 && cmdArgs[0].equals("-help")) {
- System.out.println(getUsageDescription());
- } else {
- config = getCommandConfig();
- CmdLineParser parser = new CmdLineParser(config);
- parser.parseArgument(cmdArgs);
- execCommand();
- }
+ 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
deleted file mode 100644
index f28dfd9..0000000
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/AbstractCommandConfig.java
+++ /dev/null
@@ -1,15 +0,0 @@
-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 e52308e..5ef7449 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
@@ -52,14 +52,13 @@
protected String getUsageDescription() {
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\nAvailable arguments/options" + "\n-n name of the ASTERIX instance"
+ "\n-conf path to the ASTERIX configuration file.";
}
}
-class AlterConfig extends AbstractCommandConfig {
+class AlterConfig extends CommandConfig {
@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/BackupCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/BackupCommand.java
index cd4cc5c..603862c 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
@@ -59,15 +59,14 @@
+ "\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:"
+ + "\nThe backed up snapshot is stored in HDFS." + "\n\nAvailable arguments/options:"
+ "\n-n name of the Asterix instance";
}
}
-class BackupConfig extends AbstractCommandConfig {
+class BackupConfig extends CommandConfig {
@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/CommandConfig.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/CommandConfig.java
index 94aa935..55b0c3b 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
@@ -1,20 +1,5 @@
-/*
- * 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;
-public interface CommandConfig {
+public abstract class 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 8a9347a..7fc3884 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
@@ -55,6 +55,9 @@
case SHUTDOWN:
cmd = new ShutdownCommand();
break;
+ case HELP:
+ cmd = new HelpCommand();
+ 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
index 6b0b53d..cad8632 100644
--- 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
@@ -26,9 +26,11 @@
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.setIodevices(workingDir);
+ cluster.setStore("storage");
cluster.setLogdir(workingDir + File.separator + "logs");
cluster.setJavaHome(System.getenv("JAVA_HOME"));
+ cluster.setJavaOpts("-Xmx1048m");
Marshaller marshaller = ctx.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
@@ -50,7 +52,7 @@
@Override
protected String getUsageDescription() {
return "\nAuto-generates the ASTERIX installer configruation settings and ASTERIX cluster "
- + "\n configuration settings for a single node setup.";
+ + "\nconfiguration settings for a single node setup.";
}
@Override
@@ -60,6 +62,6 @@
}
-class ConfigureConfig extends AbstractCommandConfig {
+class ConfigureConfig extends CommandConfig {
}
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 5ddc9e9..af472da 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
@@ -38,97 +38,85 @@
public class CreateCommand extends AbstractCommand {
- private String asterixInstanceName;
- private Cluster cluster;
+ private String asterixInstanceName;
+ private Cluster cluster;
- @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));
- cluster.setWorkingDir(new WorkingDir(cluster.getWorkingDir().getDir()
- + File.separator + asterixInstanceName, cluster.getWorkingDir()
- .isNFS()));
- cluster.setLogdir(cluster.getLogdir() + File.separator
- + asterixInstanceName);
- AsterixInstance asterixInstance = InstallerUtil.createAsterixInstance(
- asterixInstanceName, cluster);
- InstallerUtil.evaluateConflictWithOtherInstances(asterixInstance);
- InstallerUtil.createAsterixZip(asterixInstance, true);
- List<Property> clusterProperties = new ArrayList<Property>();
- clusterProperties.add(new Property("ASTERIX_HOME", cluster
- .getWorkingDir().getDir() + File.separator + "asterix"));
- clusterProperties.add(new Property("JAVA_OPTS", "-Xmx"
- + cluster.getJavaHeap()));
- clusterProperties.add(new Property("CLUSTER_NET_IP", cluster
- .getMasterNode().getClusterIp()));
- clusterProperties.add(new Property("CLIENT_NET_IP", cluster
- .getMasterNode().getIp()));
- clusterProperties.add(new Property("LOG_DIR", cluster.getLogdir()));
- clusterProperties.add(new Property("JAVA_HOME", cluster.getJavaHome()));
- clusterProperties.add(new Property("WORKING_DIR", cluster
- .getWorkingDir().getDir()));
- cluster.setEnv(new Env(clusterProperties));
+ @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));
+ cluster.setWorkingDir(new WorkingDir(cluster.getWorkingDir().getDir() + File.separator + asterixInstanceName,
+ cluster.getWorkingDir().isNFS()));
+ cluster.setLogdir(cluster.getLogdir() + File.separator + asterixInstanceName);
+ AsterixInstance asterixInstance = InstallerUtil.createAsterixInstance(asterixInstanceName, cluster);
+ InstallerUtil.evaluateConflictWithOtherInstances(asterixInstance);
+ InstallerUtil.createAsterixZip(asterixInstance, true);
+ List<Property> clusterProperties = new ArrayList<Property>();
+ clusterProperties.add(new Property("ASTERIX_HOME", cluster.getWorkingDir().getDir() + File.separator
+ + "asterix"));
+ StringBuilder javaOpts = new StringBuilder();
+ if (cluster.getJavaOpts() != null) {
+ javaOpts.append(cluster.getJavaOpts());
+ }
+ clusterProperties.add(new Property("JAVA_OPTS", javaOpts.toString()));
+ clusterProperties.add(new Property("CLUSTER_NET_IP", cluster.getMasterNode().getClusterIp()));
+ clusterProperties.add(new Property("CLIENT_NET_IP", cluster.getMasterNode().getClusterIp()));
+ clusterProperties.add(new Property("LOG_DIR", cluster.getLogdir()));
+ clusterProperties.add(new Property("JAVA_HOME", cluster.getJavaHome()));
+ clusterProperties.add(new Property("WORKING_DIR", cluster.getWorkingDir().getDir()));
+ cluster.setEnv(new Env(clusterProperties));
- PatternCreator pc = new PatternCreator();
- Patterns patterns = pc.getStartAsterixPattern(asterixInstanceName,
- cluster);
- InstallerUtil.getEventrixClient(cluster).submit(patterns);
+ PatternCreator pc = new PatternCreator();
+ Patterns patterns = pc.getStartAsterixPattern(asterixInstanceName, cluster);
+ InstallerUtil.getEventrixClient(cluster).submit(patterns);
- AsterixRuntimeState runtimeState = VerificationUtil
- .getAsterixRuntimeState(asterixInstance);
- VerificationUtil.updateInstanceWithRuntimeDescription(asterixInstance,
- runtimeState, true);
- ServiceProvider.INSTANCE.getLookupService().writeAsterixInstance(
- asterixInstance);
- InstallerUtil.deleteDirectory(InstallerDriver.getManagixHome()
- + File.separator + InstallerDriver.ASTERIX_DIR + File.separator
- + asterixInstanceName);
- LOGGER.info(asterixInstance.getDescription(false));
- }
+ AsterixRuntimeState runtimeState = VerificationUtil.getAsterixRuntimeState(asterixInstance);
+ VerificationUtil.updateInstanceWithRuntimeDescription(asterixInstance, runtimeState, true);
+ ServiceProvider.INSTANCE.getLookupService().writeAsterixInstance(asterixInstance);
+ InstallerUtil.deleteDirectory(InstallerDriver.getManagixHome() + File.separator + InstallerDriver.ASTERIX_DIR
+ + File.separator + asterixInstanceName);
+ LOGGER.info(asterixInstance.getDescription(false));
+ }
- @Override
- protected CommandConfig getCommandConfig() {
- return new CreateConfig();
- }
+ @Override
+ protected CommandConfig getCommandConfig() {
+ return new CreateConfig();
+ }
- public Cluster getCluster() {
- return cluster;
- }
+ public Cluster getCluster() {
+ return cluster;
+ }
- public String getAsterixInstanceName() {
- return asterixInstanceName;
- }
+ public String getAsterixInstanceName() {
+ return asterixInstanceName;
+ }
- @Override
- protected String getUsageDescription() {
- return "\nCreates an ASTERIX instance with a specified name."
- + "\n\nPost creation, the instance is in ACTIVE state, indicating 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";
- }
+ @Override
+ protected String getUsageDescription() {
+ return "\nCreates an ASTERIX instance with a specified name."
+ + "\n\nPost creation, the instance is in ACTIVE state, indicating 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";
+ }
}
-class CreateConfig extends AbstractCommandConfig {
+class CreateConfig extends CommandConfig {
- @Option(name = "-n", required = true, usage = "Name of Asterix Instance")
- public String name;
+ @Option(name = "-n", required = true, usage = "Name of Asterix Instance")
+ public String name;
- @Option(name = "-c", required = true, usage = "Path to cluster configuration")
- public String clusterPath;
+ @Option(name = "-c", required = true, usage = "Path to cluster configuration")
+ public String clusterPath;
}
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 a2788b4..2279d8f 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
@@ -26,41 +26,37 @@
public class DeleteCommand extends AbstractCommand {
- @Override
- protected void execCommand() throws Exception {
- InstallerDriver.initConfig();
- String asterixInstanceName = ((DeleteConfig) config).name;
- AsterixInstance instance = InstallerUtil.validateAsterixInstanceExists(
- asterixInstanceName, State.INACTIVE);
- PatternCreator pc = new PatternCreator();
- Patterns patterns = pc.createDeleteInstancePattern(instance);
- InstallerUtil.getEventrixClient(instance.getCluster()).submit(patterns);
+ @Override
+ protected void execCommand() throws Exception {
+ InstallerDriver.initConfig();
+ String asterixInstanceName = ((DeleteConfig) config).name;
+ AsterixInstance instance = InstallerUtil.validateAsterixInstanceExists(asterixInstanceName, State.INACTIVE);
+ PatternCreator pc = new PatternCreator();
+ Patterns patterns = pc.createDeleteInstancePattern(instance);
+ InstallerUtil.getEventrixClient(instance.getCluster()).submit(patterns);
- patterns = pc.createRemoveAsterixWorkingDirPattern(instance);
- InstallerUtil.getEventrixClient(instance.getCluster()).submit(patterns);
- ServiceProvider.INSTANCE.getLookupService().removeAsterixInstance(
- asterixInstanceName);
- LOGGER.info("Deleted Asterix instance: " + asterixInstanceName);
- }
+ patterns = pc.createRemoveAsterixWorkingDirPattern(instance);
+ InstallerUtil.getEventrixClient(instance.getCluster()).submit(patterns);
+ ServiceProvider.INSTANCE.getLookupService().removeAsterixInstance(asterixInstanceName);
+ LOGGER.info("Deleted Asterix instance: " + asterixInstanceName);
+ }
- @Override
- protected CommandConfig getCommandConfig() {
- return new DeleteConfig();
- }
+ @Override
+ protected CommandConfig getCommandConfig() {
+ return new DeleteConfig();
+ }
- @Override
- protected String getUsageDescription() {
- 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.";
- }
+ @Override
+ protected String getUsageDescription() {
+ 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 extends AbstractCommandConfig {
+class DeleteConfig extends CommandConfig {
- @Option(name = "-n", required = true, usage = "Name of Asterix Instance")
- public String name;
+ @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 bec82d5..9306a56 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
@@ -29,77 +29,63 @@
public class DescribeCommand extends AbstractCommand {
- @Override
- protected void execCommand() throws Exception {
- InstallerDriver.initConfig();
- String asterixInstanceName = ((DescribeConfig) config).name;
- boolean adminView = ((DescribeConfig) config).admin;
- if (asterixInstanceName != null) {
- InstallerUtil.validateAsterixInstanceExists(asterixInstanceName,
- State.INACTIVE, State.ACTIVE, State.UNUSABLE);
- AsterixInstance instance = ServiceProvider.INSTANCE
- .getLookupService().getAsterixInstance(asterixInstanceName);
- if (instance != null) {
- AsterixRuntimeState state = VerificationUtil
- .getAsterixRuntimeState(instance);
- boolean expectedRunning = instance.getState().equals(
- State.UNUSABLE) ? instance.getPreviousState().equals(
- State.ACTIVE) : !instance.getState().equals(
- State.INACTIVE);
- VerificationUtil.updateInstanceWithRuntimeDescription(instance,
- state, expectedRunning);
- ServiceProvider.INSTANCE.getLookupService()
- .updateAsterixInstance(instance);
- LOGGER.info(instance.getDescription(adminView));
- } else {
- throw new InstallerException("Asterix instance by the name "
- + asterixInstanceName + " does not exist.");
- }
- } else {
- List<AsterixInstance> asterixInstances = ServiceProvider.INSTANCE
- .getLookupService().getAsterixInstances();
- if (asterixInstances.size() > 0) {
- for (AsterixInstance instance : asterixInstances) {
- AsterixRuntimeState state = VerificationUtil
- .getAsterixRuntimeState(instance);
- boolean expectedRunning = instance.getState().equals(
- State.UNUSABLE) ? instance.getPreviousState()
- .equals(State.ACTIVE) : !instance.getState()
- .equals(State.INACTIVE);
- VerificationUtil.updateInstanceWithRuntimeDescription(
- instance, state, expectedRunning);
- ServiceProvider.INSTANCE.getLookupService()
- .updateAsterixInstance(instance);
- LOGGER.info(instance.getDescription(adminView));
- }
- } else {
- LOGGER.info("No Asterix instances found!");
- }
+ @Override
+ protected void execCommand() throws Exception {
+ InstallerDriver.initConfig();
+ String asterixInstanceName = ((DescribeConfig) config).name;
+ boolean adminView = ((DescribeConfig) config).admin;
+ if (asterixInstanceName != null) {
+ InstallerUtil.validateAsterixInstanceExists(asterixInstanceName, State.INACTIVE, State.ACTIVE,
+ State.UNUSABLE);
+ AsterixInstance instance = ServiceProvider.INSTANCE.getLookupService().getAsterixInstance(
+ asterixInstanceName);
+ if (instance != null) {
+ AsterixRuntimeState state = VerificationUtil.getAsterixRuntimeState(instance);
+ boolean expectedRunning = instance.getState().equals(State.UNUSABLE) ? instance.getPreviousState()
+ .equals(State.ACTIVE) : !instance.getState().equals(State.INACTIVE);
+ VerificationUtil.updateInstanceWithRuntimeDescription(instance, state, expectedRunning);
+ ServiceProvider.INSTANCE.getLookupService().updateAsterixInstance(instance);
+ LOGGER.info(instance.getDescription(adminView));
+ } else {
+ throw new InstallerException("Asterix instance by the name " + asterixInstanceName + " does not exist.");
+ }
+ } else {
+ List<AsterixInstance> asterixInstances = ServiceProvider.INSTANCE.getLookupService().getAsterixInstances();
+ if (asterixInstances.size() > 0) {
+ for (AsterixInstance instance : asterixInstances) {
+ AsterixRuntimeState state = VerificationUtil.getAsterixRuntimeState(instance);
+ boolean expectedRunning = instance.getState().equals(State.UNUSABLE) ? instance.getPreviousState()
+ .equals(State.ACTIVE) : !instance.getState().equals(State.INACTIVE);
+ VerificationUtil.updateInstanceWithRuntimeDescription(instance, state, expectedRunning);
+ ServiceProvider.INSTANCE.getLookupService().updateAsterixInstance(instance);
+ LOGGER.info(instance.getDescription(adminView));
+ }
+ } else {
+ LOGGER.info("No Asterix instances found!");
+ }
- }
- }
+ }
+ }
- @Override
- protected CommandConfig getCommandConfig() {
- return new DescribeConfig();
- }
+ @Override
+ protected CommandConfig getCommandConfig() {
+ return new DescribeConfig();
+ }
- @Override
- protected String getUsageDescription() {
- return "\nProvides information about an ASTERIX instance."
- + "\n\nUsage arguments/options:-"
- + "\n[-n] Name of the ASTERIX instance."
- + "\n[-admin] Provides a detailed description";
- }
+ @Override
+ protected String getUsageDescription() {
+ 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 extends AbstractCommandConfig {
+class DescribeConfig extends CommandConfig {
- @Option(name = "-n", required = false, usage = "Name of Asterix Instance")
- public String name;
+ @Option(name = "-n", required = false, usage = "Name of Asterix Instance")
+ public String name;
- @Option(name = "-admin", required = false, usage = "Detailed description")
- public boolean admin;
+ @Option(name = "-admin", required = false, usage = "Detailed description")
+ public boolean admin;
}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/HelpCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/HelpCommand.java
new file mode 100644
index 0000000..a9864a3
--- /dev/null
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/HelpCommand.java
@@ -0,0 +1,85 @@
+/*
+ * 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;
+
+public class HelpCommand extends AbstractCommand {
+
+ @Override
+ protected void execCommand() throws Exception {
+ HelpConfig helpConfig = (HelpConfig) config;
+ String command = helpConfig.command;
+ CommandType cmdType = CommandType.valueOf(command.toUpperCase());
+ String helpMessage = null;
+ switch (cmdType) {
+ case CREATE:
+ helpMessage = new CreateCommand().getUsageDescription();
+ break;
+ case CONFIGURE:
+ helpMessage = new ConfigureCommand().getUsageDescription();
+ break;
+ case DELETE:
+ helpMessage = new DeleteCommand().getUsageDescription();
+ break;
+ case DESCRIBE:
+ helpMessage = new DescribeCommand().getUsageDescription();
+ break;
+ case RESTORE:
+ helpMessage = new RestoreCommand().getUsageDescription();
+ break;
+ case START:
+ helpMessage = new StartCommand().getUsageDescription();
+ break;
+ case SHUTDOWN:
+ helpMessage = new ShutdownCommand().getUsageDescription();
+ break;
+ case BACKUP:
+ helpMessage = new BackupCommand().getUsageDescription();
+ break;
+ case STOP:
+ helpMessage = new StopCommand().getUsageDescription();
+ break;
+ case VALIDATE:
+ helpMessage = new ValidateCommand().getUsageDescription();
+ break;
+ default:
+ helpMessage = "Unknown command " + command;
+ }
+
+ System.out.println(helpMessage);
+ }
+
+ @Override
+ protected CommandConfig getCommandConfig() {
+ return new HelpConfig();
+ }
+
+ @Override
+ protected String getUsageDescription() {
+ 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 HelpConfig extends CommandConfig {
+
+ @Option(name = "-cmd", required = true, usage = "Name of Asterix Instance")
+ public String command;
+
+}
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 d27fee9..979c414 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
@@ -27,7 +27,8 @@
ALTER,
VALIDATE,
CONFIGURE,
- SHUTDOWN
+ SHUTDOWN,
+ HELP
}
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 49629a4..9ef925a 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
@@ -60,7 +60,7 @@
}
-class RestoreConfig extends AbstractCommandConfig {
+class RestoreConfig extends CommandConfig {
@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
index cbfd5c5..b9dd23d 100644
--- 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
@@ -39,6 +39,6 @@
}
-class ShutdownConfig extends AbstractCommandConfig {
+class ShutdownConfig extends CommandConfig {
}
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 8004e9a..38bcf33 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
@@ -61,11 +61,9 @@
}
}
-class StartConfig extends AbstractCommandConfig {
+class StartConfig extends CommandConfig {
@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/StopCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/StopCommand.java
index 85fcb68..0e10414 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
@@ -80,7 +80,7 @@
}
-class StopConfig extends AbstractCommandConfig {
+class StopConfig extends CommandConfig {
@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
index 42c0d38..1abeb0e 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
@@ -38,230 +38,204 @@
public class ValidateCommand extends AbstractCommand {
- private static final String OK = " [" + "\u2713" + "]";
- private static final String ERROR = " [" + "x" + "]";
- private static final String WARNING = " [" + "!" + "]";
+ 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("Environment", validateEnvironment());
- if (((ValidateConfig) config).cluster != null) {
- logValidationResult("Cluster configuration",
- validateCluster(vConfig.cluster));
- } else {
- logValidationResult("Installer Configuration",
- validateConfiguration());
- }
- }
+ @Override
+ protected void execCommand() throws Exception {
+ ValidateConfig vConfig = (ValidateConfig) config;
+ logValidationResult("Environment", 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);
- }
- }
+ 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 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"
- + "\nuse managix validate"
- + "\n\nFor validating a cluster configuration"
- + "\nuse managix validate -c <path to the cluster configuration file>";
- }
+ @Override
+ protected String getUsageDescription() {
+ return "\nValidate the installer's configuration or a cluster configuration" + "\nUsage"
+ + "\nFor validating the installer configuration" + "\nuse managix validate"
+ + "\n\nFor validating a cluster configuration"
+ + "\nuse 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 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;
- Cluster cluster = null;
- 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) unmarshaller.unmarshal(new File(clusterPath));
- validateClusterProperties(cluster);
+ public boolean validateCluster(String clusterPath) throws Exception {
+ boolean valid = true;
+ Cluster cluster = null;
+ 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) 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());
+ Set<String> servers = new HashSet<String>();
+ Set<String> serverIds = new HashSet<String>();
+ servers.add(cluster.getMasterNode().getClusterIp());
+ serverIds.add(cluster.getMasterNode().getId());
- MasterNode masterNode = cluster.getMasterNode();
- Node master = new Node(masterNode.getId(), masterNode.getIp(),
- masterNode.getJavaHeap(), masterNode.getJavaHome(),
- masterNode.getLogdir(), null, masterNode.getDebug());
+ MasterNode masterNode = cluster.getMasterNode();
+ Node master = new Node(masterNode.getId(), masterNode.getClusterIp(), masterNode.getJavaOpts(),
+ masterNode.getJavaHome(), masterNode.getLogdir(), null, null, null);
- valid = valid & validateNodeConfiguration(master, cluster);
+ 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);
- }
- }
- }
+ for (Node node : cluster.getNode()) {
+ servers.add(node.getClusterIp());
+ if (serverIds.contains(node.getId())) {
+ valid = false;
+ LOGGER.error("Duplicate node id :" + node.getId() + ERROR);
+ } else {
+ valid = valid & validateNodeConfiguration(node, cluster);
+ }
+ }
+ }
- return valid;
- }
+ 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());
- }
+ 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);
- }
+ 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);
- }
- }
+ private boolean validateNodeConfiguration(Node node, Cluster cluster) {
+ boolean valid = true;
+ valid = checkNodeReachability(node.getClusterIp());
+ 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.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.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.getJavaHeap() == null || node.getJavaHeap().length() == 0) {
- if (cluster.getJavaHeap() == null
- || cluster.getJavaHeap().length() == 0) {
- valid = false;
- LOGGER.fatal("java heap size not defined at cluster/node level for node: "
- + node.getId() + ERROR);
- }
- }
- return valid;
- }
+ return valid;
+ }
- private boolean checkTemporaryPath(String logdir) {
- return logdir.startsWith("/tmp/");
+ 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);
- }
+ 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();
+ 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.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);
- }
+ 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);
- }
+ boolean validEnsemble = true;
+ for (String server : zk.getServers().getServer()) {
+ validEnsemble = validEnsemble && checkNodeReachability(server);
+ }
- return valid;
- }
+ 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;
- }
+ 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 {
+class ValidateConfig extends CommandConfig {
- @Option(name = "-c", required = false, usage = "Path to the cluster configuration xml")
- public String cluster;
+ @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/InstallerUtil.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/driver/InstallerUtil.java
index 24b531a..a688abf 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
@@ -25,9 +25,12 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
+import java.net.URL;
+import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import java.util.Random;
import java.util.jar.JarEntry;
@@ -71,10 +74,27 @@
unzip(InstallerDriver.getAsterixZip(), asterixInstanceDir);
File sourceJar = new File(asterixInstanceDir + File.separator + "lib" + File.separator + "asterix-app-"
+ asterixInstance.getAsterixVersion() + ".jar");
- String origFile = "test.properties";
+
+ String txnLogPropertyFile = "log.properties";
+ Properties txnLogProperties = new Properties();
+ URLClassLoader urlClassLoader = new URLClassLoader(new URL[] { sourceJar.toURI().toURL() });
+ InputStream in = urlClassLoader.getResourceAsStream(txnLogPropertyFile);
+ if (in != null) {
+ txnLogProperties.load(in);
+ }
+
+ writeAsterixLogConfigurationFile(asterixInstance.getName(), asterixInstance.getCluster(), txnLogProperties);
+
+ String asterixPropertyFile = "test.properties";
File replacementFile = new File(asterixInstanceDir + File.separator + "test.properties");
- replaceInJar(sourceJar, origFile, replacementFile);
+ replaceInJar(sourceJar, asterixPropertyFile, replacementFile);
+
+ replacementFile = new File(asterixInstanceDir + File.separator + "log.properties");
+ replaceInJar(sourceJar, txnLogPropertyFile, replacementFile);
+
new File(asterixInstanceDir + File.separator + "test.properties").delete();
+ new File(asterixInstanceDir + File.separator + "log.properties").delete();
+
String asterixZipName = InstallerDriver.getAsterixZip().substring(
InstallerDriver.getAsterixZip().lastIndexOf(File.separator) + 1);
zipDir(new File(asterixInstanceDir), new File(asterixInstanceDir + File.separator + asterixZipName));
@@ -111,7 +131,6 @@
public static String getNodeDirectories(String asterixInstanceName, Node node, Cluster cluster) {
String storeDataSubDir = asterixInstanceName + File.separator + "data" + File.separator;
- String storeLibrarySubDir = asterixInstanceName + File.separator + "library" + File.separator;
String[] storeDirs = null;
StringBuffer nodeDataStore = new StringBuffer();
String storeDirValue = node.getStore();
@@ -121,7 +140,6 @@
throw new IllegalStateException(" Store not defined for node " + node.getId());
}
storeDataSubDir = node.getId() + File.separator + storeDataSubDir;
- storeLibrarySubDir = node.getId() + File.separator + storeLibrarySubDir;
}
storeDirs = storeDirValue.split(",");
@@ -143,19 +161,40 @@
conf.append("MetadataNode=" + asterixInstanceName + "_" + metadataNodeId + "\n");
conf.append("NewUniverse=" + newData + "\n");
+ String storeDir = null;
for (Node node : cluster.getNode()) {
- String nodeDir = getNodeDirectories(asterixInstance.getName(), node, cluster);
- conf.append(asterixInstanceName + "_" + node.getId() + ".stores" + "=" + nodeDir + "\n");
+ storeDir = node.getStore() == null ? cluster.getStore() : node.getStore();
+ conf.append(asterixInstanceName + "_" + node.getId() + ".stores" + "=" + storeDir + "\n");
}
+
Properties asterixConfProp = asterixInstance.getConfiguration();
String outputDir = asterixConfProp.getProperty("output_dir");
conf.append("OutputDir=" + outputDir);
+
File asterixConfDir = new File(InstallerDriver.getAsterixDir() + File.separator + asterixInstanceName);
asterixConfDir.mkdirs();
dumpToFile(InstallerDriver.getAsterixDir() + File.separator + asterixInstanceName + File.separator
+ "test.properties", conf.toString());
}
+ private static void writeAsterixLogConfigurationFile(String asterixInstanceName, Cluster cluster,
+ Properties logProperties) throws IOException {
+ StringBuffer conf = new StringBuffer();
+ for (Map.Entry<Object, Object> p : logProperties.entrySet()) {
+ conf.append(p.getKey() + "=" + p.getValue() + "\n");
+ }
+
+ for (Node node : cluster.getNode()) {
+ String iodevices = node.getIodevices() == null ? cluster.getIodevices() : node.getIodevices();
+ String store = node.getStore() == null ? cluster.getStore() : node.getStore();
+ String txnLogDir = iodevices.split(",")[0].trim() + File.separator + store;
+ conf.append(asterixInstanceName + "_" + node.getId() + "." + "txnLogDir=" + txnLogDir + "\n");
+ }
+ dumpToFile(InstallerDriver.getAsterixDir() + File.separator + asterixInstanceName + File.separator
+ + "log.properties", conf.toString());
+
+ }
+
public static Properties getAsterixConfiguration(String asterixConf) throws FileNotFoundException, IOException {
Properties prop = new Properties();
prop.load(new FileInputStream(asterixConf));
@@ -301,21 +340,21 @@
public static void evaluateConflictWithOtherInstances(AsterixInstance instance) throws Exception {
List<AsterixInstance> existingInstances = ServiceProvider.INSTANCE.getLookupService().getAsterixInstances();
List<String> usedIps = new ArrayList<String>();
- String masterIp = instance.getCluster().getMasterNode().getIp();
+ String masterIp = instance.getCluster().getMasterNode().getClusterIp();
for (Node node : instance.getCluster().getNode()) {
- usedIps.add(node.getIp());
+ usedIps.add(node.getClusterIp());
}
- usedIps.add(instance.getCluster().getMasterNode().getIp());
+ usedIps.add(instance.getCluster().getMasterNode().getClusterIp());
boolean conflictFound = false;
AsterixInstance conflictingInstance = null;
for (AsterixInstance existing : existingInstances) {
- conflictFound = existing.getCluster().getMasterNode().getIp().equals(masterIp);
+ conflictFound = existing.getCluster().getMasterNode().getClusterIp().equals(masterIp);
if (conflictFound) {
conflictingInstance = existing;
break;
}
for (Node n : existing.getCluster().getNode()) {
- if (usedIps.contains(n.getIp())) {
+ if (usedIps.contains(n.getClusterIp())) {
conflictFound = true;
conflictingInstance = existing;
break;
@@ -341,7 +380,7 @@
}
ProcessBuilder pb = new ProcessBuilder(pargs);
pb.environment().putAll(EventDriver.getEnvironment());
- pb.environment().put("IP_LOCATION", EventDriver.CLIENT_NODE.getIp());
+ pb.environment().put("IP_LOCATION", EventDriver.CLIENT_NODE.getClusterIp());
Process p = pb.start();
BufferedInputStream bis = new BufferedInputStream(p.getInputStream());
StringWriter writer = new StringWriter();
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 7c7a792..612c2e4 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
@@ -37,9 +37,9 @@
Cluster cluster = instance.getCluster();
List<String> args = new ArrayList<String>();
args.add(instance.getName());
- args.add(instance.getCluster().getMasterNode().getIp());
+ args.add(instance.getCluster().getMasterNode().getClusterIp());
for (Node node : cluster.getNode()) {
- args.add(node.getIp());
+ args.add(node.getClusterIp());
args.add(instance.getName() + "_" + node.getId());
}
@@ -51,10 +51,16 @@
List<ProcessInfo> processes = new ArrayList<ProcessInfo>();
for (String line : output.split("\n")) {
+ String nodeid = null;
infoFields = line.split(":");
try {
int pid = Integer.parseInt(infoFields[3]);
- pInfo = new ProcessInfo(infoFields[0], infoFields[1], pid);
+ if (infoFields[0].equals("NC")) {
+ nodeid = infoFields[2].split("_")[1];
+ } else {
+ nodeid = instance.getCluster().getMasterNode().getId();
+ }
+ pInfo = new ProcessInfo(infoFields[0], infoFields[1], nodeid, pid);
processes.add(pInfo);
} catch (Exception e) {
if (infoFields[0].equalsIgnoreCase("CC")) {
@@ -72,8 +78,8 @@
StringBuffer summary = new StringBuffer();
if (expectedRunning) {
if (!state.isCcRunning()) {
- summary.append("Cluster Controller not running at " + instance.getCluster().getMasterNode().getIp()
- + "\n");
+ summary.append("Cluster Controller not running at "
+ + instance.getCluster().getMasterNode().getClusterIp() + "\n");
instance.setState(State.UNUSABLE);
}
if (state.getFailedNCs() != null && !state.getFailedNCs().isEmpty()) {
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 fc53304..887ebda 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
@@ -41,449 +41,385 @@
public class PatternCreator {
- private ILookupService lookupService = ServiceProvider.INSTANCE
- .getLookupService();
+ private ILookupService lookupService = ServiceProvider.INSTANCE.getLookupService();
- private void addInitialDelay(Pattern p, int delay, String unit) {
- Delay d = new Delay(new Value(null, "" + delay), unit);
- p.setDelay(d);
- }
+ private void addInitialDelay(Pattern p, int delay, String unit) {
+ Delay d = new Delay(new Value(null, "" + delay), unit);
+ p.setDelay(d);
+ }
- public Patterns getStartAsterixPattern(String asterixInstanceName,
- Cluster cluster) throws Exception {
- String ccLocationId = cluster.getMasterNode().getId();
- String ccLocationIp = cluster.getMasterNode().getIp();
+ public Patterns getStartAsterixPattern(String asterixInstanceName, Cluster cluster) throws Exception {
+ String ccLocationId = cluster.getMasterNode().getId();
+ String ccLocationIp = cluster.getMasterNode().getClusterIp();
- String destDir = cluster.getWorkingDir().getDir() + File.separator
- + "asterix";
- List<Pattern> ps = new ArrayList<Pattern>();
+ String destDir = cluster.getWorkingDir().getDir() + File.separator + "asterix";
+ List<Pattern> ps = new ArrayList<Pattern>();
- Pattern copyHyracks = createCopyHyracksPattern(asterixInstanceName,
- cluster, ccLocationIp, destDir);
- ps.add(copyHyracks);
+ Pattern copyHyracks = createCopyHyracksPattern(asterixInstanceName, cluster, ccLocationIp, destDir);
+ ps.add(copyHyracks);
- Pattern createCC = createCCStartPattern(ccLocationId);
- addInitialDelay(createCC, 2, "sec");
- ps.add(createCC);
+ Pattern createCC = createCCStartPattern(ccLocationId);
+ addInitialDelay(createCC, 2, "sec");
+ ps.add(createCC);
- boolean copyHyracksToNC = !cluster.getWorkingDir().isNFS();
- for (Node node : cluster.getNode()) {
- if (copyHyracksToNC) {
- Pattern copyHyracksForNC = createCopyHyracksPattern(
- asterixInstanceName, cluster, node.getIp(), destDir);
- ps.add(copyHyracksForNC);
- }
- Pattern createNC = createNCStartPattern(cluster.getMasterNode()
- .getIp(), node.getId(),
- asterixInstanceName + "_" + node.getId());
- addInitialDelay(createNC, 4, "sec");
- ps.add(createNC);
- }
+ boolean copyHyracksToNC = !cluster.getWorkingDir().isNFS();
+ for (Node node : cluster.getNode()) {
+ if (copyHyracksToNC) {
+ Pattern copyHyracksForNC = createCopyHyracksPattern(asterixInstanceName, cluster, node.getClusterIp(),
+ destDir);
+ ps.add(copyHyracksForNC);
+ }
+ String iodevices = node.getIodevices() == null ? cluster.getIodevices() : node.getIodevices();
+ Pattern createNC = createNCStartPattern(cluster.getMasterNode().getClusterIp(), node.getId(),
+ asterixInstanceName + "_" + node.getId(), iodevices);
+ addInitialDelay(createNC, 4, "sec");
+ ps.add(createNC);
+ }
- Patterns patterns = new Patterns(ps);
- patterns.getPattern().addAll(
- createHadoopLibraryTransferPattern(cluster).getPattern());
- return patterns;
- }
+ Patterns patterns = new Patterns(ps);
+ patterns.getPattern().addAll(createHadoopLibraryTransferPattern(cluster).getPattern());
+ return patterns;
+ }
- public Patterns getStopCommandPattern(StopCommand stopCommand)
- throws Exception {
- List<Pattern> ps = new ArrayList<Pattern>();
- AsterixInstance asterixInstance = lookupService
- .getAsterixInstance(stopCommand.getAsterixInstanceName());
- Cluster cluster = asterixInstance.getCluster();
+ public Patterns getStopCommandPattern(StopCommand stopCommand) throws Exception {
+ List<Pattern> ps = new ArrayList<Pattern>();
+ AsterixInstance asterixInstance = lookupService.getAsterixInstance(stopCommand.getAsterixInstanceName());
+ Cluster cluster = asterixInstance.getCluster();
- String ccLocation = cluster.getMasterNode().getId();
- Pattern createCC = createCCStopPattern(ccLocation);
- addInitialDelay(createCC, 5, "sec");
- ps.add(createCC);
+ String ccLocation = cluster.getMasterNode().getId();
+ Pattern createCC = createCCStopPattern(ccLocation);
+ addInitialDelay(createCC, 5, "sec");
+ ps.add(createCC);
- String asterixInstanceName = stopCommand.getAsterixInstanceName();
- int nodeControllerIndex = 1;
- for (Node node : cluster.getNode()) {
- Pattern createNC = createNCStopPattern(node.getId(),
- asterixInstanceName + "_" + nodeControllerIndex);
- ps.add(createNC);
- nodeControllerIndex++;
- }
+ String asterixInstanceName = stopCommand.getAsterixInstanceName();
+ int nodeControllerIndex = 1;
+ for (Node node : cluster.getNode()) {
+ Pattern createNC = createNCStopPattern(node.getId(), asterixInstanceName + "_" + nodeControllerIndex);
+ ps.add(createNC);
+ nodeControllerIndex++;
+ }
- Patterns patterns = new Patterns(ps);
- return patterns;
- }
+ Patterns patterns = new Patterns(ps);
+ return patterns;
+ }
- 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 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;
- }
+ 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 = 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;
- 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("backup", nodeid, pargs);
- patternList.add(new Pattern(null, 1, null, event));
- }
- return new Patterns(patternList);
- }
+ private Patterns getHDFSBackUpAsterixPattern(AsterixInstance instance, Backup backupConf) throws Exception {
+ Cluster cluster = instance.getCluster();
+ String clusterStore = instance.getCluster().getStore();
+ 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;
+ 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("backup", nodeid, pargs);
+ patternList.add(new Pattern(null, 1, null, event));
+ }
+ return new Patterns(patternList);
+ }
- private Patterns getLocalBackUpAsterixPattern(AsterixInstance instance,
- Backup backupConf) throws Exception {
- Cluster cluster = instance.getCluster();
- String clusterStore = instance.getCluster().getStore();
- 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 + " " + backupDir + " " + "local" + " "
- + node.getId();
- Event event = new Event("backup", nodeid, pargs);
- patternList.add(new Pattern(null, 1, null, event));
- }
- return new Patterns(patternList);
- }
+ private Patterns getLocalBackUpAsterixPattern(AsterixInstance instance, Backup backupConf) throws Exception {
+ Cluster cluster = instance.getCluster();
+ String clusterStore = instance.getCluster().getStore();
+ 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 + " " + 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 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));
- }
- 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));
+ }
+ return new Patterns(patternList);
+ }
- public Patterns createHadoopLibraryTransferPattern(Cluster cluster)
- throws Exception {
- List<Pattern> patternList = new ArrayList<Pattern>();
- String workingDir = cluster.getWorkingDir().getDir();
- String hadoopVersion = InstallerDriver.getConfiguration().getBackup()
- .getHdfs().getVersion();
- File hadoopDir = new File(InstallerDriver.getManagixHome()
- + File.separator + InstallerDriver.MANAGIX_INTERNAL_DIR
- + File.separator + "hadoop-" + hadoopVersion);
- if (!hadoopDir.exists()) {
- throw new IllegalStateException("Hadoop version :" + hadoopVersion
- + " not supported");
- }
+ public Patterns createHadoopLibraryTransferPattern(Cluster cluster) throws Exception {
+ List<Pattern> patternList = new ArrayList<Pattern>();
+ String workingDir = cluster.getWorkingDir().getDir();
+ String hadoopVersion = InstallerDriver.getConfiguration().getBackup().getHdfs().getVersion();
+ File hadoopDir = new File(InstallerDriver.getManagixHome() + File.separator
+ + InstallerDriver.MANAGIX_INTERNAL_DIR + File.separator + "hadoop-" + hadoopVersion);
+ if (!hadoopDir.exists()) {
+ throw new IllegalStateException("Hadoop version :" + hadoopVersion + " not supported");
+ }
- Nodeid nodeid = new Nodeid(new Value(null,
- EventDriver.CLIENT_NODE.getId()));
- String username = cluster.getUsername() != null ? cluster.getUsername()
- : System.getProperty("user.name");
- String pargs = username + " " + hadoopDir.getAbsolutePath() + " "
- + cluster.getMasterNode().getIp() + " " + workingDir;
- Event event = new Event("directory_transfer", nodeid, pargs);
- Pattern p = new Pattern(null, 1, null, event);
- addInitialDelay(p, 2, "sec");
- patternList.add(p);
+ Nodeid nodeid = new Nodeid(new Value(null, EventDriver.CLIENT_NODE.getId()));
+ String username = cluster.getUsername() != null ? cluster.getUsername() : System.getProperty("user.name");
+ String pargs = username + " " + hadoopDir.getAbsolutePath() + " " + cluster.getMasterNode().getClusterIp()
+ + " " + workingDir;
+ Event event = new Event("directory_transfer", nodeid, pargs);
+ Pattern p = new Pattern(null, 1, null, event);
+ addInitialDelay(p, 2, "sec");
+ patternList.add(p);
- boolean copyToNC = !cluster.getWorkingDir().isNFS();
- if (copyToNC) {
- for (Node node : cluster.getNode()) {
- nodeid = new Nodeid(new Value(null, node.getId()));
- pargs = cluster.getUsername() + " "
- + hadoopDir.getAbsolutePath() + " " + node.getIp()
- + " " + workingDir;
- event = new Event("directory_transfer", nodeid, pargs);
- p = new Pattern(null, 1, null, event);
- addInitialDelay(p, 2, "sec");
- patternList.add(p);
- }
- }
- Patterns patterns = new Patterns(patternList);
- return patterns;
- }
+ boolean copyToNC = !cluster.getWorkingDir().isNFS();
+ if (copyToNC) {
+ for (Node node : cluster.getNode()) {
+ nodeid = new Nodeid(new Value(null, node.getId()));
+ pargs = cluster.getUsername() + " " + hadoopDir.getAbsolutePath() + " " + node.getClusterIp() + " "
+ + workingDir;
+ event = new Event("directory_transfer", nodeid, pargs);
+ p = new Pattern(null, 1, null, event);
+ addInitialDelay(p, 2, "sec");
+ patternList.add(p);
+ }
+ }
+ Patterns patterns = new Patterns(patternList);
+ return patterns;
+ }
- public Patterns createDeleteInstancePattern(AsterixInstance instance)
- throws Exception {
- List<Pattern> patternList = new ArrayList<Pattern>();
- patternList.addAll(createRemoveAsterixStoragePattern(instance)
- .getPattern());
- if (instance.getBackupInfo() != null
- && instance.getBackupInfo().size() > 0) {
- List<BackupInfo> backups = instance.getBackupInfo();
- Set<String> removedBackupDirsHDFS = new HashSet<String>();
- Set<String> removedBackupDirsLocal = new HashSet<String>();
+ public Patterns createDeleteInstancePattern(AsterixInstance instance) throws Exception {
+ List<Pattern> patternList = new ArrayList<Pattern>();
+ patternList.addAll(createRemoveAsterixStoragePattern(instance).getPattern());
+ if (instance.getBackupInfo() != null && instance.getBackupInfo().size() > 0) {
+ List<BackupInfo> backups = instance.getBackupInfo();
+ Set<String> removedBackupDirsHDFS = new HashSet<String>();
+ Set<String> removedBackupDirsLocal = new HashSet<String>();
- String backupDir;
- for (BackupInfo binfo : backups) {
- backupDir = binfo.getBackupConf().getBackupDir();
- switch (binfo.getBackupType()) {
- case HDFS:
- if (removedBackupDirsHDFS.contains(backups)) {
- continue;
- }
- patternList.addAll(createRemoveHDFSBackupPattern(instance,
- backupDir).getPattern());
- removedBackupDirsHDFS.add(backupDir);
- break;
+ String backupDir;
+ for (BackupInfo binfo : backups) {
+ backupDir = binfo.getBackupConf().getBackupDir();
+ switch (binfo.getBackupType()) {
+ case HDFS:
+ if (removedBackupDirsHDFS.contains(backups)) {
+ continue;
+ }
+ patternList.addAll(createRemoveHDFSBackupPattern(instance, backupDir).getPattern());
+ removedBackupDirsHDFS.add(backupDir);
+ break;
- case LOCAL:
- if (removedBackupDirsLocal.contains(backups)) {
- continue;
- }
- patternList.addAll(createRemoveLocalBackupPattern(instance,
- backupDir).getPattern());
- removedBackupDirsLocal.add(backupDir);
- break;
- }
+ case LOCAL:
+ if (removedBackupDirsLocal.contains(backups)) {
+ continue;
+ }
+ patternList.addAll(createRemoveLocalBackupPattern(instance, backupDir).getPattern());
+ removedBackupDirsLocal.add(backupDir);
+ break;
+ }
- }
- }
- patternList.addAll(createRemoveAsterixLogDirPattern(instance)
- .getPattern());
- Patterns patterns = new Patterns(patternList);
- return patterns;
- }
+ }
+ }
+ patternList.addAll(createRemoveAsterixLogDirPattern(instance).getPattern());
+ Patterns patterns = new Patterns(patternList);
+ return patterns;
+ }
- private Patterns createRemoveHDFSBackupPattern(AsterixInstance instance,
- String hdfsBackupDir) throws Exception {
- List<Pattern> patternList = new ArrayList<Pattern>();
- Cluster cluster = instance.getCluster();
- String hdfsUrl = InstallerDriver.getConfiguration().getBackup()
- .getHdfs().getUrl();
- String hadoopVersion = InstallerDriver.getConfiguration().getBackup()
- .getHdfs().getVersion();
- String workingDir = cluster.getWorkingDir().getDir();
- Node launchingNode = cluster.getNode().get(0);
- Nodeid nodeid = new Nodeid(new Value(null, launchingNode.getId()));
- String pathToDelete = hdfsBackupDir + File.separator
- + instance.getName();
- String pargs = workingDir + " " + hadoopVersion + " " + hdfsUrl + " "
- + pathToDelete;
- Event event = new Event("hdfs_delete", nodeid, pargs);
- patternList.add(new Pattern(null, 1, null, event));
- Patterns patterns = new Patterns(patternList);
- return patterns;
- }
+ private Patterns createRemoveHDFSBackupPattern(AsterixInstance instance, String hdfsBackupDir) throws Exception {
+ List<Pattern> patternList = new ArrayList<Pattern>();
+ Cluster cluster = instance.getCluster();
+ String hdfsUrl = InstallerDriver.getConfiguration().getBackup().getHdfs().getUrl();
+ String hadoopVersion = InstallerDriver.getConfiguration().getBackup().getHdfs().getVersion();
+ String workingDir = cluster.getWorkingDir().getDir();
+ Node launchingNode = cluster.getNode().get(0);
+ Nodeid nodeid = new Nodeid(new Value(null, launchingNode.getId()));
+ String pathToDelete = hdfsBackupDir + File.separator + instance.getName();
+ String pargs = workingDir + " " + hadoopVersion + " " + hdfsUrl + " " + pathToDelete;
+ Event event = new Event("hdfs_delete", nodeid, pargs);
+ patternList.add(new Pattern(null, 1, null, event));
+ Patterns patterns = new Patterns(patternList);
+ return patterns;
+ }
- private Patterns createRemoveLocalBackupPattern(AsterixInstance instance,
- String localBackupDir) throws Exception {
- List<Pattern> patternList = new ArrayList<Pattern>();
- Cluster cluster = instance.getCluster();
+ private Patterns createRemoveLocalBackupPattern(AsterixInstance instance, String localBackupDir) throws Exception {
+ List<Pattern> patternList = new ArrayList<Pattern>();
+ Cluster cluster = instance.getCluster();
- String pathToDelete = localBackupDir + File.separator
- + instance.getName();
- String pargs = pathToDelete;
- List<String> removedBackupDirs = new ArrayList<String>();
- for (Node node : cluster.getNode()) {
- if (removedBackupDirs.contains(node.getIp())) {
- continue;
- }
- Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
- Event event = new Event("file_delete", nodeid, pargs);
- patternList.add(new Pattern(null, 1, null, event));
- removedBackupDirs.add(node.getIp());
- }
+ String pathToDelete = localBackupDir + File.separator + instance.getName();
+ String pargs = pathToDelete;
+ List<String> removedBackupDirs = new ArrayList<String>();
+ for (Node node : cluster.getNode()) {
+ if (removedBackupDirs.contains(node.getClusterIp())) {
+ continue;
+ }
+ Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
+ Event event = new Event("file_delete", nodeid, pargs);
+ patternList.add(new Pattern(null, 1, null, event));
+ removedBackupDirs.add(node.getClusterIp());
+ }
- Patterns patterns = new Patterns(patternList);
- return patterns;
- }
+ Patterns patterns = new Patterns(patternList);
+ return patterns;
+ }
- public Patterns createRemoveAsterixWorkingDirPattern(
- AsterixInstance instance) throws Exception {
- List<Pattern> patternList = new ArrayList<Pattern>();
- Cluster cluster = instance.getCluster();
- String workingDir = cluster.getWorkingDir().getDir();
- String pargs = workingDir;
- Nodeid nodeid = new Nodeid(new Value(null, cluster.getMasterNode()
- .getId()));
- Event event = new Event("file_delete", nodeid, pargs);
- patternList.add(new Pattern(null, 1, null, event));
+ public Patterns createRemoveAsterixWorkingDirPattern(AsterixInstance instance) throws Exception {
+ List<Pattern> patternList = new ArrayList<Pattern>();
+ Cluster cluster = instance.getCluster();
+ String workingDir = cluster.getWorkingDir().getDir();
+ String pargs = workingDir;
+ Nodeid nodeid = new Nodeid(new Value(null, cluster.getMasterNode().getId()));
+ Event event = new Event("file_delete", nodeid, pargs);
+ patternList.add(new Pattern(null, 1, null, event));
- if (!cluster.getWorkingDir().isNFS()) {
- for (Node node : cluster.getNode()) {
- nodeid = new Nodeid(new Value(null, node.getId()));
- event = new Event("file_delete", nodeid, pargs);
- patternList.add(new Pattern(null, 1, null, event));
- }
- }
- Patterns patterns = new Patterns(patternList);
- return patterns;
- }
+ if (!cluster.getWorkingDir().isNFS()) {
+ for (Node node : cluster.getNode()) {
+ nodeid = new Nodeid(new Value(null, node.getId()));
+ event = new Event("file_delete", nodeid, pargs);
+ patternList.add(new Pattern(null, 1, null, event));
+ }
+ }
+ Patterns patterns = new Patterns(patternList);
+ return patterns;
+ }
- private Patterns createRemoveAsterixLogDirPattern(AsterixInstance instance)
- throws Exception {
- List<Pattern> patternList = new ArrayList<Pattern>();
- Cluster cluster = instance.getCluster();
- String pargs = instance.getCluster().getLogdir();
- Nodeid nodeid = new Nodeid(new Value(null, cluster.getMasterNode()
- .getId()));
- Event event = new Event("file_delete", nodeid, pargs);
- patternList.add(new Pattern(null, 1, null, event));
+ private Patterns createRemoveAsterixLogDirPattern(AsterixInstance instance) throws Exception {
+ List<Pattern> patternList = new ArrayList<Pattern>();
+ Cluster cluster = instance.getCluster();
+ String pargs = instance.getCluster().getLogdir();
+ Nodeid nodeid = new Nodeid(new Value(null, cluster.getMasterNode().getId()));
+ Event event = new Event("file_delete", nodeid, pargs);
+ patternList.add(new Pattern(null, 1, null, event));
- if (!cluster.getWorkingDir().isNFS()) {
- for (Node node : cluster.getNode()) {
- nodeid = new Nodeid(new Value(null, node.getId()));
- event = new Event("file_delete", nodeid, pargs);
- patternList.add(new Pattern(null, 1, null, event));
- }
- }
- Patterns patterns = new Patterns(patternList);
- return patterns;
- }
+ if (!cluster.getWorkingDir().isNFS()) {
+ for (Node node : cluster.getNode()) {
+ nodeid = new Nodeid(new Value(null, node.getId()));
+ event = new Event("file_delete", nodeid, pargs);
+ patternList.add(new Pattern(null, 1, null, event));
+ }
+ }
+ Patterns patterns = new Patterns(patternList);
+ return patterns;
+ }
- private Patterns createRemoveAsterixStoragePattern(AsterixInstance instance)
- throws Exception {
- List<Pattern> patternList = new ArrayList<Pattern>();
- Cluster cluster = instance.getCluster();
- String pargs = null;
+ private Patterns createRemoveAsterixStoragePattern(AsterixInstance instance) throws Exception {
+ List<Pattern> patternList = new ArrayList<Pattern>();
+ Cluster cluster = instance.getCluster();
+ String pargs = null;
- for (Node node : cluster.getNode()) {
- Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
- String[] nodeStores;
- if (node.getStore() != null) {
- nodeStores = node.getStore().trim().split(",");
- for (String ns : nodeStores) {
- pargs = ns + File.separator + instance.getName();
- }
- } else {
- nodeStores = cluster.getStore().trim().split(",");
- for (String ns : nodeStores) {
- pargs = ns + File.separator + node.getId() + File.separator
- + instance.getName();
- }
- }
- Event event = new Event("file_delete", nodeid, pargs);
- patternList.add(new Pattern(null, 1, null, event));
- }
- Patterns patterns = new Patterns(patternList);
- return patterns;
- }
+ for (Node node : cluster.getNode()) {
+ Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
+ String[] nodeIODevices;
+ String iodevices = node.getIodevices() == null ? cluster.getIodevices() : node.getIodevices();
+ nodeIODevices = iodevices.trim().split(",");
+ for (String nodeIODevice : nodeIODevices) {
+ String nodeStore = node.getStore() == null ? cluster.getStore() : node.getStore();
+ pargs = nodeIODevice.trim() + File.separator + nodeStore;
+ Event event = new Event("file_delete", nodeid, pargs);
+ patternList.add(new Pattern(null, 1, null, event));
+ }
+ }
+ Patterns patterns = new Patterns(patternList);
+ return patterns;
+ }
- private Pattern createCopyHyracksPattern(String instanceName,
- Cluster cluster, String destinationIp, String destDir) {
- Nodeid nodeid = new Nodeid(new Value(null,
- EventDriver.CLIENT_NODE.getId()));
- String username = cluster.getUsername() != null ? cluster.getUsername()
- : System.getProperty("user.name");
- String asterixZipName = InstallerDriver.getAsterixZip()
- .substring(
- InstallerDriver.getAsterixZip().lastIndexOf(
- File.separator) + 1);
- String fileToTransfer = new File(InstallerDriver.getAsterixDir()
- + File.separator + instanceName + File.separator
- + asterixZipName).getAbsolutePath();
- String pargs = username + " " + fileToTransfer + " " + destinationIp
- + " " + destDir + " " + "unpack";
- Event event = new Event("file_transfer", nodeid, pargs);
- return new Pattern(null, 1, null, event);
- }
+ private Pattern createCopyHyracksPattern(String instanceName, Cluster cluster, String destinationIp, String destDir) {
+ Nodeid nodeid = new Nodeid(new Value(null, EventDriver.CLIENT_NODE.getId()));
+ String username = cluster.getUsername() != null ? cluster.getUsername() : System.getProperty("user.name");
+ String asterixZipName = InstallerDriver.getAsterixZip().substring(
+ InstallerDriver.getAsterixZip().lastIndexOf(File.separator) + 1);
+ String fileToTransfer = new File(InstallerDriver.getAsterixDir() + File.separator + instanceName
+ + File.separator + asterixZipName).getAbsolutePath();
+ String pargs = username + " " + fileToTransfer + " " + destinationIp + " " + destDir + " " + "unpack";
+ Event event = new Event("file_transfer", nodeid, pargs);
+ return new Pattern(null, 1, null, event);
+ }
- private Pattern createCCStartPattern(String hostId) {
- Nodeid nodeid = new Nodeid(new Value(null, hostId));
- Event event = new Event("cc_start", nodeid, "");
- return new Pattern(null, 1, null, event);
- }
+ private Pattern createCCStartPattern(String hostId) {
+ Nodeid nodeid = new Nodeid(new Value(null, hostId));
+ Event event = new Event("cc_start", nodeid, "");
+ return new Pattern(null, 1, null, event);
+ }
- public Pattern createCCStopPattern(String hostId) {
- Nodeid nodeid = new Nodeid(new Value(null, hostId));
- Event event = new Event("cc_failure", nodeid, null);
- return new Pattern(null, 1, null, event);
- }
+ public Pattern createCCStopPattern(String hostId) {
+ Nodeid nodeid = new Nodeid(new Value(null, hostId));
+ Event event = new Event("cc_failure", nodeid, null);
+ return new Pattern(null, 1, null, event);
+ }
- public Pattern createNCStartPattern(String ccHost, String hostId,
- String nodeControllerId) {
- Nodeid nodeid = new Nodeid(new Value(null, hostId));
- Event event = new Event("node_join", nodeid, ccHost + " "
- + nodeControllerId);
- return new Pattern(null, 1, null, event);
- }
+ public Pattern createNCStartPattern(String ccHost, String hostId, String nodeControllerId, String iodevices) {
+ Nodeid nodeid = new Nodeid(new Value(null, hostId));
+ String pargs = ccHost + " " + nodeControllerId + " " + iodevices;
+ Event event = new Event("node_join", nodeid, pargs);
+ return new Pattern(null, 1, null, event);
+ }
- public Pattern createNCStopPattern(String hostId, String nodeControllerId) {
- Nodeid nodeid = new Nodeid(new Value(null, hostId));
- Event event = new Event("node_failure", nodeid, nodeControllerId);
- return new Pattern(null, 1, null, event);
- }
+ public Pattern createNCStopPattern(String hostId, String nodeControllerId) {
+ Nodeid nodeid = new Nodeid(new Value(null, hostId));
+ Event event = new Event("node_failure", nodeid, nodeControllerId);
+ return new Pattern(null, 1, null, event);
+ }
}
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 d3ba758..de1dcb3 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
@@ -58,7 +58,7 @@
this.asterixVersion = asterixVersion;
this.createdTimestamp = new Date();
this.backupInfo = new ArrayList<BackupInfo>();
- this.webInterfaceUrl = "http://" + cluster.getMasterNode().getIp() + ":" + 19001;
+ this.webInterfaceUrl = "http://" + cluster.getMasterNode().getClusterIp() + ":" + 19001;
}
public Date getModifiedTimestamp() {
@@ -155,9 +155,10 @@
}
private void addDetailedInformation(StringBuffer buffer) {
- buffer.append("Master node:" + cluster.getMasterNode().getId() + ":" + cluster.getMasterNode().getIp() + "\n");
+ buffer.append("Master node:" + cluster.getMasterNode().getId() + ":" + cluster.getMasterNode().getClusterIp()
+ + "\n");
for (Node node : cluster.getNode()) {
- buffer.append(node.getId() + ":" + node.getIp() + "\n");
+ buffer.append(node.getId() + ":" + node.getClusterIp() + "\n");
}
if (backupInfo != null && backupInfo.size() > 0) {
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/ProcessInfo.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/ProcessInfo.java
index 2880671..42ee112 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/ProcessInfo.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/ProcessInfo.java
@@ -21,11 +21,13 @@
private static final long serialVersionUID = 304186774065853730L;
private final String processName;
private final String host;
+ private final String nodeId;
private final int processId;
- public ProcessInfo(String processName, String host, int processId) {
+ public ProcessInfo(String processName, String host, String nodeId, int processId) {
this.processName = processName;
this.host = host;
+ this.nodeId = nodeId;
this.processId = processId;
}
@@ -41,8 +43,12 @@
return processId;
}
+ public String getNodeId() {
+ return nodeId;
+ }
+
public String toString() {
- return processName + " at " + host + " [ " + processId + " ] ";
+ return processName + " at " + nodeId + " [ " + processId + " ] ";
}
}
diff --git a/asterix-installer/src/main/resources/clusters/local/local.xml b/asterix-installer/src/main/resources/clusters/local/local.xml
index 7a8e78f..b6589d0 100644
--- a/asterix-installer/src/main/resources/clusters/local/local.xml
+++ b/asterix-installer/src/main/resources/clusters/local/local.xml
@@ -1,20 +1,21 @@
<cluster xmlns="cluster">
<name>local</name>
<workingDir>
- <dir>/tmp/asterix-installer</dir>
- <NFS>true</NFS>
+ <dir>/tmp/asterix-installer</dir>
+ <NFS>true</NFS>
</workingDir>
<logdir>/tmp/asterix/logs</logdir>
- <store>/tmp/asterix/storage</store>
+ <iodevices>/tmp</iodevices>
+ <store>asterix/storage</store>
<java_home></java_home>
<java_heap>1024m</java_heap>
<master-node>
- <id>master</id>
- <ip>127.0.0.1</ip>
- <cluster-ip>127.0.0.1</cluster-ip>
+ <id>master</id>
+ <client-ip>127.0.0.1</client-ip>
+ <cluster-ip>127.0.0.1</cluster-ip>
</master-node>
<node>
- <id>node1</id>
- <ip>127.0.0.1</ip>
+ <id>node1</id>
+ <cluster-ip>127.0.0.1</cluster-ip>
</node>
</cluster>
diff --git a/asterix-installer/src/main/resources/conf/managix-conf.xml b/asterix-installer/src/main/resources/conf/managix-conf.xml
index ed3f8a2..10a62a9 100644
--- a/asterix-installer/src/main/resources/conf/managix-conf.xml
+++ b/asterix-installer/src/main/resources/conf/managix-conf.xml
@@ -10,7 +10,7 @@
<homeDir>/tmp/zookeeper</homeDir>
<clientPort>2900</clientPort>
<servers>
- <server>localhost</server>
+ <server>127.0.0.1</server>
</servers>
</zookeeper>
</configuration>