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

x33g5p2x  于2022-01-20 转载在 其他  
字(1.5k)|赞(0)|评价(0)|浏览(148)

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

Gauge.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() {
  String[] tagValue = new String[] { "default" };
  Gauge g = factory.gauge(factory.createId("testHasExpired",
    Collections.singleton(new TestTagFactory(tagValue))));

  Assertions.assertFalse(g.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);
 Gauge g = newGauge("foo");
 Assertions.assertFalse(g.hasExpired());
 g.set(42.0);
 Assertions.assertFalse(g.hasExpired());
 Assertions.assertEquals(g.value(), 42.0, 1e-12);
 // Expires with inactivity
 clock.setWallTime(initTime + fifteenMinutes);
 Assertions.assertFalse(g.hasExpired());
 // Expires with inactivity
 clock.setWallTime(initTime + fifteenMinutes + 1);
 Assertions.assertEquals(g.value(), Double.NaN, 1e-12);
 Assertions.assertTrue(g.hasExpired());
 // Activity brings it back
 g.set(1.0);
 Assertions.assertEquals(g.value(), 1.0, 1e-12);
 Assertions.assertFalse(g.hasExpired());
}

相关文章