protected <T extends Serializable> void registerStatistic(String name, StatisticType type, Set<String> tags, Supplier<T> valueSupplier) { StatisticsManager.createPassThroughStatistic(this, name, tags, type, valueSupplier); }
private void registerStatistic(Object context, String name, String observerName, String tag, String propertyKey, ValueStatistic<Number> source) { Map<String, Object> properties = new HashMap<>(); properties.put("discriminator", tag); properties.put(propertyKey, name); StatisticsManager.createPassThroughStatistic(context, observerName, tags(tag, "tier"), properties, source); }
public static <T extends Number> void createPassThroughStatistic(Object context, String name, Set<String> tags, Callable<T> source) { createPassThroughStatistic(context, name, tags, Collections.<String, Object>emptyMap(), source); }
private static void parseStatisticAnnotations(final Object object) { for (final Method m : object.getClass().getMethods()) { Statistic anno = m.getAnnotation(Statistic.class); if (anno != null) { Class<?> returnType = m.getReturnType(); if (m.getParameterTypes().length != 0) { throw new IllegalArgumentException("Statistic methods must be no-arg: " + m); } else if (!Number.class.isAssignableFrom(returnType) && (!m.getReturnType().isPrimitive() || m.getReturnType().equals(Boolean.TYPE))) { throw new IllegalArgumentException("Statistic methods must return a Number: " + m); } else if (Modifier.isStatic(m.getModifiers())) { throw new IllegalArgumentException("Statistic methods must be non-static: " + m); } else { StatisticsManager.createPassThroughStatistic(object, anno.name(), new HashSet<String>(Arrays.asList(anno.tags())), new MethodCallable<Number>(object, m)); } } } }
@Before public void before() { CacheConfiguration<Long, String> cacheConfiguration = CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class, heap(10)) .add(new StoreStatisticsConfiguration(true)) // explicitly enable statistics .build(); cacheManager = CacheManagerBuilder.newCacheManagerBuilder() .withCache("aCache", cacheConfiguration) .build(true); cache = cacheManager.getCache("aCache", Long.class, String.class); StatisticsManager.createPassThroughStatistic(cache, "test", tags(), properties("myproperty=myvalue"), StatisticType.COUNTER, () -> 0); cache.get(1L); }
protected <T extends Serializable> void registerStatistic(String name, StatisticType type, Set<String> tags, Supplier<T> valueSupplier) { StatisticsManager.createPassThroughStatistic(this, name, tags, type, valueSupplier); }
public static <T extends Number> void createPassThroughStatistic(Object context, String name, Set<String> tags, Callable<T> source) { createPassThroughStatistic(context, name, tags, Collections.<String, Object>emptyMap(), source); }
public static <T extends Serializable> void createPassThroughStatistic(Object context, String name, Set<String> tags, ValueStatistic<T> source) { createPassThroughStatistic(context, name, tags, Collections.emptyMap(), source); }
public static <T extends Number> void createPassThroughStatistic(Object context, String name, Set<String> tags, Callable<T> source) { createPassThroughStatistic(context, name, tags, Collections.<String, Object>emptyMap(), source); }
public static <T extends Serializable> void createPassThroughStatistic(Object context, String name, Set<String> tags, StatisticType type, Supplier<T> source) { createPassThroughStatistic(context, name, tags, Collections.emptyMap(), supply(type, source)); }
public static <T extends Serializable> void createPassThroughStatistic(Object context, String name, Set<String> tags, Map<String, ? extends Object> properties, StatisticType type, Supplier<T> source) { createPassThroughStatistic(context, name, tags, properties, supply(type, source)); }
private static void parseStatisticAnnotations(final Object object) { for (final Method m : object.getClass().getMethods()) { Statistic anno = m.getAnnotation(Statistic.class); if (anno != null) { Class<?> returnType = m.getReturnType(); if (m.getParameterTypes().length != 0) { throw new IllegalArgumentException("Statistic methods must be no-arg: " + m); } else if (!Number.class.isAssignableFrom(returnType) && (!m.getReturnType().isPrimitive() || m.getReturnType().equals(Boolean.TYPE))) { throw new IllegalArgumentException("Statistic methods must return a Number: " + m); } else if (Modifier.isStatic(m.getModifiers())) { throw new IllegalArgumentException("Statistic methods must be non-static: " + m); } else { StatisticsManager.createPassThroughStatistic(object, anno.name(), new HashSet<String>(Arrays.asList(anno.tags())), new MethodCallable<Number>(object, m)); } } } }
private static void parseStatisticAnnotations(final Object object) { for (final Method m : object.getClass().getMethods()) { Statistic anno = m.getAnnotation(Statistic.class); if (anno != null) { Class<?> returnType = m.getReturnType(); if (m.getParameterTypes().length != 0) { throw new IllegalArgumentException("Statistic methods must be no-arg: " + m); } else if (!Number.class.isAssignableFrom(returnType) && (!m.getReturnType().isPrimitive() || m.getReturnType().equals(Boolean.TYPE))) { throw new IllegalArgumentException("Statistic methods must return a Number: " + m); } else if (Modifier.isStatic(m.getModifiers())) { throw new IllegalArgumentException("Statistic methods must be non-static: " + m); } else { StatisticsManager.createPassThroughStatistic(object, anno.name(), new HashSet<String>(Arrays.asList(anno.tags())), new MethodCallable<Number>(object, m)); } } } }
private static void parseStatisticAnnotations(final Object object) { for (final Method m : object.getClass().getMethods()) { Statistic anno = m.getAnnotation(Statistic.class); if (anno != null) { Class<?> returnType = m.getReturnType(); if (m.getParameterTypes().length != 0) { throw new IllegalArgumentException("Statistic methods must be no-arg: " + m); } else if (!Number.class.isAssignableFrom(returnType) && (!m.getReturnType().isPrimitive() || m.getReturnType().equals(Boolean.TYPE))) { throw new IllegalArgumentException("Statistic methods must return a Number: " + m); } else if (Modifier.isStatic(m.getModifiers())) { throw new IllegalArgumentException("Statistic methods must be non-static: " + m); } else { StatisticsManager.createPassThroughStatistic(object, anno.name(), new HashSet<>(Arrays.asList(anno.tags())), supply(anno.type(), new ReflectionSupplier<>(object, m))); } } } }