@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; }
@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; }
public static ComponentCommon prepareComponentCommon(Map<GlobalStreamId, Grouping> inputs, Map<String, StreamInfo> outputs, Integer parallelismHint, Map<String, Object> conf) { Map<GlobalStreamId, Grouping> mappedInputs = new HashMap<>(); Map<String, StreamInfo> mappedOutputs = new HashMap<>(); if (inputs != null && !inputs.isEmpty()) { mappedInputs.putAll(inputs); } if (outputs != null && !outputs.isEmpty()) { mappedOutputs.putAll(outputs); } ComponentCommon component = new ComponentCommon(mappedInputs, mappedOutputs); if (parallelismHint != null) { component.set_parallelism_hint(parallelismHint); } if (conf != null) { component.set_json_conf(JSONValue.toJSONString(conf)); } return component; }
private void initCommon(String id, IComponent component, Number parallelism) throws IllegalArgumentException { ComponentCommon common = new ComponentCommon(); common.set_inputs(new HashMap<GlobalStreamId, Grouping>()); if (parallelism != null) { int dop = parallelism.intValue(); if (dop < 1) { throw new IllegalArgumentException("Parallelism must be positive."); } common.set_parallelism_hint(dop); } Map<String, Object> conf = component.getComponentConfiguration(); if (conf != null) { common.set_json_conf(JSONValue.toJSONString(conf)); } commons.put(id, common); }
.RESOURCE_NAME_NORMALIZER.normalizedResourceMap(resourceUpdatesMap.get(spoutName)); String newJsonConf = getJsonWithUpdatedResources(spoutCommon.get_json_conf(), resourcesUpdate); spoutCommon.set_json_conf(newJsonConf); componentsUpdated.put(spoutName, resourcesUpdate); .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);
private static StormTopology normalizeTopology(Map<String, Object> topoConf, StormTopology topology) throws InvalidTopologyException { StormTopology ret = topology.deepCopy(); for (Object comp : StormCommon.allComponents(ret).values()) { Map<String, Object> mergedConf = StormCommon.componentConf(comp); mergedConf.put(Config.TOPOLOGY_TASKS, ServerUtils.getComponentParallelism(topoConf, comp)); String jsonConf = JSONValue.toJSONString(mergedConf); StormCommon.getComponentCommon(comp).set_json_conf(jsonConf); } return ret; }
spoutConf.put(Config.TOPOLOGY_TICK_TUPLE_FREQ_SECS, ObjectReader.getInt(conf.get(Config.TOPOLOGY_MESSAGE_TIMEOUT_SECS))); common.set_json_conf(JSONValue.toJSONString(spoutConf)); common.put_to_streams(Acker.ACKER_INIT_STREAM_ID, Thrift.outputFields(Arrays.asList("id", "init-val", "spout-task")));
unset_json_conf(); } else { set_json_conf((java.lang.String)value);
@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; } }
private void initCommon(String id, IComponent component, Number parallelism) throws IllegalArgumentException { ComponentCommon common = new ComponentCommon(); common.set_inputs(new HashMap<GlobalStreamId, Grouping>()); if(parallelism!=null) { int dop = parallelism.intValue(); if(dop < 1) { throw new IllegalArgumentException("Parallelism must be positive."); } common.set_parallelism_hint(dop); } Map conf = component.getComponentConfiguration(); if(conf!=null) common.set_json_conf(JSONValue.toJSONString(conf)); _commons.put(id, common); }
unset_json_conf(); } else { set_json_conf((String)value);