Beispiel #1
0
        public override void Execute(IJobHandlerConfiguration configuration, ExecutionEntity execution,
                                     CommandContext commandContext, string tenantId)
        {
            throw new System.NotImplementedException();
            //ResourceEntity configurationEntity = commandContext.Get(typeof(ResourceEntity),
            //    configuration.ConfigurationByteArrayId);

            //var batchConfiguration = readConfiguration(configurationEntity.Bytes);

            //var initialLegacyRestrictions = commandContext.RestrictUserOperationLogToAuthenticatedUsers;
            //commandContext.disableUserOperationLog();
            //commandContext.RestrictUserOperationLogToAuthenticatedUsers = true;
            //try
            //{
            //    commandContext.ProcessEngineConfiguration.RuntimeService.deleteProcessInstances(batchConfiguration.Ids,
            //        batchConfiguration.deleteReason, false, true);
            //}
            //finally
            //{
            //    commandContext.enableUserOperationLog();
            //    commandContext.RestrictUserOperationLogToAuthenticatedUsers = initialLegacyRestrictions;
            //}

            //commandContext.ByteArrayManager.delete(configurationEntity);
        }
        public virtual void Execute(IJobHandlerConfiguration configuration, ExecutionEntity execution,
                                    CommandContext commandContext, string tenantId)
        {
            var         config  = (BatchSeedJobConfiguration)configuration;
            var         batchId = config.BatchId;
            BatchEntity batch   = commandContext.BatchManager.FindBatchById(batchId);

            EnsureUtil.EnsureNotNull("Batch with id '" + batchId + "' cannot be found", "batch", batch);

            IBatchJobHandler batchJobHandler =
                commandContext.ProcessEngineConfiguration.BatchHandlers[batch.Type];

            var done = batchJobHandler.CreateJobs(batch);

            if (!done)
            {
                batch.CreateSeedJob();
            }
            else
            {
                // create monitor job initially without due date to
                // enable rapid completion of simple batches
                batch.CreateMonitorJob(false);
            }
        }
        public virtual void Execute(IJobHandlerConfiguration configuration,
                                    ExecutionEntity execution, CommandContext commandContext, string tenantId)
        {
            var cmd = GetCommand((ProcessDefinitionSuspensionStateConfiguration)configuration);

            cmd.DisableLogUserOperation();
            cmd.Execute(commandContext);
        }
        //protected internal override MigrationBatchConfigurationJsonConverter JsonConverterInstance
        //{
        // get
        // {
        //return MigrationBatchConfigurationJsonConverter.INSTANCE;
        // }
        //}

        protected internal override IJobHandlerConfiguration CreateJobConfiguration(
            IJobHandlerConfiguration configuration, IList <string> processIdsForJob)
        {
            var config = (MigrationBatchConfiguration)configuration;

            return(new MigrationBatchConfiguration(processIdsForJob, config.MigrationPlan,
                                                   config.SkipCustomListeners, config.SkipIoMappings));
        }
        public void Execute(IJobHandlerConfiguration configuration, ExecutionEntity execution, CommandContext commandContext, string tenantId)
        {
            var conf = (HistoryCleanupJobHandlerConfiguration)configuration;
            //find JobEntity
            JobEntity jobEntity = commandContext.JobManager.FindJobByHandlerType(Type);

            bool rescheduled = false;

            if (conf.ImmediatelyDue || (HistoryCleanupHelper.IsBatchWindowConfigured(commandContext) && HistoryCleanupHelper.IsWithinBatchWindow(ClockUtil.CurrentTime, commandContext)))
            {
                //find data to delete
                HistoryCleanupBatch nextBatch = HistoryCleanupHelper.GetNextBatch(commandContext);
                if (nextBatch.Size() >= GetBatchSizeThreshold(commandContext))
                {
                    //delete bunch of data
                    nextBatch.PerformCleanup();

                    //ReSchedule now
                    commandContext.JobManager.ReSchedule(jobEntity, ClockUtil.CurrentTime);
                    rescheduled = true;
                    CancelCountEmptyRuns(conf, jobEntity);
                }
                else
                {
                    //still have something to delete
                    if (nextBatch.Size() > 0)
                    {
                        nextBatch.PerformCleanup();
                    }
                    //not enough data for cleanup was found
                    if (HistoryCleanupHelper.IsWithinBatchWindow(ClockUtil.CurrentTime, commandContext))
                    {
                        //ReSchedule after some delay
                        DateTime nextRunDate = conf.GetNextRunWithDelay(ClockUtil.CurrentTime);
                        if (HistoryCleanupHelper.IsWithinBatchWindow(nextRunDate, commandContext))
                        {
                            commandContext.JobManager.ReSchedule(jobEntity, nextRunDate);
                            rescheduled = true;
                            IncrementCountEmptyRuns(conf, jobEntity);
                        }
                    }
                }
            }
            if (!rescheduled)
            {
                if (HistoryCleanupHelper.IsBatchWindowConfigured(commandContext))
                {
                    ReScheduleRegularCall(commandContext, jobEntity);
                }
                else
                {
                    //nothing more to do, suspend the job
                    SuspendJob(jobEntity);
                }
                CancelCountEmptyRuns(conf, jobEntity);
            }
        }
        public void OnDelete(IJobHandlerConfiguration configuration, JobEntity jobEntity)
        {
            var byteArrayId = ((BatchJobConfiguration)configuration).ConfigurationByteArrayId;

            if (!ReferenceEquals(byteArrayId, null))
            {
                //Context.CommandContext.ByteArrayManager.deleteByteArrayById(byteArrayId);
            }
        }
        protected internal override void PostProcessJob(IJobHandlerConfiguration configuration, JobEntity job)
        {
            var config                    = (MigrationBatchConfiguration)configuration;
            var commandContext            = Context.CommandContext;
            var sourceProcessDefinitionId = config.MigrationPlan.SourceProcessDefinitionId;

            var processDefinition = GetProcessDefinition(commandContext, sourceProcessDefinitionId);

            job.DeploymentId = processDefinition.DeploymentId;
        }
        // protected internal virtual ResourceEntity saveConfiguration(ByteArrayManager byteArrayManager, T jobConfiguration)
        // {
        //ResourceEntity configurationEntity = new ResourceEntity();
        //configurationEntity.Bytes = writeConfiguration(jobConfiguration);
        //byteArrayManager.insert(configurationEntity);
        //return configurationEntity;
        // }

        public virtual byte[] WriteConfiguration(IJobHandlerConfiguration configuration)
        {
            //JSONObject jsonObject = JsonConverterInstance.toJsonObject(configuration);

            var outStream = new MemoryStream();

            //Writer writer = StringUtil.writerForStream(outStream);

            //jsonObject.write(writer);
            //IoUtil.flushSilently(writer);

            return(outStream.ToArray());
        }
        public virtual void Execute(IJobHandlerConfiguration configuration, ExecutionEntity execution,
                                    CommandContext commandContext, string tenantId)
        {
            // lookup subscription:
            //var eventSubscriptionId = configuration.EventSubscriptionId;
            //EventSubscriptionEntity eventSubscription =
            //    commandContext.EventSubscriptionManager.findEventSubscriptionById(eventSubscriptionId);

            //// if event subscription is null, ignore
            //if (eventSubscription != null)
            //{
            //    eventSubscription.eventReceived(null, false);
            //}
        }
        public override void Execute(IJobHandlerConfiguration configuration, ExecutionEntity execution,
                                     CommandContext commandContext, string tenantId)
        {
            var          activityId = ((TimerJobConfiguration)configuration).TimerElementKey;
            ActivityImpl eventSubprocessActivity = execution.ProcessDefinition.FindActivity(activityId) as ActivityImpl;

            if (eventSubprocessActivity != null)
            {
                execution.ExecuteEventHandlerActivity(eventSubprocessActivity);
            }
            else
            {
                throw new ProcessEngineException(
                          "Error while triggering event subprocess using timer start event: cannot find activity with id '" +
                          configuration + "'.");
            }
        }
