本文整理汇总了Java中backtype.storm.generated.ComponentCommon类的典型用法代码示例。如果您正苦于以下问题:Java ComponentCommon类的具体用法?Java ComponentCommon怎么用?Java ComponentCommon使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ComponentCommon类属于backtype.storm.generated包,在下文中一共展示了ComponentCommon类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: IdDictionary
import backtype.storm.generated.ComponentCommon; //导入依赖的package包/类
public IdDictionary(StormTopology topology) {
List<String> componentNames = new ArrayList<String>(topology
.get_spouts().keySet());
componentNames.addAll(topology.get_bolts().keySet());
componentNames.addAll(topology.get_state_spouts().keySet());
for (String name : componentNames) {
ComponentCommon common = Utils.getComponentCommon(topology,
name);
List<String> streams = new ArrayList<String>(common
.get_streams().keySet());
streamNametoId.put(name, idify(streams));
streamIdToName.put(name,
Utils.reverseMap(streamNametoId.get(name)));
}
}
示例2: getComponentCommon
import backtype.storm.generated.ComponentCommon; //导入依赖的package包/类
public static ComponentCommon getComponentCommon(StormTopology topology,
String componentId) {
for (StormTopology._Fields f : StormTopology.metaDataMap.keySet()) {
Map<String, Object> componentMap = (Map<String, Object>) topology
.getFieldValue(f);
if (componentMap.containsKey(componentId)) {
Object component = componentMap.get(componentId);
if (component instanceof Bolt) {
return ((Bolt) component).get_common();
}
if (component instanceof SpoutSpec) {
return ((SpoutSpec) component).get_common();
}
if (component instanceof StateSpoutSpec) {
return ((StateSpoutSpec) component).get_common();
}
throw new RuntimeException(
"Unreachable code! No get_common conversion for component "
+ component);
}
}
throw new IllegalArgumentException(
"Could not find component common for " + componentId);
}
示例3: maxTopologyMessageTimeout
import backtype.storm.generated.ComponentCommon; //导入依赖的package包/类
public int maxTopologyMessageTimeout() {
Integer max = Utils.getInt(_stormConf
.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) {
Map conf = (Map) Utils.from_json(jsonConf);
Object comp = conf.get(Config.TOPOLOGY_MESSAGE_TIMEOUT_SECS);
if (comp != null) {
max = Math.max(Utils.getInt(comp), max);
}
}
}
return max;
}
示例4: createStreams
import backtype.storm.generated.ComponentCommon; //导入依赖的package包/类
/**
* Creates the streams for <code>common</code>.
*
* @param procs already known processors
* @param originName the name of the origin processor
* @param common the common instance to create streams for
* @param cfg configuration
* @param hwAlgType the hardware algorithm type
* @param mapping the name mapping
*/
private static void createStreams(Map<String, StormProcessor> procs, String originName,
ComponentCommon common, Configuration cfg, IDatatype hwAlgType, INameMapping mapping) {
StormProcessor target = getProcessor(procs, originName);
if (null != target) {
for (Map.Entry<GlobalStreamId, Grouping> grouping : common.get_inputs().entrySet()) {
GlobalStreamId id = grouping.getKey();
StormProcessor origin = getProcessor(procs, mapName(mapping, id.get_componentId()));
if (null != origin) {
if (!leaveOutConnection(mapping, origin, cfg, hwAlgType) && !origin.hasOutputTo(target)) {
Stream stream = new Stream(id.get_streamId(), origin, target);
origin.addOutput(stream);
target.addInput(stream);
}
}
}
}
}
示例5: createProcessors
import backtype.storm.generated.ComponentCommon; //导入依赖的package包/类
/**
* Creates processors for a set of <code>entries</code> (bolts or spouts).
*
* @param <T> the entry type of <code>entries</code>
* @param mapping the name mapping
* @param executors the actual executors
* @param entries the entries to process
* @param procs the processors to modify as a side effect
* @param spout are we processing spouts
*/
private static <T> void createProcessors(INameMapping mapping, Map<String, ExecutorSummary> executors,
Set<Map.Entry<String, T>> entries, Map<String, StormProcessor> procs, boolean spout) {
for (Map.Entry<String, T> entry : entries) {
String name = mapName(mapping, entry);
ExecutorSummary executor = getNonInternalExecutor(executors, entry);
if (null != name && null != executor) { // avoid Storm internal streams for now
ComponentCommon common = getComponentCommon(entry.getValue());
if (null != common) {
StormProcessor proc = procs.get(name);
if (null != proc) {
proc.update(executor);
} else {
procs.put(name, new StormProcessor(name, common, executor, spout));
}
}
}
}
}
示例6: getComponentCommon
import backtype.storm.generated.ComponentCommon; //导入依赖的package包/类
public static ComponentCommon getComponentCommon(StormTopology topology, String componentId) {
for(StormTopology._Fields f: StormTopology.metaDataMap.keySet()) {
Map<String, Object> componentMap = (Map<String, Object>) topology.getFieldValue(f);
if(componentMap.containsKey(componentId)) {
Object component = componentMap.get(componentId);
if(component instanceof Bolt) {
return ((Bolt) component).get_common();
}
if(component instanceof SpoutSpec) {
return ((SpoutSpec) component).get_common();
}
if(component instanceof StateSpoutSpec) {
return ((StateSpoutSpec) component).get_common();
}
throw new RuntimeException("Unreachable code! No get_common conversion for component " + component);
}
}
throw new IllegalArgumentException("Could not find component common for " + componentId);
}
示例7: initCommon
import backtype.storm.generated.ComponentCommon; //导入依赖的package包/类
protected 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);
} else {
common.set_parallelism_hint(1);
}
Map conf = component.getComponentConfiguration();
if(conf!=null) common.set_json_conf(JSONValue.toJSONString(conf));
_commons.put(id, common);
}
示例8: parallelismHint
import backtype.storm.generated.ComponentCommon; //导入依赖的package包/类
public static int parallelismHint(ComponentCommon component_common) {
int phint = component_common.get_parallelism_hint();
if (!component_common.is_set_parallelism_hint()) {
phint = 1;
}
return phint;
}
示例9: mkComponentcommon
import backtype.storm.generated.ComponentCommon; //导入依赖的package包/类
private static ComponentCommon mkComponentcommon(
Map<GlobalStreamId, Grouping> inputs,
HashMap<String, StreamInfo> output_spec, Integer parallelism_hint) {
ComponentCommon ret = new ComponentCommon(inputs, output_spec);
if (parallelism_hint != null) {
ret.set_parallelism_hint(parallelism_hint);
}
return ret;
}
示例10: mkBolt
import backtype.storm.generated.ComponentCommon; //导入依赖的package包/类
public static Bolt mkBolt(Map<GlobalStreamId, Grouping> inputs,
IBolt bolt, HashMap<String, StreamInfo> output, Integer p) {
ComponentCommon common = mkComponentcommon(inputs, output, p);
byte[] boltSer = Utils.serialize(bolt);
ComponentObject component = ComponentObject.serialized_java(boltSer);
return new Bolt(component, common);
}
示例11: computeWorkerNum
import backtype.storm.generated.ComponentCommon; //导入依赖的package包/类
@SuppressWarnings("unused")
private int computeWorkerNum() {
Integer settingNum = JStormUtils.parseInt(stormConf
.get(Config.TOPOLOGY_WORKERS));
int hintSum = 0;
Map<String, Object> components = ThriftTopologyUtils
.getComponents(sysTopology);
for (Entry<String, Object> entry : components.entrySet()) {
String componentName = entry.getKey();
Object component = entry.getValue();
ComponentCommon common = null;
if (component instanceof Bolt) {
common = ((Bolt) component).get_common();
}
if (component instanceof SpoutSpec) {
common = ((SpoutSpec) component).get_common();
}
if (component instanceof StateSpoutSpec) {
common = ((StateSpoutSpec) component).get_common();
}
int hint = common.get_parallelism_hint();
hintSum += hint;
}
if (settingNum == null) {
return hintSum;
} else {
return Math.min(settingNum, hintSum);
}
}
示例12: componentParalism
import backtype.storm.generated.ComponentCommon; //导入依赖的package包/类
public static Integer componentParalism(Map stormConf,
ComponentCommon common) {
Map mergeMap = new HashMap();
mergeMap.putAll(stormConf);
String jsonConfString = common.get_json_conf();
if (jsonConfString != null) {
Map componentMap = (Map) JStormUtils.from_json(jsonConfString);
mergeMap.putAll(componentMap);
}
Integer taskNum = common.get_parallelism_hint();
if (taskNum == null) {
taskNum = Integer.valueOf(1);
}
// don't get taskNum from component configuraiton
// skip .setTaskNum
// Integer taskNum = null;
// Object taskNumObject = mergeMap.get(Config.TOPOLOGY_TASKS);
// if (taskNumObject != null) {
// taskNum = JStormUtils.parseInt(taskNumObject);
// } else {
// taskNum = common.get_parallelism_hint();
// if (taskNum == null) {
// taskNum = Integer.valueOf(1);
// }
// }
Object maxTaskParalismObject = mergeMap
.get(Config.TOPOLOGY_MAX_TASK_PARALLELISM);
if (maxTaskParalismObject == null) {
return taskNum;
} else {
int maxTaskParalism = JStormUtils.parseInt(maxTaskParalismObject);
return Math.min(maxTaskParalism, taskNum);
}
}
示例13: add_system_components
import backtype.storm.generated.ComponentCommon; //导入依赖的package包/类
@SuppressWarnings("unused")
public static StormTopology add_system_components(StormTopology topology) {
// generate inputs
Map<GlobalStreamId, Grouping> inputs = new HashMap<GlobalStreamId, Grouping>();
// generate outputs
HashMap<String, StreamInfo> outputs = new HashMap<String, StreamInfo>();
ArrayList<String> fields = new ArrayList<String>();
outputs.put(Constants.SYSTEM_TICK_STREAM_ID,
Thrift.outputFields(JStormUtils.mk_list("rate_secs")));
outputs.put(Constants.METRICS_TICK_STREAM_ID,
Thrift.outputFields(JStormUtils.mk_list("interval")));
outputs.put(Constants.CREDENTIALS_CHANGED_STREAM_ID,
Thrift.outputFields(JStormUtils.mk_list("creds")));
ComponentCommon common = new ComponentCommon(inputs, outputs);
IBolt ackerbolt = new SystemBolt();
Bolt bolt = Thrift.mkBolt(inputs, ackerbolt, outputs,
Integer.valueOf(0));
topology.put_to_bolts(Constants.SYSTEM_COMPONENT_ID, bolt);
add_system_streams(topology);
return topology;
}
示例14: getComponentMap
import backtype.storm.generated.ComponentCommon; //导入依赖的package包/类
/**
* get the component's configuration
*
* @param topology_context
* @param task_id
* @return component's configurations
*/
public static Map getComponentMap(DefaultTopologyAssignContext context,
Integer task) {
String componentName = context.getTaskToComponent().get(task);
ComponentCommon componentCommon = ThriftTopologyUtils
.getComponentCommon(context.getSysTopology(), componentName);
Map componentMap = (Map) JStormUtils.from_json(componentCommon
.get_json_conf());
if (componentMap == null) {
componentMap = Maps.newHashMap();
}
return componentMap;
}
示例15: getComponentCommon
import backtype.storm.generated.ComponentCommon; //导入依赖的package包/类
public static ComponentCommon getComponentCommon(StormTopology topology,
String id) {
if (topology.get_spouts().containsKey(id)) {
return topology.get_spouts().get(id).get_common();
}
if (topology.get_bolts().containsKey(id)) {
return topology.get_bolts().get(id).get_common();
}
if (topology.get_state_spouts().containsKey(id)) {
return topology.get_state_spouts().get(id).get_common();
}
throw new IllegalArgumentException("Could not find component with id "
+ id);
}