org.apache.hadoop.metrics2.annotation.Metrics Java Examples
The following examples show how to use
org.apache.hadoop.metrics2.annotation.Metrics.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MetricsSourceBuilder.java From hadoop with Apache License 2.0 | 5 votes |
private MetricsRegistry initRegistry(Object source) { Class<?> cls = source.getClass(); MetricsRegistry r = null; // Get the registry if it already exists. for (Field field : ReflectionUtils.getDeclaredFieldsIncludingInherited(cls)) { if (field.getType() != MetricsRegistry.class) continue; try { field.setAccessible(true); r = (MetricsRegistry) field.get(source); hasRegistry = r != null; break; } catch (Exception e) { LOG.warn("Error accessing field "+ field, e); continue; } } // Create a new registry according to annotation for (Annotation annotation : cls.getAnnotations()) { if (annotation instanceof Metrics) { Metrics ma = (Metrics) annotation; info = factory.getInfo(cls, ma); if (r == null) { r = new MetricsRegistry(info); } r.setContext(ma.context()); } } if (r == null) return new MetricsRegistry(cls.getSimpleName()); return r; }
Example #2
Source File: MetricsSourceBuilder.java From big-c with Apache License 2.0 | 5 votes |
private MetricsRegistry initRegistry(Object source) { Class<?> cls = source.getClass(); MetricsRegistry r = null; // Get the registry if it already exists. for (Field field : ReflectionUtils.getDeclaredFieldsIncludingInherited(cls)) { if (field.getType() != MetricsRegistry.class) continue; try { field.setAccessible(true); r = (MetricsRegistry) field.get(source); hasRegistry = r != null; break; } catch (Exception e) { LOG.warn("Error accessing field "+ field, e); continue; } } // Create a new registry according to annotation for (Annotation annotation : cls.getAnnotations()) { if (annotation instanceof Metrics) { Metrics ma = (Metrics) annotation; info = factory.getInfo(cls, ma); if (r == null) { r = new MetricsRegistry(info); } r.setContext(ma.context()); } } if (r == null) return new MetricsRegistry(cls.getSimpleName()); return r; }
Example #3
Source File: MutableMetricsFactory.java From hadoop with Apache License 2.0 | 4 votes |
protected MetricsInfo getInfo(Class<?> cls, Metrics annotation) { String name = annotation.name(); String about = annotation.about(); String name2 = name.isEmpty() ? cls.getSimpleName() : name; return Interns.info(name2, about.isEmpty() ? name2 : about); }
Example #4
Source File: MutableMetricsFactory.java From big-c with Apache License 2.0 | 4 votes |
protected MetricsInfo getInfo(Class<?> cls, Metrics annotation) { String name = annotation.name(); String about = annotation.about(); String name2 = name.isEmpty() ? cls.getSimpleName() : name; return Interns.info(name2, about.isEmpty() ? name2 : about); }