private ServiceConfiguration buildStormServiceConfiguration(Config config) { ServiceConfiguration storm = new ServiceConfiguration(); storm.setName(CONF_STORM); Map<String, String> confMap = new HashMap<>(); if (config.contains(PARAM_NIMBUS_THRIFT_MAX_BUFFER_SIZE)) { Number thriftMaxBufferSize = readNumberFromConfig(config, PARAM_NIMBUS_THRIFT_MAX_BUFFER_SIZE); confMap.put(PARAM_NIMBUS_THRIFT_MAX_BUFFER_SIZE, String.valueOf(thriftMaxBufferSize)); } if (config.contains(PARAM_THRIFT_TRANSPORT)) { confMap.put(PARAM_THRIFT_TRANSPORT, config.getString(PARAM_THRIFT_TRANSPORT)); } if (config.contains(PARAM_PRINCIPAL_TO_LOCAL)) { confMap.put(PARAM_PRINCIPAL_TO_LOCAL, config.getString(PARAM_PRINCIPAL_TO_LOCAL)); } try { String json = objectMapper.writeValueAsString(confMap); storm.setConfiguration(json); } catch (JsonProcessingException e) { throw new RuntimeException(e); } return storm; }
private ServiceConfiguration buildServerPropertiesServiceConfiguration(Config config) { ServiceConfiguration serverProperties = new ServiceConfiguration(); serverProperties.setName(CONFIG_SERVER_PROPERTIES); Map<String, String> confMap = new HashMap<>(); if (config.contains(PARAM_ZOOKEEPER_CONNECT)) { confMap.put(PARAM_ZOOKEEPER_CONNECT, config.getString(PARAM_ZOOKEEPER_CONNECT)); } if (config.contains(PARAM_SECURITY_INTER_BROKER_PROTOCOL)) { confMap.put(PARAM_SECURITY_INTER_BROKER_PROTOCOL, config.getString(PARAM_SECURITY_INTER_BROKER_PROTOCOL)); } try { String json = objectMapper.writeValueAsString(confMap); serverProperties.setConfiguration(json); } catch (JsonProcessingException e) { throw new RuntimeException(e); } return serverProperties; }
private ServiceConfiguration buildCommonRuntimeServiceConfiguration(Config config) { ServiceConfiguration commonRuntime = new ServiceConfiguration(); commonRuntime.setName(Constants.Druid.CONF_TYPE_COMMON_RUNTIME); Map<String, String> confMap = new HashMap<>(); if (config.contains(PARAM_ZOOKEEPER_CONNECTION_STRING)) { confMap.put(PARAM_ZOOKEEPER_CONNECTION_STRING, config.getString(PARAM_ZOOKEEPER_CONNECTION_STRING)); } if (config.contains(PARAM_INDEXING_SERVICE_NAME)) { confMap.put(PARAM_INDEXING_SERVICE_NAME, config.getString(PARAM_INDEXING_SERVICE_NAME)); } if (config.contains(PARAM_DISCOVERY_CURATOR_PATH)) { confMap.put(PARAM_DISCOVERY_CURATOR_PATH, config.getString(PARAM_DISCOVERY_CURATOR_PATH)); } try { String json = objectMapper.writeValueAsString(confMap); commonRuntime.setConfiguration(json); } catch (JsonProcessingException e) { throw new RuntimeException(e); } return commonRuntime; } }
private ServiceConfiguration buildZooCfgServiceConfiguration(Config config) { ServiceConfiguration zooCfg = new ServiceConfiguration(); zooCfg.setName(CONFIG_ZOO_CFG); Map<String, String> confMap = new HashMap<>(); if (config.contains(PARAM_ZOOKEEPER_PORT)) { Number zookeeperPort = config.getAny(PARAM_ZOOKEEPER_PORT); confMap.put(PARAM_ZOOKEEPER_PORT, String.valueOf(zookeeperPort)); } try { String json = objectMapper.writeValueAsString(confMap); zooCfg.setConfiguration(json); } catch (JsonProcessingException e) { throw new RuntimeException(e); } return zooCfg; } }
private ServiceConfiguration buildStormEnvServiceConfiguration(Config config) { Map<String, String> confMap; ServiceConfiguration stormEnv = new ServiceConfiguration(); stormEnv.setName(CONF_STORM_ENV); confMap = new HashMap<>(); if (config.contains(PARAM_NIMBUS_PRINCIPAL_NAME)) { confMap.put(PARAM_NIMBUS_PRINCIPAL_NAME, config.get(PARAM_NIMBUS_PRINCIPAL_NAME)); } try { String json = objectMapper.writeValueAsString(confMap); stormEnv.setConfiguration(json); } catch (JsonProcessingException e) { throw new RuntimeException(e); } return stormEnv; }
private Pair<Component, List<ComponentProcess>> createNimbusComponent(Config config, Map<String, String> flatConfigMap) { if (!config.contains(PARAM_NIMBUS_SEEDS)) { throw new IllegalArgumentException("Required parameter " + PARAM_NIMBUS_SEEDS + " not present."); } if (!config.contains(PARAM_NIMBUS_THRIFT_PORT)) { throw new IllegalArgumentException("Required parameter " + PARAM_NIMBUS_THRIFT_PORT + " not present."); } String nimbusSeeds; try { nimbusSeeds = config.getString(PARAM_NIMBUS_SEEDS); } catch (ClassCastException e) { throw new IllegalArgumentException("Required parameter " + PARAM_NIMBUS_SEEDS + " should be a string."); } Number nimbusThriftPort = readNumberFromConfig(config, PARAM_NIMBUS_THRIFT_PORT); Component nimbus = new Component(); nimbus.setName(COMPONENT_NIMBUS); List<ComponentProcess> componentProcesses = Arrays.stream(nimbusSeeds.split(",")).map(nimbusHost -> { ComponentProcess cp = new ComponentProcess(); cp.setHost(nimbusHost); cp.setPort(nimbusThriftPort.intValue()); return cp; }).collect(toList()); return new Pair<>(nimbus, componentProcesses); }
private Pair<Component, List<ComponentProcess>> createZookeeperServerComponent(Config config, Map<String, String> flattenConfigMap) { if (!config.contains(PARAM_ZOOKEEPER_SERVER_HOSTNAMES)) { throw new IllegalArgumentException("Required parameter " + PARAM_ZOOKEEPER_SERVER_HOSTNAMES + " not present."); } if (!config.contains(PARAM_ZOOKEEPER_PORT)) { throw new IllegalArgumentException("Required parameter " + PARAM_ZOOKEEPER_PORT + " not present."); } List<String> zookeeperServerHosts; try { zookeeperServerHosts = config.getAny(PARAM_ZOOKEEPER_SERVER_HOSTNAMES); } catch (ClassCastException e) { throw new IllegalArgumentException("Required parameter " + PARAM_ZOOKEEPER_SERVER_HOSTNAMES + " should be list of string."); } Number zookeeperPort; try { zookeeperPort = config.getAny(PARAM_ZOOKEEPER_PORT); } catch (ClassCastException e) { throw new IllegalArgumentException("Required parameter " + PARAM_ZOOKEEPER_PORT + " should be number."); } Component zookeeperServer = new Component(); zookeeperServer.setName(COMPONENT_ZOOKEEPER_SERVER); List<ComponentProcess> componentProcesses = zookeeperServerHosts.stream().map(host -> { ComponentProcess cp = new ComponentProcess(); cp.setHost(host); cp.setPort(zookeeperPort.intValue()); return cp; }).collect(toList()); return new Pair<>(zookeeperServer, componentProcesses); }
private Pair<Component, List<ComponentProcess>> createStormUIServerComponent(Config config, Map<String, String> flattenConfigMap) { if (!config.contains(PARAM_UI_HOST)) { throw new IllegalArgumentException("Required parameter " + PARAM_UI_HOST + " not present."); } if (!config.contains(PARAM_UI_PORT)) { throw new IllegalArgumentException("Required parameter " + PARAM_UI_PORT + " not present."); } String stormUiServerHost; try { stormUiServerHost = config.getString(PARAM_UI_HOST); } catch (ClassCastException e) { throw new IllegalArgumentException("Required parameter " + PARAM_UI_HOST + " should be a string."); } Number stormUiServerPort = readNumberFromConfig(config, PARAM_UI_PORT); Component stormUiServer = new Component(); stormUiServer.setName(COMPONENT_STORM_UI_SERVER); ComponentProcess uiProcess = new ComponentProcess(); uiProcess.setHost(stormUiServerHost); uiProcess.setPort(stormUiServerPort.intValue()); return new Pair<>(stormUiServer, Collections.singletonList(uiProcess)); }
private Pair<Component, List<ComponentProcess>> createKafkaBrokerComponent(Config config, Map<String, String> flattenConfigMap) { if (!config.contains(PARAM_LISTENERS)) { throw new IllegalArgumentException("Required parameter " + PARAM_LISTENERS + " not present."); } Map<String, String> confMap = new HashMap<>(); confMap.put(PARAM_LISTENERS, config.getString(PARAM_LISTENERS)); Component kafkaBroker = new Component(); kafkaBroker.setName(COMPONENT_KAFKA_BROKER); List<KafkaBrokerListeners.ListenersPropEntry> parsedProps = new KafkaBrokerListeners .ListenersPropParsed(confMap).getParsedProps(); List<ComponentProcess> componentProcesses = parsedProps.stream().map(propEntry -> { ComponentProcess cp = new ComponentProcess(); cp.setHost(propEntry.getHost()); cp.setPort(propEntry.getPort()); cp.setProtocol(propEntry.getProtocol().name()); return cp; }).collect(toList()); return new Pair<>(kafkaBroker, componentProcesses); } }