@Override public int getInt(String key) { return Integer.parseInt(get(key)); }
public StreamlineComponent() { config = new Config(); }
@Override protected List<ServiceConfiguration> createServiceConfigurations(Config config) { ServiceConfiguration serviceConfiguration = new ServiceConfiguration(); serviceConfiguration.setName(Constants.Email.CONF_TYPE_PROPERTIES); Map<String, String> confMap = new HashMap<>(); confMap.put(PARAM_HOST, config.get(Constants.Email.PROPERTY_KEY_HOST)); confMap.put(PARAM_PORT, String.valueOf((Integer) config.getAny(Constants.Email.PROPERTY_KEY_PORT))); confMap.put(PARAM_SSL, String.valueOf((Boolean) config.getAny(Constants.Email.PROPERTY_KEY_SSL))); confMap.put(PARAM_STARTTLS, String.valueOf((Boolean) config.getAny(Constants.Email.PROPERTY_KEY_STARTTLS))); confMap.put(PARAM_PROTOCOL, config.get(Constants.Email.PROPERTY_KEY_PROTOCOL)); confMap.put(PARAM_AUTH, String.valueOf((Boolean) config.getAny(Constants.Email.PROPERTY_KEY_AUTH))); ObjectMapper objectMapper = new ObjectMapper(); try { String json = objectMapper.writeValueAsString(confMap); serviceConfiguration.setConfiguration(json); } catch (JsonProcessingException e) { throw new RuntimeException(e); } return Collections.singletonList(serviceConfiguration); }
public TopologyLayout(Long id, String name, String configStr, TopologyDag topologyDag) throws IOException { this.id = id; this.name = name; if (!StringUtils.isEmpty(configStr)) { ObjectMapper mapper = new ObjectMapper(); Map<String, Object> properties = mapper.readValue(configStr, new TypeReference<Map<String, Object>>(){}); config = new Config(); config.putAll(properties); } else { config = new Config(); } this.topologyDag = topologyDag; }
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; } }
String subType = topologyData.getBundleIdToType().get(topologyProcessor.getTopologyComponentBundleId().toString()); if (TopologyLayoutConstants.JSON_KEY_CUSTOM_PROCESSOR_SUB_TYPE.equals(subType)) { QueryParam queryParam = new QueryParam(CustomProcessorInfo.NAME, topologyProcessor.getConfig().get(CustomProcessorInfo.NAME)); Collection<TopologyComponentBundle> result = listCustomProcessorBundlesWithFilter(Collections.singletonList(queryParam)); if (result.size() != 1) { throw new IllegalStateException("Not able to find topology component bundle for custom processor :" + topologyProcessor.getConfig().get (CustomProcessorInfo.NAME)); Optional<Object> ruleListObj = topologyProcessor.getConfig().getAnyOptional(RulesProcessor.CONFIG_KEY_RULES); ruleListObj.ifPresent(ruleList -> { List<Long> ruleIds = new ObjectMapper().convertValue(ruleList, new TypeReference<List<Long>>() {}); ruleIds.forEach(ruleId -> updatedRuleIds.add(oldToNewWindowIds.get(ruleId))); topologyProcessor.getConfig().setAny(RulesProcessor.CONFIG_KEY_RULES, updatedRuleIds); }); addTopologyProcessor(newTopology.getId(), topologyProcessor);
private String findKafkaTopicName(Component component) { if (!(component instanceof StreamlineSource)) { throw new IllegalStateException("Component must be Source."); } try { Map<String, Object> componentConfig = component.getConfig().getProperties(); return (String) componentConfig.get(TopologyLayoutConstants.JSON_KEY_TOPIC); } catch (RuntimeException e) { throw new IllegalStateException("Failed to parse topology configuration.", e); } }
private Number readNumberFromConfig(Config config, String parameterName) { try { return config.getAny(parameterName); } catch (ClassCastException e) { throw new IllegalArgumentException("Required parameter " + parameterName + " should be a number."); } }
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 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; } }
public void put(String key, int value) { put(key, String.valueOf(value)); }
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()); } }
topologyConfig.put(clusterKey, clusterConf); clusterKeys.add(clusterKey); topologyConfig.put(credentialConfigKeyName, clusterKeys); Optional<List<String>> autoCredentialsOptional = topologyConfig.getAnyOptional(STORM_TOPOLOGY_CONFIG_AUTO_CREDENTIALS); if (autoCredentialsOptional.isPresent()) { List<String> autoCredentials = autoCredentialsOptional.get(); autoCredentials.add(topologyAutoCredentialClassName); } else { topologyConfig.put(STORM_TOPOLOGY_CONFIG_AUTO_CREDENTIALS, Lists.newArrayList(topologyAutoCredentialClassName));
@Override public StreamlineProcessor create(TopologyComponent component) { RulesProcessor processor = new RulesProcessor(); ObjectMapper objectMapper = new ObjectMapper(); if (component instanceof TopologyOutputComponent) { Set<Stream> outputStreams = createOutputStreams((TopologyOutputComponent) component); processor.addOutputStreams(outputStreams); } else { throw new IllegalArgumentException("Component " + component + " must be an instance of TopologyOutputComponent"); } boolean processAll = component.getConfig().getBoolean(RulesProcessor.CONFIG_PROCESS_ALL, true); processor.setProcessAll(processAll); Object ruleList = component.getConfig().getAny(RulesProcessor.CONFIG_KEY_RULES); List<Long> ruleIds = objectMapper.convertValue(ruleList, new TypeReference<List<Long>>() { }); try { List<Rule> rules = new ArrayList<>(); for (Long ruleId : ruleIds) { rules.add(ruleExtractor.getRule(component.getTopologyId(), ruleId, component.getVersionId())); } processor.setRules(rules); } catch (Exception ex) { throw new RuntimeException(ex); } return processor; } };
private void handleNonWindowedRules(RulesProcessor rulesProcessor, List<Rule> rulesWithoutWindow) { rulesProcessor.setRules(rulesWithoutWindow); rulesProcessor.getConfig().setAny(RulesProcessor.CONFIG_KEY_RULES, Collections2.transform(rulesWithoutWindow, new Function<Rule, Long>() { @Override public Long apply(Rule input) { return input.getId(); } })); keysAndComponents.add(makeEntry(StormTopologyLayoutConstants.YAML_KEY_BOLTS, getYamlComponents(fluxComponentFactory.getFluxComponent(rulesProcessor), rulesProcessor))); }
private void putAutoTokenDelegationConfig(Config topologyConfig, TopologyDag topologyDag) { Optional<?> securityConfigsOptional = topologyConfig.getAnyOptional(STREAMLINE_TOPOLOGY_CONFIG_CLUSTER_SECURITY_CONFIG); Map<Long, Map<String, String>> clusterToConfiguration = new HashMap<>(); if (securityConfigsOptional.isPresent()) {
@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; } };
@Override public void validate (TopologyLayout topology) throws Exception { Map<String, Object> topologyConfig = topology.getConfig().getProperties(); if (!topologyConfig.isEmpty()) { StormTopologyValidator validator = new StormTopologyValidator(topologyConfig, this.catalogRootUrl); validator.validate(); } }
public Map<String, Object> getNotifierProperties() { return getConfig().getAny(CONFIG_KEY_PROPERTIES); }