Beispiel #11
0
        public override void Execute(IJobHandlerConfiguration configuration, ExecutionEntity execution,
                                     CommandContext commandContext, string tenantId)
        {
            DeploymentCache deploymentCache = Context.ProcessEngineConfiguration.DeploymentCache;

            var definitionKey = ((TimerJobConfiguration)configuration).TimerElementKey;
            IProcessDefinition processDefinition =
                deploymentCache.FindDeployedLatestProcessDefinitionByKeyAndTenantId(definitionKey, tenantId);

            try
            {
                StartProcessInstance(commandContext, tenantId, processDefinition);
            }
            catch (System.Exception e)
            {
                throw e;
            }
        }
        public virtual void Execute(IJobHandlerConfiguration configuration, ExecutionEntity execution,
                                    CommandContext commandContext, string tenantId)
        {
            var         conf    = (BatchMonitorJobConfiguration)configuration;
            var         batchId = conf.BatchId;
            BatchEntity batch   = commandContext.BatchManager.FindBatchById(conf.BatchId);

            EnsureUtil.EnsureNotNull("Batch with id '" + batchId + "' cannot be found", "batch", batch);

            bool completed = batch.Completed;

            if (!completed)
            {
                //batch.CreateMonitorJob(true);
            }
            else
            {
                batch.Delete(false);
            }
        }
