Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-3808

PartitionPlan.getThreads() returning zero value causes batch job not be started

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 9.0.0.Alpha1
    • 8.1.0.Final
    • Batch
    • None
    • Hide

      Create a simple batch application. Define and write a PartitionMapper returning a PartionPlanImpl object, but don't override getThreads method. For example:

      package batchtest;

      import java.util.Properties;

      import javax.batch.api.partition.PartitionMapper;
      import javax.batch.api.partition.PartitionPlan;
      import javax.batch.api.partition.PartitionPlanImpl;
      import javax.enterprise.context.Dependent;
      import javax.inject.Named;

      @Dependent
      @Named("TestPartitionMapper")
      public class TestPartitionMapper implements PartitionMapper {
      @Override
      public PartitionPlan mapPartitions() throws Exception {
      return new PartitionPlanImpl() {
      @Override
      public int getPartitions()

      { return 2; }

      // getThreads() is not overridden
      // Defaults to zero, which means thread count
      // should be equal to partition count

      @Override
      public Properties[] getPartitionProperties()

      { Properties[] props = new Properties[getPartitions()]; props[0] = new Properties(); props[1] = new Properties(); return props; }

      };
      }
      }

      Then try to start the batch job. Number of threads should be equal to number of partitions, but the batch job don't start in WildFly. In GlassFish the batch job is started in 2 threads as expected.

      Show
      Create a simple batch application. Define and write a PartitionMapper returning a PartionPlanImpl object, but don't override getThreads method. For example: package batchtest; import java.util.Properties; import javax.batch.api.partition.PartitionMapper; import javax.batch.api.partition.PartitionPlan; import javax.batch.api.partition.PartitionPlanImpl; import javax.enterprise.context.Dependent; import javax.inject.Named; @Dependent @Named("TestPartitionMapper") public class TestPartitionMapper implements PartitionMapper { @Override public PartitionPlan mapPartitions() throws Exception { return new PartitionPlanImpl() { @Override public int getPartitions() { return 2; } // getThreads() is not overridden // Defaults to zero, which means thread count // should be equal to partition count @Override public Properties[] getPartitionProperties() { Properties[] props = new Properties[getPartitions()]; props[0] = new Properties(); props[1] = new Properties(); return props; } }; } } Then try to start the batch job. Number of threads should be equal to number of partitions, but the batch job don't start in WildFly. In GlassFish the batch job is started in 2 threads as expected.

      If you define a batch job to be divided to multiple partitions and write a PartitionMapper returning a PartitionPlanImpl object but don't override getThreads method, which means getThreads returns zero meaning thread count should be equal to partition count, but the batch job doesn't start.

      See http://docs.oracle.com/javaee/7/api/javax/batch/api/partition/PartitionPlan.html#setThreads(int)

      In GlassFish this works as expected: if getThreads is not overridden (thus returning zero), batch job is started in as many threads as there are partitions.

      See steps to reproduce for further details.

              elguardian@gmail.com Enrique González Martínez (Inactive)
              arialfred Ari Silvan (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: