Search in sources :

Example 1 with GetDaemonMetricsResponseProto

use of org.apache.hadoop.hive.llap.daemon.rpc.LlapDaemonProtocolProtos.GetDaemonMetricsResponseProto in project hive by apache.

the class TestLlapDaemonProtocolServerImpl method testGetDaemonMetrics.

@Test(timeout = 10000)
public void testGetDaemonMetrics() throws ServiceException, IOException {
    LlapDaemonConfiguration daemonConf = new LlapDaemonConfiguration();
    int numHandlers = HiveConf.getIntVar(daemonConf, ConfVars.LLAP_DAEMON_RPC_NUM_HANDLERS);
    LlapDaemonExecutorMetrics executorMetrics = LlapDaemonExecutorMetrics.create("LLAP", "SessionId", numHandlers, 1, new int[] { 30, 60, 300 }, 0, 0L, 0);
    LlapProtocolServerImpl server = new LlapProtocolServerImpl(null, numHandlers, null, new AtomicReference<InetSocketAddress>(), new AtomicReference<InetSocketAddress>(), 0, 0, 0, null, executorMetrics);
    executorMetrics.addMetricsFallOffFailedTimeLost(10);
    executorMetrics.addMetricsFallOffKilledTimeLost(11);
    executorMetrics.addMetricsFallOffSuccessTimeLost(12);
    executorMetrics.addMetricsPreemptionTimeLost(13);
    executorMetrics.addMetricsPreemptionTimeToKill(14);
    executorMetrics.incrExecutorTotalExecutionFailed();
    executorMetrics.incrExecutorTotalKilled();
    executorMetrics.incrExecutorTotalRequestsHandled();
    executorMetrics.incrExecutorTotalSuccess();
    executorMetrics.incrTotalEvictedFromWaitQueue();
    executorMetrics.incrTotalRejectedRequests();
    executorMetrics.setCacheMemoryPerInstance(15);
    executorMetrics.setExecutorNumPreemptableRequests(16);
    executorMetrics.setExecutorNumQueuedRequests(17);
    executorMetrics.setJvmMaxMemory(18);
    executorMetrics.setMemoryPerInstance(19);
    executorMetrics.setNumExecutorsAvailable(20);
    executorMetrics.setWaitQueueSize(21);
    try {
        server.init(new Configuration());
        server.start();
        InetSocketAddress serverAddr = server.getManagementBindAddress();
        LlapManagementProtocolPB client = new LlapManagementProtocolClientImpl(new Configuration(), serverAddr.getHostName(), serverAddr.getPort(), null, null);
        GetDaemonMetricsResponseProto responseProto = client.getDaemonMetrics(null, GetDaemonMetricsRequestProto.newBuilder().build());
        Map<String, Long> result = new HashMap<>(responseProto.getMetricsCount());
        responseProto.getMetricsList().forEach(me -> result.put(me.getKey(), me.getValue()));
        assertTrue("Checking ExecutorFallOffFailedTimeLost", result.get("ExecutorFallOffFailedTimeLost") == 10);
        assertTrue("Checking ExecutorFallOffKilledTimeLost", result.get("ExecutorFallOffKilledTimeLost") == 11);
        assertTrue("Checking ExecutorFallOffSuccessTimeLost", result.get("ExecutorFallOffSuccessTimeLost") == 12);
        assertTrue("Checking ExecutorTotalPreemptionTimeLost", result.get("ExecutorTotalPreemptionTimeLost") == 13);
        assertTrue("Checking ExecutorTotalPreemptionTimeToKill", result.get("ExecutorTotalPreemptionTimeToKill") == 14);
        assertTrue("Checking ExecutorTotalFailed", result.get("ExecutorTotalFailed") == 1);
        assertTrue("Checking ExecutorTotalKilled", result.get("ExecutorTotalKilled") == 1);
        assertTrue("Checking ExecutorTotalRequestsHandled", result.get("ExecutorTotalRequestsHandled") == 1);
        assertTrue("Checking ExecutorTotalSuccess", result.get("ExecutorTotalSuccess") == 1);
        assertTrue("Checking ExecutorTotalEvictedFromWaitQueue", result.get("ExecutorTotalEvictedFromWaitQueue") == 1);
        assertTrue("Checking ExecutorTotalRejectedRequests", result.get("ExecutorTotalRejectedRequests") == 1);
        assertTrue("Checking ExecutorCacheMemoryPerInstance", result.get("ExecutorCacheMemoryPerInstance") == 15);
        assertTrue("Checking ExecutorNumPreemptableRequests", result.get("ExecutorNumPreemptableRequests") == 16);
        assertTrue("Checking ExecutorNumQueuedRequests", result.get("ExecutorNumQueuedRequests") == 17);
        assertTrue("Checking ExecutorJvmMaxMemory", result.get("ExecutorJvmMaxMemory") == 18);
        assertTrue("Checking ExecutorMemoryPerInstance", result.get("ExecutorMemoryPerInstance") == 19);
        assertTrue("Checking ExecutorNumExecutorsAvailable", result.get("ExecutorNumExecutorsAvailable") == 20);
        assertTrue("Checking ExecutorWaitQueueSize", result.get("ExecutorWaitQueueSize") == 21);
    } finally {
        server.stop();
    }
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) LlapDaemonConfiguration(org.apache.hadoop.hive.llap.configuration.LlapDaemonConfiguration) LlapDaemonExecutorMetrics(org.apache.hadoop.hive.llap.metrics.LlapDaemonExecutorMetrics) HashMap(java.util.HashMap) InetSocketAddress(java.net.InetSocketAddress) LlapDaemonConfiguration(org.apache.hadoop.hive.llap.configuration.LlapDaemonConfiguration) LlapManagementProtocolPB(org.apache.hadoop.hive.llap.protocol.LlapManagementProtocolPB) GetDaemonMetricsResponseProto(org.apache.hadoop.hive.llap.daemon.rpc.LlapDaemonProtocolProtos.GetDaemonMetricsResponseProto) LlapManagementProtocolClientImpl(org.apache.hadoop.hive.llap.impl.LlapManagementProtocolClientImpl) Test(org.junit.Test)

Aggregations

InetSocketAddress (java.net.InetSocketAddress)1 HashMap (java.util.HashMap)1 Configuration (org.apache.hadoop.conf.Configuration)1 LlapDaemonConfiguration (org.apache.hadoop.hive.llap.configuration.LlapDaemonConfiguration)1 GetDaemonMetricsResponseProto (org.apache.hadoop.hive.llap.daemon.rpc.LlapDaemonProtocolProtos.GetDaemonMetricsResponseProto)1 LlapManagementProtocolClientImpl (org.apache.hadoop.hive.llap.impl.LlapManagementProtocolClientImpl)1 LlapDaemonExecutorMetrics (org.apache.hadoop.hive.llap.metrics.LlapDaemonExecutorMetrics)1 LlapManagementProtocolPB (org.apache.hadoop.hive.llap.protocol.LlapManagementProtocolPB)1 Test (org.junit.Test)1