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());
}
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());
}
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());
}
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());
}
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);
}
Aggregations