[jira] [Work logged] (HIVE-21846) Create a thread in TezAM which periodically fetches LlapDaemon metrics

2020-06-02 Thread ASF GitHub Bot (Jira)


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

ASF GitHub Bot logged work on HIVE-21846:
-

Author: ASF GitHub Bot
Created on: 02/Jun/20 06:58
Start Date: 02/Jun/20 06:58
Worklog Time Spent: 10m 
  Work Description: asinkovits closed pull request #683:
URL: https://github.com/apache/hive/pull/683


   



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: 439942)
Time Spent: 2h  (was: 1h 50m)

> 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
> Fix For: 4.0.0
>
> Attachments: HIVE-21846.01.patch, HIVE-21846.02.patch, 
> HIVE-21846.03.patch
>
>  Time Spent: 2h
>  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
(v8.3.4#803005)


[jira] [Work logged] (HIVE-21846) Create a thread in TezAM which periodically fetches LlapDaemon metrics

2019-06-26 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot logged work on HIVE-21846:
-

Author: ASF GitHub Bot
Created on: 26/Jun/19 07:09
Start Date: 26/Jun/19 07:09
Worklog Time Spent: 10m 
  Work Description: asinkovits 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_r297512929
 
 

 ##
 File path: 
llap-tez/src/java/org/apache/hadoop/hive/llap/tezplugins/LlapTaskSchedulerService.java
 ##
 @@ -790,6 +794,8 @@ public void run() {
 }
   }, 0, 1L, TimeUnit.MILLISECONDS);
 
+  llapMetricsCollector.start();
 
 Review comment:
   Now this is a bit tricky. I didn't wanted to do a tight coupling between the 
registry and the collector, but I agree that there is a dependency between the 
starts. So I've added the ServiceStateChangeListener to the Collector, and 
subscribed to the state changes of the registry. This way we can ensure, that 
the starts and stops happen in the correct way.
 

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: 267312)
Time Spent: 1h 50m  (was: 1h 40m)

> 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, HIVE-21846.02.patch
>
>  Time Spent: 1h 50m
>  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)


[jira] [Work logged] (HIVE-21846) Create a thread in TezAM which periodically fetches LlapDaemon metrics

2019-06-26 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot logged work on HIVE-21846:
-

