@Override public ExternalProperties newExternalProperties() { return new ExternalProperties(propertiesAccessor); }
@Override protected void post(IServletRequest request, IServletResponse response) throws IOException { HttpUtil.setContentType(response, HttpUtil.ContentType.APPLICATION_JSON, HttpUtil.Encoding.UTF8); ExternalProperties externalProperties = appCtx.getExternalProperties(); response.setStatus(HttpResponseStatus.OK); ObjectNode obj = OBJECT_MAPPER.createObjectNode(); try { PrintWriter out = response.writer(); obj.put("api_port", String.valueOf(externalProperties.getAPIServerPort())); out.println(obj.toString()); return; } catch (Exception e) { LOGGER.log(Level.ERROR, "Failure writing response", e); } try { response.setStatus(HttpResponseStatus.INTERNAL_SERVER_ERROR); } catch (Exception e) { LOGGER.log(Level.ERROR, "Failure setting response status", e); } } }
protected HttpServer setupQueryWebServer(ExternalProperties externalProperties) throws Exception { final HttpServerConfig config = HttpServerConfigBuilder.custom().setMaxRequestSize(externalProperties.getMaxWebRequestSize()).build(); HttpServer queryWebServer = new HttpServer(webManager.getBosses(), webManager.getWorkers(), externalProperties.getQueryWebInterfacePort(), config); queryWebServer.setAttribute(HYRACKS_CONNECTION_ATTR, hcc); ServiceLoader.load(IQueryWebServerRegistrant.class).iterator() .forEachRemaining(c -> c.register(appCtx, queryWebServer)); return queryWebServer; }
protected void configureServers() throws Exception { final ExternalProperties externalProperties = getApplicationContext().getExternalProperties(); final HttpServerConfig config = HttpServerConfigBuilder.custom().setMaxRequestSize(externalProperties.getMaxWebRequestSize()).build(); HttpServer apiServer = new HttpServer(webManager.getBosses(), webManager.getWorkers(), externalProperties.getNcApiPort(), config); apiServer.setAttribute(ServletConstants.SERVICE_CONTEXT_ATTR, ncServiceCtx); apiServer.addServlet(new StorageApiServlet(apiServer.ctx(), getApplicationContext(), Servlets.STORAGE)); apiServer.addServlet( new NetDiagnosticsApiServlet(apiServer.ctx(), getApplicationContext(), Servlets.NET_DIAGNOSTICS)); webManager.add(apiServer); }
@BeforeClass public static void setUp() throws Exception { LangExecutionUtil.setUp(TEST_CONFIG_FILE_NAME, testExecutor); final NodeControllerService[] ncs = ExecutionTestUtil.integrationUtil.ncs; final Map<String, InetSocketAddress> ncEndPoints = new HashMap<>(); final String ip = InetAddress.getLoopbackAddress().getHostAddress(); for (NodeControllerService nc : ncs) { final String nodeId = nc.getId(); final INcApplicationContext appCtx = (INcApplicationContext) nc.getApplicationContext(); int apiPort = appCtx.getExternalProperties().getNcApiPort(); ncEndPoints.put(nodeId, InetSocketAddress.createUnresolved(ip, apiPort)); } testExecutor.setNcEndPoints(ncEndPoints); }
protected HttpServer setupJSONAPIServer(ExternalProperties externalProperties) throws Exception { final HttpServerConfig config = HttpServerConfigBuilder.custom().setMaxRequestSize(externalProperties.getMaxWebRequestSize()).build(); HttpServer jsonAPIServer = new HttpServer(webManager.getBosses(), webManager.getWorkers(), externalProperties.getAPIServerPort(), config); 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); // 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); addServlet(jsonAPIServer, Servlets.CLUSTER_STATE_NODE_DETAIL); // must not precede add of CLUSTER_STATE addServlet(jsonAPIServer, Servlets.CLUSTER_STATE_CC_DETAIL); // must not precede add of CLUSTER_STATE addServlet(jsonAPIServer, Servlets.DIAGNOSTICS); addServlet(jsonAPIServer, Servlets.ACTIVE_STATS); return jsonAPIServer; }
protected HttpServer setupWebServer(ExternalProperties externalProperties) throws Exception { final HttpServerConfig config = HttpServerConfigBuilder.custom().setMaxRequestSize(externalProperties.getMaxWebRequestSize()).build(); HttpServer webServer = new HttpServer(webManager.getBosses(), webManager.getWorkers(), externalProperties.getWebInterfacePort(), config); 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; }
if (!(clusterStateManager.getState().equals(ClusterState.ACTIVE) && globalRecoveryManager.isRecoveryCompleted())) { int maxWaitCycles = appCtx.getExternalProperties().getMaxWaitClusterActive(); try { clusterStateManager.waitForState(ClusterState.ACTIVE, maxWaitCycles, TimeUnit.SECONDS); int maxWaitCycles = appCtx.getExternalProperties().getMaxWaitClusterActive(); int waitCycleCount = 0; try {
@Before public void before() throws Exception { TestUtils.redirectLoggingToConsole(); LangExecutionUtil.setUp(TEST_CONFIG_FILE_NAME, testExecutor); if (!configured) { final NodeControllerService[] ncs = ExecutionTestUtil.integrationUtil.ncs; Map<String, InetSocketAddress> ncEndPoints = new HashMap<>(); Map<String, InetSocketAddress> replicationAddress = new HashMap<>(); final String ip = InetAddress.getLoopbackAddress().getHostAddress(); for (NodeControllerService nc : ncs) { final String nodeId = nc.getId(); final INcApplicationContext appCtx = (INcApplicationContext) nc.getApplicationContext(); int apiPort = appCtx.getExternalProperties().getNcApiPort(); int replicationPort = (int) appCtx.getServiceContext().getAppConfig().get(NCConfig.Option.REPLICATION_LISTEN_PORT); ncEndPoints.put(nodeId, InetSocketAddress.createUnresolved(ip, apiPort)); replicationAddress.put(nodeId, InetSocketAddress.createUnresolved(ip, replicationPort)); } testExecutor.setNcEndPoints(ncEndPoints); testExecutor.setNcReplicationAddress(replicationAddress); configured = true; } }
@Before public void before() throws Exception { LangExecutionUtil.setUp(TEST_CONFIG_FILE_NAME, testExecutor); if (!configured) { final NodeControllerService[] ncs = ExecutionTestUtil.integrationUtil.ncs; Map<String, InetSocketAddress> ncEndPoints = new HashMap<>(); Map<String, InetSocketAddress> replicationAddress = new HashMap<>(); final String ip = InetAddress.getLoopbackAddress().getHostAddress(); for (NodeControllerService nc : ncs) { final String nodeId = nc.getId(); final INcApplicationContext appCtx = (INcApplicationContext) nc.getApplicationContext(); int apiPort = appCtx.getExternalProperties().getNcApiPort(); int replicationPort = (int) appCtx.getServiceContext().getAppConfig().get(NCConfig.Option.REPLICATION_LISTEN_PORT); ncEndPoints.put(nodeId, InetSocketAddress.createUnresolved(ip, apiPort)); replicationAddress.put(nodeId, InetSocketAddress.createUnresolved(ip, replicationPort)); } testExecutor.setNcEndPoints(ncEndPoints); testExecutor.setNcReplicationAddress(replicationAddress); configured = true; } }
externalProperties = new ExternalProperties(propertiesAccessor); metadataProperties = new MetadataProperties(propertiesAccessor); storageProperties = new StorageProperties(propertiesAccessor);