org.apache.storm.topology.IRichSpout Java Examples
The following examples show how to use
org.apache.storm.topology.IRichSpout.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Twister2Spout.java From twister2 with Apache License 2.0 | 5 votes |
public Twister2Spout(String id, IRichSpout stormSpout) { this.id = id; this.stormSpout = stormSpout; this.spoutDeclarer = new Twister2SpoutDeclarer(); this.outFieldsForEdge = new EdgeFieldMap(Utils.getDefaultStream(id)); this.keyedOutEdges = new EdgeFieldMap(Utils.getDefaultStream(id)); this.stormSpout.declareOutputFields(this.outFieldsForEdge); }
Example #2
Source File: SpoutBuilder.java From incubator-heron with Apache License 2.0 | 5 votes |
protected void buildSpouts(EcoExecutionContext executionContext, TopologyBuilder builder, ObjectBuilder objectBuilder) throws ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchFieldException, InvocationTargetException { EcoTopologyDefinition topologyDefinition = executionContext.getTopologyDefinition(); for (ObjectDefinition def: topologyDefinition.getSpouts()) { Object obj = objectBuilder.buildObject(def, executionContext); builder.setSpout(def.getId(), (IRichSpout) obj, def.getParallelism()); executionContext.addSpout(def.getId(), obj); } }
Example #3
Source File: TopologyModule.java From monasca-thresh with Apache License 2.0 | 5 votes |
public TopologyModule(ThresholdingConfiguration threshConfig, Config stormConfig, IRichSpout metricSpout, IRichSpout eventSpout) { this(threshConfig); this.stormConfig = stormConfig; this.metricSpout = metricSpout; this.eventSpout = eventSpout; }
Example #4
Source File: TopologyModule.java From monasca-thresh with Apache License 2.0 | 5 votes |
@Provides StormTopology topology() { TopologyBuilder builder = new TopologyBuilder(); // Receives metrics builder.setSpout("metrics-spout", Injector.getInstance(IRichSpout.class, "metrics"), config.metricSpoutThreads).setNumTasks(config.metricSpoutTasks); // Receives events builder.setSpout("event-spout", Injector.getInstance(IRichSpout.class, "event"), config.eventSpoutThreads).setNumTasks(config.eventSpoutTasks); // Event -> Events builder .setBolt("event-bolt", new EventProcessingBolt(config.database), config.eventBoltThreads) .shuffleGrouping("event-spout").setNumTasks(config.eventBoltTasks); // Metrics / Event -> Filtering builder .setBolt("filtering-bolt", new MetricFilteringBolt(config.database), config.filteringBoltThreads) .fieldsGrouping("metrics-spout", new Fields(MetricSpout.FIELDS[0])) .allGrouping("event-bolt", EventProcessingBolt.METRIC_ALARM_EVENT_STREAM_ID) .allGrouping("event-bolt", EventProcessingBolt.ALARM_DEFINITION_EVENT_STREAM_ID) .setNumTasks(config.filteringBoltTasks); // Filtering /Event -> Alarm Creation builder .setBolt("alarm-creation-bolt", new AlarmCreationBolt(config.database), config.alarmCreationBoltThreads) .fieldsGrouping("filtering-bolt", MetricFilteringBolt.NEW_METRIC_FOR_ALARM_DEFINITION_STREAM, new Fields(AlarmCreationBolt.ALARM_CREATION_FIELDS[3])) .allGrouping("event-bolt", EventProcessingBolt.METRIC_SUB_ALARM_EVENT_STREAM_ID) .allGrouping("event-bolt", EventProcessingBolt.ALARM_EVENT_STREAM_ID) .allGrouping("event-bolt", EventProcessingBolt.ALARM_DEFINITION_EVENT_STREAM_ID) .setNumTasks(config.alarmCreationBoltTasks); // Filtering / Event / Alarm Creation -> Aggregation builder .setBolt("aggregation-bolt", new MetricAggregationBolt(config, config.database), config.aggregationBoltThreads) .fieldsGrouping("filtering-bolt", new Fields(MetricFilteringBolt.FIELDS[0])) .allGrouping("filtering-bolt", MetricAggregationBolt.METRIC_AGGREGATION_CONTROL_STREAM) .fieldsGrouping("filtering-bolt", AlarmCreationBolt.ALARM_CREATION_STREAM, new Fields(AlarmCreationBolt.ALARM_CREATION_FIELDS[1])) .allGrouping("event-bolt", EventProcessingBolt.METRIC_SUB_ALARM_EVENT_STREAM_ID) .fieldsGrouping("event-bolt", EventProcessingBolt.METRIC_ALARM_EVENT_STREAM_ID, new Fields(EventProcessingBolt.METRIC_ALARM_EVENT_STREAM_FIELDS[1])) .fieldsGrouping("alarm-creation-bolt", AlarmCreationBolt.ALARM_CREATION_STREAM, new Fields(AlarmCreationBolt.ALARM_CREATION_FIELDS[1])) .setNumTasks(config.aggregationBoltTasks); // Alarm Creation / Event // Aggregation / Event -> Thresholding builder .setBolt("thresholding-bolt", new AlarmThresholdingBolt(config.database, config.kafkaProducerConfig), config.thresholdingBoltThreads) .fieldsGrouping("aggregation-bolt", new Fields(MetricAggregationBolt.FIELDS[0])) .fieldsGrouping("event-bolt", EventProcessingBolt.ALARM_EVENT_STREAM_ID, new Fields(EventProcessingBolt.ALARM_EVENT_STREAM_FIELDS[1])) .allGrouping("event-bolt", EventProcessingBolt.ALARM_DEFINITION_EVENT_STREAM_ID) .allGrouping("event-bolt", EventProcessingBolt.METRIC_SUB_ALARM_EVENT_STREAM_ID) .setNumTasks(config.thresholdingBoltTasks); return builder.createTopology(); }
Example #5
Source File: ReflectionUtilsTest.java From bullet-storm with Apache License 2.0 | 4 votes |
@Test public void testGettingSpoutWithDefaultConstructor() throws Exception { IRichSpout spout = ReflectionUtils.getSpout(CustomIRichSpout.class.getName(), null); Assert.assertTrue(spout instanceof CustomIRichSpout); }
Example #6
Source File: ReflectionUtilsTest.java From bullet-storm with Apache License 2.0 | 4 votes |
@Test public void testGettingSpoutWithArguments() throws Exception { IRichSpout spout = ReflectionUtils.getSpout(TestSpout.class.getName(), Collections.singletonList("foo")); Assert.assertTrue(spout instanceof TestSpout); Assert.assertEquals(((TestSpout) spout).getArgs(), Collections.singletonList("foo")); }
Example #7
Source File: ComponentUtils.java From bullet-storm with Apache License 2.0 | 4 votes |
public static <T extends IRichSpout> T open(Map config, T spout, TopologyContext context, ISpoutOutputCollector emitter) { spout.open(config, context, new SpoutOutputCollector(emitter)); return spout; }
Example #8
Source File: ComponentUtils.java From bullet-storm with Apache License 2.0 | 4 votes |
public static <T extends IRichSpout> T open(Map config, T spout, CustomEmitter emitter) { return open(config, spout, mock(TopologyContext.class), emitter); }
Example #9
Source File: ComponentUtils.java From bullet-storm with Apache License 2.0 | 4 votes |
public static <T extends IRichSpout> T open(T spout, CustomEmitter emitter) { return open(new HashMap<>(), spout, emitter); }
Example #10
Source File: CustomSpoutDeclarer.java From bullet-storm with Apache License 2.0 | 4 votes |
public CustomSpoutDeclarer(String id, IRichSpout spout, Number parallelism) { this.id = id; this.spout = spout; this.parallelism = parallelism; }
Example #11
Source File: CustomTopologyBuilder.java From bullet-storm with Apache License 2.0 | 4 votes |
@Override public SpoutDeclarer setSpout(String id, IRichSpout spout, Number parallelism) throws IllegalArgumentException { CustomSpoutDeclarer declarer = new CustomSpoutDeclarer(id, spout, parallelism); createdSpouts.add(declarer); return declarer; }
Example #12
Source File: TopologyModule.java From monasca-thresh with Apache License 2.0 | 4 votes |
@Provides @Named("metrics") IRichSpout metricSpout() { return metricSpout == null ? new MetricSpout(config.metricSpoutConfig) : metricSpout; }
Example #13
Source File: TopologyModule.java From monasca-thresh with Apache License 2.0 | 4 votes |
@Provides @Named("event") IRichSpout eventSpout() { return eventSpout == null ? new EventSpout(config.eventSpoutConfig, new EventDeserializer()) : eventSpout; }
Example #14
Source File: TestSpout.java From elasticsearch-hadoop with Apache License 2.0 | 4 votes |
public TestSpout(IRichSpout delegate) { this.spout = delegate; DONE_TUPLE = Collections.singletonList(DONE); }
Example #15
Source File: TestSpout.java From elasticsearch-hadoop with Apache License 2.0 | 4 votes |
public TestSpout(IRichSpout delegate) { this.spout = delegate; DONE_TUPLE = Collections.singletonList(DONE); }
Example #16
Source File: SpoutBuilder.java From storm_spring_boot_demo with MIT License | votes |
abstract IRichSpout buildSpout();