diff --git ql/src/java/org/apache/hadoop/hive/ql/exec/tez/Utils.java ql/src/java/org/apache/hadoop/hive/ql/exec/tez/Utils.java index 113aa49..dd1a2d6 100644 --- ql/src/java/org/apache/hadoop/hive/ql/exec/tez/Utils.java +++ ql/src/java/org/apache/hadoop/hive/ql/exec/tez/Utils.java @@ -35,9 +35,9 @@ public static SplitLocationProvider getSplitLocationProvider(Configuration conf, IOException { boolean useCustomLocations = HiveConf.getBoolVar(conf, HiveConf.ConfVars.LLAP_CLIENT_CONSISTENT_SPLITS); - SplitLocationProvider splitLocationProvider; + SplitLocationProvider splitLocationProvider = (useCustomLocations) ? null : getDefaultSplitLocationProvider(); LOG.info("SplitGenerator using llap affinitized locations: " + useCustomLocations); - if (useCustomLocations) { + if (splitLocationProvider == null) { LlapRegistryService serviceRegistry; serviceRegistry = LlapRegistryService.getClient(conf); @@ -51,24 +51,28 @@ public static SplitLocationProvider getSplitLocationProvider(Configuration conf, } 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; - } - }; + if (!locations.isEmpty()) { + splitLocationProvider = new HostAffinitySplitLocationProvider(locations); + } } return splitLocationProvider; } + + private static SplitLocationProvider getDefaultSplitLocationProvider() { + return 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; + } + }; + } }