integrating installer: checkpoint-2
git-svn-id: https://asterixdb.googlecode.com/svn/branches/asterix_stabilization_installer@1224 eaa15691-b419-025a-1212-ee371bd00084
diff --git a/asterix-events/src/main/java/edu/uci/ics/asterix/event/driver/EventDriver.java b/asterix-events/src/main/java/edu/uci/ics/asterix/event/driver/EventDriver.java
index ddefdd1..17d6647 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
@@ -42,7 +42,7 @@
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);
+ "127.0.0.1", null, null, null, null);
private static String eventsDir;
private static Events events;
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 043efa4..be60fec 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
@@ -26,52 +26,73 @@
import edu.uci.ics.asterix.event.driver.EventDriver;
import edu.uci.ics.asterix.event.schema.cluster.Cluster;
import edu.uci.ics.asterix.event.schema.cluster.Node;
+import edu.uci.ics.asterix.event.schema.cluster.Property;
import edu.uci.ics.asterix.event.schema.pattern.Pattern;
public class EventExecutor {
- public static final String EVENTS_DIR = "events";
- private static final String EXECUTE_SCRIPT = "execute.sh";
- private static final String IP_LOCATION = "IP_LOCATION";
- private static final String CLUSTER_ENV = "ENV";
- private static final String SCRIPT = "SCRIPT";
- private static final String ARGS = "ARGS";
- private static final String DAEMON = "DAEMON";
+ public static final String EVENTS_DIR = "events";
+ private static final String EXECUTE_SCRIPT = "execute.sh";
+ private static final String IP_LOCATION = "IP_LOCATION";
+ private static final String CLUSTER_ENV = "ENV";
+ private static final String SCRIPT = "SCRIPT";
+ private static final String ARGS = "ARGS";
+ private static final String DAEMON = "DAEMON";
- public void executeEvent(Node node, String script, List<String> args, boolean isDaemon, Cluster cluster,
- Pattern pattern, IOutputHandler outputHandler, EventrixClient client) throws IOException {
- List<String> pargs = new ArrayList<String>();
- pargs.add("/bin/bash");
- pargs.add(client.getEventsDir() + File.separator + "scripts" + File.separator + EXECUTE_SCRIPT);
- StringBuffer envBuffer = new StringBuffer(IP_LOCATION + "=" + node.getIp());
- if (!node.getId().equals(EventDriver.CLIENT_NODE_ID)) {
- envBuffer.append(" " + EventDriver.getStringifiedEnv(cluster));
- pargs.add(cluster.getUsername() == null ? System.getProperty("user.name") : cluster.getUsername());
- }
- StringBuffer argBuffer = new StringBuffer();
- if (args != null && args.size() > 0) {
- for (String arg : args) {
- argBuffer.append(arg + " ");
- }
- }
- ProcessBuilder pb = new ProcessBuilder(pargs);
- pb.environment().putAll(EventDriver.getEnvironment());
- pb.environment().put(IP_LOCATION, node.getIp());
- pb.environment().put(CLUSTER_ENV, envBuffer.toString());
- pb.environment().put(SCRIPT, script);
- pb.environment().put(ARGS, argBuffer.toString());
- pb.environment().put(DAEMON, isDaemon ? "true" : "false");
+ public void executeEvent(Node node, String script, List<String> args,
+ boolean isDaemon, Cluster cluster, Pattern pattern,
+ IOutputHandler outputHandler, EventrixClient client)
+ throws IOException {
+ List<String> pargs = new ArrayList<String>();
+ pargs.add("/bin/bash");
+ pargs.add(client.getEventsDir() + File.separator + "scripts"
+ + File.separator + EXECUTE_SCRIPT);
+ StringBuffer envBuffer = new StringBuffer(IP_LOCATION + "="
+ + node.getIp() + " ");
+ if (!node.getId().equals(EventDriver.CLIENT_NODE_ID)) {
+ for (Property p : cluster.getEnv().getProperty()) {
+ if (p.getKey().equals("JAVA_HOME")) {
+ String val = node.getJavaHome() == null ? p.getValue()
+ : node.getJavaHome();
+ envBuffer.append(p.getKey() + "=" + val + " ");
+ } else if (p.getKey().equals("JAVA_OPTS")) {
+ String val = "-Xmx" + (node.getRam() == null ? p.getValue()
+ : node.getRam());
+ envBuffer.append(p.getKey() + "=" + val + " ");
+ } else {
+ envBuffer.append(p.getKey() + "=" + p.getValue() + " ");
+ }
- Process p = pb.start();
- if (!isDaemon) {
- BufferedInputStream bis = new BufferedInputStream(p.getInputStream());
- StringWriter writer = new StringWriter();
- IOUtils.copy(bis, writer, "UTF-8");
- String result = writer.getBuffer().toString();
- OutputAnalysis analysis = outputHandler.reportEventOutput(pattern.getEvent(), result);
- if (!analysis.isExpected()) {
- throw new IOException(analysis.getErrorMessage() + result);
- }
- }
- }
+ }
+ pargs.add(cluster.getUsername() == null ? System
+ .getProperty("user.name") : cluster.getUsername());
+ }
+ StringBuffer argBuffer = new StringBuffer();
+ if (args != null && args.size() > 0) {
+ for (String arg : args) {
+ argBuffer.append(arg + " ");
+ }
+ }
+
+ ProcessBuilder pb = new ProcessBuilder(pargs);
+ pb.environment().put(IP_LOCATION, node.getIp());
+ pb.environment().put(CLUSTER_ENV, envBuffer.toString());
+ pb.environment().put(SCRIPT, script);
+ pb.environment().put(ARGS, argBuffer.toString());
+ pb.environment().put(DAEMON, isDaemon ? "true" : "false");
+
+ Process p = pb.start();
+ if (!isDaemon) {
+ BufferedInputStream bis = new BufferedInputStream(
+ p.getInputStream());
+ StringWriter writer = new StringWriter();
+ IOUtils.copy(bis, writer, "UTF-8");
+ String result = writer.getBuffer().toString();
+ OutputAnalysis analysis = outputHandler.reportEventOutput(
+ pattern.getEvent(), result);
+ if (!analysis.isExpected()) {
+ throw new IOException(analysis.getErrorMessage() + result);
+ }
+ }
+ }
}
diff --git a/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventUtil.java b/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventUtil.java
index 5f70c59..7fe0d7c 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
@@ -81,18 +81,18 @@
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;
- }
+
+ 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,
+ }
+ 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());
@@ -180,8 +180,14 @@
}
if (nodeid.equals(cluster.getMasterNode().getId())) {
+ String ram = cluster.getMasterNode().getRam() == null ? cluster
+ .getRam() : cluster.getMasterNode().getRam();
+ String logDir = cluster.getMasterNode().getLogdir() == null ? cluster
+ .getLogdir() : cluster.getMasterNode().getLogdir();
+ String javaHome = cluster.getMasterNode().getJavaHome() == null ? cluster
+ .getJavaHome() : cluster.getMasterNode().getJavaHome();
return new Node(cluster.getMasterNode().getId(), cluster
- .getMasterNode().getIp(), null, null, null);
+ .getMasterNode().getIp(), ram, javaHome, logDir, null);
}
List<Node> nodeList = cluster.getNode();
diff --git a/asterix-events/src/main/resources/schema/cluster.xsd b/asterix-events/src/main/resources/schema/cluster.xsd
index e5c6511..edfe220 100644
--- a/asterix-events/src/main/resources/schema/cluster.xsd
+++ b/asterix-events/src/main/resources/schema/cluster.xsd
@@ -32,6 +32,7 @@
<xs:element ref="cl:id"/>
<xs:element ref="cl:ip"/>
<xs:element ref="cl:cluster-ip"/>
+ <xs:element ref="cl:java_home" minOccurs="0"/>
<xs:element ref="cl:ram" minOccurs="0"/>
<xs:element ref="cl:logdir" minOccurs="0"/>
</xs:sequence>
@@ -61,6 +62,7 @@
<xs:element ref="cl:id"/>
<xs:element ref="cl:ip"/>
<xs:element ref="cl:ram" minOccurs="0"/>
+ <xs:element ref="cl:java_home" minOccurs="0"/>
<xs:element ref="cl:logdir" minOccurs="0"/>
<xs:element ref="cl:store" minOccurs="0"/>
</xs:sequence>
@@ -74,7 +76,7 @@
<xs:element ref="cl:username"/>
<xs:element ref="cl:env" minOccurs="0"/>
<xs:element ref="cl:ram" minOccurs="0"/>
- <xs:element ref="cl:java_home" minOccurs="1"/>
+ <xs:element ref="cl:java_home" minOccurs="0"/>
<xs:element ref="cl:logdir" minOccurs="0"/>
<xs:element ref="cl:store" minOccurs="0"/>
<xs:element ref="cl:workingDir"/>
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/EventList.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/EventList.java
index 4f5628f..e7f7264 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/EventList.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/EventList.java
@@ -25,6 +25,7 @@
BACKUP,
RESTORE,
FILE_DELETE,
+ HDFS_DELETE,
FILE_TRANSFER,
DIRECTORY_TRANSFER
}
diff --git a/asterix-installer/src/main/resources/hadoop-0.20.2/conf/hadoop-env.sh b/asterix-installer/src/main/resources/hadoop-0.20.2/conf/hadoop-env.sh
index 5463a35..e9396a4 100644
--- a/asterix-installer/src/main/resources/hadoop-0.20.2/conf/hadoop-env.sh
+++ b/asterix-installer/src/main/resources/hadoop-0.20.2/conf/hadoop-env.sh
@@ -6,7 +6,7 @@
# remote nodes.
# The java implementation to use. Required.
- export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
+# export JAVA_HOME=$JAVA_HOME
# Extra Java CLASSPATH elements. Optional.
# export HADOOP_CLASSPATH=