• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java DefaultRegistry类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.netflix.spectator.api.DefaultRegistry的典型用法代码示例。如果您正苦于以下问题:Java DefaultRegistry类的具体用法?Java DefaultRegistry怎么用?Java DefaultRegistry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DefaultRegistry类属于com.netflix.spectator.api包,在下文中一共展示了DefaultRegistry类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testAddMeasurementsToTimeSeries

import com.netflix.spectator.api.DefaultRegistry; //导入依赖的package包/类
@Test
public void testAddMeasurementsToTimeSeries() {
  DefaultRegistry testRegistry = new DefaultRegistry(clock);

  long millisA = TimeUnit.MILLISECONDS.convert(1472394975L, TimeUnit.SECONDS);
  long millisB = millisA + 987;
  String timeA = "2016-08-28T14:36:15.000000000Z";
  String timeB = "2016-08-28T14:36:15.987000000Z";
  Meter timerA = testRegistry.timer(idAXY);
  Meter timerB = testRegistry.timer(idBXY);
  Measurement measureAXY = new Measurement(idAXY, millisA, 1);
  Measurement measureBXY = new Measurement(idBXY, millisB, 20.1);

  descriptorRegistrySpy.addExtraTimeSeriesLabel(
      MetricDescriptorCache.INSTANCE_LABEL, INSTANCE_ID);
  
  Assert.assertEquals(
      makeTimeSeries(descriptorA, idAXY, 1, timeA),
      writer.measurementToTimeSeries(descriptorA.getType(), testRegistry, timerA, measureAXY));
  Assert.assertEquals(
      makeTimeSeries(descriptorB, idBXY, 20.1, timeB),
      writer.measurementToTimeSeries(descriptorB.getType(), testRegistry, timerB, measureBXY));
}
 
开发者ID:spinnaker,项目名称:kork,代码行数:24,代码来源:StackdriverWriterTest.java


示例2: basic

import com.netflix.spectator.api.DefaultRegistry; //导入依赖的package包/类
@Test
public void basic() {
  Registry r = new DefaultRegistry();
  BucketDistributionSummary c = BucketDistributionSummary.get(
      r, r.createId("test"), BucketFunctions.latency(4, TimeUnit.SECONDS));

  c.record(TimeUnit.MILLISECONDS.toNanos(3750));
  Assert.assertEquals(1, r.distributionSummaries().count());
  Assert.assertEquals(1, sum(r, "test"));

  c.record(TimeUnit.MILLISECONDS.toNanos(4221));
  Assert.assertEquals(2, r.distributionSummaries().count());
  Assert.assertEquals(2, sum(r, "test"));

  c.record(TimeUnit.MILLISECONDS.toNanos(4221));
  Assert.assertEquals(2, r.distributionSummaries().count());
  Assert.assertEquals(3, sum(r, "test"));
}
 
开发者ID:Netflix,项目名称:spectator,代码行数:19,代码来源:BucketDistributionSummaryTest.java


示例3: basic

import com.netflix.spectator.api.DefaultRegistry; //导入依赖的package包/类
@Test
public void basic() {
  Registry r = new DefaultRegistry();
  BucketTimer t = BucketTimer.get(
      r, r.createId("test"), BucketFunctions.latency(4, TimeUnit.SECONDS));

  t.record(3750, TimeUnit.MILLISECONDS);
  Assert.assertEquals(1, r.timers().count());
  Assert.assertEquals(1, sum(r, "test"));

  t.record(4221, TimeUnit.MILLISECONDS);
  Assert.assertEquals(2, r.timers().count());
  Assert.assertEquals(2, sum(r, "test"));

  t.record(4221, TimeUnit.MILLISECONDS);
  Assert.assertEquals(2, r.timers().count());
  Assert.assertEquals(3, sum(r, "test"));
}
 
开发者ID:Netflix,项目名称:spectator,代码行数:19,代码来源:BucketTimerTest.java


示例4: basic

