use of org.apache.hadoop.hive.llap.registry.impl.LlapRegistryService in project hive by apache.
the class LlapBaseInputFormat method getServiceInstance.
private ServiceInstance getServiceInstance(JobConf job, LlapInputSplit llapSplit) throws IOException {
LlapRegistryService registryService = LlapRegistryService.getClient(job);
String host = llapSplit.getLocations()[0];
ServiceInstance serviceInstance = getServiceInstanceForHost(registryService, host);
if (serviceInstance == null) {
throw new IOException("No service instances found for " + host + " in registry");
}
return serviceInstance;
}
use of org.apache.hadoop.hive.llap.registry.impl.LlapRegistryService in project hive by apache.
the class Utils method getSplitLocationProvider.
public static SplitLocationProvider getSplitLocationProvider(Configuration conf, Logger LOG) throws IOException {
boolean useCustomLocations = HiveConf.getVar(conf, HiveConf.ConfVars.HIVE_EXECUTION_MODE).equals("llap") && HiveConf.getBoolVar(conf, HiveConf.ConfVars.LLAP_CLIENT_CONSISTENT_SPLITS);
SplitLocationProvider splitLocationProvider;
LOG.info("SplitGenerator using llap affinitized locations: " + useCustomLocations);
if (useCustomLocations) {
LlapRegistryService serviceRegistry = LlapRegistryService.getClient(conf);
LOG.info("Using LLAP instance " + serviceRegistry.getApplicationId());
Collection<ServiceInstance> 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 (ServiceInstance serviceInstance : serviceInstances) {
if (LOG.isDebugEnabled()) {
LOG.debug("Adding " + serviceInstance.getWorkerIdentity() + " with hostname=" + serviceInstance.getHost() + " to list for split locations");
}
locations.add(serviceInstance.getHost());
}
splitLocationProvider = new HostAffinitySplitLocationProvider(locations);
} else {
splitLocationProvider = new SplitLocationProvider() {
@Override
public String[] getLocations(InputSplit split) throws IOException {
if (split == null) {
return null;
}
String[] locations = split.getLocations();
if (locations != null && locations.length == 1) {
if ("localhost".equals(locations[0])) {
return ArrayUtils.EMPTY_STRING_ARRAY;
}
}
return locations;
}
};
}
return splitLocationProvider;
}
Aggregations