本文整理汇总了Java中backtype.storm.generated.SpoutSpec类的典型用法代码示例。如果您正苦于以下问题:Java SpoutSpec类的具体用法?Java SpoutSpec怎么用?Java SpoutSpec使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SpoutSpec类属于backtype.storm.generated包,在下文中一共展示了SpoutSpec类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getComponentCommon
import backtype.storm.generated.SpoutSpec; //导入依赖的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);
}
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:25,代码来源:ThriftTopologyUtils.java
示例2: getComponentCommon
import backtype.storm.generated.SpoutSpec; //导入依赖的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);
}
开发者ID:metamx,项目名称:incubator-storm,代码行数:20,代码来源:ThriftTopologyUtils.java
示例3: computeWorkerNum
import backtype.storm.generated.SpoutSpec; //导入依赖的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);
}
}
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:35,代码来源:DefaultTopologyAssignContext.java
示例4: componentType
import backtype.storm.generated.SpoutSpec; //导入依赖的package包/类
public static String componentType(StormTopology topology, String id) {
Map<String, Bolt> bolts = topology.get_bolts();
Map<String, SpoutSpec> spouts = topology.get_spouts();
String type = "";
if (bolts.containsKey(id)) {
type = BOLT_STR;
} else if (spouts.containsKey(id)) {
type = SPOUT_STR;
}
return type;
}
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:12,代码来源:UIUtils.java
示例5: computeWorkerNum
import backtype.storm.generated.SpoutSpec; //导入依赖的package包/类
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);
}
}
开发者ID:songtk,项目名称:learn_jstorm,代码行数:34,代码来源:DefaultTopologyAssignContext.java
示例6: setSpoutInfo
import backtype.storm.generated.SpoutSpec; //导入依赖的package包/类
private int setSpoutInfo(StormTopology oldTopology, StormTopology newTopology, int cnt, StormClusterState clusterState) throws Exception {
Map<String, SpoutSpec> oldSpouts = oldTopology.get_spouts();
Map<String, SpoutSpec> spouts = newTopology.get_spouts();
for (Entry<String, SpoutSpec> entry : oldSpouts.entrySet()) {
String spoutName = entry.getKey();
SpoutSpec oldSpout = entry.getValue();
SpoutSpec spout = spouts.get(spoutName);
if (oldSpout.get_common().get_parallelism_hint() > spout.get_common().get_parallelism_hint()) {
int removedTaskNum = oldSpout.get_common().get_parallelism_hint() - spout.get_common().get_parallelism_hint();
TreeSet<Integer> taskIds = new TreeSet<Integer>(clusterState.task_ids_by_componentId(topologyid, spoutName));
Iterator<Integer> descendIterator = taskIds.descendingIterator();
while (--removedTaskNum >= 0) {
int taskId = descendIterator.next();
removeTask(topologyid, taskId, clusterState);
LOG.info("Remove spout task, taskId=" + taskId + " for " + spoutName);
}
} else if (oldSpout.get_common().get_parallelism_hint() == spout.get_common().get_parallelism_hint()) {
continue;
} else {
int delta = spout.get_common().get_parallelism_hint() - oldSpout.get_common().get_parallelism_hint();
Map<Integer, TaskInfo> taskInfoMap = new HashMap<Integer, TaskInfo>();
for (int i = 1; i <= delta; i++) {
cnt++;
TaskInfo taskInfo = new TaskInfo((String) entry.getKey(), "spout");
taskInfoMap.put(cnt, taskInfo);
newTasks.add(cnt);
LOG.info("Setup new spout task, taskId=" + cnt + " for " + spoutName);
}
clusterState.add_task(topologyid, taskInfoMap);
}
}
return cnt;
}
开发者ID:kkllwww007,项目名称:jstrom,代码行数:37,代码来源:DoRebalanceTransitionCallback.java
示例7: getComponentCommon
import backtype.storm.generated.SpoutSpec; //导入依赖的package包/类
/**
* Returns a component common from an object. This (casting) methods is required, as spouts and bolts do
* not have a common interface and currently TBase is not available.
*
* @param object the object to take the component common from
* @return the component common or <b>null</b>
*/
private static ComponentCommon getComponentCommon(Object object) {
ComponentCommon result = null;
if (object instanceof SpoutSpec) {
result = ((SpoutSpec) object).get_common();
} else if (object instanceof Bolt) {
result = ((Bolt) object).get_common();
}
return result;
}
开发者ID:QualiMaster,项目名称:Infrastructure,代码行数:17,代码来源:Utils.java
示例8: _asGraph
import backtype.storm.generated.SpoutSpec; //导入依赖的package包/类
private ListenableDirectedGraph<NamedNode, DefaultEdge> _asGraph(StormTopology t) {
final Map<String, Bolt> bolts = t.get_bolts();
final Map<String, SpoutSpec> spouts = t.get_spouts();
final ListenableDirectedGraph<NamedNode, DefaultEdge> ret = new ListenableDirectedGraph<NamedNode, DefaultEdge>(
DefaultEdge.class);
createSpouts(spouts, ret);
createBolts(bolts, ret);
createConnections(bolts, ret);
return ret;
}
开发者ID:openimaj,项目名称:openimaj,代码行数:12,代码来源:StormGraphCreator.java
示例9: createSpouts
import backtype.storm.generated.SpoutSpec; //导入依赖的package包/类
private void createSpouts(Map<String, SpoutSpec> spouts, ListenableDirectedGraph<NamedNode, DefaultEdge> ret) {
for (final Entry<String, SpoutSpec> spoutEntries : spouts.entrySet()) {
final String name = spoutEntries.getKey();
if (!nns.containsKey(name))
nns.put(name, new NamedNode(name, Type.SPOUT));
ret.addVertex(nns.get(name));
}
}
开发者ID:openimaj,项目名称:openimaj,代码行数:9,代码来源:StormGraphCreator.java
示例10: setSpoutInfo
import backtype.storm.generated.SpoutSpec; //导入依赖的package包/类
private int setSpoutInfo(StormTopology oldTopology, StormTopology newTopology,
int cnt, StormClusterState clusterState) throws Exception {
Map<String, SpoutSpec> oldSpouts = oldTopology.get_spouts();
Map<String, SpoutSpec> spouts = newTopology.get_spouts();
for (Entry<String, SpoutSpec> entry : oldSpouts.entrySet()) {
String spoutName = entry.getKey();
SpoutSpec oldSpout = entry.getValue();
SpoutSpec spout = spouts.get(spoutName);
if (oldSpout.get_common().get_parallelism_hint() > spout.get_common().get_parallelism_hint()) {
int removedTaskNum = oldSpout.get_common().get_parallelism_hint() - spout.get_common().get_parallelism_hint();
TreeSet<Integer> taskIds = new TreeSet<>(clusterState.task_ids_by_componentId(topologyId, spoutName));
Iterator<Integer> descendIterator = taskIds.descendingIterator();
while (--removedTaskNum >= 0) {
int taskId = descendIterator.next();
removeTask(topologyId, taskId, clusterState);
LOG.info("Remove spout task, taskId=" + taskId + " for " + spoutName);
}
} else if (oldSpout.get_common().get_parallelism_hint() == spout.get_common().get_parallelism_hint()) {
continue;
} else {
int delta = spout.get_common().get_parallelism_hint() - oldSpout.get_common().get_parallelism_hint();
Map<Integer, TaskInfo> taskInfoMap = new HashMap<>();
for (int i = 1; i <= delta; i++) {
cnt++;
TaskInfo taskInfo = new TaskInfo(entry.getKey(), "spout");
taskInfoMap.put(cnt, taskInfo);
newTasks.add(cnt);
LOG.info("Setup new spout task, taskId=" + cnt + " for " + spoutName);
}
clusterState.add_task(topologyId, taskInfoMap);
}
}
return cnt;
}
开发者ID:alibaba,项目名称:jstorm,代码行数:37,代码来源:DoRebalanceTransitionCallback.java
示例11: getUpstreamSpouts
import backtype.storm.generated.SpoutSpec; //导入依赖的package包/类
public static Set<String> getUpstreamSpouts(String componentId, TopologyContext context) {
Set<String> spoutIds = new HashSet<>();
StormTopology topology = context.getRawTopology();
Map<String, SpoutSpec> spouts = topology.get_spouts();
for (Entry<String, SpoutSpec> entry : spouts.entrySet()) {
String spoutId = entry.getKey();
Set<String> downstreamComponentIds = getAllDownstreamComponents(spoutId, context.getRawTopology());
if (downstreamComponentIds.contains(componentId)) {
spoutIds.add(spoutId);
}
}
return spoutIds;
}
开发者ID:alibaba,项目名称:jstorm,代码行数:14,代码来源:TransactionCommon.java
示例12: mkTaskMaker
import backtype.storm.generated.SpoutSpec; //导入依赖的package包/类
public Integer mkTaskMaker(Map<Object, Object> stormConf,
Map<String, ?> cidSpec, Map<Integer, TaskInfo> rtn, Integer cnt) {
if (cidSpec == null) {
LOG.warn("Component map is empty");
return cnt;
}
Set<?> entrySet = cidSpec.entrySet();
for (Iterator<?> it = entrySet.iterator(); it.hasNext();) {
Entry entry = (Entry) it.next();
Object obj = entry.getValue();
ComponentCommon common = null;
String componentType = "bolt";
if (obj instanceof Bolt) {
common = ((Bolt) obj).get_common();
componentType = "bolt";
} else if (obj instanceof SpoutSpec) {
common = ((SpoutSpec) obj).get_common();
componentType = "spout";
} else if (obj instanceof StateSpoutSpec) {
common = ((StateSpoutSpec) obj).get_common();
componentType = "spout";
}
if (common == null) {
throw new RuntimeException("No ComponentCommon of "
+ entry.getKey());
}
int declared = Thrift.parallelismHint(common);
Integer parallelism = declared;
// Map tmp = (Map) Utils_clj.from_json(common.get_json_conf());
Map newStormConf = new HashMap(stormConf);
// newStormConf.putAll(tmp);
Integer maxParallelism = JStormUtils.parseInt(newStormConf
.get(Config.TOPOLOGY_MAX_TASK_PARALLELISM));
if (maxParallelism != null) {
parallelism = Math.min(maxParallelism, declared);
}
for (int i = 0; i < parallelism; i++) {
cnt++;
TaskInfo taskInfo = new TaskInfo((String) entry.getKey(), componentType);
rtn.put(cnt, taskInfo);
}
}
return cnt;
}
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:51,代码来源:ServiceHandler.java
示例13: mkTaskMaker
import backtype.storm.generated.SpoutSpec; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
public Integer mkTaskMaker(Map<Object, Object> stormConf,
Map<String, ?> cidSpec, Map<Integer, TaskInfo> rtn, Integer cnt) {
if (cidSpec == null) {
LOG.warn("Component map is empty");
return cnt;
}
Set<?> entrySet = cidSpec.entrySet();
for (Iterator<?> it = entrySet.iterator(); it.hasNext();) {
Entry entry = (Entry) it.next();
Object obj = entry.getValue();
ComponentCommon common = null;
String componentType = "bolt";
if (obj instanceof Bolt) {
common = ((Bolt) obj).get_common();
componentType = "bolt";
} else if (obj instanceof SpoutSpec) {
common = ((SpoutSpec) obj).get_common();
componentType = "spout";
} else if (obj instanceof StateSpoutSpec) {
common = ((StateSpoutSpec) obj).get_common();
componentType = "spout";
}
if (common == null) {
throw new RuntimeException("No ComponentCommon of "
+ entry.getKey());
}
int declared = Thrift.parallelismHint(common);
Integer parallelism = declared;
// Map tmp = (Map) Utils_clj.from_json(common.get_json_conf());
Map newStormConf = new HashMap(stormConf);
// newStormConf.putAll(tmp);
Integer maxParallelism = JStormUtils.parseInt(newStormConf
.get(Config.TOPOLOGY_MAX_TASK_PARALLELISM));
if (maxParallelism != null) {
parallelism = Math.min(maxParallelism, declared);
}
for (int i = 0; i < parallelism; i++) {
cnt++;
TaskInfo taskInfo = new TaskInfo((String) entry.getKey(), componentType);
rtn.put(cnt, taskInfo);
}
}
return cnt;
}
开发者ID:songtk,项目名称:learn_jstorm,代码行数:52,代码来源:ServiceHandler.java
示例14: build
import backtype.storm.generated.SpoutSpec; //导入依赖的package包/类
@Test
public void build() throws Exception {
beansXml = "<breeze:topology id='t1'>" +
"<breeze:spout id='s1' beanType='eu.icolumbo.breeze.TestBean' signature='ping()' outputFields='feed'/>" +
"<breeze:bolt id='b1' beanType='eu.icolumbo.breeze.TestBean' signature='echo(feed)' outputFields='replay' scatterOutput='true'/>" +
"<breeze:bolt beanType='eu.icolumbo.breeze.TestBean' signature='drain(replay)' parallelism='2'/>" +
"</breeze:topology>";
refresh();
StormTopology topology = getBean("t1", StormTopology.class);
assertEquals("spout count", 1, topology.get_spouts_size());
assertEquals("bolt count", 2, topology.get_bolts_size());
SpringSpout spout = getBean("s1", SpringSpout.class);
assertEquals("spout ID", "s1", spout.getId());
assertEquals("spout scatter", false, spout.getScatterOutput());
SpringBolt bolt = getBean("b1", SpringBolt.class);
assertEquals("bolt ID", "b1", bolt.getId());
assertEquals("bolt scatter", true, bolt.getScatterOutput());
Map<String, SpoutSpec> topologySpouts = topology.get_spouts();
SpoutSpec spoutSpec = topologySpouts.get("s1");
assertNotNull("s1 spec", spoutSpec);
Map<String, Bolt> topologyBolts = topology.get_bolts();
Bolt boltSpec = topologyBolts.get("b1");
assertNotNull("b1 spec", boltSpec);
String anonymousBoltId = null;
for (String id : topologyBolts.keySet())
if (! "b1".equals(id))
anonymousBoltId = id;
assertNotNull("anonymous ID", anonymousBoltId);
Bolt anonymousBoltSpec = topologyBolts.get(anonymousBoltId);
assertNotNull("anonymous spec", anonymousBoltSpec);
assertEquals("s1 parralelism", 1, spoutSpec.get_common().get_parallelism_hint());
assertEquals("b1 parralelism", 1, boltSpec.get_common().get_parallelism_hint());
assertEquals("second bold parrallelism", 2, anonymousBoltSpec.get_common().get_parallelism_hint());
Map<GlobalStreamId,Grouping> boltInputs = boltSpec.get_common().get_inputs();
assertEquals("input size", 1, boltInputs.size());
GlobalStreamId streamId = boltInputs.keySet().iterator().next();
assertEquals("input component id", "s1", streamId.get_componentId());
assertEquals("input stream id", "default", streamId.get_streamId());
}
开发者ID:politie,项目名称:breeze,代码行数:47,代码来源:BeanDefinitionTest.java
注:本文中的backtype.storm.generated.SpoutSpec类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论