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