Move the hard coded hyracks IP and port number to the hyracks deployment properties file.
git-svn-id: https://asterixdb.googlecode.com/svn/branches/asterix_stabilization_result_distribution@1159 eaa15691-b419-025a-1212-ee371bd00084
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/HyracksProperties.java b/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/HyracksProperties.java
new file mode 100644
index 0000000..c5b532a
--- /dev/null
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/HyracksProperties.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2009-2011 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.api.http.servlet;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+public class HyracksProperties {
+ private final InputStream is;
+
+ private final Properties properties;
+
+ private static String HYRACKS_IP = "127.0.0.1";
+
+ private static int HYRACKS_PORT = 1098;
+
+ public HyracksProperties() throws IOException {
+ is = HyracksProperties.class.getClassLoader().getResourceAsStream("hyracks-deployment.properties");
+ properties = new Properties();
+ properties.load(is);
+ }
+
+ public String getHyracksIPAddress() {
+ String strIP = properties.getProperty("cc.ip");
+ if (strIP == null) {
+ strIP = HYRACKS_IP;
+ }
+ return strIP;
+ }
+
+ public int getHyracksPort() {
+ String strPort = properties.getProperty("cc.port");
+ int port = HYRACKS_PORT;
+ if (strPort != null) {
+ port = Integer.parseInt(strPort);
+ }
+ return port;
+ }
+}
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/QueryResultAPIServlet.java b/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/QueryResultAPIServlet.java
index 9416b0a..a3c210a 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/QueryResultAPIServlet.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/QueryResultAPIServlet.java
@@ -42,14 +42,15 @@
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
String strHandle = request.getParameter("handle");
- String strIP = "127.0.0.1";
- String strPort = "1098";
- int port = Integer.parseInt(strPort);
PrintWriter out = response.getWriter();
response.setContentType("text/html");
ServletContext context = getServletContext();
IHyracksClientConnection hcc;
try {
+ HyracksProperties hp = new HyracksProperties();
+ String strIP = hp.getHyracksIPAddress();
+ int port = hp.getHyracksPort();
+
synchronized (context) {
hcc = (IHyracksClientConnection) context.getAttribute(HYRACKS_CONNECTION_ATTR);
if (hcc == null) {
diff --git a/asterix-app/src/main/resources/hyracks-deployment.properties b/asterix-app/src/main/resources/hyracks-deployment.properties
index a8a943e..a333d38 100644
--- a/asterix-app/src/main/resources/hyracks-deployment.properties
+++ b/asterix-app/src/main/resources/hyracks-deployment.properties
@@ -1,2 +1,4 @@
cc.bootstrap.class=edu.uci.ics.asterix.hyracks.bootstrap.CCBootstrapImpl
-nc.bootstrap.class=edu.uci.ics.asterix.hyracks.bootstrap.NCBootstrapImpl
\ No newline at end of file
+nc.bootstrap.class=edu.uci.ics.asterix.hyracks.bootstrap.NCBootstrapImpl
+cc.ip=127.0.0.1
+cc.port=1098