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 void updateNotifierJarFileName(TopologySink sink) { String notifierClassName = sink.getConfig().getString(Notifier.CLASS_NAME, ""); if (!notifierClassName.isEmpty()) { Collection<Notifier> notifiers = listNotifierInfos(QueryParam.params(Notifier.CLASS_NAME, notifierClassName)); if (notifiers.isEmpty()) { throw new IllegalStateException("No registered notifier in the cluster for class '" + notifierClassName + "'"); } Notifier current = notifiers.iterator().next(); sink.getConfig().setAny(Notifier.JARFILE_NAME, current.getJarFileName()); } }
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; }
@Override public StreamlineProcessor create(TopologyComponent component) { String modelName = component.getConfig().getString(ModelProcessor.CONFIG_MODEL_NAME, StringUtils.EMPTY); ModelProcessor modelProcessor = new ModelProcessor(); if (!modelName.equals(StringUtils.EMPTY)) { modelProcessor.setPmml(modelRegistryClient.getMLModelContents(modelName)); } return modelProcessor; } };
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>> 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); } }