import com.netflix.spectator.api.DefaultRegistry; //导入依赖的package包/类
@Test
public void basic() {
  Registry r = new DefaultRegistry();
  BucketCounter c = BucketCounter.get(
      r, r.createId("test"), BucketFunctions.latency(4, TimeUnit.SECONDS));

  c.record(TimeUnit.MILLISECONDS.toNanos(3750));
  Assert.assertEquals(1, r.counters().count());
  Assert.assertEquals(1, sum(r, "test"));

  c.record(TimeUnit.MILLISECONDS.toNanos(4221));
  Assert.assertEquals(2, r.counters().count());
  Assert.assertEquals(2, sum(r, "test"));

  c.record(TimeUnit.MILLISECONDS.toNanos(4221));
  Assert.assertEquals(2, r.counters().count());
  Assert.assertEquals(3, sum(r, "test"));
}
 
开发者ID:Netflix,项目名称:spectator,代码行数:19,代码来源:BucketCounterTest.java


示例5: updateNextFixedDelay

import com.netflix.spectator.api.DefaultRegistry; //导入依赖的package包/类
@Test
public void updateNextFixedDelay() {
  ManualClock clock = new ManualClock();
  Registry registry = new DefaultRegistry(clock);
  Counter skipped = registry.counter("skipped");

  Scheduler.Options options = new Scheduler.Options()
      .withFrequency(Scheduler.Policy.FIXED_DELAY, Duration.ofSeconds(10));

  clock.setWallTime(5437L);
  Scheduler.DelayedTask task = new Scheduler.DelayedTask(clock, options, () -> {});
  Assert.assertEquals(5437L, task.getNextExecutionTime());
  Assert.assertEquals(0L, skipped.count());

  clock.setWallTime(12123L);
  task.updateNextExecutionTime(skipped);
  Assert.assertEquals(22123L, task.getNextExecutionTime());
  Assert.assertEquals(0L, skipped.count());

  clock.setWallTime(27000L);
  task.updateNextExecutionTime(skipped);
  Assert.assertEquals(37000L, task.getNextExecutionTime());
  Assert.assertEquals(0L, skipped.count());
}
 
开发者ID:Netflix,项目名称:spectator,代码行数:25,代码来源:SchedulerTest.java


示例6: shutdownStopsThreads

import com.netflix.spectator.api.DefaultRegistry; //导入依赖的package包/类
@Test
public void shutdownStopsThreads() throws Exception {
  Scheduler s = new Scheduler(new DefaultRegistry(), "shutdown", 1);

  // Schedule something to force it to start the threads
  Scheduler.Options opts = new Scheduler.Options()
      .withFrequency(Scheduler.Policy.FIXED_RATE_SKIP_IF_LONG, Duration.ofMillis(10))
      .withStopOnFailure(false);
  ScheduledFuture<?> f = s.schedule(opts, () -> {});
  Assert.assertEquals(1L, numberOfThreads("shutdown"));

  // Shutdown and wait a bit, this gives the thread a chance to restart
  s.shutdown();
  Thread.sleep(300);
  Assert.assertEquals(0L, numberOfThreads("shutdown"));
}
 
开发者ID:Netflix,项目名称:spectator,代码行数:17,代码来源:SchedulerTest.java


示例7: stopOnFailureFalseThrowable

import com.netflix.spectator.api.DefaultRegistry; //导入依赖的package包/类
@Test
public void stopOnFailureFalseThrowable() throws Exception {
  Scheduler s = new Scheduler(new DefaultRegistry(), "test", 1);

  Scheduler.Options opts = new Scheduler.Options()
      .withFrequency(Scheduler.Policy.FIXED_RATE_SKIP_IF_LONG, Duration.ofMillis(10))
      .withStopOnFailure(false);

  final CountDownLatch latch = new CountDownLatch(5);
  ScheduledFuture<?> f = s.schedule(opts, () -> {
    latch.countDown();
    throw new IOError(new RuntimeException("stop"));
  });

  Assert.assertTrue(latch.await(60, TimeUnit.SECONDS));
  Assert.assertFalse(f.isDone());
  s.shutdown();
}
 
开发者ID:Netflix,项目名称:spectator,代码行数:19,代码来源:SchedulerTest.java


示例8: stopOnFailureFalse