Author: ASF GitHub Bot
Created on: 26/Jun/19 07:05
Start Date: 26/Jun/19 07:05
Worklog Time Spent: 10m 
  Work Description: asinkovits 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_r297511592
 
 

 ##
 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 {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(LlapMetricsCollector.class);
+  private static final String THREAD_NAME = 
"LlapTaskSchedulerMetricsCollectorThread";
+  private static final long INITIAL_DELAY_MSEC = 6L;
+
+  private final Configuration conf;
+  private final ScheduledExecutorService scheduledMetricsExecutor;
+  private final LlapManagementProtocolClientImplFactory clientFactory;
+  private final Map llapClients;
+  private final Map 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()) {
+  for (Map.Entry entry : 
llapClients.entrySet()) {
+String identity = entry.getKey();
+LlapManagementProtocolClientImpl client = entry.getValue();
+try {
+  LlapDaemonProtocolProtos.GetDaemonMetricsResponseProto metrics =
+  client.getDaemonMetrics(null,
+  
LlapDaemonProtocolProtos.GetDaemonMetricsRequestProto.newBuilder().build());
+  

[jira] [Work logged] (HIVE-21846) Create a thread in TezAM which periodically fetches LlapDaemon metrics

2019-06-26 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot logged work on HIVE-21846:
-

Author: ASF GitHub Bot
Created on: 26/Jun/19 07:04
Start Date: 26/Jun/19 07:04
Worklog Time Spent: 10m 
  Work Description: asinkovits 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_r297511385
 
 

 ##
 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 {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(LlapMetricsCollector.class);
+  private static final String THREAD_NAME = 
"LlapTaskSchedulerMetricsCollectorThread";
+  private static final long INITIAL_DELAY_MSEC = 6L;
+
+  private final Configuration conf;
+  private final ScheduledExecutorService scheduledMetricsExecutor;
+  private final LlapManagementProtocolClientImplFactory clientFactory;
+  private final Map llapClients;
+  private final Map 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:
   Fixed.
 

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: 267310)
Time 

[jira] [Work logged] (HIVE-21846) Create a thread in TezAM which periodically fetches LlapDaemon metrics

2019-06-26 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot logged work on HIVE-21846:
-

Author: ASF GitHub Bot
Created on: 26/Jun/19 07:03
Start Date: 26/Jun/19 07:03
Worklog Time Spent: 10m 
  Work Description: asinkovits 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_r297511224
 
 

 ##
 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 {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(LlapMetricsCollector.class);
+  private static final String THREAD_NAME = 
"LlapTaskSchedulerMetricsCollectorThread";
+  private static final long INITIAL_DELAY_MSEC = 6L;
+
+  private final Configuration conf;
 
 Review comment:
   Removed.
 

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: 267309)
Time Spent: 1h 20m  (was: 1h 10m)

> 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, HIVE-21846.02.patch
>
>  Time Spent: 1h 20m
>  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)


[jira] [Work logged] (HIVE-21846) Create a thread in TezAM which periodically fetches LlapDaemon metrics

2019-06-26 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot logged work on HIVE-21846:
-

Author: ASF GitHub Bot
Created on: 26/Jun/19 07:03
Start Date: 26/Jun/19 07:03
Worklog Time Spent: 10m 
  Work Description: asinkovits 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_r297511069
 
 

 ##
 File path: common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
 ##
 @@ -4342,6 +4342,9 @@ private static void 
populateLlapDaemonVarsSet(Set llapDaemonVarsSetLocal
 "Number of threads to use in LLAP task plugin client."),
 
LLAP_DAEMON_DOWNLOAD_PERMANENT_FNS("hive.llap.daemon.download.permanent.fns", 
false,
 "Whether LLAP daemon should localize the resources for permanent 
UDFs."),
+
LLAP_TASK_SCHEDULER_AM_COLLECT_DAEMON_METRICS_MS("hive.llap.task.scheduler.am.collect.daemon.metrics",
 "0ms",
+  new TimeValidator(TimeUnit.MILLISECONDS), "Collect llap daemon metrics 
in the AM every given milliseconds." +
 
 Review comment:
   Yes, this makes sense, I've updated the description.
 

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: 267308)
Time Spent: 1h 10m  (was: 1h)

> 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, HIVE-21846.02.patch
>
>  Time Spent: 1h 10m
>  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)


[jira] [Work logged] (HIVE-21846) Create a thread in TezAM which periodically fetches LlapDaemon metrics

2019-06-24 Thread ASF GitHub Bot (JIRA)


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

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_r296798202
 
 

 ##
 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 {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(LlapMetricsCollector.class);
+  private static final String THREAD_NAME = 
"LlapTaskSchedulerMetricsCollectorThread";
+  private static final long INITIAL_DELAY_MSEC = 6L;
+
+  private final Configuration conf;
 
 Review comment:
   This conf is currently used nowhere.
   I would suggest to either make the collector a Configurable (and have a 
getConf()) or to remove the variable.
 

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: 265789)
Time Spent: 50m  (was: 40m)

> 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: 50m
>  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)


[jira] [Work logged] (HIVE-21846) Create a thread in TezAM which periodically fetches LlapDaemon metrics

2019-06-24 Thread ASF GitHub Bot (JIRA)


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

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_r296797083
 
 

 ##
 File path: common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
 ##
 @@ -4342,6 +4342,9 @@ private static void 
populateLlapDaemonVarsSet(Set llapDaemonVarsSetLocal
 "Number of threads to use in LLAP task plugin client."),
 
LLAP_DAEMON_DOWNLOAD_PERMANENT_FNS("hive.llap.daemon.download.permanent.fns", 
false,
 "Whether LLAP daemon should localize the resources for permanent 
UDFs."),
+
LLAP_TASK_SCHEDULER_AM_COLLECT_DAEMON_METRICS_MS("hive.llap.task.scheduler.am.collect.daemon.metrics",
 "0ms",
+  new TimeValidator(TimeUnit.MILLISECONDS), "Collect llap daemon metrics 
in the AM every given milliseconds." +
 
 Review comment:
   Some hint, why these metrics are collected every x milliseconds (reason) 
would be good.
 

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: 265786)
Time Spent: 20m  (was: 10m)

> 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: 20m
>  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)


[jira] [Work logged] (HIVE-21846) Create a thread in TezAM which periodically fetches LlapDaemon metrics

2019-06-24 Thread ASF GitHub Bot (JIRA)


 [ 
https://issues.apache.org/jira/browse/HIVE-21846?focusedWorklogId=265787=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 {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(LlapMetricsCollector.class);
+  private static final String THREAD_NAME = 
"LlapTaskSchedulerMetricsCollectorThread";
+  private static final long INITIAL_DELAY_MSEC = 6L;
+
+  private final Configuration conf;
+  private final ScheduledExecutorService scheduledMetricsExecutor;
+  private final LlapManagementProtocolClientImplFactory clientFactory;
+  private final Map llapClients;
+  private final Map 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 

[jira] [Work logged] (HIVE-21846) Create a thread in TezAM which periodically fetches LlapDaemon metrics

2019-06-24 Thread ASF GitHub Bot (JIRA)


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

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_r296803805
 
 

 ##
 File path: 
llap-tez/src/java/org/apache/hadoop/hive/llap/tezplugins/LlapTaskSchedulerService.java
 ##
 @@ -790,6 +794,8 @@ public void run() {
 }
   }, 0, 1L, TimeUnit.MILLISECONDS);
 
