deniskuzZ commented on PR #6436:
URL: https://github.com/apache/hive/pull/6436#issuecomment-4259913706

   > @abstractdog , can you please help me in understanding this, I might be 
wrong but won't this work, if we just overload the initSingleton and its 
subsequent methods?
   > 
   > ```
   > diff --git i/common/src/java/org/apache/hadoop/hive/common/JvmMetrics.java 
w/common/src/java/org/apache/hadoop/hive/common/JvmMetrics.java
   > index fa0d285faf..7445bf2617 100644
   > --- i/common/src/java/org/apache/hadoop/hive/common/JvmMetrics.java
   > +++ w/common/src/java/org/apache/hadoop/hive/common/JvmMetrics.java
   > @@ -56,6 +56,13 @@ synchronized JvmMetrics init(String processName, String 
sessionId) {
   >        }
   >        return impl;
   >      }
   > +
   > +    synchronized JvmMetrics init(String processName, String sessionId, 
MetricsSystem ms) {
   > +      if (impl == null) {
   > +        impl = create(processName, sessionId, ms);
   > +      }
   > +      return impl;
   > +    }
   >    }
   >  
   >    static final float M = 1024*1024;
   > @@ -87,6 +94,10 @@ public static JvmMetrics initSingleton(String 
processName, String sessionId) {
   >      return Singleton.INSTANCE.init(processName, sessionId);
   >    }
   >  
   > +  public static JvmMetrics initSingleton(String processName, String 
sessionId, MetricsSystem ms) {
   > +    return Singleton.INSTANCE.init(processName, sessionId, ms);
   > +  }
   > +
   >    @Override
   >    public void getMetrics(MetricsCollector collector, boolean all) {
   >      MetricsRecordBuilder rb = collector.addRecord(JvmMetrics)
   > diff --git 
i/llap-tez/src/java/org/apache/hadoop/hive/llap/tezplugins/metrics/LlapTaskSchedulerMetrics.java
 
w/llap-tez/src/java/org/apache/hadoop/hive/llap/tezplugins/metrics/LlapTaskSchedulerMetrics.java
   > index 7518bae318..1eb9376408 100644
   > --- 
i/llap-tez/src/java/org/apache/hadoop/hive/llap/tezplugins/metrics/LlapTaskSchedulerMetrics.java
   > +++ 
w/llap-tez/src/java/org/apache/hadoop/hive/llap/tezplugins/metrics/LlapTaskSchedulerMetrics.java
   > @@ -113,7 +113,7 @@ public static LlapTaskSchedulerMetrics create(String 
displayName, String metrics
   >        // Using different displayNames within the same JVM can still 
trigger an issue even after fixing HIVE-29566,
   >        // however it has not been observed in practice (including tests).
   >        // This highlights the need to clean up this area.
   > -      JvmMetrics jm = 
JvmMetrics.create(MetricsUtils.METRICS_PROCESS_NAME, metricsSessionId, ms);
   > +      JvmMetrics jm = 
JvmMetrics.initSingleton(MetricsUtils.METRICS_PROCESS_NAME, metricsSessionId, 
ms);
   >        return ms.register(name, "Llap Task Scheduler Metrics",
   >            new LlapTaskSchedulerMetrics(name, jm, metricsSessionId));
   >      });
   > ```
   
   looks ok, but we could reuse now genric signature 
   ````
       synchronized JvmMetrics init(String processName, String sessionId) {
         return init(processName, sessionId, DefaultMetricsSystem.instance());
       }
   
       synchronized JvmMetrics init(String processName, String sessionId, 
MetricsSystem ms) {
         if (impl == null) {
           impl = create(processName, sessionId, ms);
         }
         return impl;
       }
   ````


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to