import com.netflix.spectator.api.DefaultRegistry; //导入依赖的package包/类
@Test
public void stopOnFailureFalse() throws Exception {
  Scheduler s = new Scheduler(new DefaultRegistry(), "test", 2);

  Scheduler.Options opts = new Scheduler.Options()
      .withFrequency(Scheduler.Policy.FIXED_DELAY, Duration.ofMillis(10))
      .withStopOnFailure(false);

  final CountDownLatch latch = new CountDownLatch(5);
  ScheduledFuture<?> f = s.schedule(opts, () -> {
    latch.countDown();
    throw new RuntimeException("stop");
  });

  Assert.assertTrue(latch.await(60, TimeUnit.SECONDS));
  Assert.assertFalse(f.isDone());
  s.shutdown();
}
 
开发者ID:Netflix,项目名称:spectator,代码行数:19,代码来源:SchedulerTest.java


示例9: stopOnFailureTrue

import com.netflix.spectator.api.DefaultRegistry; //导入依赖的package包/类
@Test
public void stopOnFailureTrue() throws Exception {
  Scheduler s = new Scheduler(new DefaultRegistry(), "test", 2);

  Scheduler.Options opts = new Scheduler.Options()
      .withFrequency(Scheduler.Policy.FIXED_DELAY, Duration.ofMillis(10))
      .withStopOnFailure(true);

  final CountDownLatch latch = new CountDownLatch(1);
  ScheduledFuture<?> f = s.schedule(opts, () -> {
    latch.countDown();
    throw new RuntimeException("stop");
  });

  Assert.assertTrue(latch.await(60, TimeUnit.SECONDS));
  while (!f.isDone()); // This will be an endless loop if broken
  s.shutdown();
}
 
开发者ID:Netflix,项目名称:spectator,代码行数:19,代码来源:SchedulerTest.java


示例10: cancel

import com.netflix.spectator.api.DefaultRegistry; //导入依赖的package包/类
@Test
public void cancel() throws Exception {
  Scheduler s = new Scheduler(new DefaultRegistry(), "test", 2);

  Scheduler.Options opts = new Scheduler.Options()
      .withFrequency(Scheduler.Policy.FIXED_DELAY, Duration.ofMillis(10))
      .withStopOnFailure(false);

  final CountDownLatch latch = new CountDownLatch(1);
  final AtomicReference<ScheduledFuture<?>> ref = new AtomicReference<>();
  ref.set(s.schedule(opts, () -> {
    try {
      while (ref.get() == null);
      ref.get().cancel(true);
      Thread.sleep(600000L);
    } catch (InterruptedException e) {
      latch.countDown();
    }
  }));

  Assert.assertTrue(latch.await(60, TimeUnit.SECONDS));
  Assert.assertTrue(ref.get().isDone());
  s.shutdown();
}
 
开发者ID:Netflix,项目名称:spectator,代码行数:25,代码来源:SchedulerTest.java


示例11: threadsAreReplaced

import com.netflix.spectator.api.DefaultRegistry; //导入依赖的package包/类
@Test
public void threadsAreReplaced() throws Exception {
  Scheduler s = new Scheduler(new DefaultRegistry(), "test", 1);

  Scheduler.Options opts = new Scheduler.Options()
      .withFrequency(Scheduler.Policy.FIXED_DELAY, Duration.ofMillis(10))
      .withStopOnFailure(false);

  final CountDownLatch latch = new CountDownLatch(10);
  s.schedule(opts, () -> {
    latch.countDown();
    Thread.currentThread().interrupt();
  });

  Assert.assertTrue(latch.await(60, TimeUnit.SECONDS));
  s.shutdown();
}
 
开发者ID:Netflix,项目名称:spectator,代码行数:18,代码来源:SchedulerTest.java


示例12: testEncodeCombinedRegistry

import com.netflix.spectator.api.DefaultRegistry; //导入依赖的package包/类
@Test
public void testEncodeCombinedRegistry() {
  // Multiple occurrences of measurements in the same registry
  // (confirm these are handled within the registry itself).
  Measurement measureBXY2 = new Measurement(idBXY, 5, 5.5);
  Meter meterB2 = new TestMeter("ignoreB", measureBXY2);

  DefaultRegistry registry = new DefaultRegistry(clock);
  registry.register(meterB);
  registry.register(meterB2);

  List<TaggedDataPoints> expectedTaggedDataPoints = Arrays.asList(
     new TaggedDataPoints(
           Arrays.asList(new BasicTag("tagA", "X"),
                         new BasicTag("tagB", "Y")),
           Arrays.asList(new DataPoint(clock.wallTime(), 50.5 + 5.5))));

  HashMap<String, MetricValues> expect = new HashMap<>();
  expect.put("idB", new MetricValues("Counter", expectedTaggedDataPoints));

  Assert.assertEquals(expect, controller.encodeRegistry(registry, allowAll));
}
 
