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;
}
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;
}
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();
}
}
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();
}
}
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;
}
Aggregations