@@ -841,19 +841,19 @@ protected String getRole() {
841841 /**
842842 * Returns an {@link Tasks.Submitter} for parallel tasks. The number of
843843 * threads in the thread-pool is set by fs.s3a.committer.threads.
844- * If num-threads is 0, this will a submitter instance which will
845- * declare itself as disabled; this is used in Tasks as a cue
844+ * If num-threads is 0, this will return null;
845+ * this is used in Tasks as a cue
846846 * to switch to single-threaded execution.
847847 *
848848 * @param context the JobContext for this commit
849- * @return a submitter
849+ * @return a submitter or null
850850 */
851851 protected Tasks .Submitter buildSubmitter (
852852 JobContext context ) {
853853 if (getThreadCount (context ) > 0 ) {
854854 return new PoolSubmitter (context );
855855 } else {
856- return new Tasks . DisabledSubmitter () ;
856+ return null ;
857857 }
858858 }
859859
@@ -863,15 +863,14 @@ protected Tasks.Submitter buildSubmitter(
863863 * If num-threads is 0, this will raise an exception.
864864 *
865865 * @param context the JobContext for this commit
866- * @return an {@link ExecutorService} or null for the number of threads
866+ * @param numThreads threads
867+ * @return an {@link ExecutorService} for the number of threads
867868 */
868869 private synchronized ExecutorService buildThreadPool (
869- JobContext context ) {
870-
870+ JobContext context , int numThreads ) {
871+ Preconditions .checkArgument (numThreads > 0 ,
872+ "Cannot create a thread pool with no threads" );
871873 if (threadPool == null ) {
872- int numThreads = getThreadCount (context );
873- Preconditions .checkState (numThreads > 0 ,
874- "Cannot create a thread pool with no threads" );
875874 LOG .debug ("{}: creating thread pool of size {}" , getRole (), numThreads );
876875 threadPool = HadoopExecutors .newFixedThreadPool (numThreads ,
877876 new ThreadFactoryBuilder ()
@@ -906,7 +905,7 @@ private int getThreadCount(final JobContext context) {
906905 private synchronized Future <?> submitRunnable (
907906 final JobContext context ,
908907 final Runnable task ) {
909- return buildThreadPool (context ).submit (task );
908+ return buildThreadPool (context , getThreadCount ( context ) ).submit (task );
910909 }
911910
912911 /**
@@ -917,7 +916,12 @@ private final class PoolSubmitter implements Tasks.Submitter {
917916
918917 private final JobContext context ;
919918
919+ private final int numThreads ;
920+
920921 private PoolSubmitter (final JobContext context ) {
922+ this .numThreads = getThreadCount (context );
923+ Preconditions .checkArgument (numThreads > 0 ,
924+ "Cannot create a thread pool with no threads" );
921925 this .context = context ;
922926 }
923927
@@ -926,10 +930,6 @@ public Future<?> submit(final Runnable task) {
926930 return submitRunnable (context , task );
927931 }
928932
929- @ Override
930- public boolean enabled () {
931- return true ;
932- }
933933 }
934934
935935 /**
@@ -953,13 +953,14 @@ protected void destroyThreadPool() {
953953 }
954954
955955 /**
956- * Get the submitter pool for executing the single file commit/revert
956+ * Get the thread pool for executing the single file commit/revert
957957 * within the commit of all uploads of a single task.
958- *
959- * @return a disabled submitter
958+ * This is currently null; it is here to allow the Tasks class to
959+ * provide the logic for execute/revert.
960+ * @return null. always.
960961 */
961962 protected final synchronized Tasks .Submitter singleThreadSubmitter () {
962- return new Tasks . DisabledSubmitter () ;
963+ return null ;
963964 }
964965
965966 /**
0 commit comments