Guest User

Untitled

a guest
May 30th, 2018
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. --- a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/metrics/BaseSourceImpl.java
  2. +++ b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/metrics/BaseSourceImpl.java
  3. @@ -45,8 +45,11 @@ public class BaseSourceImpl implements BaseSource, MetricsSource {
  4. INSTANCE;
  5. private boolean inited = false;
  6.  
  7. - synchronized void init(String name) {
  8. - if (inited) return;
  9. + /*
  10. + * @return whether actual initialization is done by this call
  11. + */
  12. + synchronized boolean init(String name) {
  13. + if (inited) return false;
  14. inited = true;
  15. DefaultMetricsSystem.initialize(HBASE_METRICS_SYSTEM_NAME);
  16. JvmMetrics.initSingleton(name, "");
  17. @@ -55,6 +58,7 @@ public class BaseSourceImpl implements BaseSource, MetricsSource {
  18. // doing it here. Once BaseSourceSourceImpl is removed, we should do the initialization of
  19. // these elsewhere.
  20. GlobalMetricRegistriesAdapter.init();
  21. + return true;
  22. }
  23. }
  24.  
  25. @@ -109,10 +113,10 @@ public class BaseSourceImpl implements BaseSource, MetricsSource {
  26. this.metricsJmxContext = metricsJmxContext;
  27.  
  28. metricsRegistry = new DynamicMetricsRegistry(metricsName).setContext(metricsContext);
  29. - DefaultMetricsSystemInitializer.INSTANCE.init(metricsName);
  30. -
  31. - //Register this instance.
  32. - DefaultMetricsSystem.instance().register(metricsJmxContext, metricsDescription, this);
  33. + if (DefaultMetricsSystemInitializer.INSTANCE.init(metricsName)) {
  34. + //Register this instance.
  35. + DefaultMetricsSystem.instance().register(metricsJmxContext, metricsDescription, this);
  36. + }
  37.  
  38. // hbase-metrics module based metrics are registered in the hbase MetricsRegistry.
  39. registry = MetricRegistries.global().create(this.getMetricRegistryInfo());
Advertisement
Add Comment
Please, Sign In to add comment