Search in sources :

Example 1 with LlapRegistryService

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;
}
Also used : ServiceInstance(org.apache.hadoop.hive.llap.registry.ServiceInstance) LlapRegistryService(org.apache.hadoop.hive.llap.registry.impl.LlapRegistryService) ByteString(com.google.protobuf.ByteString) IOException(java.io.IOException)

Example 2 with LlapRegistryService

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;
}
Also used : ArrayList(java.util.ArrayList) ServiceInstance(org.apache.hadoop.hive.llap.registry.ServiceInstance) SplitLocationProvider(org.apache.hadoop.mapred.split.SplitLocationProvider) LlapRegistryService(org.apache.hadoop.hive.llap.registry.impl.LlapRegistryService) IOException(java.io.IOException) InputSplit(org.apache.hadoop.mapred.InputSplit)

Aggregations

IOException (java.io.IOException)2 ServiceInstance (org.apache.hadoop.hive.llap.registry.ServiceInstance)2 LlapRegistryService (org.apache.hadoop.hive.llap.registry.impl.LlapRegistryService)2 ByteString (com.google.protobuf.ByteString)1 ArrayList (java.util.ArrayList)1 InputSplit (org.apache.hadoop.mapred.InputSplit)1 SplitLocationProvider (org.apache.hadoop.mapred.split.SplitLocationProvider)1