private SortedMap<KeyExtent,Bulk.Files> computeMappingFromFiles(FileSystem fs, Table.ID tableId, Path dirPath) throws IOException { Executor executor; ExecutorService service = null; if (this.executor != null) { executor = this.executor; } else if (numThreads > 0) { executor = service = Executors.newFixedThreadPool(numThreads); } else { String threads = context.getConfiguration().get(ClientProperty.BULK_LOAD_THREADS.getKey()); executor = service = Executors .newFixedThreadPool(ConfigurationTypeHelper.getNumThreads(threads)); } try { return computeFileToTabletMappings(fs, tableId, dirPath, executor, context); } finally { if (service != null) { service.shutdown(); } } }