@SuppressWarnings("unchecked") @Override public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) { this.collector = collector; classifier = new TupleClassifier(); // Enable built in metrics metricsEnabled = config.getAs(BulletStormConfig.TOPOLOGY_METRICS_BUILT_IN_ENABLE, Boolean.class); metricsIntervalMapping = config.getAs(BulletStormConfig.TOPOLOGY_METRICS_BUILT_IN_EMIT_INTERVAL_MAPPING, Map.class); }
/** * Registers a metric that counts values monotonically increasing with the configured interval for it (if any). * * @param name The name of the metric to register. * @param context The {@link TopologyContext} to register the metric for. * @return The registered {@link AbsoluteCountMetric} that is counting. */ protected AbsoluteCountMetric registerAbsoluteCountMetric(String name, TopologyContext context) { return registerMetric(new AbsoluteCountMetric(), name, context); }
/** * Creates an instance of this class with the given non-null config. * * @param config The non-null {@link BulletStormConfig} which is the config for this component. */ public TickSpout(BulletStormConfig config) { super(config); tickInterval = config.getAs(BulletStormConfig.TICK_SPOUT_INTERVAL, Integer.class); }
private static BulletStormConfig oneRecordConfig() { BulletStormConfig config = new BulletStormConfig(); // Set aggregation default size to 1 since most queries here are RAW with filtering and projections. This // makes them isClosedForPartition even if they are not done. immediately. config.set(BulletStormConfig.AGGREGATION_DEFAULT_SIZE, 1); config.validate(); return config; }
@Override public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) { super.prepare(stormConf, context, collector); // Set the record component into the classifier classifier.setRecordComponent(recordComponent); // Set up the stats report intervals statsTickInterval = config.getAs(BulletStormConfig.FILTER_BOLT_STATS_REPORT_TICKS, Integer.class); statsTickCount = 0; // Set up the manager manager = new QueryManager(config); if (metricsEnabled) { averageLatency = registerAveragingMetric(TopologyConstants.LATENCY_METRIC, context); } }
@Override public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) { super.prepare(stormConf, context, collector); queries = new HashMap<>(); averagingMetric = registerAveragingMetric("foo", context); countMetric = registerAbsoluteCountMetric("bar", context); }
@Override public void prepare(Map conf, TopologyContext context, OutputCollector collector) { // Add the Storm Config and the context as is, in case any PubSubs need it. config.set(BulletStormConfig.STORM_CONFIG, conf); config.set(BulletStormConfig.STORM_CONTEXT, context); this.collector = collector; try { this.publisher = createPublisher(); } catch (PubSubException e) { throw new RuntimeException("Cannot create PubSub instance or a Publisher for it.", e); } }
@Override public void open(Map conf, TopologyContext context, SpoutOutputCollector collector) { // Add the Storm Config and the context as is, in case any PubSubs need it. config.set(BulletStormConfig.STORM_CONFIG, conf); config.set(BulletStormConfig.STORM_CONTEXT, context); this.collector = collector; }
private void submitWithSpout(String name, List<String> args, Number parallelism, Number cpu, Number on, Number off) { try { StormUtils.submit(builder, name, args, config, parallelism, cpu, on, off); } catch (Exception ignored) { } }
/** * Adds the given count to the given metric. * * @param metric The {@link AbsoluteCountMetric} to add the count. * @param count The count to add to it. */ protected void updateCount(AbsoluteCountMetric metric, long count) { if (metricsEnabled) { metric.add(count); } }
@Override public void cleanup() { super.cleanup(); cleaned = true; }
private static BulletStormConfig configWithRawMaxAndNoMeta() { BulletStormConfig config = new BulletStormConfig(); config.set(BulletStormConfig.RAW_AGGREGATION_MAX_SIZE, RAW_MAX_SIZE); config.set(BulletStormConfig.RESULT_METADATA_ENABLE, false); config.validate(); return config; }
@Override public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) { super.prepare(stormConf, context, collector); // Set the record component into the classifier classifier.setRecordComponent(recordComponent); // Set up the stats report intervals statsTickInterval = config.getAs(BulletStormConfig.FILTER_BOLT_STATS_REPORT_TICKS, Integer.class); statsTickCount = 0; // Set up the manager manager = new QueryManager(config); if (metricsEnabled) { averageLatency = registerAveragingMetric(TopologyConstants.LATENCY_METRIC, context); } }
@Override public void prepare(Map conf, TopologyContext context, OutputCollector collector) { // Add the Storm Config and the context as is, in case any PubSubs need it. config.set(BulletStormConfig.STORM_CONFIG, conf); config.set(BulletStormConfig.STORM_CONTEXT, context); this.collector = collector; try { this.publisher = createPublisher(); } catch (PubSubException e) { throw new RuntimeException("Cannot create PubSub instance or a Publisher for it.", e); } }
@SuppressWarnings("unchecked") @Override public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) { this.collector = collector; classifier = new TupleClassifier(); // Enable built in metrics metricsEnabled = config.getAs(BulletStormConfig.TOPOLOGY_METRICS_BUILT_IN_ENABLE, Boolean.class); metricsIntervalMapping = config.getAs(BulletStormConfig.TOPOLOGY_METRICS_BUILT_IN_EMIT_INTERVAL_MAPPING, Map.class); }
/** * Registers a metric that counts values monotonically increasing with the configured interval for it (if any). * * @param name The name of the metric to register. * @param context The {@link TopologyContext} to register the metric for. * @return The registered {@link AbsoluteCountMetric} that is counting. */ protected AbsoluteCountMetric registerAbsoluteCountMetric(String name, TopologyContext context) { return registerMetric(new AbsoluteCountMetric(), name, context); }
@Override public void open(Map conf, TopologyContext context, SpoutOutputCollector collector) { // Add the Storm Config and the context as is, in case any PubSubs need it. config.set(BulletStormConfig.STORM_CONFIG, conf); config.set(BulletStormConfig.STORM_CONTEXT, context); this.collector = collector; }
private void submitWithTopology(String recordComponent) { try { StormUtils.submit(config, recordComponent, builder); } catch (Exception ignored) { } }
/** * Creates an instance of this class with the given non-null config. * * @param config The non-null {@link BulletStormConfig} which is the config for this component. */ public TickSpout(BulletStormConfig config) { super(config); tickInterval = config.getAs(BulletStormConfig.TICK_SPOUT_INTERVAL, Integer.class); }
/** * Adds the given count to the given metric. * * @param metric The {@link AbsoluteCountMetric} to add the count. * @param count The count to add to it. */ protected void updateCount(AbsoluteCountMetric metric, long count) { if (metricsEnabled) { metric.add(count); } }