Search in sources :

Example 1 with HttpServer

use of org.apache.hyracks.http.server.HttpServer in project asterixdb by apache.

the class CCApplication method setupQueryWebServer.

protected HttpServer setupQueryWebServer(ExternalProperties externalProperties) throws Exception {
    HttpServer queryWebServer = new HttpServer(webManager.getBosses(), webManager.getWorkers(), externalProperties.getQueryWebInterfacePort());
    IHyracksClientConnection hcc = getHcc();
    queryWebServer.setAttribute(HYRACKS_CONNECTION_ATTR, hcc);
    queryWebServer.addServlet(new QueryWebInterfaceServlet(appCtx, queryWebServer.ctx(), new String[] { "/*" }));
    return queryWebServer;
}
Also used : IHyracksClientConnection(org.apache.hyracks.api.client.IHyracksClientConnection) QueryWebInterfaceServlet(org.apache.asterix.api.http.server.QueryWebInterfaceServlet) HttpServer(org.apache.hyracks.http.server.HttpServer)

Example 2 with HttpServer

use of org.apache.hyracks.http.server.HttpServer in project asterixdb by apache.

the class CCApplication method setupWebServer.

protected HttpServer setupWebServer(ExternalProperties externalProperties) throws Exception {
    HttpServer webServer = new HttpServer(webManager.getBosses(), webManager.getWorkers(), externalProperties.getWebInterfacePort());
    IHyracksClientConnection hcc = getHcc();
    webServer.setAttribute(HYRACKS_CONNECTION_ATTR, hcc);
    webServer.addServlet(new ApiServlet(webServer.ctx(), new String[] { "/*" }, appCtx, ccExtensionManager.getCompilationProvider(AQL), ccExtensionManager.getCompilationProvider(SQLPP), getStatementExecutorFactory(), componentProvider));
    return webServer;
}
Also used : IHyracksClientConnection(org.apache.hyracks.api.client.IHyracksClientConnection) ShutdownApiServlet(org.apache.asterix.api.http.server.ShutdownApiServlet) VersionApiServlet(org.apache.asterix.api.http.server.VersionApiServlet) QueryResultApiServlet(org.apache.asterix.api.http.server.QueryResultApiServlet) UpdateApiServlet(org.apache.asterix.api.http.server.UpdateApiServlet) RebalanceApiServlet(org.apache.asterix.api.http.server.RebalanceApiServlet) QueryStatusApiServlet(org.apache.asterix.api.http.server.QueryStatusApiServlet) ClusterApiServlet(org.apache.asterix.api.http.server.ClusterApiServlet) ApiServlet(org.apache.asterix.api.http.server.ApiServlet) FullApiServlet(org.apache.asterix.api.http.server.FullApiServlet) QueryApiServlet(org.apache.asterix.api.http.server.QueryApiServlet) NodeControllerDetailsApiServlet(org.apache.asterix.api.http.server.NodeControllerDetailsApiServlet) ConnectorApiServlet(org.apache.asterix.api.http.server.ConnectorApiServlet) DdlApiServlet(org.apache.asterix.api.http.server.DdlApiServlet) ClusterControllerDetailsApiServlet(org.apache.asterix.api.http.server.ClusterControllerDetailsApiServlet) DiagnosticsApiServlet(org.apache.asterix.api.http.server.DiagnosticsApiServlet) HttpServer(org.apache.hyracks.http.server.HttpServer)

Example 3 with HttpServer

use of org.apache.hyracks.http.server.HttpServer in project asterixdb by apache.

the class HttpServerTest method testOverloadingServer.

@Test
public void testOverloadingServer() throws Exception {
    WebManager webMgr = new WebManager();
    HttpServer server = new HttpServer(webMgr.getBosses(), webMgr.getWorkers(), PORT, NUM_EXECUTOR_THREADS, SERVER_QUEUE_SIZE);
    SlowServlet servlet = new SlowServlet(server.ctx(), new String[] { PATH });
    server.addServlet(servlet);
    webMgr.add(server);
    webMgr.start();
    try {
        request(NUM_OF_REQUESTS);
        for (Thread thread : THREADS) {
            thread.join();
        }
        Assert.assertEquals(32, SUCCESS_COUNT.get());
        Assert.assertEquals(16, UNAVAILABLE_COUNT.get());
        Assert.assertEquals(0, OTHER_COUNT.get());
    } finally {
        webMgr.stop();
    }
}
Also used : SlowServlet(org.apache.hyracks.http.servlet.SlowServlet) WebManager(org.apache.hyracks.http.server.WebManager) HttpServer(org.apache.hyracks.http.server.HttpServer) Test(org.junit.Test)

Example 4 with HttpServer

use of org.apache.hyracks.http.server.HttpServer in project asterixdb by apache.

the class HttpServerTest method testMalformedString.

