You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by ti...@apache.org on 2017/01/26 15:29:29 UTC

[2/5] asterixdb git commit: Replace Servlets with Netty Based HTTP Servers

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/60e7f12b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/ShutdownAPIServlet.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/ShutdownAPIServlet.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/ShutdownAPIServlet.java
deleted file mode 100644
index d07166e..0000000
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/ShutdownAPIServlet.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * 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.asterix.api.http.servlet;
-
-import static org.apache.asterix.api.http.servlet.ServletConstants.HYRACKS_CONNECTION_ATTR;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Date;
-import java.util.logging.Level;
-
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.apache.asterix.common.config.GlobalConfig;
-import org.apache.asterix.runtime.util.ClusterStateManager;
-import org.apache.hyracks.api.client.IHyracksClientConnection;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-public class ShutdownAPIServlet extends HttpServlet {
-    private static final long serialVersionUID = 1L;
-    public static final String NODE_ID_KEY = "node_id";
-    public static final String NCSERVICE_PID = "ncservice_pid";
-    public static final String INI = "ini";
-    public static final String PID = "pid";
-
-    @Override
-    protected void doPost(HttpServletRequest request, HttpServletResponse response)
-            throws ServletException, IOException {
-
-        ServletContext context = getServletContext();
-        IHyracksClientConnection hcc = (IHyracksClientConnection) context.getAttribute(HYRACKS_CONNECTION_ATTR);
-        boolean terminateNCServices = "true".equalsIgnoreCase(request.getParameter("all"));
-        Thread t = new Thread(() -> {
-            try {
-                hcc.stopCluster(terminateNCServices);
-            } catch (Exception e) {
-                GlobalConfig.ASTERIX_LOGGER.log(Level.SEVERE, "Exception stopping cluster", e);
-            }
-        }, "Shutdown Servlet Worker");
-
-        response.setContentType("application/json");
-        response.setCharacterEncoding("utf-8");
-        response.setStatus(HttpServletResponse.SC_ACCEPTED);
-        ObjectMapper om = new ObjectMapper();
-        ObjectNode jsonObject = om.createObjectNode();
-        try {
-            jsonObject.put("status", "SHUTTING_DOWN");
-            jsonObject.putPOJO("date", new Date());
-            ObjectNode clusterState = ClusterStateManager.INSTANCE.getClusterStateDescription();
-            ArrayNode ncs = (ArrayNode) clusterState.get("ncs");
-            for (int i = 0; i < ncs.size(); i++) {
-                ObjectNode nc = (ObjectNode) ncs.get(i);
-                String node = nc.get(NODE_ID_KEY).asText();
-                ObjectNode details = (ObjectNode) om.readTree(hcc.getNodeDetailsJSON(node, false, true));
-                nc.set(PID, details.get(PID));
-                if (details.has(INI) && details.get(INI).has(NCSERVICE_PID)) {
-                    nc.put(NCSERVICE_PID, details.get(INI).get(NCSERVICE_PID).asInt());
-                }
-            }
-            jsonObject.set("cluster", clusterState);
-            final PrintWriter writer = response.getWriter();
-            writer.print(om.writeValueAsString(jsonObject));
-            writer.close();
-        } catch (Exception e) {
-            GlobalConfig.ASTERIX_LOGGER.log(Level.INFO, "Exception writing response", e);
-        }
-        t.start();
-    }
-}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/60e7f12b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/UpdateAPIServlet.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/UpdateAPIServlet.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/UpdateAPIServlet.java
deleted file mode 100644
index 1c62cdb..0000000
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/UpdateAPIServlet.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.asterix.api.http.servlet;
-
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.asterix.compiler.provider.ILangCompilationProvider;
-import org.apache.asterix.lang.common.base.Statement;
-import org.apache.asterix.translator.IStatementExecutorFactory;
-
-public class UpdateAPIServlet extends RESTAPIServlet {
-    private static final long serialVersionUID = 1L;
-    private static final byte ALLOWED_CATEGORIES = Statement.Category.QUERY | Statement.Category.UPDATE;
-
-    public UpdateAPIServlet(ILangCompilationProvider compilationProvider,
-            IStatementExecutorFactory statementExecutorFactory) {
-        super(compilationProvider, statementExecutorFactory);
-    }
-
-    @Override
-    protected String getQueryParameter(HttpServletRequest request) {
-        return request.getParameter("statements");
-    }
-
-    @Override
-    protected byte getAllowedCategories() {
-        return ALLOWED_CATEGORIES;
-    }
-
-    @Override
-    protected String getErrorMessage() {
-        return "Invalid statement: Non-Update statement %s to the Update API.";
-    }
-}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/60e7f12b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/VersionAPIServlet.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/VersionAPIServlet.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/VersionAPIServlet.java
deleted file mode 100644
index 398a355..0000000
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/VersionAPIServlet.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.asterix.api.http.servlet;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Map;
-
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.apache.asterix.runtime.util.AppContextInfo;
-
-import static org.apache.asterix.api.http.servlet.ServletConstants.ASTERIX_BUILD_PROP_ATTR;
-
-public class VersionAPIServlet extends HttpServlet {
-    private static final long serialVersionUID = 1L;
-
-    @Override
-    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
-        ServletContext context = getServletContext();
-        AppContextInfo props = (AppContextInfo) context.getAttribute(ASTERIX_BUILD_PROP_ATTR);
-        Map<String, String> buildProperties = props.getBuildProperties().getAllProps();
-        ObjectMapper om = new ObjectMapper();
-        ObjectNode responseObject = om.createObjectNode();
-        for (Map.Entry<String, String> e : buildProperties.entrySet()) {
-            responseObject.put(e.getKey(), e.getValue());
-        }
-        response.setCharacterEncoding("utf-8");
-        PrintWriter responseWriter = response.getWriter();
-        responseWriter.write(responseObject.toString());
-        response.setStatus(HttpServletResponse.SC_OK);
-        responseWriter.flush();
-    }
-}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/60e7f12b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/external/FeedWorkCollection.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/external/FeedWorkCollection.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/external/FeedWorkCollection.java
index f42beb3..6be7af9 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/external/FeedWorkCollection.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/external/FeedWorkCollection.java
@@ -88,7 +88,7 @@ public class FeedWorkCollection {
                     DataverseDecl dataverseDecl = new DataverseDecl(
                             new Identifier(request.getReceivingFeedId().getDataverse()));
                     SubscribeFeedStatement subscribeStmt = new SubscribeFeedStatement(locations, request);
-                    List<Statement> statements = new ArrayList<Statement>();
+                    List<Statement> statements = new ArrayList<>();
                     statements.add(dataverseDecl);
                     statements.add(subscribeStmt);
                     IStatementExecutor translator = qtFactory.create(statements, pc, compilationProvider);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/60e7f12b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/result/ResultUtil.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/result/ResultUtil.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/result/ResultUtil.java
index 80b8ffe..3afb653 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/result/ResultUtil.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/result/ResultUtil.java
@@ -33,8 +33,6 @@ import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.apache.asterix.api.http.servlet.APIServlet;
 import org.apache.asterix.om.types.ARecordType;
 import org.apache.asterix.translator.IStatementExecutor.Stats;
 import org.apache.asterix.translator.SessionConfig;
@@ -43,8 +41,9 @@ import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.prettyprint.AlgebricksAppendable;
 import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.log4j.Logger;
-import com.fasterxml.jackson.databind.node.ArrayNode;
 
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 
 public class ResultUtil {
@@ -244,7 +243,7 @@ public class ResultUtil {
         String errorTemplate = defaultTemplate;
         try {
             String resourcePath = "/webui/errortemplate_message.html";
-            InputStream is = APIServlet.class.getResourceAsStream(resourcePath);
+            InputStream is = ResultUtil.class.getResourceAsStream(resourcePath);
             InputStreamReader isr = new InputStreamReader(is);
             StringBuilder sb = new StringBuilder();
             BufferedReader br = new BufferedReader(isr);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/60e7f12b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java
index f039271..d60ed37 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java
@@ -46,7 +46,7 @@ import org.apache.asterix.active.EntityId;
 import org.apache.asterix.active.IActiveEntityEventsListener;
 import org.apache.asterix.algebra.extension.IExtensionStatement;
 import org.apache.asterix.api.common.APIFramework;
-import org.apache.asterix.api.http.servlet.APIServlet;
+import org.apache.asterix.api.http.server.ApiServlet;
 import org.apache.asterix.app.external.ExternalIndexingOperations;
 import org.apache.asterix.app.external.FeedJoint;
 import org.apache.asterix.app.external.FeedOperations;
@@ -284,7 +284,7 @@ public class QueryTranslator extends AbstractLangTranslator implements IStatemen
         try {
             for (Statement stmt : statements) {
                 if (sessionConfig.is(SessionConfig.FORMAT_HTML)) {
-                    sessionConfig.out().println(APIServlet.HTML_STATEMENT_SEPARATOR);
+                    sessionConfig.out().println(ApiServlet.HTML_STATEMENT_SEPARATOR);
                 }
                 validateOperation(activeDefaultDataverse, stmt);
                 rewriteStatement(stmt); // Rewrite the statement's AST.

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/60e7f12b/asterixdb/asterix-app/src/main/java/org/apache/asterix/drivers/AsterixWebServer.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/drivers/AsterixWebServer.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/drivers/AsterixWebServer.java
deleted file mode 100644
index f0eac39..0000000
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/drivers/AsterixWebServer.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.asterix.drivers;
-
-import org.apache.asterix.api.http.servlet.APIServlet;
-import org.apache.asterix.app.translator.DefaultStatementExecutorFactory;
-import org.apache.asterix.compiler.provider.AqlCompilationProvider;
-import org.apache.asterix.compiler.provider.SqlppCompilationProvider;
-import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.servlet.ServletContextHandler;
-import org.eclipse.jetty.servlet.ServletHolder;
-
-public class AsterixWebServer {
-    public static void main(String[] args) throws Exception {
-        Server server = new Server(8080);
-        ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
-        context.setContextPath("/");
-        server.setHandler(context);
-
-        context.addServlet(new ServletHolder(new APIServlet(new AqlCompilationProvider(),
-                new SqlppCompilationProvider(), new DefaultStatementExecutorFactory())), "/*");
-        server.start();
-        server.join();
-    }
-}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/60e7f12b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplicationEntryPoint.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplicationEntryPoint.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplicationEntryPoint.java
index 5756e7d..3a8852e 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplicationEntryPoint.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplicationEntryPoint.java
@@ -21,7 +21,6 @@ package org.apache.asterix.hyracks.bootstrap;
 import static org.apache.asterix.api.http.servlet.ServletConstants.ASTERIX_BUILD_PROP_ATTR;
 import static org.apache.asterix.api.http.servlet.ServletConstants.HYRACKS_CONNECTION_ATTR;
 
-import java.util.ArrayList;
 import java.util.List;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -29,24 +28,24 @@ import java.util.logging.Logger;
 import javax.servlet.Servlet;
 
 import org.apache.asterix.active.ActiveLifecycleListener;
-import org.apache.asterix.api.http.servlet.APIServlet;
-import org.apache.asterix.api.http.servlet.ClusterAPIServlet;
-import org.apache.asterix.api.http.servlet.ClusterCCDetailsAPIServlet;
-import org.apache.asterix.api.http.servlet.ClusterNodeDetailsAPIServlet;
-import org.apache.asterix.api.http.servlet.ConnectorAPIServlet;
-import org.apache.asterix.api.http.servlet.DDLAPIServlet;
-import org.apache.asterix.api.http.servlet.DiagnosticsAPIServlet;
-import org.apache.asterix.api.http.servlet.FeedServlet;
-import org.apache.asterix.api.http.servlet.FullAPIServlet;
-import org.apache.asterix.api.http.servlet.QueryAPIServlet;
-import org.apache.asterix.api.http.servlet.QueryResultAPIServlet;
-import org.apache.asterix.api.http.servlet.QueryServiceServlet;
-import org.apache.asterix.api.http.servlet.QueryStatusAPIServlet;
-import org.apache.asterix.api.http.servlet.QueryWebInterfaceServlet;
+import org.apache.asterix.api.http.server.ApiServlet;
+import org.apache.asterix.api.http.server.FullApiServlet;
+import org.apache.asterix.api.http.server.ClusterApiServlet;
+import org.apache.asterix.api.http.server.ClusterControllerDetailsApiServlet;
+import org.apache.asterix.api.http.server.ConnectorApiServlet;
+import org.apache.asterix.api.http.server.DdlApiServlet;
+import org.apache.asterix.api.http.server.DiagnosticsApiServlet;
+import org.apache.asterix.api.http.server.FeedServlet;
+import org.apache.asterix.api.http.server.NodeControllerDetailsApiServlet;
+import org.apache.asterix.api.http.server.QueryApiServlet;
+import org.apache.asterix.api.http.server.QueryResultApiServlet;
+import org.apache.asterix.api.http.server.QueryServiceServlet;
+import org.apache.asterix.api.http.server.QueryStatusApiServlet;
+import org.apache.asterix.api.http.server.QueryWebInterfaceServlet;
+import org.apache.asterix.api.http.server.ShutdownApiServlet;
+import org.apache.asterix.api.http.server.UpdateApiServlet;
+import org.apache.asterix.api.http.server.VersionApiServlet;
 import org.apache.asterix.api.http.servlet.ServletConstants;
-import org.apache.asterix.api.http.servlet.ShutdownAPIServlet;
-import org.apache.asterix.api.http.servlet.UpdateAPIServlet;
-import org.apache.asterix.api.http.servlet.VersionAPIServlet;
 import org.apache.asterix.app.cc.CompilerExtensionManager;
 import org.apache.asterix.app.cc.ResourceIdManager;
 import org.apache.asterix.app.external.ExternalLibraryUtils;
@@ -55,7 +54,7 @@ import org.apache.asterix.common.config.AsterixExtension;
 import org.apache.asterix.common.config.ExternalProperties;
 import org.apache.asterix.common.config.MetadataProperties;
 import org.apache.asterix.common.library.ILibraryManager;
-import org.apache.asterix.common.utils.ServletUtil.Servlets;
+import org.apache.asterix.common.utils.LetUtil.Lets;
 import org.apache.asterix.external.library.ExternalLibraryManager;
 import org.apache.asterix.messaging.CCMessageBroker;
 import org.apache.asterix.metadata.MetadataManager;
@@ -73,7 +72,8 @@ import org.apache.hyracks.api.lifecycle.LifeCycleComponentManager;
 import org.apache.hyracks.api.messages.IMessageBroker;
 import org.apache.hyracks.control.cc.ClusterControllerService;
 import org.apache.hyracks.control.common.controllers.CCConfig;
-import org.eclipse.jetty.server.Server;
+import org.apache.hyracks.http.server.HttpServer;
+import org.apache.hyracks.http.server.IServlet;
 import org.eclipse.jetty.servlet.ServletContextHandler;
 import org.eclipse.jetty.servlet.ServletHolder;
 import org.eclipse.jetty.servlet.ServletMapping;
@@ -81,13 +81,11 @@ import org.eclipse.jetty.servlet.ServletMapping;
 public class CCApplicationEntryPoint implements ICCApplicationEntryPoint {
 
     private static final Logger LOGGER = Logger.getLogger(CCApplicationEntryPoint.class.getName());
-
-    private List<Server> servers;
-
     private static IAsterixStateProxy proxy;
     protected ICCApplicationContext appCtx;
     protected CompilerExtensionManager ccExtensionManager;
     private IJobCapacityController jobCapacityController;
+    protected WebManager webManager;
 
     @Override
     public void start(ICCApplicationContext ccAppCtx, String[] args) throws Exception {
@@ -124,14 +122,11 @@ public class CCApplicationEntryPoint implements ICCApplicationEntryPoint {
         AppContextInfo.INSTANCE.getCCApplicationContext()
                 .addJobLifecycleListener(ActiveLifecycleListener.INSTANCE);
 
-        servers = configureServers();
-
-        for (Server server : servers) {
-            server.start();
-        }
-
+        // create event loop groups
+        webManager = new WebManager();
+        configureServers();
+        webManager.start();
         ClusterManagerProvider.getClusterManager().registerSubscriber(GlobalRecoveryManager.instance());
-
         ccAppCtx.addClusterLifecycleListener(ClusterLifecycleListener.INSTANCE);
         ccAppCtx.setMessageBroker(messageBroker);
 
@@ -142,15 +137,11 @@ public class CCApplicationEntryPoint implements ICCApplicationEntryPoint {
         return AppContextInfo.INSTANCE.getExtensionProperties().getExtensions();
     }
 
-    protected List<Server> configureServers() throws Exception {
-        ExternalProperties externalProperties = AppContextInfo.INSTANCE.getExternalProperties();
-
-        List<Server> serverList = new ArrayList<>();
-        serverList.add(setupWebServer(externalProperties));
-        serverList.add(setupJSONAPIServer(externalProperties));
-        serverList.add(setupFeedServer(externalProperties));
-        serverList.add(setupQueryWebServer(externalProperties));
-        return serverList;
+    protected void configureServers() throws Exception {
+        webManager.add(setupWebServer(AppContextInfo.INSTANCE.getExternalProperties()));
+        webManager.add(setupJSONAPIServer(AppContextInfo.INSTANCE.getExternalProperties()));
+        webManager.add(setupFeedServer(AppContextInfo.INSTANCE.getExternalProperties()));
+        webManager.add(setupQueryWebServer(AppContextInfo.INSTANCE.getExternalProperties()));
     }
 
     @Override
@@ -160,14 +151,7 @@ public class CCApplicationEntryPoint implements ICCApplicationEntryPoint {
             LOGGER.info("Stopping Asterix cluster controller");
         }
         AsterixStateProxy.unregisterRemoteObject();
-        // Stop servers
-        for (Server server : servers) {
-            server.stop();
-        }
-        // Make sure servers are stopped before proceeding
-        for (Server server : servers) {
-            server.join();
-        }
+        webManager.stop();
     }
 
     protected IHyracksClientConnection getNewHyracksClientConnection() throws Exception {
@@ -176,77 +160,62 @@ public class CCApplicationEntryPoint implements ICCApplicationEntryPoint {
         return new HyracksConnection(strIP, port);
     }
 
-    protected Server setupWebServer(ExternalProperties externalProperties) throws Exception {
-
-        Server webServer = new Server(externalProperties.getWebInterfacePort());
-
-        ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
-        context.setContextPath("/");
-
+    protected HttpServer setupWebServer(ExternalProperties externalProperties) throws Exception {
+        HttpServer webServer = new HttpServer(webManager.getBosses(), webManager.getWorkers(), externalProperties
+                .getWebInterfacePort());
         IHyracksClientConnection hcc = getNewHyracksClientConnection();
-        context.setAttribute(HYRACKS_CONNECTION_ATTR, hcc);
-
-        webServer.setHandler(context);
-        context.addServlet(new ServletHolder(new APIServlet(ccExtensionManager.getAqlCompilationProvider(),
-                ccExtensionManager.getSqlppCompilationProvider(), ccExtensionManager.getQueryTranslatorFactory())),
-                "/*");
-
+        webServer.setAttribute(HYRACKS_CONNECTION_ATTR, hcc);
+        webServer.addLet(new ApiServlet(webServer.ctx(), new String[] { "/*" }, ccExtensionManager
+                .getAqlCompilationProvider(), ccExtensionManager.getSqlppCompilationProvider(), ccExtensionManager
+                        .getQueryTranslatorFactory()));
         return webServer;
     }
 
-    protected Server setupJSONAPIServer(ExternalProperties externalProperties) throws Exception {
-        Server jsonAPIServer = new Server(externalProperties.getAPIServerPort());
-
-        ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
-        context.setContextPath("/");
-
+    protected HttpServer setupJSONAPIServer(ExternalProperties externalProperties) throws Exception {
+        HttpServer jsonAPIServer = new HttpServer(webManager.getBosses(), webManager.getWorkers(), externalProperties
+                .getAPIServerPort());
         IHyracksClientConnection hcc = getNewHyracksClientConnection();
-        context.setAttribute(HYRACKS_CONNECTION_ATTR, hcc);
-        context.setAttribute(ASTERIX_BUILD_PROP_ATTR, AppContextInfo.INSTANCE);
-        context.setAttribute(ServletConstants.EXECUTOR_SERVICE,
+        jsonAPIServer.setAttribute(HYRACKS_CONNECTION_ATTR, hcc);
+        jsonAPIServer.setAttribute(ASTERIX_BUILD_PROP_ATTR, AppContextInfo.INSTANCE);
+        jsonAPIServer.setAttribute(ServletConstants.EXECUTOR_SERVICE,
                 ((ClusterControllerService) appCtx.getControllerService()).getExecutor());
 
-        jsonAPIServer.setHandler(context);
-
         // AQL rest APIs.
-        addServlet(context, Servlets.AQL_QUERY);
-        addServlet(context, Servlets.AQL_UPDATE);
-        addServlet(context, Servlets.AQL_DDL);
-        addServlet(context, Servlets.AQL);
+        addLet(jsonAPIServer, Lets.AQL_QUERY);
+        addLet(jsonAPIServer, Lets.AQL_UPDATE);
+        addLet(jsonAPIServer, Lets.AQL_DDL);
+        addLet(jsonAPIServer, Lets.AQL);
 
         // SQL+x+ rest APIs.
-        addServlet(context, Servlets.SQLPP_QUERY);
-        addServlet(context, Servlets.SQLPP_UPDATE);
-        addServlet(context, Servlets.SQLPP_DDL);
-        addServlet(context, Servlets.SQLPP);
+        addLet(jsonAPIServer, Lets.SQLPP_QUERY);
+        addLet(jsonAPIServer, Lets.SQLPP_UPDATE);
+        addLet(jsonAPIServer, Lets.SQLPP_DDL);
+        addLet(jsonAPIServer, Lets.SQLPP);
 
         // Other APIs.
-        addServlet(context, Servlets.QUERY_STATUS);
-        addServlet(context, Servlets.QUERY_RESULT);
-        addServlet(context, Servlets.QUERY_SERVICE);
-        addServlet(context, Servlets.CONNECTOR);
-        addServlet(context, Servlets.SHUTDOWN);
-        addServlet(context, Servlets.VERSION);
-        addServlet(context, Servlets.CLUSTER_STATE);
-        addServlet(context, Servlets.CLUSTER_STATE_NODE_DETAIL); // this must not precede add of CLUSTER_STATE
-        addServlet(context, Servlets.CLUSTER_STATE_CC_DETAIL); // this must not precede add of CLUSTER_STATE
-        addServlet(context, Servlets.DIAGNOSTICS);
-
+        addLet(jsonAPIServer, Lets.QUERY_STATUS);
+        addLet(jsonAPIServer, Lets.QUERY_RESULT);
+        addLet(jsonAPIServer, Lets.QUERY_SERVICE);
+        addLet(jsonAPIServer, Lets.CONNECTOR);
+        addLet(jsonAPIServer, Lets.SHUTDOWN);
+        addLet(jsonAPIServer, Lets.VERSION);
+        addLet(jsonAPIServer, Lets.CLUSTER_STATE);
+        addLet(jsonAPIServer, Lets.CLUSTER_STATE_NODE_DETAIL); // this must not precede add of CLUSTER_STATE
+        addLet(jsonAPIServer, Lets.CLUSTER_STATE_CC_DETAIL); // this must not precede add of CLUSTER_STATE
+        addLet(jsonAPIServer, Lets.DIAGNOSTICS);
         return jsonAPIServer;
     }
 
-    protected Server setupQueryWebServer(ExternalProperties externalProperties) throws Exception {
-
-        Server queryWebServer = new Server(externalProperties.getQueryWebInterfacePort());
-
-        ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
-        context.setContextPath("/");
+    protected void addLet(HttpServer server, Lets let) {
+        server.addLet(createServLet(server, let, let.getPath()));
+    }
 
+    protected HttpServer setupQueryWebServer(ExternalProperties externalProperties) throws Exception {
+        HttpServer queryWebServer = new HttpServer(webManager.getBosses(), webManager.getWorkers(), externalProperties
+                .getQueryWebInterfacePort());
         IHyracksClientConnection hcc = getNewHyracksClientConnection();
-        context.setAttribute(HYRACKS_CONNECTION_ATTR, hcc);
-
-        queryWebServer.setHandler(context);
-        context.addServlet(new ServletHolder(new QueryWebInterfaceServlet()), "/*");
+        queryWebServer.setAttribute(HYRACKS_CONNECTION_ATTR, hcc);
+        queryWebServer.addLet(new QueryWebInterfaceServlet(queryWebServer.ctx(), new String[] { "/*" }));
         return queryWebServer;
     }
 
@@ -259,77 +228,66 @@ public class CCApplicationEntryPoint implements ICCApplicationEntryPoint {
         context.getServletHandler().addServletMapping(mapping);
     }
 
-    protected void addServlet(ServletContextHandler context, Servlets key) {
-        addServlet(context, createServlet(key), key.getPath());
+    protected HttpServer setupFeedServer(ExternalProperties externalProperties) throws Exception {
+        HttpServer feedServer = new HttpServer(webManager.getBosses(), webManager.getWorkers(), externalProperties
+                .getFeedServerPort());
+        feedServer.setAttribute(HYRACKS_CONNECTION_ATTR, getNewHyracksClientConnection());
+        feedServer.addLet(new FeedServlet(feedServer.ctx(), new String[] { "/" }));
+        return feedServer;
     }
 
-    protected Servlet createServlet(Servlets key) {
+    protected IServlet createServLet(HttpServer server, Lets key, String... paths) {
         switch (key) {
             case AQL:
-                return new FullAPIServlet(ccExtensionManager.getAqlCompilationProvider(),
+                return new FullApiServlet(server.ctx(), paths, ccExtensionManager.getAqlCompilationProvider(),
                         ccExtensionManager.getQueryTranslatorFactory());
             case AQL_QUERY:
-                return new QueryAPIServlet(ccExtensionManager.getAqlCompilationProvider(),
+                return new QueryApiServlet(server.ctx(), paths, ccExtensionManager.getAqlCompilationProvider(),
                         ccExtensionManager.getQueryTranslatorFactory());
             case AQL_UPDATE:
-                return new UpdateAPIServlet(ccExtensionManager.getAqlCompilationProvider(),
+                return new UpdateApiServlet(server.ctx(), paths, ccExtensionManager.getAqlCompilationProvider(),
                         ccExtensionManager.getQueryTranslatorFactory());
             case AQL_DDL:
-                return new DDLAPIServlet(ccExtensionManager.getAqlCompilationProvider(),
+                return new DdlApiServlet(server.ctx(), paths, ccExtensionManager.getAqlCompilationProvider(),
                         ccExtensionManager.getQueryTranslatorFactory());
             case SQLPP:
-                return new FullAPIServlet(ccExtensionManager.getSqlppCompilationProvider(),
+                return new FullApiServlet(server.ctx(), paths, ccExtensionManager.getSqlppCompilationProvider(),
                         ccExtensionManager.getQueryTranslatorFactory());
             case SQLPP_QUERY:
-                return new QueryAPIServlet(ccExtensionManager.getSqlppCompilationProvider(),
+                return new QueryApiServlet(server.ctx(), paths, ccExtensionManager.getSqlppCompilationProvider(),
                         ccExtensionManager.getQueryTranslatorFactory());
             case SQLPP_UPDATE:
-                return new UpdateAPIServlet(ccExtensionManager.getSqlppCompilationProvider(),
+                return new UpdateApiServlet(server.ctx(), paths, ccExtensionManager.getSqlppCompilationProvider(),
                         ccExtensionManager.getQueryTranslatorFactory());
             case SQLPP_DDL:
-                return new DDLAPIServlet(ccExtensionManager.getSqlppCompilationProvider(),
+                return new DdlApiServlet(server.ctx(), paths, ccExtensionManager.getSqlppCompilationProvider(),
                         ccExtensionManager.getQueryTranslatorFactory());
             case QUERY_STATUS:
-                return new QueryStatusAPIServlet();
+                return new QueryStatusApiServlet(server.ctx(), paths);
             case QUERY_RESULT:
-                return new QueryResultAPIServlet();
+                return new QueryResultApiServlet(server.ctx(), paths);
             case QUERY_SERVICE:
-                return new QueryServiceServlet(ccExtensionManager.getSqlppCompilationProvider(),
-                        ccExtensionManager.getQueryTranslatorFactory());
+                return new QueryServiceServlet(server.ctx(), paths, ccExtensionManager
+                        .getSqlppCompilationProvider(), ccExtensionManager.getQueryTranslatorFactory());
             case CONNECTOR:
-                return new ConnectorAPIServlet();
+                return new ConnectorApiServlet(server.ctx(), paths);
             case SHUTDOWN:
-                return new ShutdownAPIServlet();
+                return new ShutdownApiServlet(server.ctx(), paths);
             case VERSION:
-                return new VersionAPIServlet();
+                return new VersionApiServlet(server.ctx(), paths);
             case CLUSTER_STATE:
-                return new ClusterAPIServlet();
+                return new ClusterApiServlet(server.ctx(), paths);
             case CLUSTER_STATE_NODE_DETAIL:
-                return new ClusterNodeDetailsAPIServlet();
+                return new NodeControllerDetailsApiServlet(server.ctx(), paths);
             case CLUSTER_STATE_CC_DETAIL:
-                return new ClusterCCDetailsAPIServlet();
+                return new ClusterControllerDetailsApiServlet(server.ctx(), paths);
             case DIAGNOSTICS:
-                return new DiagnosticsAPIServlet();
+                return new DiagnosticsApiServlet(server.ctx(), paths);
             default:
                 throw new IllegalStateException(String.valueOf(key));
         }
     }
 
-    protected Server setupFeedServer(ExternalProperties externalProperties) throws Exception {
-        Server feedServer = new Server(externalProperties.getFeedServerPort());
-
-        ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
-        context.setContextPath("/");
-
-        IHyracksClientConnection hcc = getNewHyracksClientConnection();
-        context.setAttribute(HYRACKS_CONNECTION_ATTR, hcc);
-
-        feedServer.setHandler(context);
-        context.addServlet(new ServletHolder(new FeedServlet()), "/");
-
-        return feedServer;
-    }
-
     @Override
     public void startupCompleted() throws Exception {
         ClusterManagerProvider.getClusterManager().notifyStartupCompleted();

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/60e7f12b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/WebManager.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/WebManager.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/WebManager.java
new file mode 100644
index 0000000..070a530
--- /dev/null
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/WebManager.java
@@ -0,0 +1,69 @@
+/*
+ * 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.asterix.hyracks.bootstrap;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.hyracks.http.server.HttpServer;
+
+import io.netty.channel.EventLoopGroup;
+import io.netty.channel.nio.NioEventLoopGroup;
+
+public class WebManager {
+    private final List<HttpServer> servers;
+    private final EventLoopGroup bosses;
+    private final EventLoopGroup workers;
+
+    public WebManager() {
+        servers = new ArrayList<>();
+        bosses = new NioEventLoopGroup(1);
+        workers = new NioEventLoopGroup();
+    }
+
+    public List<HttpServer> getServers() {
+        return servers;
+    }
+
+    public EventLoopGroup getBosses() {
+        return bosses;
+    }
+
+    public EventLoopGroup getWorkers() {
+        return workers;
+    }
+
+    public void start() throws Exception {
+        for (HttpServer server : servers) {
+            server.start();
+        }
+    }
+
+    public void stop() throws Exception {
+        for (HttpServer server : servers) {
+            server.stop();
+        }
+        workers.shutdownGracefully().sync();
+        bosses.shutdownGracefully().sync();
+    }
+
+    public void add(HttpServer server) {
+        servers.add(server);
+    }
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/60e7f12b/asterixdb/asterix-app/src/test/java/org/apache/asterix/api/http/servlet/ConnectorAPIServletTest.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/api/http/servlet/ConnectorAPIServletTest.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/api/http/servlet/ConnectorAPIServletTest.java
deleted file mode 100644
index 41785e5..0000000
--- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/api/http/servlet/ConnectorAPIServletTest.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * 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.asterix.api.http.servlet;
-
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
-import java.io.ByteArrayOutputStream;
-import java.io.PrintWriter;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import junit.extensions.PA;
-import org.apache.asterix.metadata.MetadataManager;
-import org.apache.asterix.metadata.MetadataTransactionContext;
-import org.apache.asterix.metadata.declared.MetadataProvider;
-import org.apache.asterix.metadata.entities.Dataset;
-import org.apache.asterix.om.types.ARecordType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.asterix.om.util.JSONDeserializerForTypes;
-import org.apache.asterix.test.runtime.SqlppExecutionTest;
-import org.apache.hyracks.api.client.IHyracksClientConnection;
-import org.apache.hyracks.api.client.NodeControllerInfo;
-import org.apache.hyracks.api.comm.NetworkAddress;
-import org.apache.hyracks.api.io.FileSplit;
-import org.apache.hyracks.api.io.ManagedFileSplit;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class ConnectorAPIServletTest {
-
-    @Test
-    public void testGet() throws Exception {
-        // Starts test asterixdb cluster.
-        SqlppExecutionTest.setUp();
-
-        // Configures a test connector api servlet.
-        ConnectorAPIServlet servlet = spy(new ConnectorAPIServlet());
-        ServletConfig mockServletConfig = mock(ServletConfig.class);
-        servlet.init(mockServletConfig);
-        Map<String, NodeControllerInfo> nodeMap = new HashMap<>();
-        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
-        PrintWriter outputWriter = new PrintWriter(outputStream);
-
-        // Creates mocks.
-        ServletContext mockContext = mock(ServletContext.class);
-        IHyracksClientConnection mockHcc = mock(IHyracksClientConnection.class);
-        NodeControllerInfo mockInfo1 = mock(NodeControllerInfo.class);
-        NodeControllerInfo mockInfo2 = mock(NodeControllerInfo.class);
-        HttpServletRequest mockRequest = mock(HttpServletRequest.class);
-        HttpServletResponse mockResponse = mock(HttpServletResponse.class);
-
-        // Sets up mock returns.
-        when(servlet.getServletContext()).thenReturn(mockContext);
-        when(mockRequest.getParameter("dataverseName")).thenReturn("Metadata");
-        when(mockRequest.getParameter("datasetName")).thenReturn("Dataset");
-        when(mockResponse.getWriter()).thenReturn(outputWriter);
-        when(mockContext.getAttribute(anyString())).thenReturn(mockHcc);
-        when(mockHcc.getNodeControllerInfos()).thenReturn(nodeMap);
-        when(mockInfo1.getNetworkAddress()).thenReturn(new NetworkAddress("127.0.0.1", 3099));
-        when(mockInfo2.getNetworkAddress()).thenReturn(new NetworkAddress("127.0.0.2", 3099));
-
-        // Calls ConnectorAPIServlet.formResponseObject.
-        nodeMap.put("asterix_nc1", mockInfo1);
-        nodeMap.put("asterix_nc2", mockInfo2);
-        servlet.doGet(mockRequest, mockResponse);
-
-        // Constructs the actual response.
-        ObjectMapper om = new ObjectMapper();
-        ObjectNode actualResponse = (ObjectNode) om.readTree(outputStream.toString());
-
-        // Checks the temp-or-not, primary key, data type of the dataset.
-        boolean temp = actualResponse.get("temp").asBoolean();
-        Assert.assertFalse(temp);
-        String primaryKey = actualResponse.get("keys").asText();
-        Assert.assertEquals("DataverseName,DatasetName", primaryKey);
-        ARecordType recordType = (ARecordType) JSONDeserializerForTypes
-                .convertFromJSON((ObjectNode) actualResponse.get("type"));
-        Assert.assertEquals(getMetadataRecordType("Metadata", "Dataset"), recordType);
-
-        // Checks the correctness of results.
-        ArrayNode splits = (ArrayNode) actualResponse.get("splits");
-        String path = (splits.get(0)).get("path").asText();
-        Assert.assertTrue(path.endsWith("Metadata/Dataset_idx_Dataset"));
-
-        // Tears down the asterixdb cluster.
-        SqlppExecutionTest.tearDown();
-    }
-
-    @Test
-    public void testFormResponseObject() throws Exception {
-        ConnectorAPIServlet servlet = new ConnectorAPIServlet();
-        ObjectMapper om = new ObjectMapper();
-        ObjectNode actualResponse = om.createObjectNode();
-        FileSplit[] splits = new FileSplit[2];
-        splits[0] = new ManagedFileSplit("asterix_nc1", "foo1");
-        splits[1] = new ManagedFileSplit("asterix_nc2", "foo2");
-        Map<String, NodeControllerInfo> nodeMap = new HashMap<>();
-        NodeControllerInfo mockInfo1 = mock(NodeControllerInfo.class);
-        NodeControllerInfo mockInfo2 = mock(NodeControllerInfo.class);
-
-        // Sets up mock returns.
-        when(mockInfo1.getNetworkAddress()).thenReturn(new NetworkAddress("127.0.0.1", 3099));
-        when(mockInfo2.getNetworkAddress()).thenReturn(new NetworkAddress("127.0.0.2", 3099));
-
-        String[] fieldNames = new String[] { "a1", "a2" };
-        IAType[] fieldTypes = new IAType[] { BuiltinType.ABOOLEAN, BuiltinType.ADAYTIMEDURATION };
-        ARecordType recordType = new ARecordType("record", fieldNames, fieldTypes, true);
-        String primaryKey = "a1";
-
-        // Calls ConnectorAPIServlet.formResponseObject.
-        nodeMap.put("asterix_nc1", mockInfo1);
-        nodeMap.put("asterix_nc2", mockInfo2);
-        PA.invokeMethod(servlet, "formResponseObject(" + ObjectNode.class.getName() + ", " + FileSplit.class.getName()
-                + "[], " + ARecordType.class.getName() + ", " + String.class.getName() + ", boolean, " + Map.class
-                        .getName() + ")", actualResponse, splits, recordType, primaryKey, true, nodeMap);
-        // Constructs expected response.
-        ObjectNode expectedResponse = om.createObjectNode();
-        expectedResponse.put("temp", true);
-        expectedResponse.put("keys", primaryKey);
-        expectedResponse.set("type", recordType.toJSON());
-        ArrayNode splitsArray = om.createArrayNode();
-        ObjectNode element1 = om.createObjectNode();
-        element1.put("ip", "127.0.0.1");
-        element1.put("path", splits[0].getPath());
-        ObjectNode element2 = om.createObjectNode();
-        element2.put("ip", "127.0.0.2");
-        element2.put("path", splits[1].getPath());
-        splitsArray.add(element1);
-        splitsArray.add(element2);
-        expectedResponse.set("splits", splitsArray);
-
-        // Checks results.
-        Assert.assertEquals(actualResponse.toString(), expectedResponse.toString());
-    }
-
-    private ARecordType getMetadataRecordType(String dataverseName, String datasetName) throws Exception {
-        MetadataTransactionContext mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
-        // Retrieves file splits of the dataset.
-        MetadataProvider metadataProvider = new MetadataProvider(null);
-        metadataProvider.setMetadataTxnContext(mdTxnCtx);
-        Dataset dataset = metadataProvider.findDataset(dataverseName, datasetName);
-        ARecordType recordType = (ARecordType) metadataProvider.findType(dataset.getItemTypeDataverseName(),
-                dataset.getItemTypeName());
-        // Metadata transaction commits.
-        MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
-        return recordType;
-    }
-}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/60e7f12b/asterixdb/asterix-app/src/test/java/org/apache/asterix/api/http/servlet/ConnectorApiLetTest.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/api/http/servlet/ConnectorApiLetTest.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/api/http/servlet/ConnectorApiLetTest.java
new file mode 100644
index 0000000..b1fdab5
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/api/http/servlet/ConnectorApiLetTest.java
@@ -0,0 +1,178 @@
+/*
+ * 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.asterix.api.http.servlet;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintWriter;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.asterix.api.http.server.ConnectorApiServlet;
+import org.apache.asterix.metadata.MetadataManager;
+import org.apache.asterix.metadata.MetadataTransactionContext;
+import org.apache.asterix.metadata.declared.MetadataProvider;
+import org.apache.asterix.metadata.entities.Dataset;
+import org.apache.asterix.om.types.ARecordType;
+import org.apache.asterix.om.types.BuiltinType;
+import org.apache.asterix.om.types.IAType;
+import org.apache.asterix.om.util.JSONDeserializerForTypes;
+import org.apache.asterix.test.runtime.SqlppExecutionTest;
+import org.apache.hyracks.api.client.IHyracksClientConnection;
+import org.apache.hyracks.api.client.NodeControllerInfo;
+import org.apache.hyracks.api.comm.NetworkAddress;
+import org.apache.hyracks.api.io.FileSplit;
+import org.apache.hyracks.api.io.ManagedFileSplit;
+import org.apache.hyracks.http.server.IServletRequest;
+import org.apache.hyracks.http.server.IServletResponse;
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+import io.netty.handler.codec.http.FullHttpRequest;
+import io.netty.handler.codec.http.HttpMethod;
+import junit.extensions.PA;
+
+public class ConnectorApiLetTest {
+
+    @Test
+    public void testGet() throws Exception {
+        // Starts test asterixdb cluster.
+        SqlppExecutionTest.setUp();
+
+        // Configures a test connector api servlet.
+        ConnectorApiServlet let = new ConnectorApiServlet(new ConcurrentHashMap<>(), new String[] { "/" });
+        Map<String, NodeControllerInfo> nodeMap = new HashMap<>();
+        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+        PrintWriter outputWriter = new PrintWriter(outputStream);
+
+        // Creates mocks.
+        IHyracksClientConnection mockHcc = mock(IHyracksClientConnection.class);
+        NodeControllerInfo mockInfo1 = mock(NodeControllerInfo.class);
+        NodeControllerInfo mockInfo2 = mock(NodeControllerInfo.class);
+        IServletRequest mockRequest = mock(IServletRequest.class);
+        IServletResponse mockResponse = mock(IServletResponse.class);
+        FullHttpRequest mockHttpRequest = mock(FullHttpRequest.class);
+
+        // Put stuff in let map
+        let.ctx().put(ServletConstants.HYRACKS_CONNECTION_ATTR, mockHcc);
+        // Sets up mock returns.
+        when(mockRequest.getHttpRequest()).thenReturn(mockHttpRequest);
+        when(mockHttpRequest.method()).thenReturn(HttpMethod.GET);
+        when(mockRequest.getParameter("dataverseName")).thenReturn("Metadata");
+        when(mockRequest.getParameter("datasetName")).thenReturn("Dataset");
+        when(mockResponse.writer()).thenReturn(outputWriter);
+        when(mockHcc.getNodeControllerInfos()).thenReturn(nodeMap);
+        when(mockInfo1.getNetworkAddress()).thenReturn(new NetworkAddress("127.0.0.1", 3099));
+        when(mockInfo2.getNetworkAddress()).thenReturn(new NetworkAddress("127.0.0.2", 3099));
+
+        // Calls ConnectorAPIServlet.formResponseObject.
+        nodeMap.put("asterix_nc1", mockInfo1);
+        nodeMap.put("asterix_nc2", mockInfo2);
+        let.handle(mockRequest, mockResponse);
+
+        // Constructs the actual response.
+        ObjectMapper om = new ObjectMapper();
+        ObjectNode actualResponse = (ObjectNode) om.readTree(outputStream.toString());
+
+        // Checks the temp-or-not, primary key, data type of the dataset.
+        boolean temp = actualResponse.get("temp").asBoolean();
+        Assert.assertFalse(temp);
+        String primaryKey = actualResponse.get("keys").asText();
+        Assert.assertEquals("DataverseName,DatasetName", primaryKey);
+        ARecordType recordType = (ARecordType) JSONDeserializerForTypes
+                .convertFromJSON(actualResponse.get("type"));
+        Assert.assertEquals(getMetadataRecordType("Metadata", "Dataset"), recordType);
+
+        // Checks the correctness of results.
+        ArrayNode splits = (ArrayNode) actualResponse.get("splits");
+        String path = (splits.get(0)).get("path").asText();
+        Assert.assertTrue(path.endsWith("Metadata/Dataset_idx_Dataset"));
+
+        // Tears down the asterixdb cluster.
+        SqlppExecutionTest.tearDown();
+    }
+
+    @Test
+    public void testFormResponseObject() throws Exception {
+        ConnectorApiServlet let = new ConnectorApiServlet(new ConcurrentHashMap<>(), new String[] { "/" });
+        ObjectMapper om = new ObjectMapper();
+        ObjectNode actualResponse = om.createObjectNode();
+        FileSplit[] splits = new FileSplit[2];
+        splits[0] = new ManagedFileSplit("asterix_nc1", "foo1");
+        splits[1] = new ManagedFileSplit("asterix_nc2", "foo2");
+        Map<String, NodeControllerInfo> nodeMap = new HashMap<>();
+        NodeControllerInfo mockInfo1 = mock(NodeControllerInfo.class);
+        NodeControllerInfo mockInfo2 = mock(NodeControllerInfo.class);
+
+        // Sets up mock returns.
+        when(mockInfo1.getNetworkAddress()).thenReturn(new NetworkAddress("127.0.0.1", 3099));
+        when(mockInfo2.getNetworkAddress()).thenReturn(new NetworkAddress("127.0.0.2", 3099));
+
+        String[] fieldNames = new String[] { "a1", "a2" };
+        IAType[] fieldTypes = new IAType[] { BuiltinType.ABOOLEAN, BuiltinType.ADAYTIMEDURATION };
+        ARecordType recordType = new ARecordType("record", fieldNames, fieldTypes, true);
+        String primaryKey = "a1";
+
+        // Calls ConnectorAPIServlet.formResponseObject.
+        nodeMap.put("asterix_nc1", mockInfo1);
+        nodeMap.put("asterix_nc2", mockInfo2);
+        PA.invokeMethod(let, "formResponseObject(" + ObjectNode.class.getName() + ", " + FileSplit.class.getName()
+                + "[], " + ARecordType.class.getName() + ", " + String.class.getName() + ", boolean, " + Map.class
+                        .getName() + ")", actualResponse, splits, recordType, primaryKey, true, nodeMap);
+        // Constructs expected response.
+        ObjectNode expectedResponse = om.createObjectNode();
+        expectedResponse.put("temp", true);
+        expectedResponse.put("keys", primaryKey);
+        expectedResponse.set("type", recordType.toJSON());
+        ArrayNode splitsArray = om.createArrayNode();
+        ObjectNode element1 = om.createObjectNode();
+        element1.put("ip", "127.0.0.1");
+        element1.put("path", splits[0].getPath());
+        ObjectNode element2 = om.createObjectNode();
+        element2.put("ip", "127.0.0.2");
+        element2.put("path", splits[1].getPath());
+        splitsArray.add(element1);
+        splitsArray.add(element2);
+        expectedResponse.set("splits", splitsArray);
+
+        // Checks results.
+        Assert.assertEquals(actualResponse.toString(), expectedResponse.toString());
+    }
+
+    private ARecordType getMetadataRecordType(String dataverseName, String datasetName) throws Exception {
+        MetadataTransactionContext mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
+        // Retrieves file splits of the dataset.
+        MetadataProvider metadataProvider = new MetadataProvider(null);
+        metadataProvider.setMetadataTxnContext(mdTxnCtx);
+        Dataset dataset = metadataProvider.findDataset(dataverseName, datasetName);
+        ARecordType recordType = (ARecordType) metadataProvider.findType(dataset.getItemTypeDataverseName(),
+                dataset.getItemTypeName());
+        // Metadata transaction commits.
+        MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
+        return recordType;
+    }
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/60e7f12b/asterixdb/asterix-app/src/test/java/org/apache/asterix/api/http/servlet/QueryServiceLetTest.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/api/http/servlet/QueryServiceLetTest.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/api/http/servlet/QueryServiceLetTest.java
new file mode 100644
index 0000000..7b7c0d2
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/api/http/servlet/QueryServiceLetTest.java
@@ -0,0 +1,46 @@
+/*
+ * 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.asterix.api.http.servlet;
+
+import org.apache.asterix.api.http.server.QueryServiceServlet;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class QueryServiceLetTest {
+
+    @Test
+    public void testTimeUnitFormatNanos() throws Exception {
+        Assert.assertEquals("123.456789012s", QueryServiceServlet.TimeUnit.formatNanos(123456789012l));
+        Assert.assertEquals("12.345678901s", QueryServiceServlet.TimeUnit.formatNanos(12345678901l));
+        Assert.assertEquals("1.234567890s", QueryServiceServlet.TimeUnit.formatNanos(1234567890l));
+        Assert.assertEquals("123.456789ms", QueryServiceServlet.TimeUnit.formatNanos(123456789l));
+        Assert.assertEquals("12.345678ms", QueryServiceServlet.TimeUnit.formatNanos(12345678l));
+        Assert.assertEquals("1.234567ms", QueryServiceServlet.TimeUnit.formatNanos(1234567l));
+        Assert.assertEquals("123.456�s", QueryServiceServlet.TimeUnit.formatNanos(123456l));
+        Assert.assertEquals("12.345�s", QueryServiceServlet.TimeUnit.formatNanos(12345l));
+        Assert.assertEquals("1.234�s", QueryServiceServlet.TimeUnit.formatNanos(1234l));
+        Assert.assertEquals("123ns", QueryServiceServlet.TimeUnit.formatNanos(123l));
+        Assert.assertEquals("12ns", QueryServiceServlet.TimeUnit.formatNanos(12l));
+        Assert.assertEquals("1ns", QueryServiceServlet.TimeUnit.formatNanos(1l));
+        Assert.assertEquals("-123.456789012s", QueryServiceServlet.TimeUnit.formatNanos(-123456789012l));
+        Assert.assertEquals("120.000000000s", QueryServiceServlet.TimeUnit.formatNanos(120000000000l));
+        Assert.assertEquals("-12ns", QueryServiceServlet.TimeUnit.formatNanos(-12l));
+    }
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/60e7f12b/asterixdb/asterix-app/src/test/java/org/apache/asterix/api/http/servlet/QueryServiceServletTest.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/api/http/servlet/QueryServiceServletTest.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/api/http/servlet/QueryServiceServletTest.java
deleted file mode 100644
index f4889a0..0000000
--- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/api/http/servlet/QueryServiceServletTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.asterix.api.http.servlet;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class QueryServiceServletTest {
-
-    @Test
-    public void testTimeUnitFormatNanos() throws Exception {
-        Assert.assertEquals("123.456789012s", QueryServiceServlet.TimeUnit.formatNanos(123456789012l));
-        Assert.assertEquals("12.345678901s", QueryServiceServlet.TimeUnit.formatNanos(12345678901l));
-        Assert.assertEquals("1.234567890s", QueryServiceServlet.TimeUnit.formatNanos(1234567890l));
-        Assert.assertEquals("123.456789ms", QueryServiceServlet.TimeUnit.formatNanos(123456789l));
-        Assert.assertEquals("12.345678ms", QueryServiceServlet.TimeUnit.formatNanos(12345678l));
-        Assert.assertEquals("1.234567ms", QueryServiceServlet.TimeUnit.formatNanos(1234567l));
-        Assert.assertEquals("123.456�s", QueryServiceServlet.TimeUnit.formatNanos(123456l));
-        Assert.assertEquals("12.345�s", QueryServiceServlet.TimeUnit.formatNanos(12345l));
-        Assert.assertEquals("1.234�s", QueryServiceServlet.TimeUnit.formatNanos(1234l));
-        Assert.assertEquals("123ns", QueryServiceServlet.TimeUnit.formatNanos(123l));
-        Assert.assertEquals("12ns", QueryServiceServlet.TimeUnit.formatNanos(12l));
-        Assert.assertEquals("1ns", QueryServiceServlet.TimeUnit.formatNanos(1l));
-        Assert.assertEquals("-123.456789012s", QueryServiceServlet.TimeUnit.formatNanos(-123456789012l));
-        Assert.assertEquals("120.000000000s", QueryServiceServlet.TimeUnit.formatNanos(120000000000l));
-        Assert.assertEquals("-12ns", QueryServiceServlet.TimeUnit.formatNanos(-12l));
-    }
-}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/60e7f12b/asterixdb/asterix-app/src/test/java/org/apache/asterix/api/http/servlet/VersionAPIServletTest.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/api/http/servlet/VersionAPIServletTest.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/api/http/servlet/VersionAPIServletTest.java
deleted file mode 100644
index da0ec0c..0000000
--- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/api/http/servlet/VersionAPIServletTest.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * 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.asterix.api.http.servlet;
-
-import static org.apache.asterix.api.http.servlet.ServletConstants.ASTERIX_BUILD_PROP_ATTR;
-import static org.apache.asterix.api.http.servlet.ServletConstants.HYRACKS_CONNECTION_ATTR;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.InputStreamReader;
-import java.io.PrintWriter;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.apache.asterix.common.config.BuildProperties;
-import org.apache.asterix.runtime.util.AppContextInfo;
-import org.apache.asterix.test.runtime.SqlppExecutionTest;
-import org.apache.hyracks.api.client.IHyracksClientConnection;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class VersionAPIServletTest {
-
-    @Test
-    public void testGet() throws Exception {
-        // Starts test asterixdb cluster.
-        SqlppExecutionTest.setUp();
-
-        // Configures a test version api servlet.
-        VersionAPIServlet servlet = spy(new VersionAPIServlet());
-        ServletConfig mockServletConfig = mock(ServletConfig.class);
-        servlet.init(mockServletConfig);
-        Map<String, String> propMap = new HashMap<String, String>();
-        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
-        PrintWriter outputWriter = new PrintWriter(outputStream);
-
-        // Creates mocks.
-        ServletContext mockContext = mock(ServletContext.class);
-        AppContextInfo mockCtx = mock(AppContextInfo.class);
-        HttpServletRequest mockRequest = mock(HttpServletRequest.class);
-        IHyracksClientConnection mockHcc = mock(IHyracksClientConnection.class);
-        HttpServletResponse mockResponse = mock(HttpServletResponse.class);
-        BuildProperties mockProperties = mock(BuildProperties.class);
-
-        // Sets up mock returns.
-        when(servlet.getServletContext()).thenReturn(mockContext);
-        when(mockResponse.getWriter()).thenReturn(outputWriter);
-        when(mockContext.getAttribute(HYRACKS_CONNECTION_ATTR)).thenReturn(mockHcc);
-        when(mockContext.getAttribute(ASTERIX_BUILD_PROP_ATTR)).thenReturn(mockCtx);
-        when(mockCtx.getBuildProperties()).thenReturn(mockProperties);
-        when(mockProperties.getAllProps()).thenReturn(propMap);
-
-        propMap.put("git.build.user.email", "foo@bar.baz");
-        propMap.put("git.build.host", "fulliautomatix");
-        propMap.put("git.dirty", "true");
-        propMap.put("git.remote.origin.url", "git@github.com:apache/incubator-asterixdb.git");
-        propMap.put("git.closest.tag.name", "asterix-0.8.7-incubating");
-        propMap.put("git.commit.id.describe-short", "asterix-0.8.7-incubating-19-dirty");
-        propMap.put("git.commit.user.email", "foo@bar.baz");
-        propMap.put("git.commit.time", "21.10.2015 @ 23:36:41 PDT");
-        propMap.put("git.commit.message.full",
-                "ASTERIXDB-1045: fix log file reading during recovery\n\nChange-Id: Ic83ee1dd2d7ba88180c25f4ec6c7aa8d0a5a7162\nReviewed-on: https://asterix-gerrit.ics.uci.edu/465\nTested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>");
-        propMap.put("git.build.version", "0.8.8-SNAPSHOT");
-        propMap.put("git.commit.message.short", "ASTERIXDB-1045: fix log file reading during recovery");
-        propMap.put("git.commit.id.abbrev", "e1dad19");
-        propMap.put("git.branch", "foo/bar");
-        propMap.put("git.build.user.name", "Asterix");
-        propMap.put("git.closest.tag.commit.count", "19");
-        propMap.put("git.commit.id.describe", "asterix-0.8.7-incubating-19-ge1dad19-dirty");
-        propMap.put("git.commit.id", "e1dad1984640517366a7e73e323c9de27b0676f7");
-        propMap.put("git.tags", "");
-        propMap.put("git.build.time", "22.10.2015 @ 17:11:07 PDT");
-        propMap.put("git.commit.user.name", "Obelix");
-
-        // Calls VersionAPIServlet.formResponseObject.
-        servlet.doGet(mockRequest, mockResponse);
-
-        // Constructs the actual response.
-
-        ObjectMapper om = new ObjectMapper();
-        ObjectNode actualResponse = (ObjectNode) om.readTree(outputStream.toByteArray());
-        ObjectNode expectedResponse = om.createObjectNode();
-        for (Map.Entry<String, String> e : propMap.entrySet()) {
-            expectedResponse.put(e.getKey(), e.getValue());
-        }
-
-        // Checks the response contains all the expected keys.
-        Assert.assertEquals(actualResponse.toString(), expectedResponse.toString());
-
-        // Tears down the asterixdb cluster.
-        SqlppExecutionTest.tearDown();
-    }
-}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/60e7f12b/asterixdb/asterix-app/src/test/java/org/apache/asterix/api/http/servlet/VersionApiLetTest.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/api/http/servlet/VersionApiLetTest.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/api/http/servlet/VersionApiLetTest.java
new file mode 100644
index 0000000..936b717
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/api/http/servlet/VersionApiLetTest.java
@@ -0,0 +1,120 @@
+/*
+ * 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.asterix.api.http.servlet;
+
+import static org.apache.asterix.api.http.servlet.ServletConstants.ASTERIX_BUILD_PROP_ATTR;
+import static org.apache.asterix.api.http.servlet.ServletConstants.HYRACKS_CONNECTION_ATTR;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintWriter;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.asterix.api.http.server.VersionApiServlet;
+import org.apache.asterix.common.config.BuildProperties;
+import org.apache.asterix.runtime.util.AppContextInfo;
+import org.apache.asterix.test.runtime.SqlppExecutionTest;
+import org.apache.hyracks.api.client.IHyracksClientConnection;
+import org.apache.hyracks.http.server.IServletRequest;
+import org.apache.hyracks.http.server.IServletResponse;
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+import io.netty.handler.codec.http.FullHttpRequest;
+import io.netty.handler.codec.http.HttpMethod;
+
+public class VersionApiLetTest {
+
+    @Test
+    public void testGet() throws Exception {
+        // Starts test asterixdb cluster.
+        SqlppExecutionTest.setUp();
+
+        // Configures a test version api servlet.
+        VersionApiServlet servlet = new VersionApiServlet(new ConcurrentHashMap<>(), new String[] { "/" });
+        Map<String, String> propMap = new HashMap<>();
+        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+        PrintWriter outputWriter = new PrintWriter(outputStream);
+
+        // Creates mocks.
+        AppContextInfo mockCtx = mock(AppContextInfo.class);
+        IServletRequest mockRequest = mock(IServletRequest.class);
+        IHyracksClientConnection mockHcc = mock(IHyracksClientConnection.class);
+        IServletResponse mockResponse = mock(IServletResponse.class);
+        BuildProperties mockProperties = mock(BuildProperties.class);
+        FullHttpRequest mockHttpRequest = mock(FullHttpRequest.class);
+
+        // Put stuff in let map
+        servlet.ctx().put(HYRACKS_CONNECTION_ATTR, mockHcc);
+        servlet.ctx().put(ASTERIX_BUILD_PROP_ATTR, mockCtx);
+        // Sets up mock returns.
+        when(mockResponse.writer()).thenReturn(outputWriter);
+        when(mockRequest.getHttpRequest()).thenReturn(mockHttpRequest);
+        when(mockHttpRequest.method()).thenReturn(HttpMethod.GET);
+        when(mockCtx.getBuildProperties()).thenReturn(mockProperties);
+        when(mockProperties.getAllProps()).thenReturn(propMap);
+
+        propMap.put("git.build.user.email", "foo@bar.baz");
+        propMap.put("git.build.host", "fulliautomatix");
+        propMap.put("git.dirty", "true");
+        propMap.put("git.remote.origin.url", "git@github.com:apache/incubator-asterixdb.git");
+        propMap.put("git.closest.tag.name", "asterix-0.8.7-incubating");
+        propMap.put("git.commit.id.describe-short", "asterix-0.8.7-incubating-19-dirty");
+        propMap.put("git.commit.user.email", "foo@bar.baz");
+        propMap.put("git.commit.time", "21.10.2015 @ 23:36:41 PDT");
+        propMap.put("git.commit.message.full",
+                "ASTERIXDB-1045: fix log file reading during recovery\n\nChange-Id: Ic83ee1dd2d7ba88180c25f4ec6c7aa8d0a5a7162\nReviewed-on: https://asterix-gerrit.ics.uci.edu/465\nTested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>");
+        propMap.put("git.build.version", "0.8.8-SNAPSHOT");
+        propMap.put("git.commit.message.short", "ASTERIXDB-1045: fix log file reading during recovery");
+        propMap.put("git.commit.id.abbrev", "e1dad19");
+        propMap.put("git.branch", "foo/bar");
+        propMap.put("git.build.user.name", "Asterix");
+        propMap.put("git.closest.tag.commit.count", "19");
+        propMap.put("git.commit.id.describe", "asterix-0.8.7-incubating-19-ge1dad19-dirty");
+        propMap.put("git.commit.id", "e1dad1984640517366a7e73e323c9de27b0676f7");
+        propMap.put("git.tags", "");
+        propMap.put("git.build.time", "22.10.2015 @ 17:11:07 PDT");
+        propMap.put("git.commit.user.name", "Obelix");
+
+        // Calls VersionAPIServlet.formResponseObject.
+        servlet.handle(mockRequest, mockResponse);
+
+        // Constructs the actual response.
+
+        ObjectMapper om = new ObjectMapper();
+        ObjectNode actualResponse = (ObjectNode) om.readTree(outputStream.toByteArray());
+        ObjectNode expectedResponse = om.createObjectNode();
+        for (Map.Entry<String, String> e : propMap.entrySet()) {
+            expectedResponse.put(e.getKey(), e.getValue());
+        }
+
+        // Checks the response contains all the expected keys.
+        Assert.assertEquals(actualResponse.toString(), expectedResponse.toString());
+
+        // Tears down the asterixdb cluster.
+        SqlppExecutionTest.tearDown();
+    }
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/60e7f12b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/LetUtil.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/LetUtil.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/LetUtil.java
new file mode 100644
index 0000000..2fe9380
--- /dev/null
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/LetUtil.java
@@ -0,0 +1,58 @@
+/*
+ * 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.asterix.common.utils;
+
+public class LetUtil {
+
+    public enum Lets {
+        AQL("/aql"),
+        AQL_QUERY("/query"),
+        AQL_UPDATE("/update"),
+        AQL_DDL("/ddl"),
+        SQLPP("/sqlpp"),
+        SQLPP_QUERY("/query/sqlpp"),
+        SQLPP_UPDATE("/update/sqlpp"),
+        SQLPP_DDL("/ddl/sqlpp"),
+        QUERY_STATUS("/query/status"),
+        QUERY_RESULT("/query/result"),
+        QUERY_SERVICE("/query/service"),
+        CONNECTOR("/connector"),
+        SHUTDOWN("/admin/shutdown"),
+        VERSION("/admin/version"),
+        CLUSTER_STATE("/admin/cluster/*"),
+        CLUSTER_STATE_NODE_DETAIL("/admin/cluster/node/*"),
+        CLUSTER_STATE_CC_DETAIL("/admin/cluster/cc/*"),
+        DIAGNOSTICS("/admin/diagnostics");
+
+        private final String path;
+
+        Lets(String path) {
+            this.path = path;
+        }
+
+        public String getPath() {
+            return path;
+        }
+
+    }
+
+    private LetUtil() {
+        throw new AssertionError("No objects of this class should be created.");
+    }
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/60e7f12b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/ServletUtil.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/ServletUtil.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/ServletUtil.java
deleted file mode 100644
index f0b124d..0000000
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/ServletUtil.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.asterix.common.utils;
-
-public class ServletUtil {
-
-    public enum Servlets {
-        AQL("/aql"),
-        AQL_QUERY("/query"),
-        AQL_UPDATE("/update"),
-        AQL_DDL("/ddl"),
-        SQLPP("/sqlpp"),
-        SQLPP_QUERY("/query/sqlpp"),
-        SQLPP_UPDATE("/update/sqlpp"),
-        SQLPP_DDL("/ddl/sqlpp"),
-        QUERY_STATUS("/query/status"),
-        QUERY_RESULT("/query/result"),
-        QUERY_SERVICE("/query/service"),
-        CONNECTOR("/connector"),
-        SHUTDOWN("/admin/shutdown"),
-        VERSION("/admin/version"),
-        CLUSTER_STATE("/admin/cluster/*"),
-        CLUSTER_STATE_NODE_DETAIL("/admin/cluster/node/*"),
-        CLUSTER_STATE_CC_DETAIL("/admin/cluster/cc/*"),
-        DIAGNOSTICS("/admin/diagnostics");
-
-        private final String path;
-
-        Servlets(String path) {
-            this.path = path;
-        }
-
-        public String getPath() {
-            return path;
-        }
-
-    }
-
-    private ServletUtil() {
-        throw new AssertionError("No objects of this class should be created.");
-    }
-}