Overhaul of Hyracks configuration management.
Includes Asterix changes to make use of new conf management as a
Hyracks application.
Change-Id: Ie3027c8c839f25ea858790bd3340187f4b11f212
Reviewed-on: https://asterix-gerrit.ics.uci.edu/336
Tested-by: Chris Hillery <ceej@lambda.nu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Michael Blow <michael.blow@couchbase.com>
Reviewed-by: Ian Maxon <imaxon@apache.org>
diff --git a/hyracks-fullstack/hyracks/hyracks-server/src/test/java/org/apache/hyracks/server/test/NCServiceIT.java b/hyracks-fullstack/hyracks/hyracks-server/src/test/java/org/apache/hyracks/server/test/NCServiceIT.java
new file mode 100644
index 0000000..7f431f6
--- /dev/null
+++ b/hyracks-fullstack/hyracks/hyracks-server/src/test/java/org/apache/hyracks/server/test/NCServiceIT.java
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 at
+ *
+ * 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 org.apache.hyracks.server.test;
+
+import junit.framework.Assert;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpStatus;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.lang3.StringUtils;
+import org.json.JSONArray;
+import org.json.JSONObject;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.File;
+import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Logger;
+
+public class NCServiceIT {
+
+ private static final String RESOURCE_DIR = StringUtils
+ .join(new String[]{System.getProperty("user.dir"), "src", "test", "resources", "NCServiceIT"},
+ File.separator);
+ private static final String APP_DIR = StringUtils
+ .join(new String[]{System.getProperty("user.dir"), "target", "appassembler", "bin"},
+ File.separator);
+ private static final Logger LOGGER = Logger.getLogger(NCServiceIT.class.getName());
+ private static List<Process> procs = new ArrayList<>();
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ // Start two NC Services - don't read their output as they don't terminate
+ procs.add(invoke(APP_DIR + File.separator + "hyracksncservice",
+ "-config-file", RESOURCE_DIR + File.separator + "nc-red.conf",
+ "-command", APP_DIR + File.separator + "hyracksnc"));
+ procs.add(invoke(APP_DIR + File.separator + "hyracksncservice",
+ "-config-file", RESOURCE_DIR + File.separator + "nc-blue.conf",
+ "-command", APP_DIR + File.separator + "hyracksnc"));
+ try {
+ Thread.sleep(2000);
+ }
+ catch (InterruptedException ignored) {
+ }
+
+ // Start CC
+ procs.add(invoke(APP_DIR + File.separator + "hyrackscc",
+ "-config-file", RESOURCE_DIR + File.separator + "cc.conf"));
+ try {
+ Thread.sleep(10000);
+ }
+ catch (InterruptedException ignored) {
+ }
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ for (Process p : procs) {
+ p.destroy();
+ p.waitFor();
+ }
+ }
+
+ private static String getHttp(String url) throws Exception {
+ HttpClient client = new HttpClient();
+ GetMethod get = new GetMethod(url);
+ int statusCode;
+ try {
+ statusCode = client.executeMethod(get);
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw e;
+ }
+ String response = get.getResponseBodyAsString();
+ if (statusCode == HttpStatus.SC_OK) {
+ return response;
+ } else {
+ throw new Exception("HTTP error " + statusCode + ":\n" + response);
+ }
+ }
+
+ private static Process invoke(String... args) throws Exception {
+ ProcessBuilder pb = new ProcessBuilder(args);
+ pb.redirectErrorStream(true);
+ Process p = pb.start();
+ return p;
+ }
+
+ @Test
+ public void IsNodelistCorrect() throws Exception {
+ // Ping the nodelist HTTP API
+ String localhost = InetAddress.getLoopbackAddress().getHostAddress();
+ String response = getHttp("http://" + localhost + ":12345/rest/nodes");
+ JSONObject result = new JSONObject(response);
+ JSONArray nodes = result.getJSONArray("result");
+ int numNodes = nodes.length();
+ Assert.assertEquals("Wrong number of nodes!", numNodes, 2);
+ for (int i = 0; i < nodes.length(); i++) {
+ JSONObject node = nodes.getJSONObject(i);
+ String id = node.getString("node-id");
+ if (id.equals("red") || id.equals("blue")) {
+ continue;
+ }
+ Assert.fail("Unexpected node ID '" + id + "'!");
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ try {
+ setUp();
+ } catch (Exception e) {
+ e.printStackTrace();
+ LOGGER.severe("TEST CASE(S) FAILED");
+ } finally {
+ tearDown();
+ }
+ }
+
+}
diff --git a/hyracks-fullstack/hyracks/hyracks-server/src/test/resources/NCServiceIT/cc.conf b/hyracks-fullstack/hyracks/hyracks-server/src/test/resources/NCServiceIT/cc.conf
new file mode 100644
index 0000000..25ac530
--- /dev/null
+++ b/hyracks-fullstack/hyracks/hyracks-server/src/test/resources/NCServiceIT/cc.conf
@@ -0,0 +1,11 @@
+[nc/red]
+address=127.0.0.1
+
+[nc/blue]
+address=127.0.0.1
+port=9091
+
+[cc]
+cluster.address = 127.0.0.1
+http.port = 12345
+
diff --git a/hyracks-fullstack/hyracks/hyracks-server/src/test/resources/NCServiceIT/nc-blue.conf b/hyracks-fullstack/hyracks/hyracks-server/src/test/resources/NCServiceIT/nc-blue.conf
new file mode 100644
index 0000000..d070b59
--- /dev/null
+++ b/hyracks-fullstack/hyracks/hyracks-server/src/test/resources/NCServiceIT/nc-blue.conf
@@ -0,0 +1,3 @@
+[ncservice]
+address=127.0.0.1
+port=9091
diff --git a/hyracks-fullstack/hyracks/hyracks-server/src/test/resources/NCServiceIT/nc-red.conf b/hyracks-fullstack/hyracks/hyracks-server/src/test/resources/NCServiceIT/nc-red.conf
new file mode 100644
index 0000000..58a8f1d
--- /dev/null
+++ b/hyracks-fullstack/hyracks/hyracks-server/src/test/resources/NCServiceIT/nc-red.conf
@@ -0,0 +1,4 @@
+[ncservice]
+address=127.0.0.1
+port=9090
+
diff --git a/hyracks-fullstack/hyracks/hyracks-server/src/test/resources/logging.properties b/hyracks-fullstack/hyracks/hyracks-server/src/test/resources/logging.properties
new file mode 100644
index 0000000..c888bb1
--- /dev/null
+++ b/hyracks-fullstack/hyracks/hyracks-server/src/test/resources/logging.properties
@@ -0,0 +1,76 @@
+#/*
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you 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 at
+#
+# 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.
+############################################################
+# Default Logging Configuration File
+#
+# You can use a different file by specifying a filename
+# with the java.util.logging.config.file system property.
+# For example java -Djava.util.logging.config.file=myfile
+############################################################
+
+############################################################
+# Global properties
+############################################################
+
+# "handlers" specifies a comma separated list of log Handler
+# classes. These handlers will be installed during VM startup.
+# Note that these classes must be on the system classpath.
+# By default we only configure a ConsoleHandler, which will only
+# show messages at the INFO and above levels.
+
+handlers= java.util.logging.ConsoleHandler
+
+# To also add the FileHandler, use the following line instead.
+
+# handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler
+
+# Default global logging level.
+# This specifies which kinds of events are logged across
+# all loggers. For any given facility this global level
+# can be overriden by a facility specific level
+# Note that the ConsoleHandler also has a separate level
+# setting to limit messages printed to the console.
+
+.level= WARNING
+# .level= INFO
+# .level= FINE
+# .level = FINEST
+
+############################################################
+# Handler specific properties.
+# Describes specific configuration info for Handlers.
+############################################################
+
+# default file output is in user's home directory.
+
+# java.util.logging.FileHandler.pattern = %h/java%u.log
+# java.util.logging.FileHandler.limit = 50000
+# java.util.logging.FileHandler.count = 1
+# java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter
+
+# Limit the message that are printed on the console to FINE and above.
+
+java.util.logging.ConsoleHandler.level = FINE
+java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
+
+
+############################################################
+# Facility specific properties.
+# Provides extra control for each logger.
+############################################################
+