开发者ID:Netflix,项目名称:spectator,代码行数:23,代码来源:MetricsControllerTest.java


示例13: readLatency

import com.netflix.spectator.api.DefaultRegistry; //导入依赖的package包/类
@Test
public void readLatency() throws Exception {
  Registry r = new DefaultRegistry(new ManualClock());
  List<JmxConfig> configs = configs();

  JmxData data = timer("keyspace=test,name=ReadLatency,scope=foo,type=ColumnFamily", 0);
  List<Measurement> ms = measure(r, configs, data);
  Assert.assertEquals(7, ms.size());
  Assert.assertEquals(
      50.0e-4,
      Utils.first(ms, "statistic", "percentile_50").value(),
      1e-12);

  data = timer("keyspace=test,name=ReadLatency,scope=foo,type=ColumnFamily", 1);
  ms = measure(r, configs, data);
  Assert.assertEquals(7, ms.size());
  Assert.assertEquals(
      50.01e-4,
      Utils.first(ms, "statistic", "percentile_50").value(),
      1e-12);
}
 
开发者ID:Netflix,项目名称:spectator,代码行数:22,代码来源:CassandraTest.java


示例14: run

import com.netflix.spectator.api.DefaultRegistry; //导入依赖的package包/类
public static Collection<String> run() throws Exception {
  ManualClock clock = new ManualClock();
  clock.setWallTime(1234567890L);
  Registry r = new DefaultRegistry(clock);
  checkDistributionSummary(r);
  checkTimer(r);
  checkLongTaskTimer(r);
  checkCounter(r);
  checkGauge(r);

  // Histogram utilities
  checkBucketCounter(r, "age");
  checkBucketCounter(r, "ageBiasOld");
  checkBucketCounter(r, "latency");
  checkBucketCounter(r, "latencyBiasSlow");
  checkBucketCounter(r, "bytes");
  checkBucketCounter(r, "decimal");
  checkBucketDistributionSummary(r);
  checkBucketTimer(r);
  checkPercentileDistributionSummary(r);
  checkPercentileTimer(r);

  List<String> ms = new ArrayList<>();
  for (Meter meter : r) {
    for (Measurement m : meter.measure()) {
      ms.add(m.toString());
    }
  }
  Collections.sort(ms);
  return ms.stream()
      .filter(s -> !s.contains("non-deterministic"))
      .collect(Collectors.toList());
}
 
开发者ID:brharrington,项目名称:spectator-examples,代码行数:34,代码来源:Main.java


示例15: testMeasurementsToTimeSeries

import com.netflix.spectator.api.DefaultRegistry; //导入依赖的package包/类
@Test
public void testMeasurementsToTimeSeries() throws IOException {
    Measurement measureAXY
        = new Measurement(idAXY, clock.monotonicTime(), 1);
    Measurement measureBXY
        = new Measurement(idBXY, clock.monotonicTime(), 2);

  DefaultRegistry testRegistry = new DefaultRegistry(clock);
  testRegistry.counter(idAXY).increment();
  testRegistry.counter(idBXY).increment(2);

  // Note this writer is still using the mock Monitoring client stub.
  TestableStackdriverWriter spy
      = spy(new TestableStackdriverWriter(writerConfig.build()));

  Meter counterA = testRegistry.counter(idAXY);
  Meter counterB = testRegistry.counter(idBXY);

  doReturn(new TimeSeries()).when(spy).measurementToTimeSeries(
      eq(descriptorA.getType()), eq(testRegistry), eq(counterA), eq(measureAXY));
  doReturn(new TimeSeries()).when(spy).measurementToTimeSeries(
      eq(descriptorB.getType()), eq(testRegistry), eq(counterB), eq(measureBXY));

  // Just testing the call flow produces descriptors since
  // we return empty TimeSeries values.
  spy.registryToTimeSeries(testRegistry);
}
 
开发者ID:spinnaker,项目名称:kork,代码行数:28,代码来源:StackdriverWriterTest.java


示例16: writeRegistryWithSmallRegistry

