Search in sources :

Example 1 with LlapServiceInstanceSet

use of org.apache.hadoop.hive.llap.registry.LlapServiceInstanceSet 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 2 with LlapServiceInstanceSet

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

the class GenericUDTFGetSplits method populateLlapDaemonInfos.

private LlapDaemonInfo[] populateLlapDaemonInfos(JobConf job, SplitLocationInfo[] locations) throws IOException {
    LlapRegistryService registryService = LlapRegistryService.getClient(job);
    LlapServiceInstanceSet instanceSet = registryService.getInstances();
    Collection<LlapServiceInstance> llapServiceInstances = null;
    // this means a valid location, see makeLocationHints()
    if (locations.length == 1 && locations[0].getLocation() != null) {
        llapServiceInstances = instanceSet.getByHost(locations[0].getLocation());
    }
    // let's populate them all so that we can fetch data from any of them.
    if (CollectionUtils.isEmpty(llapServiceInstances)) {
        llapServiceInstances = instanceSet.getAll();
    }
    Preconditions.checkState(llapServiceInstances.size() > 0, "Unable to find any of the llap instances in zk registry");
    LlapDaemonInfo[] llapDaemonInfos = new LlapDaemonInfo[llapServiceInstances.size()];
    int count = 0;
    for (LlapServiceInstance inst : llapServiceInstances) {
        LlapDaemonInfo info;
        if (LlapUtil.isCloudDeployment(job)) {
            info = new LlapDaemonInfo(inst.getExternalHostname(), inst.getExternalClientsRpcPort(), inst.getOutputFormatPort());
        } else {
            info = new LlapDaemonInfo(inst.getHost(), inst.getRpcPort(), inst.getOutputFormatPort());
        }
        llapDaemonInfos[count++] = info;
    }
    return llapDaemonInfos;
}
Also used : LlapDaemonInfo(org.apache.hadoop.hive.llap.ext.LlapDaemonInfo) 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) TaskLocationHint(org.apache.tez.dag.api.TaskLocationHint)

Aggregations

LlapServiceInstance (org.apache.hadoop.hive.llap.registry.LlapServiceInstance)2 LlapServiceInstanceSet (org.apache.hadoop.hive.llap.registry.LlapServiceInstanceSet)2 LlapRegistryService (org.apache.hadoop.hive.llap.registry.impl.LlapRegistryService)2 LlapDaemonInfo (org.apache.hadoop.hive.llap.ext.LlapDaemonInfo)1 TaskLocationHint (org.apache.tez.dag.api.TaskLocationHint)1 Test (org.junit.Test)1