Beispiel #13
0
        public virtual void Execute(CommandContext commandContext)
        {
            if (ExecutionId != null)
            {
                ExecutionEntity exec = Execution;
                EnsureUtil.EnsureNotNull("Cannot find execution with id '" + ExecutionId + "' referenced from job '" + this + "'", "execution", exec);
            }

            // initialize activity id
            GetActivityId();

            // increment sequence counter before job execution
            IncrementSequenceCounter();

            PreExecute(commandContext);
            IJobHandler jobHandler = JobHandler;
            IJobHandlerConfiguration configuration = JobHandlerConfiguration;

            EnsureUtil.EnsureNotNull("Cannot find job handler '" + JobHandlerType + "' from job '" + this + "'", "jobHandler", jobHandler);
            jobHandler.Execute(configuration, execution, commandContext, TenantId);
            PostExecute(commandContext);
        }
        public override void Execute(IJobHandlerConfiguration _configuration, ExecutionEntity execution,
                                     CommandContext commandContext, string tenantId)
        {
            TimerJobConfiguration configuration = _configuration as TimerJobConfiguration;
            var          activityId             = configuration.TimerElementKey;
            ActivityImpl activity = execution.GetProcessDefinition().FindActivity(activityId) as ActivityImpl;

            EnsureUtil.EnsureNotNull(
                "Error while firing timer: boundary event activity " + configuration + " not found",
                "boundary event activity", activity);

            try
            {
                execution.ExecuteEventHandlerActivity(activity);
            }
            //catch (Exception e)
            //{
            //    throw e;
            //}
            catch (System.Exception e)
            {
                throw new ProcessEngineException("exception during timer execution: " + e.Message, e);
            }
        }
        public virtual void Execute(IJobHandlerConfiguration configuration, ExecutionEntity execution,
                                    CommandContext commandContext, string tenantId)
        {
            var config = (AsyncContinuationConfiguration)configuration;

            LegacyBehavior.RepairMultiInstanceAsyncJob(execution);

            var atomicOperation = FindMatchingAtomicOperation(config.AtomicOperation);

            EnsureUtil.EnsureNotNull("Cannot process job with configuration " + configuration, "atomicOperation",
                                     atomicOperation);

            // reset transition id.
            var transitionId = config.TransitionId;

            if (!ReferenceEquals(transitionId, null))
            {
                IPvmActivity activity   = execution.GetActivity();
                var          transition = (TransitionImpl)activity.FindOutgoingTransition(transitionId);
                execution.Transition = transition;
            }

            Context.CommandInvocationContext.PerformOperation(atomicOperation, execution);
        }
Beispiel #16
0
        public override void Execute(IJobHandlerConfiguration _configuration, ExecutionEntity execution,
                                     CommandContext commandContext, string tenantId)
        {
            TimerJobConfiguration configuration    = _configuration as TimerJobConfiguration;
            var          activityId                = configuration.TimerElementKey;
            ActivityImpl intermediateEventActivity = execution.GetProcessDefinition().FindActivity(activityId) as ActivityImpl;

            EnsureUtil.EnsureNotNull(
                "Error while firing timer: intermediate event activity " + configuration + " not found",
                "intermediateEventActivity", intermediateEventActivity);

            try
            {
                if (activityId.Equals(execution.ActivityId))
                {
                    // Regular Intermediate timer catch
                    execution.Signal("signal", null);
                }
            }
            catch (System.Exception e)
            {
                throw new ProcessEngineException("exception during timer execution: " + e.Message, e);
            }
        }
 protected internal virtual void PostProcessJob(IJobHandlerConfiguration configuration, JobEntity job)
 {
     // do nothing as default
 }
 protected internal abstract IJobHandlerConfiguration CreateJobConfiguration(IJobHandlerConfiguration configuration, IList <string> processIdsForJob);
 public virtual void Execute(IJobHandlerConfiguration configuration, ExecutionEntity execution,
                             CommandContext commandContext, string tenantId)
 {
     throw new NotImplementedException();
 }
 protected internal override IJobHandlerConfiguration CreateJobConfiguration(IJobHandlerConfiguration jobHandlerConfiguration,
                                                                             IList <string> processIdsForJob)
 {
     return(new BatchConfiguration(processIdsForJob));
 }
 public void OnDelete(IJobHandlerConfiguration configuration, JobEntity jobEntity)
 {
 }
 public virtual void OnDelete(IJobHandlerConfiguration configuration, JobEntity jobEntity)
 {
     // do nothing
 }
Beispiel #23
0
 public virtual void Execute(IJobHandlerConfiguration configuration, ExecutionEntity execution,
                             CommandContext commandContext, string tenantId)
 {
     messages.Add(((TweetJobConfiguration)configuration).Message);
     Assert.NotNull(commandContext);
 }
 public abstract void Execute(IJobHandlerConfiguration configuration, ExecutionEntity execution,
                              CommandContext commandContext, string tenantId);
Beispiel #25
0
        //protected internal override DeleteHistoricProcessInstanceBatchConfigurationJsonConverter JsonConverterInstance
        //{
        //    get
        //    {
        //        throw new NotImplementedException();
        //    }
        //}

        protected internal override IJobHandlerConfiguration CreateJobConfiguration(
            IJobHandlerConfiguration configuration, IList <string> processIdsForJob)
        {
            return(new DeleteProcessInstanceBatchConfiguration(processIdsForJob, ((DeleteProcessInstanceBatchConfiguration)configuration).DeleteReason));
        }
 protected internal override IJobHandlerConfiguration CreateJobConfiguration(
     IJobHandlerConfiguration configuration, IList <string> jobIds)
 {
     return(new SetJobRetriesBatchConfiguration(jobIds, ((SetJobRetriesBatchConfiguration)configuration).Retries));
 }