import com.netflix.spectator.api.DefaultRegistry; //导入依赖的package包/类
@Test
public void writeRegistryWithSmallRegistry() throws IOException {
  TestableStackdriverWriter spy
      = spy(new TestableStackdriverWriter(writerConfig.build()));
  Monitoring.Projects.TimeSeries.Create mockCreateMethod
      = Mockito.mock(Monitoring.Projects.TimeSeries.Create.class);

  DefaultRegistry registry = new DefaultRegistry(clock);
  Counter counterA = registry.counter(idAXY);
  Counter counterB = registry.counter(idBXY);
  counterA.increment(4);
  counterB.increment(10);

  when(timeseriesApi.create(eq("projects/test-project"),
                            any(CreateTimeSeriesRequest.class)))
      .thenReturn(mockCreateMethod);
  when(mockCreateMethod.execute())
      .thenReturn(null);

  spy.writeRegistry(registry);
  verify(mockCreateMethod, times(1)).execute();

  ArgumentCaptor<CreateTimeSeriesRequest> captor
        = ArgumentCaptor.forClass(CreateTimeSeriesRequest.class);
  verify(timeseriesApi, times(1)).create(eq("projects/test-project"),
                                         captor.capture());
    // A, B, timer count and totalTime.
  Assert.assertEquals(4, captor.getValue().getTimeSeries().size());
}
 
开发者ID:spinnaker,项目名称:kork,代码行数:30,代码来源:StackdriverWriterTest.java


示例17: writeRegistryWithTimer

import com.netflix.spectator.api.DefaultRegistry; //导入依赖的package包/类
@Test
public void writeRegistryWithTimer() throws IOException {
  DefaultRegistry testRegistry = new DefaultRegistry(clock);   
  Timer timer = testRegistry.timer(idAXY);
  timer.record(123, TimeUnit.MILLISECONDS);

  // If we get the expected result then we matched the expected descriptors,
  // which means the transforms occurred as expected.
  List<TimeSeries> tsList = writer.registryToTimeSeries(testRegistry);
  Assert.assertEquals(2, tsList.size());
}
 
开发者ID:spinnaker,项目名称:kork,代码行数:12,代码来源:StackdriverWriterTest.java


示例18: testInit

import com.netflix.spectator.api.DefaultRegistry; //导入依赖的package包/类
@Test
public void testInit() {
  Registry r = new DefaultRegistry(clock);
  clock.setWallTime(42 * 1000L);
  Id id = r.createId("test");
  IntervalCounter c = IntervalCounter.get(r, id);
  Assert.assertEquals(0L, c.count());
  Assert.assertEquals(42.0, c.secondsSinceLastUpdate(), EPSILON);
}
 
开发者ID:Netflix,项目名称:spectator,代码行数:10,代码来源:IntervalCounterTest.java


示例19: testInterval

import com.netflix.spectator.api.DefaultRegistry; //导入依赖的package包/类
@Test
public void testInterval() {
  Registry r = new DefaultRegistry(clock);
  Id id = r.createId("test");
  IntervalCounter c = IntervalCounter.get(r, id);
  Assert.assertEquals(c.secondsSinceLastUpdate(), 0.0, EPSILON);
  clock.setWallTime(1000);
  Assert.assertEquals(c.secondsSinceLastUpdate(), 1.0, EPSILON);
  c.increment();
  Assert.assertEquals(c.secondsSinceLastUpdate(), 0.0, EPSILON);
}
 
开发者ID:Netflix,项目名称:spectator,代码行数:12,代码来源:IntervalCounterTest.java


示例20: testIncrement

import com.netflix.spectator.api.DefaultRegistry; //导入依赖的package包/类
@Test
public void testIncrement() {
  Registry r = new DefaultRegistry(clock);
  Id id = r.createId("test");
  Counter c = IntervalCounter.get(r, id);
  Assert.assertEquals(0, c.count());
  c.increment();
  Assert.assertEquals(1, c.count());
  c.increment(41);
  Assert.assertEquals(42, c.count());
}
 
开发者ID:Netflix,项目名称:spectator,代码行数:12,代码来源:IntervalCounterTest.java



注:本文中的com.netflix.spectator.api.DefaultRegistry类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IEditCommandRequest类代码示例发布时间:2022-05-23
下一篇:
Java PublicKeyPacket类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap