public CountMetric scope(String key) { CountMetric val = _value.get(key); if (val == null) { _value.put(key, val = new CountMetric()); } return val; }
public Object getValueAndReset() { Map ret = new HashMap(); for (Map.Entry<String, CountMetric> e : _value.entrySet()) { ret.put(e.getKey(), e.getValue().getValueAndReset()); } return ret; } }
@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 incrBy(String scopeName, int length) { countMetric.scope(scopeName).incrBy(length); }
@SuppressWarnings("unchecked") @Override public List<T> multiGet(List<List<Object>> keys) { try { List<T> values = new ArrayList<T>(); for (List<Object> rowKey : keys) { Statement statement = mapper.retrieve(rowKey); ResultSet results = session.execute(statement); // TODO: Better way to check for empty results besides accessing entire results list Iterator<Row> rowIter = results.iterator(); Row row; if (results != null && rowIter.hasNext() && (row = rowIter.next()) != null) { if (rowIter.hasNext()) { LOG.error("Found non-unique value for key [{}]", rowKey); } else { values.add((T) mapper.getValue(row)); } } else { values.add(null); } } _mreads.incrBy(values.size()); LOG.debug("Retrieving the following keys: {} with values: {}", keys, values); return values; } catch (Exception e) { checkCassandraException(e); throw new IllegalStateException("Impossible to reach this code"); } }
public CountMetric scope(String key) { CountMetric val = _value.get(key); if(val == null) { _value.put(key, val = new CountMetric()); } return val; }
@Override public void handleRuleNoMatch(OutputCollector eventCollector, Tuple eventContainer, Event inputEvent, Rule rule) { ruleNoHitCount.scope(String.valueOf(rule.getRuleId())).incr(); }
public Object getValueAndReset() { Map ret = new HashMap(); for(Map.Entry<String, CountMetric> e : _value.entrySet()) { ret.put(e.getKey(), e.getValue().getValueAndReset()); } return ret; } }
_mwrites.incrBy(statements.size()); } catch (Exception e) { checkCassandraException(e);
public CountMetric scope(String key) { CountMetric val = value.get(key); if (val == null) { value.put(key, val = new CountMetric()); } return val; }
@Override public void reportRuleHit(String ruleGroup, short ruleId) { ruleHitCount.scope(Utils.concat(ruleGroup, TENANTID_SEPARATOR, String.valueOf(ruleId))).incr(); }
public Object getValueAndReset() { Map ret = new HashMap(); for (Map.Entry<String, CountMetric> e : _value.entrySet()) { ret.put(e.getKey(), e.getValue().getValueAndReset()); } return ret; } }
public CountMetric scope(String key) { CountMetric val = _value.get(key); if (val == null) { _value.put(key, val = new CountMetric()); } return val; }
@Override public void handleRuleNoMatch(OutputCollector eventCollector, Tuple eventContainer, Event inputEvent, Rule rule) { ruleNoHitCount.scope(String.valueOf(rule.getRuleId())).incr(); }
public Object getValueAndReset() { Map<String, Object> ret = new HashMap<>(); for (Map.Entry<String, CountMetric> e : value.entrySet()) { ret.put(e.getKey(), e.getValue().getValueAndReset()); } return ret; } }
@SuppressWarnings("rawtypes") public void registerMetrics(Map conf, IMetricsContext context, String mapStateMetricName) { int bucketSize = (Integer) (conf.get(Config.TOPOLOGY_BUILTIN_METRICS_BUCKET_SIZE_SECS)); String metricBaseName = "cassandra/" + mapStateMetricName; _mreads = context.registerMetric(metricBaseName + "/readCount", new CountMetric(), bucketSize); _mwrites = context.registerMetric(metricBaseName + "/writeCount", new CountMetric(), bucketSize); _mexceptions = context.registerMetric(metricBaseName + "/exceptionCount", new CountMetric(), bucketSize); } }
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); } }
public Map getMetricsDataMap() { Map ret = new HashMap(); ret.put(_partition + "/fetchAPILatencyMax", _fetchAPILatencyMax.getValueAndReset()); ret.put(_partition + "/fetchAPILatencyMean", _fetchAPILatencyMean.getValueAndReset()); ret.put(_partition + "/fetchAPICallCount", _fetchAPICallCount.getValueAndReset()); ret.put(_partition + "/fetchAPIMessageCount", _fetchAPIMessageCount.getValueAndReset()); return ret; }