@Test
public void testMalformedString() throws Exception {
    WebManager webMgr = new WebManager();
    HttpServer server = new HttpServer(webMgr.getBosses(), webMgr.getWorkers(), PORT, NUM_EXECUTOR_THREADS, SERVER_QUEUE_SIZE);
    SlowServlet servlet = new SlowServlet(server.ctx(), new String[] { PATH });
    server.addServlet(servlet);
    webMgr.add(server);
    webMgr.start();
    try {
        StringBuilder response = new StringBuilder();
        try (Socket s = new Socket(InetAddress.getLocalHost(), PORT)) {
            PrintWriter pw = new PrintWriter(s.getOutputStream());
            pw.println("GET /?handle=%7B%22handle%22%3A%5B0%2C%200%5D%7 HTTP/1.1");
            pw.println("Host: 127.0.0.1");
            pw.println();
            pw.flush();
            BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream()));
            String line;
            while ((line = br.readLine()) != null) {
                response.append(line).append('\n');
            }
            br.close();
        }
        String output = response.toString();
        Assert.assertTrue(output.contains(HttpResponseStatus.BAD_REQUEST.toString()));
    } catch (Exception e) {
        e.printStackTrace();
        throw e;
    } finally {
        webMgr.stop();
    }
}
Also used : SlowServlet(org.apache.hyracks.http.servlet.SlowServlet) WebManager(org.apache.hyracks.http.server.WebManager) InputStreamReader(java.io.InputStreamReader) HttpServer(org.apache.hyracks.http.server.HttpServer) BufferedReader(java.io.BufferedReader) Socket(java.net.Socket) URISyntaxException(java.net.URISyntaxException) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Example 5 with HttpServer

use of org.apache.hyracks.http.server.HttpServer in project asterixdb by apache.

the class CCApplication method setupJSONAPIServer.

protected HttpServer setupJSONAPIServer(ExternalProperties externalProperties) throws Exception {
    HttpServer jsonAPIServer = new HttpServer(webManager.getBosses(), webManager.getWorkers(), externalProperties.getAPIServerPort());
    IHyracksClientConnection hcc = getHcc();
    jsonAPIServer.setAttribute(HYRACKS_CONNECTION_ATTR, hcc);
    jsonAPIServer.setAttribute(ASTERIX_APP_CONTEXT_INFO_ATTR, appCtx);
    jsonAPIServer.setAttribute(ServletConstants.EXECUTOR_SERVICE_ATTR, ccServiceCtx.getControllerService().getExecutor());
    jsonAPIServer.setAttribute(ServletConstants.RUNNING_QUERIES_ATTR, statementExecutorCtx);
    jsonAPIServer.setAttribute(ServletConstants.SERVICE_CONTEXT_ATTR, ccServiceCtx);
    // AQL rest APIs.
    addServlet(jsonAPIServer, Servlets.AQL_QUERY);
    addServlet(jsonAPIServer, Servlets.AQL_UPDATE);
    addServlet(jsonAPIServer, Servlets.AQL_DDL);
    addServlet(jsonAPIServer, Servlets.AQL);
    // SQL+x+ rest APIs.
    addServlet(jsonAPIServer, Servlets.SQLPP_QUERY);
    addServlet(jsonAPIServer, Servlets.SQLPP_UPDATE);
    addServlet(jsonAPIServer, Servlets.SQLPP_DDL);
    addServlet(jsonAPIServer, Servlets.SQLPP);
    // Other APIs.
    addServlet(jsonAPIServer, Servlets.QUERY_STATUS);
    addServlet(jsonAPIServer, Servlets.QUERY_RESULT);
    addServlet(jsonAPIServer, Servlets.QUERY_SERVICE);
    addServlet(jsonAPIServer, Servlets.QUERY_AQL);
    addServlet(jsonAPIServer, Servlets.RUNNING_REQUESTS);
    addServlet(jsonAPIServer, Servlets.CONNECTOR);
    addServlet(jsonAPIServer, Servlets.SHUTDOWN);
    addServlet(jsonAPIServer, Servlets.VERSION);
    addServlet(jsonAPIServer, Servlets.CLUSTER_STATE);
    addServlet(jsonAPIServer, Servlets.REBALANCE);
    // must not precede add of CLUSTER_STATE
    addServlet(jsonAPIServer, Servlets.CLUSTER_STATE_NODE_DETAIL);
    // must not precede add of CLUSTER_STATE
    addServlet(jsonAPIServer, Servlets.CLUSTER_STATE_CC_DETAIL);
    addServlet(jsonAPIServer, Servlets.DIAGNOSTICS);
    return jsonAPIServer;
}
Also used : IHyracksClientConnection(org.apache.hyracks.api.client.IHyracksClientConnection) HttpServer(org.apache.hyracks.http.server.HttpServer)

Aggregations

HttpServer (org.apache.hyracks.http.server.HttpServer)5 IHyracksClientConnection (org.apache.hyracks.api.client.IHyracksClientConnection)3 WebManager (org.apache.hyracks.http.server.WebManager)2 SlowServlet (org.apache.hyracks.http.servlet.SlowServlet)2 Test (org.junit.Test)2 BufferedReader (java.io.BufferedReader)1 InputStreamReader (java.io.InputStreamReader)1 PrintWriter (java.io.PrintWriter)1 Socket (java.net.Socket)1 URISyntaxException (java.net.URISyntaxException)1 ApiServlet (org.apache.asterix.api.http.server.ApiServlet)1 ClusterApiServlet (org.apache.asterix.api.http.server.ClusterApiServlet)1 ClusterControllerDetailsApiServlet (org.apache.asterix.api.http.server.ClusterControllerDetailsApiServlet)1 ConnectorApiServlet (org.apache.asterix.api.http.server.ConnectorApiServlet)1 DdlApiServlet (org.apache.asterix.api.http.server.DdlApiServlet)1 DiagnosticsApiServlet (org.apache.asterix.api.http.server.DiagnosticsApiServlet)1 FullApiServlet (org.apache.asterix.api.http.server.FullApiServlet)1 NodeControllerDetailsApiServlet (org.apache.asterix.api.http.server.NodeControllerDetailsApiServlet)1 QueryApiServlet (org.apache.asterix.api.http.server.QueryApiServlet)1 QueryResultApiServlet (org.apache.asterix.api.http.server.QueryResultApiServlet)1