@Override public void cleanup() { super.cleanup(); cleaned = true; }
/** * 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 prepare(Map stormConf, TopologyContext context, OutputCollector collector) { super.prepare(stormConf, context, collector); queries = new HashMap<>(); averagingMetric = registerAveragingMetric("foo", context); countMetric = registerAbsoluteCountMetric("bar", context); }
/** * Handles a metadata message for a query. * * @param tuple The metadata tuple. * @return The created {@link Metadata}. */ protected Metadata onMeta(Tuple tuple) { String id = tuple.getString(TopologyConstants.ID_POSITION); Metadata metadata = (Metadata) tuple.getValue(TopologyConstants.METADATA_POSITION); if (metadata == null) { return null; } Metadata.Signal signal = metadata.getSignal(); if (signal == Metadata.Signal.KILL || signal == Metadata.Signal.COMPLETE) { removeQuery(id); log.info("Received {} signal and killed query: {}", signal, id); } return metadata; }
@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); } }
/** * Handles a metadata message for a query. * * @param tuple The metadata tuple. * @return The created {@link Metadata}. */ protected Metadata onMeta(Tuple tuple) { String id = tuple.getString(TopologyConstants.ID_POSITION); Metadata metadata = (Metadata) tuple.getValue(TopologyConstants.METADATA_POSITION); if (metadata == null) { return null; } Metadata.Signal signal = metadata.getSignal(); if (signal == Metadata.Signal.KILL || signal == Metadata.Signal.COMPLETE) { removeQuery(id); log.info("Received {} signal and killed query: {}", signal, id); } return metadata; }
@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); } }
/** * 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); }
@SuppressWarnings("unchecked") @Override public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) { super.prepare(stormConf, context, collector); bufferedMetadata = new HashMap<>(); queries = new HashMap<>(); int preStartDelayTicks = config.getAs(BulletStormConfig.JOIN_BOLT_WINDOW_PRE_START_DELAY_TICKS, Integer.class); preStartBuffer = new RotatingMap<>(preStartDelayTicks); int postFinishBufferTicks = config.getAs(BulletStormConfig.JOIN_BOLT_QUERY_POST_FINISH_BUFFER_TICKS, Integer.class); postFinishBuffer = new RotatingMap<>(postFinishBufferTicks); if (metricsEnabled) { activeQueriesCount = registerAbsoluteCountMetric(TopologyConstants.ACTIVE_QUERIES_METRIC, context); createdQueriesCount = registerAbsoluteCountMetric(TopologyConstants.CREATED_QUERIES_METRIC, context); improperQueriesCount = registerAbsoluteCountMetric(TopologyConstants.IMPROPER_QUERIES_METRIC, context); rateExceededQueries = registerAbsoluteCountMetric(TopologyConstants.RATE_EXCEEDED_QUERIES_METRIC, context); duplicatedQueriesCount = registerAbsoluteCountMetric(TopologyConstants.DUPLICATED_QUERIES_METRIC, context); } }
/** * Registers a metric that averages its values 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 ReducedMetric} that is averaging. */ protected ReducedMetric registerAveragingMetric(String name, TopologyContext context) { return registerMetric(new ReducedMetric(new MeanReducer()), name, context); }
@SuppressWarnings("unchecked") @Override public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) { super.prepare(stormConf, context, collector); bufferedMetadata = new HashMap<>(); queries = new HashMap<>(); int preStartDelayTicks = config.getAs(BulletStormConfig.JOIN_BOLT_WINDOW_PRE_START_DELAY_TICKS, Integer.class); preStartBuffer = new RotatingMap<>(preStartDelayTicks); int postFinishBufferTicks = config.getAs(BulletStormConfig.JOIN_BOLT_QUERY_POST_FINISH_BUFFER_TICKS, Integer.class); postFinishBuffer = new RotatingMap<>(postFinishBufferTicks); if (metricsEnabled) { activeQueriesCount = registerAbsoluteCountMetric(TopologyConstants.ACTIVE_QUERIES_METRIC, context); createdQueriesCount = registerAbsoluteCountMetric(TopologyConstants.CREATED_QUERIES_METRIC, context); improperQueriesCount = registerAbsoluteCountMetric(TopologyConstants.IMPROPER_QUERIES_METRIC, context); rateExceededQueries = registerAbsoluteCountMetric(TopologyConstants.RATE_EXCEEDED_QUERIES_METRIC, context); duplicatedQueriesCount = registerAbsoluteCountMetric(TopologyConstants.DUPLICATED_QUERIES_METRIC, context); } }
/** * Registers a metric that averages its values 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 ReducedMetric} that is averaging. */ protected ReducedMetric registerAveragingMetric(String name, TopologyContext context) { return registerMetric(new ReducedMetric(new MeanReducer()), name, context); }