本文整理了Java中com.netflix.spectator.api.Utils.propagateTypeError()
方法的一些代码示例,展示了Utils.propagateTypeError()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.propagateTypeError()
方法的具体详情如下:
包路径:com.netflix.spectator.api.Utils
类名称:Utils
方法名:propagateTypeError
[英]Propagate a type error exception. Used in situations where an existing id has already been registered but with a different class.
[中]传播类型错误异常。用于现有id已注册但属于不同类别的情况。
代码示例来源:origin: Netflix/spectator
/**
* Provided for backwards compatibility to support the {@link Registry#register(Meter)}
* method. Use the builder created with {@link #using(Registry)} instead.
*
* @deprecated This method only exists to allow for backwards compatibility and should
* be considered an internal detail. Scheduled to be removed in 2.0.
*/
@Deprecated
public static void monitorMeter(Registry registry, Meter meter) {
ConcurrentMap<Id, Object> state = registry.state();
Object c = Utils.computeIfAbsent(state, meter.id(), MeterState::new);
if (!(c instanceof MeterState)) {
Utils.propagateTypeError(registry, meter.id(), MeterState.class, c.getClass());
} else {
MeterState t = (MeterState) c;
t.add(meter);
long delay = registry.config().gaugePollingFrequency().toMillis();
t.schedule(registry, null, delay);
}
}
代码示例来源:origin: com.netflix.spectator/spectator-api
/**
* Provided for backwards compatibility to support the {@link Registry#register(Meter)}
* method. Use the builder created with {@link #using(Registry)} instead.
*
* @deprecated This method only exists to allow for backwards compatibility and should
* be considered an internal detail. Scheduled to be removed in 2.0.
*/
@Deprecated
public static void monitorMeter(Registry registry, Meter meter) {
ConcurrentMap<Id, Object> state = registry.state();
Object c = Utils.computeIfAbsent(state, meter.id(), MeterState::new);
if (!(c instanceof MeterState)) {
Utils.propagateTypeError(registry, meter.id(), MeterState.class, c.getClass());
} else {
MeterState t = (MeterState) c;
t.add(meter);
long delay = registry.config().gaugePollingFrequency().toMillis();
t.schedule(registry, null, delay);
}
}
代码示例来源:origin: Netflix/spectator
/**
* Create a new instance.
*
* @param registry
* Registry to use.
* @param id
* Identifier for the metric being registered.
* @return
* Counter instance.
*/
public static IntervalCounter get(Registry registry, Id id) {
ConcurrentMap<Id, Object> state = registry.state();
Object c = Utils.computeIfAbsent(state, id, i -> new IntervalCounter(registry, i));
if (!(c instanceof IntervalCounter)) {
Utils.propagateTypeError(registry, id, IntervalCounter.class, c.getClass());
c = new IntervalCounter(new NoopRegistry(), id);
}
return (IntervalCounter) c;
}
代码示例来源:origin: com.netflix.spectator/spectator-api
/**
* Create a new instance.
*
* @param registry
* Registry to use.
* @param id
* Identifier for the metric being registered.
* @return
* Counter instance.
*/
public static IntervalCounter get(Registry registry, Id id) {
ConcurrentMap<Id, Object> state = registry.state();
Object c = Utils.computeIfAbsent(state, id, i -> new IntervalCounter(registry, i));
if (!(c instanceof IntervalCounter)) {
Utils.propagateTypeError(registry, id, IntervalCounter.class, c.getClass());
c = new IntervalCounter(new NoopRegistry(), id);
}
return (IntervalCounter) c;
}
代码示例来源:origin: Netflix/spectator
Object c = Utils.computeIfAbsent(state, id, i -> tuple);
if (!(c instanceof ValueState)) {
Utils.propagateTypeError(registry, id, PolledMeter.class, c.getClass());
} else {
ValueState<T> t = (ValueState<T>) c;
代码示例来源:origin: com.netflix.spectator/spectator-api
Object c = Utils.computeIfAbsent(state, id, i -> tuple);
if (!(c instanceof ValueState)) {
Utils.propagateTypeError(registry, id, PolledMeter.class, c.getClass());
} else {
ValueState<T> t = (ValueState<T>) c;
代码示例来源:origin: Netflix/spectator
Object c = Utils.computeIfAbsent(state, id, i -> tuple);
if (!(c instanceof CounterState)) {
Utils.propagateTypeError(registry, id, PolledMeter.class, c.getClass());
} else {
CounterState<T> t = (CounterState<T>) c;
代码示例来源:origin: com.netflix.spectator/spectator-api
Object c = Utils.computeIfAbsent(state, id, i -> tuple);
if (!(c instanceof CounterState)) {
Utils.propagateTypeError(registry, id, PolledMeter.class, c.getClass());
} else {
CounterState<T> t = (CounterState<T>) c;
代码示例来源:origin: com.netflix.spectator/spectator-api
/**
* Creates a timer for tracking long running tasks.
*
* @param registry
* Registry to use.
* @param id
* Identifier for the metric being registered.
* @return
* Timer instance.
*/
public static LongTaskTimer get(Registry registry, Id id) {
ConcurrentMap<Id, Object> state = registry.state();
Object obj = Utils.computeIfAbsent(state, id, i -> {
LongTaskTimer timer = new LongTaskTimer(registry, id);
PolledMeter.using(registry)
.withId(id)
.withTag(Statistic.activeTasks)
.monitorValue(timer, LongTaskTimer::activeTasks);
PolledMeter.using(registry)
.withId(id)
.withTag(Statistic.duration)
.monitorValue(timer, t -> t.duration() / NANOS_PER_SECOND);
return timer;
});
if (!(obj instanceof LongTaskTimer)) {
Utils.propagateTypeError(registry, id, LongTaskTimer.class, obj.getClass());
obj = new LongTaskTimer(new NoopRegistry(), id);
}
return (LongTaskTimer) obj;
}
代码示例来源:origin: Netflix/spectator
/**
* Creates a timer for tracking long running tasks.
*
* @param registry
* Registry to use.
* @param id
* Identifier for the metric being registered.
* @return
* Timer instance.
*/
public static LongTaskTimer get(Registry registry, Id id) {
ConcurrentMap<Id, Object> state = registry.state();
Object obj = Utils.computeIfAbsent(state, id, i -> {
LongTaskTimer timer = new LongTaskTimer(registry, id);
PolledMeter.using(registry)
.withId(id)
.withTag(Statistic.activeTasks)
.monitorValue(timer, LongTaskTimer::activeTasks);
PolledMeter.using(registry)
.withId(id)
.withTag(Statistic.duration)
.monitorValue(timer, t -> t.duration() / NANOS_PER_SECOND);
return timer;
});
if (!(obj instanceof LongTaskTimer)) {
Utils.propagateTypeError(registry, id, LongTaskTimer.class, obj.getClass());
obj = new LongTaskTimer(new NoopRegistry(), id);
}
return (LongTaskTimer) obj;
}
内容来源于网络,如有侵权,请联系作者删除!