Search in sources :

Example 26 with LlapServiceInstance

use of org.apache.hadoop.hive.llap.registry.LlapServiceInstance in project hive by apache.

the class TestLlapMetricsCollector method testAddService.

@Test(timeout = DEFAULT_TIMEOUT)
public void testAddService() {
    // Given
    LlapServiceInstance mockService = mock(LlapServiceInstance.class);
    when(mockService.getWorkerIdentity()).thenReturn(TEST_IDENTITY_1);
    assertTrue(collector != null);
    // When
    collector.onCreate(mockService, TEST_SEQ_VERSION);
    collector.collectMetrics();
    // Then
    assertEquals(1, collector.getMetrics().size());
}
Also used : LlapServiceInstance(org.apache.hadoop.hive.llap.registry.LlapServiceInstance) Test(org.junit.Test)

Example 27 with LlapServiceInstance

use of org.apache.hadoop.hive.llap.registry.LlapServiceInstance in project hive by apache.

the class TestLlapMetricsCollector method testCollectOnMultipleInstances.

@Test(timeout = DEFAULT_TIMEOUT)
public void testCollectOnMultipleInstances() {
    // Given
    LlapServiceInstance mockService1 = mock(LlapServiceInstance.class);
    when(mockService1.getWorkerIdentity()).thenReturn(TEST_IDENTITY_1);
    LlapServiceInstance mockService2 = mock(LlapServiceInstance.class);
    when(mockService2.getWorkerIdentity()).thenReturn(TEST_IDENTITY_2);
    // When
    collector.onCreate(mockService1, TEST_SEQ_VERSION);
    collector.onCreate(mockService2, TEST_SEQ_VERSION);
    collector.collectMetrics();
    // Then
    assertEquals(2, collector.getMetrics().size());
}
Also used : LlapServiceInstance(org.apache.hadoop.hive.llap.registry.LlapServiceInstance) Test(org.junit.Test)

Example 28 with LlapServiceInstance

use of org.apache.hadoop.hive.llap.registry.LlapServiceInstance in project hive by apache.

the class TestLlapMetricsCollector method testRemoveService.

@Test(timeout = DEFAULT_TIMEOUT)
public void testRemoveService() {
    // Given
    LlapServiceInstance mockService = mock(LlapServiceInstance.class);
    when(mockService.getWorkerIdentity()).thenReturn(TEST_IDENTITY_1);
    // When
    collector.onCreate(mockService, TEST_SEQ_VERSION);
    collector.collectMetrics();
    collector.onRemove(mockService, TEST_SEQ_VERSION);
    // Then
    assertEquals(0, collector.getMetrics().size());
}
Also used : LlapServiceInstance(org.apache.hadoop.hive.llap.registry.LlapServiceInstance) Test(org.junit.Test)

Example 29 with LlapServiceInstance

use of org.apache.hadoop.hive.llap.registry.LlapServiceInstance in project hive by apache.

the class TestLlapMetricsCollector method testConsumeInitialInstances.

@Test(timeout = DEFAULT_TIMEOUT)
public void testConsumeInitialInstances() throws IOException {
    // Given
    LlapServiceInstance mockService = mock(LlapServiceInstance.class);
    LlapServiceInstanceSet serviceInstances = mock(LlapServiceInstanceSet.class);
    LlapRegistryService mockRegistryService = mock(LlapRegistryService.class);
    when(mockService.getWorkerIdentity()).thenReturn(TEST_IDENTITY_1);
    when(serviceInstances.getAll()).thenReturn(Lists.newArrayList(mockService));
    when(mockRegistryService.getInstances()).thenReturn(serviceInstances);
    // When
    collector.consumeInitialInstances(mockRegistryService);
    collector.collectMetrics();
    // Then
    assertEquals(1, collector.getMetrics().size());
}
Also used : LlapServiceInstance(org.apache.hadoop.hive.llap.registry.LlapServiceInstance) LlapRegistryService(org.apache.hadoop.hive.llap.registry.impl.LlapRegistryService) LlapServiceInstanceSet(org.apache.hadoop.hive.llap.registry.LlapServiceInstanceSet) Test(org.junit.Test)

Example 30 with LlapServiceInstance

use of org.apache.hadoop.hive.llap.registry.LlapServiceInstance in project hive by apache.

the class Utils method getCustomSplitLocationProvider.

@VisibleForTesting
static SplitLocationProvider getCustomSplitLocationProvider(LlapRegistryService serviceRegistry, Logger LOG) throws IOException {
    LOG.info("Using LLAP instance " + serviceRegistry.getApplicationId());
    Collection<LlapServiceInstance> serviceInstances = serviceRegistry.getInstances().getAllInstancesOrdered(true);
    Preconditions.checkArgument(!serviceInstances.isEmpty(), "No running LLAP daemons! Please check LLAP service status and zookeeper configuration");
    ArrayList<String> locations = new ArrayList<>(serviceInstances.size());
    for (LlapServiceInstance serviceInstance : serviceInstances) {
        String executors = serviceInstance.getProperties().get(LlapRegistryService.LLAP_DAEMON_NUM_ENABLED_EXECUTORS);
        if (executors != null && Integer.parseInt(executors) == 0) {
            // If the executors set to 0 we should not consider this location for affinity
            locations.add(null);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Not adding " + serviceInstance.getWorkerIdentity() + " with hostname=" + serviceInstance.getHost() + " since executor number is 0");
            }
        } else {
            locations.add(serviceInstance.getHost());
            if (LOG.isDebugEnabled()) {
                LOG.debug("Adding " + serviceInstance.getWorkerIdentity() + " with hostname=" + serviceInstance.getHost() + " to list for split locations");
            }
        }
    }
    return new HostAffinitySplitLocationProvider(locations);
}
Also used : ArrayList(java.util.ArrayList) LlapServiceInstance(org.apache.hadoop.hive.llap.registry.LlapServiceInstance) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

LlapServiceInstance (org.apache.hadoop.hive.llap.registry.LlapServiceInstance)32 Test (org.junit.Test)11 IOException (java.io.IOException)7 ArrayList (java.util.ArrayList)6 LlapRegistryService (org.apache.hadoop.hive.llap.registry.impl.LlapRegistryService)5 ByteString (com.google.protobuf.ByteString)4 LinkedList (java.util.LinkedList)4 InactiveServiceInstance (org.apache.hadoop.hive.llap.registry.impl.InactiveServiceInstance)4 Resource (org.apache.hadoop.yarn.api.records.Resource)3 HashMap (java.util.HashMap)2 List (java.util.List)2 LlapServiceInstanceSet (org.apache.hadoop.hive.llap.registry.LlapServiceInstanceSet)2 LlapZookeeperRegistryImpl (org.apache.hadoop.hive.llap.registry.impl.LlapZookeeperRegistryImpl)2 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ServiceException (com.google.protobuf.ServiceException)1 InetAddress (java.net.InetAddress)1 InetSocketAddress (java.net.InetSocketAddress)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1