@Override public String toString() { return "DataStoreServerConfig{" + "websocketWorkerCount=" + websocketWorkerCount() + ", dataStoreDrainerCount=" + dataStoreDrainerCount() + ", websocketURI='" + websocketURI() + '\'' + ", restURI='" + restURI() + '\'' + ", httpCompression=" + httpCompression() + ", maxFrameSize=" + maxFrameSize() + ", batchResultSize=" + batchResultSize() + ", port=" + port() + ", startupMode=" + startupMode() + ", debug=" + debug() + ", adminPort=" + adminPort() + ", adminName=" + adminName() + ", replicationDataStoreConfig=" + replicationDataStoreConfig() + '}'; }
public static DataStoreServerConfig config() { return new DataStoreServerConfig(); }
@Override public String toString() { return "DataStoreServerConfig{" + "websocketWorkerCount=" + websocketWorkerCount() + ", dataStoreDrainerCount=" + dataStoreDrainerCount() + ", websocketURI='" + websocketURI() + '\'' + ", restURI='" + restURI() + '\'' + ", httpCompression=" + httpCompression() + ", maxFrameSize=" + maxFrameSize() + ", batchResultSize=" + batchResultSize() + ", port=" + port() + ", startupMode=" + startupMode() + ", debug=" + debug() + '}'; }
public AdminFile(DataStoreServerConfig dataStoreServerConfig, Path path) { serverport = "" + dataStoreServerConfig.port(); adminPort = "" + dataStoreServerConfig.adminPort(); adminName = dataStoreServerConfig.adminName(); this.absoluteFileName = path.toAbsolutePath().toString(); String fileName = path.getFileName().toString(); if (fileName.contains("index.html")) { file = "/admin"; } else { int at = fileName.lastIndexOf(".html"); // finding the extension file = "/admin/" + fileName.substring(0, at); } }
Action.NONE, "CONFIG websocketWorkerCount", config.websocketWorkerCount()); queue.put(statCount); Action.NONE, "CONFIG dataStoreDrainerCount", config.dataStoreDrainerCount()); queue.put(statCount); Action.NONE, "CONFIG broadcastInterval", config.broadcastInterval()); queue.put(statCount); Action.NONE, "CONFIG broadcastInterval", config.broadcastInterval()); queue.put(statCount); Action.NONE, "CONFIG maxFrameSize", config.maxFrameSize()); queue.put(statCount); Action.NONE, "CONFIG port", config.port()); queue.put(statCount);
private void configureAndStartHttpServer(Map<String, ClassMeta<?>> servicesDefinition) { HttpServer server = vertx.createHttpServer(); server.setTCPKeepAlive(true); server.setTCPNoDelay(true); server.setSoLinger(0); server.setCompressionSupported(config.httpCompression()); if (config.maxFrameSize() == -1) { server.setMaxWebSocketFrameSize(MAX_MESSAGE_SIZE); maxMessageSize = MAX_MESSAGE_SIZE; } else { server.setMaxWebSocketFrameSize(config.maxFrameSize()); maxMessageSize = config.maxFrameSize(); } if (debug) { logger.info("DataStoreServer::configureAndStartHttpServer()", config); } server.websocketHandler(websocketHandler()) .requestHandler(clientRequestHandler()) .listen(config.port()); HttpServer admin = vertx.createHttpServer(); admin.setTCPKeepAlive(true); admin.setTCPNoDelay(true); admin.setSoLinger(0); admin.setCompressionSupported(config.httpCompression()); admin.requestHandler(adminRouteMatchers(servicesDefinition)); admin.listen(config.adminPort()); puts("Admin port on", config.adminPort()); }
public void start() { logger.info("Data Store Service Starting"); try { config = DataStoreServerConfig.load(); dataStoreServer.init(config); JsonObject configOverrides = container.config(); if (configOverrides.containsField("port")) { config.port(configOverrides.getInteger("port")); } puts("SERVER CONFIG", config.port()); configureAndStartHttpServer(dataStoreServer.getServicesDefinition()); } catch (Throwable ex) { logger.error(ex, "Data Store Service Starting FAILED"); } }
private Handler<HttpServerRequest> clientRequestHandler() { final String restURI = config.restURI(); return new Handler<HttpServerRequest>() { @Override public void handle(final HttpServerRequest request) { handleRESTCall(restURI, request); } }; }
private Handler<ServerWebSocket> websocketHandler() { final String websocketURI = config.websocketURI(); return new Handler<ServerWebSocket>() { public void handle(final ServerWebSocket ws) {
private void handleBatchRead(DataStoreRequest request) { try { ReadBatchRequest batchRequest = (ReadBatchRequest) request; int chunkSize = config.batchResultSize() * 2; List<String> keysToFetch = new ArrayList<>(); for (String key : batchRequest.keys()) { keysToFetch.add(key); if (keysToFetch.size() > chunkSize) { masterDataStore.batchRead( new ReadBatchRequest(batchRequest, new ArrayList<>(keysToFetch))); keysToFetch.clear(); } } if (keysToFetch.size() > 0) { masterDataStore.batchRead( new ReadBatchRequest(batchRequest, new ArrayList<>(keysToFetch))); } } catch (Exception ex) { logger.error(ex, "Unable to handle bulk send", request.clientId(), request.payload()); } }
private void sendMapInBatches(BatchResult batchResult) { int batchResultSize = config.batchResultSize(); final String clientId = batchResult.clientId(); final Map<String, String> results = batchResult.getResults(); if (debug) logger.info("ResponseHandler::sendMapInBatches()", clientId, results.size()); if (results.size() <= batchResultSize) { sendBatchResponse(batchResult); } else { LazyMap map = new LazyMap(results.size() > batchResultSize ? batchResultSize : results.size(), true); final Set<String> keys = results.keySet(); for (String key : keys) { map.put(key, results.get(key)); if (map.size() >= batchResultSize) { sendBatchResponse(new BatchResult(batchResult, map.clearAndCopy())); } } if (map.size() > 0) { sendBatchResponse(new BatchResult(batchResult, map.clearAndCopy())); } } }
public static DataStoreServerConfig config() { return new DataStoreServerConfig(); }
public static DataStoreServerConfig load() { if (IO.exists(FILE_LOCATION)) { return new JsonParserFactory().create().parseFile(DataStoreServerConfig.class, FILE_LOCATION); } else { return new DataStoreServerConfig(); } }