public SessionGauge(final String ctx, final AtomicLong counter) { this.role = new Role(SESSIONS_PREFIX + ctx, Unit.UNARY); this.counter = counter; }
public JMXAttributeGaugeBase(final ObjectName name, final String attribute, final String role, final Unit unit) { this.name = name; this.attribute = attribute; this.role = new Role(role, unit); }
private static StatusGauge statusGauge(final String prefix, final ConcurrentMap<Integer, StatusGauge> gauges, final int status) { final StatusGauge gauge = gauges.get(status); if (gauge != null) { return gauge; } final StatusGauge newGauge = new StatusGauge(new Role(prefix + "-HTTP-" + Integer.toString(status), Unit.UNARY)); final StatusGauge old = gauges.putIfAbsent(status, newGauge); if (old != null) { return old; } return newGauge; } }
@Override public void contextInitialized(final ServletContextEvent sce) { String contextPath = sce.getServletContext().getContextPath(); if (contextPath == null || contextPath.isEmpty()) { contextPath = "/"; } counter = Repository.INSTANCE.getCounter(new Counter.Key(new Role("session-durations", Unit.Time.NANOSECOND), "session-durations-" + contextPath)); gauge = new SessionGauge(contextPath, sessionNumber); Repository.INSTANCE.addGauge(gauge); }
private Role keyToRole(final String key) { final String[] segments = key.split(cassandra.keySeparator()); return new Role(segments[0], Unit.get(segments[1])); // no need of segments[2] (= marker) }
public CounterGauge(final Counter counter, final MetricData metric) { this.counter = counter; this.metric = metric; this.role = new Role("counter-" + counter.getKey().getRole().getName() + "-" + counter.getKey().getName() + "-" + metric.name(), Unit.UNARY); }
@Override public Collection<? extends LeafCollectorCounter> getCounters(final String marker) { final QueryResult<ColumnSlice<String, String>> qResult = HFactory .createSliceQuery(keyspace, StringSerializer.get(), StringSerializer.get(), StringSerializer.get()) // .setKey(marker) // .setColumnFamily(markerFamily) // .setRange(null, null, false, Integer.MAX_VALUE) // .execute(); final Collection<CassandraLeafCounter> counters = new LinkedList<CassandraLeafCounter>(); if (qResult == null || qResult.get() == null) { return counters; } for (final HColumn<String, String> colum : qResult.get().getColumns()) { final String[] segments = colum.getName().split(cassandra.keySeparator()); final Counter.Key ckey = new Counter.Key(new Role(segments[0], Unit.get(segments[1])), segments[2]); counters.add(findByKey(ckey, marker)); } return counters; }