Added a Virtual Cluster Driver
git-svn-id: https://hyracks.googlecode.com/svn/branches/hyracks_dev_next@582 123451ca-8445-de46-9d55-352943316053
diff --git a/hyracks-server/.classpath b/hyracks-server/.classpath
index 3f62785..1f3c1ff 100644
--- a/hyracks-server/.classpath
+++ b/hyracks-server/.classpath
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
+ <classpathentry kind="src" output="target/classes" path="src/main/java"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
diff --git a/hyracks-server/.settings/org.eclipse.jdt.core.prefs b/hyracks-server/.settings/org.eclipse.jdt.core.prefs
index f362c73..611528f 100644
--- a/hyracks-server/.settings/org.eclipse.jdt.core.prefs
+++ b/hyracks-server/.settings/org.eclipse.jdt.core.prefs
@@ -1,6 +1,6 @@
-#Sun Aug 14 10:18:14 PDT 2011
+#Tue Sep 20 17:16:43 PDT 2011
eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4
-org.eclipse.jdt.core.compiler.compliance=1.4
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
-org.eclipse.jdt.core.compiler.source=1.4
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/hyracks-server/pom.xml b/hyracks-server/pom.xml
index 73819b3..8732ca4 100644
--- a/hyracks-server/pom.xml
+++ b/hyracks-server/pom.xml
@@ -13,6 +13,15 @@
<build>
<plugins>
<plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0.2</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
<executions>
@@ -27,6 +36,10 @@
<mainClass>edu.uci.ics.hyracks.control.nc.NCDriver</mainClass>
<name>hyracksnc</name>
</program>
+ <program>
+ <mainClass>edu.uci.ics.hyracks.server.drivers.VirtualClusterDriver</mainClass>
+ <name>hyracks-virtual-cluster</name>
+ </program>
</programs>
<repositoryLayout>flat</repositoryLayout>
<repositoryName>lib</repositoryName>
diff --git a/hyracks-server/src/main/java/edu/uci/ics/hyracks/server/drivers/VirtualClusterDriver.java b/hyracks-server/src/main/java/edu/uci/ics/hyracks/server/drivers/VirtualClusterDriver.java
new file mode 100644
index 0000000..92a1ad5
--- /dev/null
+++ b/hyracks-server/src/main/java/edu/uci/ics/hyracks/server/drivers/VirtualClusterDriver.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2009-2010 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.hyracks.server.drivers;
+
+import org.kohsuke.args4j.CmdLineParser;
+import org.kohsuke.args4j.Option;
+
+import edu.uci.ics.hyracks.control.common.controllers.CCConfig;
+import edu.uci.ics.hyracks.control.common.controllers.NCConfig;
+import edu.uci.ics.hyracks.server.process.HyracksCCProcess;
+import edu.uci.ics.hyracks.server.process.HyracksNCProcess;
+
+public class VirtualClusterDriver {
+ private static class Options {
+ @Option(name = "-n", required = false, usage = "Number of node controllers (default: 2)")
+ public int n = 2;
+
+ @Option(name = "-cc-port", required = false, usage = "CC Port (default: 1099)")
+ public int ccPort = 1099;
+ }
+
+ public static void main(String[] args) throws Exception {
+ Options options = new Options();
+ CmdLineParser cp = new CmdLineParser(options);
+ try {
+ cp.parseArgument(args);
+ } catch (Exception e) {
+ System.err.println(e.getMessage());
+ cp.printUsage(System.err);
+ return;
+ }
+
+ CCConfig ccConfig = new CCConfig();
+ ccConfig.port = options.ccPort;
+ HyracksCCProcess ccp = new HyracksCCProcess(ccConfig);
+ ccp.start();
+
+ Thread.sleep(2000);
+
+ HyracksNCProcess ncps[] = new HyracksNCProcess[options.n];
+ for (int i = 0; i < options.n; ++i) {
+ NCConfig ncConfig = new NCConfig();
+ ncConfig.ccHost = "localhost";
+ ncConfig.nodeId = "nc" + i;
+ ncConfig.dataIPAddress = "127.0.0.1";
+ ncps[i] = new HyracksNCProcess(ncConfig);
+ ncps[i].start();
+ }
+
+ while (true) {
+ Thread.sleep(10000);
+ }
+ }
+}
\ No newline at end of file
diff --git a/hyracks-server/src/main/java/edu/uci/ics/hyracks/server/process/HyracksCCProcess.java b/hyracks-server/src/main/java/edu/uci/ics/hyracks/server/process/HyracksCCProcess.java
new file mode 100644
index 0000000..cb1be95
--- /dev/null
+++ b/hyracks-server/src/main/java/edu/uci/ics/hyracks/server/process/HyracksCCProcess.java
@@ -0,0 +1,24 @@
+package edu.uci.ics.hyracks.server.process;
+
+import java.util.List;
+
+import edu.uci.ics.hyracks.control.cc.CCDriver;
+import edu.uci.ics.hyracks.control.common.controllers.CCConfig;
+
+public class HyracksCCProcess extends HyracksServerProcess {
+ private CCConfig config;
+
+ public HyracksCCProcess(CCConfig config) {
+ this.config = config;
+ }
+
+ @Override
+ protected void addCmdLineArgs(List<String> cList) {
+ config.toCommandLine(cList);
+ }
+
+ @Override
+ protected String getMainClassName() {
+ return CCDriver.class.getName();
+ }
+}
\ No newline at end of file
diff --git a/hyracks-server/src/main/java/edu/uci/ics/hyracks/server/process/HyracksNCProcess.java b/hyracks-server/src/main/java/edu/uci/ics/hyracks/server/process/HyracksNCProcess.java
new file mode 100644
index 0000000..cd110c8
--- /dev/null
+++ b/hyracks-server/src/main/java/edu/uci/ics/hyracks/server/process/HyracksNCProcess.java
@@ -0,0 +1,24 @@
+package edu.uci.ics.hyracks.server.process;
+
+import java.util.List;
+
+import edu.uci.ics.hyracks.control.common.controllers.NCConfig;
+import edu.uci.ics.hyracks.control.nc.NCDriver;
+
+public class HyracksNCProcess extends HyracksServerProcess {
+ private NCConfig config;
+
+ public HyracksNCProcess(NCConfig config) {
+ this.config = config;
+ }
+
+ @Override
+ protected void addCmdLineArgs(List<String> cList) {
+ config.toCommandLine(cList);
+ }
+
+ @Override
+ protected String getMainClassName() {
+ return NCDriver.class.getName();
+ }
+}
\ No newline at end of file
diff --git a/hyracks-server/src/main/java/edu/uci/ics/hyracks/server/process/HyracksServerProcess.java b/hyracks-server/src/main/java/edu/uci/ics/hyracks/server/process/HyracksServerProcess.java
new file mode 100644
index 0000000..17169ac
--- /dev/null
+++ b/hyracks-server/src/main/java/edu/uci/ics/hyracks/server/process/HyracksServerProcess.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2009-2010 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.hyracks.server.process;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+public abstract class HyracksServerProcess {
+ private static final Logger LOGGER = Logger.getLogger(HyracksServerProcess.class.getName());
+
+ protected Process process;
+
+ public void start() throws IOException {
+ String[] cmd = buildCommand();
+ if (LOGGER.isLoggable(Level.INFO)) {
+ LOGGER.info("Starting command: " + Arrays.toString(cmd));
+ }
+ process = Runtime.getRuntime().exec(cmd, null, null);
+ dump(process.getInputStream());
+ dump(process.getErrorStream());
+ }
+
+ private void dump(InputStream input) {
+ final int streamBufferSize = 1000;
+ final Reader in = new InputStreamReader(input);
+ new Thread(new Runnable() {
+ public void run() {
+ try {
+ char[] chars = new char[streamBufferSize];
+ int c;
+ while ((c = in.read(chars)) != -1) {
+ if (c > 0) {
+ System.out.print(String.valueOf(chars, 0, c));
+ }
+ }
+ } catch (IOException e) {
+ }
+ }
+ }).start();
+ }
+
+ private String[] buildCommand() {
+ List<String> cList = new ArrayList<String>();
+ cList.add(getJavaCommand());
+ cList.add("-classpath");
+ cList.add(getClasspath());
+ cList.add(getMainClassName());
+ addCmdLineArgs(cList);
+ return cList.toArray(new String[cList.size()]);
+ }
+
+ protected abstract void addCmdLineArgs(List<String> cList);
+
+ protected abstract String getMainClassName();
+
+ private final String getClasspath() {
+ return System.getProperty("java.class.path");
+ }
+
+ protected final String getJavaCommand() {
+ return System.getProperty("java.home") + File.separator + "bin" + File.separator + "java";
+ }
+}
\ No newline at end of file