@Override public void incr(String scopeName) { countMetric.scope(scopeName).incr(); }
private void fill() { long start = System.nanoTime(); ByteBufferMessageSet msgs = KafkaUtils.fetchMessages(_spoutConfig, _consumer, _partition, _emittedToOffset); long end = System.nanoTime(); long millis = (end - start) / 1000000; _fetchAPILatencyMax.update(millis); _fetchAPILatencyMean.update(millis); _fetchAPICallCount.incr(); int numMessages = countMessages(msgs); _fetchAPIMessageCount.incrBy(numMessages); if (numMessages > 0) { LOG.info("Fetched " + numMessages + " messages from: " + _partition); } for (MessageAndOffset msg : msgs) { _pending.add(_emittedToOffset); _waitingToEmit.add(new MessageAndRealOffset(msg.message(), _emittedToOffset)); _emittedToOffset = msg.nextOffset(); } if (numMessages > 0) { LOG.info("Added " + numMessages + " messages from: " + _partition + " to internal buffers"); } }
@Override public void reportRuleHit(String ruleGroup, short ruleId) { ruleHitCount.scope(Utils.concat(ruleGroup, TENANTID_SEPARATOR, String.valueOf(ruleId))).incr(); }
@Override public void handleRuleNoMatch(OutputCollector eventCollector, Tuple eventContainer, Event inputEvent, Rule rule) { ruleNoHitCount.scope(String.valueOf(rule.getRuleId())).incr(); }
protected void checkCassandraException(Exception e) { _mexceptions.incr(); if (e instanceof AlreadyExistsException || e instanceof AuthenticationException || e instanceof DriverException || e instanceof DriverInternalError || e instanceof InvalidConfigurationInQueryException || e instanceof InvalidQueryException || e instanceof InvalidTypeException || e instanceof QueryExecutionException || e instanceof QueryValidationException || e instanceof ReadTimeoutException || e instanceof SyntaxError || e instanceof TraceRetrievalException || e instanceof TruncateException || e instanceof UnauthorizedException || e instanceof UnavailableException || e instanceof ReadTimeoutException || e instanceof WriteTimeoutException || e instanceof ReadFailureException || e instanceof WriteFailureException || e instanceof FunctionExecutionException) { throw new ReportedFailedException(e); } else { throw new RuntimeException(e); } }
@Override public void handleRuleNoMatch(OutputCollector eventCollector, Tuple eventContainer, Event inputEvent, Rule rule) { ruleNoHitCount.scope(String.valueOf(rule.getRuleId())).incr(); }
@Override public void execute(Tuple input) { String jsonStr = input.getString(0); try { JsonObject json = gson.fromJson(jsonStr, JsonObject.class); try { interceptor.validate(json); collector.emit(input, new Values(gson.toJson(json))); if (sucessMetric != null) { sucessMetric.incr(); } } catch (ValidationException e) { if (failMetric != null) { failMetric.incr(); } StormContextUtil.emitErrorTuple(collector, input, InterceptionBolt.class, jsonStr, e.getMessage(), e); } } catch (Exception e) { if (failMetric != null) { failMetric.incr(); } StormContextUtil.emitErrorTuple(collector, input, InterceptionBolt.class, jsonStr, e.getMessage(), e); } collector.ack(input); }
@Override public void execute(Tuple input) { String jsonStr = input.getString(0); try { JsonObject json = gson.fromJson(jsonStr, JsonObject.class); try { interceptor.validate(json); collector.emit(input, new Values(gson.toJson(json))); if (sucessMetric != null) { sucessMetric.incr(); } } catch (ValidationException e) { if (failMetric != null) { failMetric.incr(); } StormContextUtil.emitErrorTuple(collector, input, InterceptionBolt.class, jsonStr, e.getMessage(), e); } } catch (Exception e) { if (failMetric != null) { failMetric.incr(); } StormContextUtil.emitErrorTuple(collector, input, InterceptionBolt.class, jsonStr, e.getMessage(), e); } collector.ack(input); }
@SuppressWarnings("unchecked") @Override public void execute(Tuple input) { String eventLine = input.getString(0); try { Event event = factory.buildEvent(); Map<String, Object> map = (Map<String, Object>) gson.fromJson(eventLine, type); if (map != null) { event.getHeaders().putAll(map); event.getHeaders().put(Constants.FIELD_TIMESTAMP, ((Double) event.getHeaders().get(timestampKey)).longValue()); event.getHeaders().put(Constants.FIELD_RULE_GROUP, event.getHeaders().get(tenantIdKey)); collector.emit(input, new Values(event)); } else { throw INVALID_JSON; } if (sucessMetric != null) { sucessMetric.incr(); } } catch (Exception e) { // emit error if (failMetric != null) { failMetric.incr(); } StormContextUtil.emitErrorTuple(collector, input, JSONTranslatorBolt.class, "JSON to Map issue", eventLine, e); } collector.ack(input); }
long timestamp) { Alert alert = new Alert(); templateHit.scope(String.valueOf(templateId)).incr(); VelocityAlertTemplate template = templateMap.get(templateId); if (template != null) {
short templateId, long timestamp) { Alert alert = new Alert(); templateHit.scope(String.valueOf(templateId)).incr(); VelocityAlertTemplate template = templateMap.get(templateId); if (template != null) {
protected void aggregate(Tuple tuple) { try { aggregationHit.scope(Utils.separateRuleActionId(tuple.getStringByField(Constants.FIELD_RULE_ACTION_ID)) .getKey().toString()).incr(); engine.aggregate(tuple.getLongByField(Constants.FIELD_TIMESTAMP), tuple.getIntegerByField(Constants.FIELD_AGGREGATION_WINDOW), tuple.getStringByField(Constants.FIELD_RULE_ACTION_ID), tuple.getStringByField(Constants.FIELD_AGGREGATION_KEY), tuple.getStringByField(Constants.FIELD_AGGREGATION_VALUE)); buffer.add(tuple); if (buffer.size() >= bufferSize) { flushAckAndClearBuffer(); } } catch (AggregationRejectException e) { StormContextUtil.emitErrorTuple(collector, tuple, MarkovianAggregationBolt.class, "", "Aggregation rejected", e); collector.ack(tuple); } catch (IOException e) { failAndClearBuffer(); StormContextUtil.emitErrorTuple(collector, tuple, MarkovianAggregationBolt.class, "", "Aggregation flush failed", e); } }
protected void aggregate(Tuple tuple) { try { aggregationHit.scope(Utils.separateRuleActionId(tuple.getStringByField(Constants.FIELD_RULE_ACTION_ID)) .getKey().toString()).incr(); engine.aggregate(tuple.getLongByField(Constants.FIELD_TIMESTAMP), tuple.getIntegerByField(Constants.FIELD_AGGREGATION_WINDOW), tuple.getStringByField(Constants.FIELD_RULE_ACTION_ID), tuple.getStringByField(Constants.FIELD_AGGREGATION_KEY), tuple.getStringByField(Constants.FIELD_AGGREGATION_VALUE)); buffer.add(tuple); if (buffer.size() >= bufferSize) { flushAckAndClearBuffer(); } } catch (AggregationRejectException e) { StormContextUtil.emitErrorTuple(collector, tuple, MarkovianAggregationBolt.class, "", "Aggregation rejected", e); collector.ack(tuple); } catch (IOException e) { failAndClearBuffer(); StormContextUtil.emitErrorTuple(collector, tuple, MarkovianAggregationBolt.class, "", "Aggregation flush failed", e); } }
protected void trackState(Tuple tuple) { try { stateHit.scope(Utils.separateRuleActionId(tuple.getStringByField(Constants.FIELD_RULE_ACTION_ID)) .getKey().toString()).incr(); if (tuple.getBooleanByField(Constants.FIELD_STATE_TRACK)) { logger.fine("State tracking true:" + tuple);
protected void trackState(Tuple tuple) { try { stateHit.scope(Utils.separateRuleActionId(tuple.getStringByField(Constants.FIELD_RULE_ACTION_ID)) .getKey().toString()).incr(); if (tuple.getBooleanByField(Constants.FIELD_STATE_TRACK)) { logger.fine("State tracking true:" + tuple);