use of com.hazelcast.internal.metrics.Probe in project hazelcast by hazelcast.
the class SourceMetadata method scanFields.
private void scanFields(Class<?> clazz) {
for (Field field : clazz.getDeclaredFields()) {
Probe probe = field.getAnnotation(Probe.class);
if (probe == null) {
continue;
}
FieldProbe fieldProbe = createFieldProbe(field, probe, this);
fields.add(fieldProbe);
}
}
use of com.hazelcast.internal.metrics.Probe in project hazelcast by hazelcast.
the class FieldProbeTest method whenUnknownType.
@Test(expected = IllegalArgumentException.class)
public void whenUnknownType() throws NoSuchFieldException {
UnknownFieldType unknownFieldType = new UnknownFieldType();
Field field = unknownFieldType.getClass().getDeclaredField("field");
Probe probe = field.getAnnotation(Probe.class);
SourceMetadata ignoredSourceMetadata = new SourceMetadata(Object.class);
createFieldProbe(field, probe, ignoredSourceMetadata);
}
use of com.hazelcast.internal.metrics.Probe in project hazelcast by hazelcast.
the class MethodProbeTest method getDouble.
public void getDouble(String fieldName, double expected) throws Exception {
SomeSource source = new SomeSource();
Method method = source.getClass().getDeclaredMethod(fieldName);
Probe probe = method.getAnnotation(Probe.class);
MethodProbe methodProbe = createMethodProbe(method, probe, new SourceMetadata(SomeSource.class));
MethodProbe.DoubleMethodProbe doubleMethodProbe = assertInstanceOf(MethodProbe.DoubleMethodProbe.class, methodProbe);
double value = doubleMethodProbe.get(source);
assertEquals(expected, value, 0.1);
}
use of com.hazelcast.internal.metrics.Probe in project hazelcast by hazelcast.
the class MethodProbeTest method getLong.
public void getLong(String methodName, int expectedValue) throws Exception {
SomeSource source = new SomeSource();
Method method = source.getClass().getDeclaredMethod(methodName);
Probe probe = method.getAnnotation(Probe.class);
MethodProbe methodProbe = createMethodProbe(method, probe, new SourceMetadata(SomeSource.class));
LongMethodProbe longMethodProbe = assertInstanceOf(LongMethodProbe.class, methodProbe);
long value = longMethodProbe.get(source);
assertEquals(expectedValue, value);
}
use of com.hazelcast.internal.metrics.Probe in project hazelcast by hazelcast.
the class SourceMetadata method scanMethods.
private void scanMethods(Class<?> clazz) {
for (Method method : clazz.getDeclaredMethods()) {
Probe probe = method.getAnnotation(Probe.class);
if (probe == null) {
continue;
}
MethodProbe methodProbe = createMethodProbe(method, probe, this);
methods.add(methodProbe);
}
}
Aggregations