protected internal virtual int CalculateSize(ProcessEngineConfigurationImpl engineConfiguration,
                                                     MigrationBatchConfiguration batchConfiguration)
        {
            double invocationsPerBatchJob = engineConfiguration.InvocationsPerBatchJob;
            double processInstanceCount   = batchConfiguration.Ids.Count;

            return((int)Math.Ceiling(processInstanceCount / invocationsPerBatchJob));
        }
        protected internal virtual BatchEntity CreateBatch(CommandContext commandContext, IMigrationPlan migrationPlan,
                                                           ICollection <string> processInstanceIds, ProcessDefinitionEntity sourceProcessDefinition)
        {
            var processEngineConfiguration = commandContext.ProcessEngineConfiguration;
            var batchJobHandler            = getBatchJobHandler(processEngineConfiguration);

            var configuration = new MigrationBatchConfiguration(new List <string>(processInstanceIds), migrationPlan,
                                                                ExecutionBuilder.SkipCustomListenersRenamed, ExecutionBuilder.SkipIoMappingsRenamed);

            var batch = new BatchEntity();

            batch.Type                   = batchJobHandler.Type;
            batch.TotalJobs              = CalculateSize(processEngineConfiguration, configuration);
            batch.BatchJobsPerSeed       = processEngineConfiguration.BatchJobsPerSeed;
            batch.InvocationsPerBatchJob = processEngineConfiguration.InvocationsPerBatchJob;
            batch.ConfigurationBytes     = batchJobHandler.WriteConfiguration(configuration);
            batch.TenantId               = sourceProcessDefinition.TenantId;
            (commandContext.BatchManager).Add(batch);

            return(batch);
        }