use of com.codahale.metrics.MetricRegistry in project graylog2-server by Graylog2.
the class KafkaJournalTest method segmentCommittedCleanup.
@Test
public void segmentCommittedCleanup() throws Exception {
final Size segmentSize = Size.kilobytes(1L);
final KafkaJournal journal = new KafkaJournal(journalDirectory, scheduler, segmentSize, Duration.standardHours(1), // never clean by size in this test
Size.petabytes(1L), Duration.standardDays(1), 1_000_000, Duration.standardMinutes(1), 100, new MetricRegistry(), serverStatus);
final File messageJournalDir = new File(journalDirectory, "messagejournal-0");
assertTrue(messageJournalDir.exists());
final int bulkSize = createBulkChunks(journal, segmentSize, 3);
// make sure everything is on disk
journal.flushDirtyLogs();
assertEquals(countSegmentsInDir(messageJournalDir), 3);
// we haven't committed any offsets, this should not touch anything.
final int cleanedLogs = journal.cleanupLogs();
assertEquals(cleanedLogs, 0);
final int numberOfSegments = countSegmentsInDir(messageJournalDir);
assertEquals(numberOfSegments, 3);
// mark first half of first segment committed, should not clean anything
journal.markJournalOffsetCommitted(bulkSize / 2);
assertEquals("should not touch segments", journal.cleanupLogs(), 0);
assertEquals(countSegmentsInDir(messageJournalDir), 3);
journal.markJournalOffsetCommitted(bulkSize + 1);
assertEquals("first segment should've been purged", journal.cleanupLogs(), 1);
assertEquals(countSegmentsInDir(messageJournalDir), 2);
journal.markJournalOffsetCommitted(bulkSize * 4);
assertEquals("only purge one segment, not the active one", journal.cleanupLogs(), 1);
assertEquals(countSegmentsInDir(messageJournalDir), 1);
}
use of com.codahale.metrics.MetricRegistry in project alluxio by Alluxio.
the class AlluxioMasterRestServiceHandler method getMetricsInternal.
private Map<String, Long> getMetricsInternal() {
MetricRegistry metricRegistry = MetricsSystem.METRIC_REGISTRY;
// Get all counters.
Map<String, Counter> counters = metricRegistry.getCounters();
// Only the gauge for pinned files is retrieved here, other gauges are statistics of
// free/used
// spaces, those statistics can be gotten via other REST apis.
String filesPinnedProperty = MetricsSystem.getMasterMetricName(FileSystemMaster.Metrics.FILES_PINNED);
@SuppressWarnings("unchecked") Gauge<Integer> filesPinned = (Gauge<Integer>) MetricsSystem.METRIC_REGISTRY.getGauges().get(filesPinnedProperty);
// Get values of the counters and gauges and put them into a metrics map.
SortedMap<String, Long> metrics = new TreeMap<>();
for (Map.Entry<String, Counter> counter : counters.entrySet()) {
metrics.put(counter.getKey(), counter.getValue().getCount());
}
metrics.put(filesPinnedProperty, filesPinned.getValue().longValue());
return metrics;
}
use of com.codahale.metrics.MetricRegistry in project riposte by Nike-Inc.
the class CodahaleMetricsListenerTest method getMetricRegistry_delegates_to_metricsCollector.
@Test
public void getMetricRegistry_delegates_to_metricsCollector() {
// given
MetricRegistry mrMock = mock(MetricRegistry.class);
doReturn(mrMock).when(cmcMock).getMetricRegistry();
// when
MetricRegistry result = listener.getMetricRegistry();
// then
assertThat(result).isSameAs(mrMock);
}
use of com.codahale.metrics.MetricRegistry in project opennms by OpenNMS.
the class StressCommand method doExecute.
@Override
protected Object doExecute() throws Exception {
// Create the client
final RpcClient<EchoRequest, EchoResponse> client = rpcClientFactory.getClient(EchoRpcModule.INSTANCE);
// Create metrics to capture the results
final MetricRegistry metrics = new MetricRegistry();
final Histogram responseTimes = metrics.histogram("response-times");
final Counter successes = metrics.counter("successes");
final Counter failures = metrics.counter("failures");
// Build and issue the requests
System.out.printf("Executing %d requests.\n", count);
final String message = Strings.repeat("*", messageSize);
final CountDownLatch doneSignal = new CountDownLatch(count);
long beforeExec = System.currentTimeMillis();
for (int i = 0; i < count; i++) {
client.execute(buildRequest(message)).whenComplete((r, e) -> {
if (e != null) {
failures.inc();
} else {
responseTimes.update(System.currentTimeMillis() - r.getId());
successes.inc();
}
doneSignal.countDown();
});
}
long afterExec = System.currentTimeMillis();
// Wait for the responses...
System.out.printf("Waiting for responses.\n");
while (true) {
try {
if (doneSignal.await(1, TimeUnit.SECONDS)) {
// Done!
System.out.printf("\nDone!\n");
break;
}
} catch (InterruptedException e) {
System.out.println("\nInterrupted!");
break;
}
System.out.print(".");
System.out.flush();
}
long afterResponse = System.currentTimeMillis();
System.out.println();
ConsoleReporter reporter = ConsoleReporter.forRegistry(metrics).convertRatesTo(TimeUnit.MILLISECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).build();
reporter.report();
reporter.close();
System.out.printf("Total miliseconds elapsed: %d\n", afterResponse - beforeExec);
System.out.printf("Miliseconds spent generating requests: %d\n", afterExec - beforeExec);
System.out.printf("Miliseconds spent waiting for responses: %d\n", afterResponse - afterExec);
return null;
}
use of com.codahale.metrics.MetricRegistry in project riposte by Nike-Inc.
the class ReporterFactoryInstanceTest method test.
@Test
public void test() {
MetricRegistry registry = new MetricRegistry();
Reporter r = new DefaultConsoleReporterFactory().getReporter(registry);
assertNotNull(r);
r = new DefaultJMXReporterFactory().getReporter(registry);
assertNotNull(r);
r = new DefaultSLF4jReporterFactory().getReporter(registry);
assertNotNull(r);
r = new DefaultGraphiteReporterFactory("test", "fakeurl.com", 4242).getReporter(registry);
assertNotNull(r);
r = new RiposteGraphiteReporterFactory("test", "fakeurl.com", 4242).getReporter(registry);
}
Aggregations