+  llapMetricsCollector.start();
 
 Review comment:
   Should we maybe move the start below the code, adding the collector to the 
registry? Otherwise, the collector doesn't have any LLAP daemons and the first 
scheduler execution is a NOOP
 

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: 265788)
Time Spent: 40m  (was: 0.5h)

> 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: 40m
>  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)


[jira] [Work logged] (HIVE-21846) Create a thread in TezAM which periodically fetches LlapDaemon metrics

2019-06-24 Thread ASF GitHub Bot (JIRA)


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

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_r296801109
 
 

 ##
 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 {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(LlapMetricsCollector.class);
+  private static final String THREAD_NAME = 
"LlapTaskSchedulerMetricsCollectorThread";
+  private static final long INITIAL_DELAY_MSEC = 6L;
+
+  private final Configuration conf;
+  private final ScheduledExecutorService scheduledMetricsExecutor;
+  private final LlapManagementProtocolClientImplFactory clientFactory;
+  private final Map llapClients;
+  private final Map 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()) {
+  for (Map.Entry entry : 
llapClients.entrySet()) {
+String identity = entry.getKey();
+LlapManagementProtocolClientImpl client = entry.getValue();
+try {
+  LlapDaemonProtocolProtos.GetDaemonMetricsResponseProto metrics =
+  client.getDaemonMetrics(null,
+  
LlapDaemonProtocolProtos.GetDaemonMetricsRequestProto.newBuilder().build());
+  

[jira] [Work logged] (HIVE-21846) Create a thread in TezAM which periodically fetches LlapDaemon metrics

2019-06-24 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot logged work on HIVE-21846:
-

Author: ASF GitHub Bot
Created on: 24/Jun/19 09:51
Start Date: 24/Jun/19 09:51
Worklog Time Spent: 10m 
  Work Description: asinkovits 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
 
 
   
 

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: 265635)
Time Spent: 10m
Remaining Estimate: 0h

> 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: 10m
>  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)