/** * return the current component configuration. * * @return the current configuration. */ @Override public Map<String, Object> getComponentConfiguration() { return parseJson(commons.get(id).get_json_conf()); }
@SuppressWarnings("unchecked") @Override public T addResource(String resourceName, Number resourceValue) { Map<String, Object> componentConf = parseJson(commons.get(id).get_json_conf()); Map<String, Double> resourcesMap = (Map<String, Double>) componentConf.computeIfAbsent( Config.TOPOLOGY_COMPONENT_RESOURCES_MAP, (k) -> new HashMap<>()); resourcesMap.put(resourceName, resourceValue.doubleValue()); return addConfiguration(Config.TOPOLOGY_COMPONENT_RESOURCES_MAP, resourcesMap); }
@SuppressWarnings("unchecked") @Override public T addConfigurations(Map<String, Object> conf) { if (conf != null) { if (conf.containsKey(Config.TOPOLOGY_KRYO_REGISTER)) { throw new IllegalArgumentException("Cannot set serializations for a component using fluent API"); } if (!conf.isEmpty()) { String currConf = commons.get(id).get_json_conf(); commons.get(id).set_json_conf(mergeIntoJson(parseJson(currConf), conf)); } } return (T) this; }
@SuppressWarnings("unchecked") public static Map<String, Object> componentConf(Object component) { try { Map<String, Object> conf = new HashMap<>(); ComponentCommon common = getComponentCommon(component); String jconf = common.get_json_conf(); if (jconf != null) { conf.putAll((Map<String, Object>) JSONValue.parseWithException(jconf)); } return conf; } catch (Exception e) { throw new RuntimeException(e); } }
@Override public T addResources(Map<String, Double> resources) { if (resources != null && !resources.isEmpty()) { String currConf = commons.get(id).get_json_conf(); Map<String, Object> conf = parseJson(currConf); Map<String, Double> currentResources = (Map<String, Double>) conf.computeIfAbsent(Config.TOPOLOGY_COMPONENT_RESOURCES_MAP, (k) -> new HashMap<>()); currentResources.putAll(resources); commons.get(id).set_json_conf(JSONValue.toJSONString(conf)); } return (T) this; }
public static Map<String, NormalizedResourceRequest> getBoltsResources(StormTopology topology, Map<String, Object> topologyConf) { Map<String, NormalizedResourceRequest> boltResources = new HashMap<>(); if (topology.get_bolts() != null) { for (Map.Entry<String, Bolt> bolt : topology.get_bolts().entrySet()) { NormalizedResourceRequest topologyResources = new NormalizedResourceRequest(bolt.getValue().get_common(), topologyConf, bolt.getKey()); if (LOG.isTraceEnabled()) { LOG.trace("Turned {} into {}", bolt.getValue().get_common().get_json_conf(), topologyResources); } boltResources.put(bolt.getKey(), topologyResources); } } return boltResources; }
private static void addLagResultForKafkaSpout(Map<String, Map<String, Object>> finalResult, String spoutId, SpoutSpec spoutSpec) throws IOException { ComponentCommon componentCommon = spoutSpec.get_common(); String json = componentCommon.get_json_conf(); if (json != null && !json.isEmpty()) { Map<String, Object> jsonMap = null; try { jsonMap = (Map<String, Object>) JSONValue.parseWithException(json); } catch (ParseException e) { throw new IOException(e); } if (jsonMap.containsKey(TOPICS_CONFIG) && jsonMap.containsKey(GROUPID_CONFIG) && jsonMap.containsKey(BOOTSTRAP_CONFIG)) { finalResult.put(spoutId, getLagResultForNewKafkaSpout(spoutId, spoutSpec)); } } }
public static Map<String, NormalizedResourceRequest> getSpoutsResources(StormTopology topology, Map<String, Object> topologyConf) { Map<String, NormalizedResourceRequest> spoutResources = new HashMap<>(); if (topology.get_spouts() != null) { for (Map.Entry<String, SpoutSpec> spout : topology.get_spouts().entrySet()) { NormalizedResourceRequest topologyResources = new NormalizedResourceRequest(spout.getValue().get_common(), topologyConf, spout.getKey()); if (LOG.isTraceEnabled()) { LOG.trace("Turned {} into {}", spout.getValue().get_common().get_json_conf(), topologyResources); } spoutResources.put(spout.getKey(), topologyResources); } } return spoutResources; }
static Map<String, Map<String, Double>> getBoltsResources(StormTopology topology, Map<String, Object> topologyConf) { Map<String, Map<String, Double>> boltResources = new HashMap<>(); if (topology.get_bolts() != null) { for (Map.Entry<String, Bolt> bolt : topology.get_bolts().entrySet()) { Map<String, Double> topologyResources = parseResources(bolt.getValue().get_common().get_json_conf()); checkInitialization(topologyResources, bolt.getValue().toString(), topologyConf); boltResources.put(bolt.getKey(), topologyResources); } } return boltResources; }
public NormalizedResourceRequest(ComponentCommon component, Map<String, Object> topoConf, String componentId) { this(parseResources(component.get_json_conf()), getDefaultResources(topoConf, componentId)); }
String specJsonConf = topologyContext.getComponentCommon(componentId).get_json_conf(); if (specJsonConf != null) { try {
static Map<String, Map<String, Double>> getSpoutsResources(StormTopology topology, Map<String, Object> topologyConf) { Map<String, Map<String, Double>> spoutResources = new HashMap<>(); if (topology.get_spouts() != null) { for (Map.Entry<String, SpoutSpec> spout : topology.get_spouts().entrySet()) { Map<String, Double> topologyResources = parseResources(spout.getValue().get_common().get_json_conf()); checkInitialization(topologyResources, spout.getValue().toString(), topologyConf); spoutResources.put(spout.getKey(), topologyResources); } } return spoutResources; }
public java.lang.Object getFieldValue(_Fields field) { switch (field) { case INPUTS: return get_inputs(); case STREAMS: return get_streams(); case PARALLELISM_HINT: return get_parallelism_hint(); case JSON_CONF: return get_json_conf(); } throw new java.lang.IllegalStateException(); }
public int maxTopologyMessageTimeout() { Integer max = ObjectReader.getInt(_topoConf.get(Config.TOPOLOGY_MESSAGE_TIMEOUT_SECS)); for (String spout : getRawTopology().get_spouts().keySet()) { ComponentCommon common = getComponentCommon(spout); String jsonConf = common.get_json_conf(); if (jsonConf != null) { try { Map<String, Object> conf = (Map) JSONValue.parseWithException(jsonConf); Object comp = conf.get(Config.TOPOLOGY_MESSAGE_TIMEOUT_SECS); max = Math.max(ObjectReader.getInt(comp, max), max); } catch (ParseException e) { throw new RuntimeException(e); } } } return max; }
private static Map<String, Object> getLagResultForKafka(String spoutId, SpoutSpec spoutSpec) throws IOException { ComponentCommon componentCommon = spoutSpec.get_common(); String json = componentCommon.get_json_conf(); Map<String, Object> result = null; String errorMsg = "Offset lags for kafka not supported for older versions. Please update kafka spout to latest version.";
Map<String, Double> resourcesUpdate = NormalizedResources .RESOURCE_NAME_NORMALIZER.normalizedResourceMap(resourceUpdatesMap.get(spoutName)); String newJsonConf = getJsonWithUpdatedResources(spoutCommon.get_json_conf(), resourcesUpdate); spoutCommon.set_json_conf(newJsonConf); componentsUpdated.put(spoutName, resourcesUpdate); Map<String, Double> resourcesUpdate = NormalizedResources .RESOURCE_NAME_NORMALIZER.normalizedResourceMap(resourceUpdatesMap.get(boltName)); String newJsonConf = getJsonWithUpdatedResources(boltCommon.get_json_conf(), resourceUpdatesMap.get(boltName)); boltCommon.set_json_conf(newJsonConf); componentsUpdated.put(boltName, resourcesUpdate);
String componentConfRaw = readStormTopology.get_spouts().get("spout-1").get_common().get_json_conf();
@Override public T addConfigurations(Map<String, Object> conf) { if(conf!=null && conf.containsKey(Config.TOPOLOGY_KRYO_REGISTER)) { throw new IllegalArgumentException("Cannot set serializations for a component using fluent API"); } String currConf = _commons.get(_id).get_json_conf(); _commons.get(_id).set_json_conf(mergeIntoJson(parseJson(currConf), conf)); return (T) this; } }
public static Map<String, Map<String, Double>> getBoltsResources(StormTopology topology, Map topologyConf) { Map<String, Map<String, Double>> boltResources = new HashMap<String, Map<String, Double>>(); if (topology.get_bolts() != null) { for (Map.Entry<String, Bolt> bolt : topology.get_bolts().entrySet()) { Map<String, Double> topology_resources = parseResources(bolt.getValue().get_common().get_json_conf()); checkIntialization(topology_resources, bolt.getValue().toString(), topologyConf); boltResources.put(bolt.getKey(), topology_resources); } } return boltResources; }
public static Map<String, Map<String, Double>> getSpoutsResources(StormTopology topology, Map topologyConf) { Map<String, Map<String, Double>> spoutResources = new HashMap<String, Map<String, Double>>(); if (topology.get_spouts() != null) { for (Map.Entry<String, SpoutSpec> spout : topology.get_spouts().entrySet()) { Map<String, Double> topology_resources = parseResources(spout.getValue().get_common().get_json_conf()); checkIntialization(topology_resources, spout.getValue().toString(), topologyConf); spoutResources.put(spout.getKey(), topology_resources); } } return spoutResources; }