[ 
https://issues.apache.org/jira/browse/HIVE-21846?focusedWorklogId=265787&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-265787
 ]

ASF GitHub Bot logged work on HIVE-21846:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 24/Jun/19 16:17
            Start Date: 24/Jun/19 16:17
    Worklog Time Spent: 10m 
      Work Description: odraese commented on pull request #683: HIVE-21846: 
Create a thread in TezAM which periodically fetches LlapDaemon metrics
URL: https://github.com/apache/hive/pull/683#discussion_r296799724
 
 

 ##########
 File path: 
llap-tez/src/java/org/apache/hadoop/hive/llap/tezplugins/metrics/LlapMetricsCollector.java
 ##########
 @@ -0,0 +1,194 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.llap.tezplugins.metrics;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import com.google.protobuf.ServiceException;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.llap.daemon.rpc.LlapDaemonProtocolProtos;
+import org.apache.hadoop.hive.llap.impl.LlapManagementProtocolClientImpl;
+import org.apache.hadoop.hive.llap.registry.LlapServiceInstance;
+import org.apache.hadoop.hive.registry.ServiceInstanceStateChangeListener;
+import org.apache.hadoop.io.retry.RetryPolicies;
+import org.apache.hadoop.io.retry.RetryPolicy;
+import org.apache.hadoop.net.NetUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.net.SocketFactory;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Collect metrics from the llap daemons in every given milliseconds.
+ */
+public class LlapMetricsCollector implements 
ServiceInstanceStateChangeListener<LlapServiceInstance> {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(LlapMetricsCollector.class);
+  private static final String THREAD_NAME = 
"LlapTaskSchedulerMetricsCollectorThread";
+  private static final long INITIAL_DELAY_MSEC = 60000L;
+
+  private final Configuration conf;
+  private final ScheduledExecutorService scheduledMetricsExecutor;
+  private final LlapManagementProtocolClientImplFactory clientFactory;
+  private final Map<String, LlapManagementProtocolClientImpl> llapClients;
+  private final Map<String, LlapMetrics> instanceStatisticsMap;
+  private final long metricsCollectionMs;
+
+
+  public LlapMetricsCollector(Configuration conf) {
+    this(
+            conf,
+            Executors.newSingleThreadScheduledExecutor(
+                    new 
ThreadFactoryBuilder().setDaemon(true).setNameFormat(THREAD_NAME)
+                            .build()),
+            LlapManagementProtocolClientImplFactory.basicInstance(conf));
+  }
+
+  @VisibleForTesting
+  LlapMetricsCollector(Configuration conf, ScheduledExecutorService 
scheduledMetricsExecutor,
+                       LlapManagementProtocolClientImplFactory clientFactory) {
+    this.conf = conf;
+    this.scheduledMetricsExecutor = scheduledMetricsExecutor;
+    this.clientFactory = clientFactory;
+    this.llapClients = new HashMap<>();
+    this.instanceStatisticsMap = new ConcurrentHashMap<>();
+    this.metricsCollectionMs = HiveConf.getTimeVar(conf,
+            
HiveConf.ConfVars.LLAP_TASK_SCHEDULER_AM_COLLECT_DAEMON_METRICS_MS, 
TimeUnit.MILLISECONDS);
+  }
+
+  public void start() {
+    if (enabled()) {
+      scheduledMetricsExecutor.scheduleAtFixedRate(() -> {
+        collectMetrics();
+      }, INITIAL_DELAY_MSEC, metricsCollectionMs, TimeUnit.MILLISECONDS);
+    }
+  }
+
+  private boolean enabled() {
+    return metricsCollectionMs > 0;
+  }
+
+  public void shutdown() {
+    scheduledMetricsExecutor.shutdownNow();
+  }
+
+  @VisibleForTesting
+  void collectMetrics() {
+    if (enabled()) {
 
 Review comment:
   Unnecessary check: The thread, calling collectMetrics is never created if ms 
<= 0.
 
----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 265787)
    Time Spent: 0.5h  (was: 20m)

> Create a thread in TezAM which periodically fetches LlapDaemon metrics
> ----------------------------------------------------------------------
>
>                 Key: HIVE-21846
>                 URL: https://issues.apache.org/jira/browse/HIVE-21846
>             Project: Hive
>          Issue Type: Sub-task
>          Components: llap, Tez
>            Reporter: Peter Vary
>            Assignee: Antal Sinkovits
>            Priority: Major
>              Labels: pull-request-available
>         Attachments: HIVE-21846.01.patch
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> LlapTaskSchedulerService should start a thread which periodically fetches the 
> LlapDaemon metrics and stores them in the NodeInfo object.
> This should be just the first implementation - later we should find a way 
> where we do not need NxM requests between N TezAM and M LlapDaemon



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to