com.netflix.spectator.api.Counter.hasExpired()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(2.6k)|赞(0)|评价(0)|浏览(137)

本文整理了Java中com.netflix.spectator.api.Counter.hasExpired()方法的一些代码示例,展示了Counter.hasExpired()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Counter.hasExpired()方法的具体详情如下:
包路径:com.netflix.spectator.api.Counter
类名称:Counter
方法名:hasExpired

Counter.hasExpired介绍

暂无

代码示例

代码示例来源:origin: Netflix/servo

@Override public boolean hasExpired() {
  return get().hasExpired();
 }
}

代码示例来源:origin: com.netflix.servo/servo-core

@Override public boolean hasExpired() {
  return get().hasExpired();
 }
}

代码示例来源:origin: Netflix/spectator

@Test
public void testHasExpired() {
 CompositeRegistry r = new CompositeRegistry(clock);
 Counter c1 = r.counter("id1");
 Assertions.assertFalse(c1.hasExpired());
 Registry r1 = new DefaultRegistry(clock);
 r.add(r1);
 // depends on registry type, some will be expired until first increment
 Assertions.assertFalse(c1.hasExpired());
 c1.increment();
 Assertions.assertFalse(c1.hasExpired());
}

代码示例来源:origin: Netflix/spectator

@Test
 public void testHasExpired() {
  String[] tagValue = new String[] { "default" };
  Counter c = factory.counter(factory.createId("testHasExpired",
      Collections.singleton(new TestTagFactory(tagValue))));

  Assertions.assertFalse(c.hasExpired());
 }
}

代码示例来源:origin: Netflix/spectator

@Test
public void expiration() {
 final long initTime = TimeUnit.MINUTES.toMillis(30);
 final long fifteenMinutes = TimeUnit.MINUTES.toMillis(15);
 // Not expired on init, wait for activity to mark as active
 clock.setWallTime(initTime);
 Counter c = newCounter("foo");
 Assertions.assertFalse(c.hasExpired());
 c.increment(42);
 Assertions.assertFalse(c.hasExpired());
 // Expires with inactivity, total count in memory is maintained
 clock.setWallTime(initTime + fifteenMinutes);
 Assertions.assertFalse(c.hasExpired());
 // Expires with inactivity, total count in memory is maintained
 clock.setWallTime(initTime + fifteenMinutes + 1);
 Assertions.assertEquals(c.count(), 42);
 Assertions.assertTrue(c.hasExpired());
 // Activity brings it back
 c.increment();
 Assertions.assertEquals(c.count(), 43);
 Assertions.assertFalse(c.hasExpired());
}

代码示例来源:origin: Netflix/spectator

@Test
public void resurrectExpiredAndIncrement() {
 ManualClock clock = new ManualClock();
 ServoRegistry registry = new ServoRegistry(clock);
 Counter c = registry.counter("test");
 clock.setWallTime(60000 * 30);
 registry.getMonitors();
 Assertions.assertTrue(c.hasExpired());
 c.increment();
 Assertions.assertEquals(1, c.count());
 Assertions.assertEquals(1, registry.counter("test").count());
 clock.setWallTime(60000 * 60);
 registry.getMonitors();
 Assertions.assertTrue(c.hasExpired());
 c.increment();
 Assertions.assertEquals(1, c.count());
 Assertions.assertEquals(1, registry.counter("test").count());
}

相关文章