コード例 #1
0
ファイル: JobEntity.cs プロジェクト: zf321/ESS.FW.Bpm
 protected internal virtual void EnsureJobDefinitionInitialized()
 {
     if (jobDefinition == null && JobDefinitionId != null)
     {
         jobDefinition = context.Impl.Context.CommandContext.JobDefinitionManager.FindById(JobDefinitionId);//.FindById(jobDefinitionId);
     }
 }
コード例 #2
0
        public virtual void testSetOverridingPriority()
        {
            // given a job definition
            IJobDefinition jobDefinition = managementService.CreateJobDefinitionQuery().First();

            // when I set a job priority
            managementService.SetOverridingJobPriorityForJobDefinition(jobDefinition.Id, 42);

            // then an op log entry is written
            IUserOperationLogEntry userOperationLogEntry = historyService.CreateUserOperationLogQuery().First();

            Assert.NotNull(userOperationLogEntry);

            Assert.AreEqual(EntityTypes.JobDefinition, userOperationLogEntry.EntityType);
            Assert.AreEqual(jobDefinition.Id, userOperationLogEntry.JobDefinitionId);

            Assert.AreEqual(UserOperationLogEntryFields.OperationTypeSetPriority, userOperationLogEntry.OperationType);

            Assert.AreEqual("overridingPriority", userOperationLogEntry.Property);
            Assert.AreEqual("42", userOperationLogEntry.NewValue);
            Assert.AreEqual(null, userOperationLogEntry.OrgValue);

            Assert.AreEqual(USER_ID, userOperationLogEntry.UserId);

            Assert.AreEqual(jobDefinition.ProcessDefinitionId, userOperationLogEntry.ProcessDefinitionId);
            Assert.AreEqual(jobDefinition.ProcessDefinitionKey, userOperationLogEntry.ProcessDefinitionKey);
            Assert.AreEqual(DeploymentId, userOperationLogEntry.DeploymentId);
        }
コード例 #3
0
    protected HelixTestBase(string helixType) : base()
    {
        var helixSource = GetEnvironmentVariable("MONO_HELIX_SOURCE");

        if (helixSource.StartsWith("pr/"))
        {
            // workaround for https://github.com/dotnet/arcade/issues/1392
            var storage      = new Storage((HelixApi)_api);
            var anonymousApi = ApiFactory.GetAnonymous();
            typeof(HelixApi).GetProperty("Storage").SetValue(anonymousApi, storage, null);
            _api = anonymousApi;
        }

        var build = _api.Job.Define()
                    .WithSource(helixSource)
                    .WithType(helixType)
                    .WithBuild(GetEnvironmentVariable("MONO_HELIX_BUILD_MONIKER"));

        _job = build
               .WithTargetQueue(GetEnvironmentVariable("MONO_HELIX_TARGET_QUEUE"))
               .WithCreator(GetEnvironmentVariable("MONO_HELIX_CREATOR"))
               .WithCorrelationPayloadDirectory(GetEnvironmentVariable("MONO_HELIX_TEST_PAYLOAD_DIRECTORY"))
               .WithCorrelationPayloadFiles(GetEnvironmentVariable("MONO_HELIX_XUNIT_REPORTER_PATH"))
               // these are well-known properties used by Mission Control
               .WithProperty("architecture", GetEnvironmentVariable("MONO_HELIX_ARCHITECTURE"))
               .WithProperty("operatingSystem", GetEnvironmentVariable("MONO_HELIX_OPERATINGSYSTEM"));
    }
コード例 #4
0
        private IJobDefinition AddCorrelationPayload(IJobDefinition def, ITaskItem correlationPayload)
        {
            string path = correlationPayload.GetMetadata("FullPath");
            string uri  = correlationPayload.GetMetadata("Uri");

            if (!string.IsNullOrEmpty(uri))
            {
                Log.LogMessage(MessageImportance.Low, $"Adding Correlation Payload URI '{uri}'");
                return(def.WithCorrelationPayloadUris(new Uri(uri)));
            }

            if (Directory.Exists(path))
            {
                string includeDirectoryNameStr = correlationPayload.GetMetadata("IncludeDirectoryName");
                bool.TryParse(includeDirectoryNameStr, out bool includeDirectoryName);

                Log.LogMessage(MessageImportance.Low, $"Adding Correlation Payload Directory '{path}'");
                return(def.WithCorrelationPayloadDirectory(path, includeDirectoryName));
            }

            if (File.Exists(path))
            {
                Log.LogMessage(MessageImportance.Low, $"Adding Correlation Payload Archive '{path}'");
                return(def.WithCorrelationPayloadArchive(path));
            }

            Log.LogError($"Correlation Payload '{path}' not found.");
            return(def);
        }
コード例 #5
0
        public virtual void testClearOverridingPriority()
        {
            // given a job definition
            IJobDefinition jobDefinition = managementService.CreateJobDefinitionQuery().First();

            // with an overriding priority
            ClockUtil.CurrentTime = DateTime.Now;    // new DateTime(DateTimeHelperClass.CurrentUnixTimeMillis());
            managementService.SetOverridingJobPriorityForJobDefinition(jobDefinition.Id, 42);

            // when I clear that priority
            ClockUtil.CurrentTime = DateTime.Now;    // new DateTime(DateTimeHelperClass.CurrentUnixTimeMillis() + 10000);
            managementService.ClearOverridingJobPriorityForJobDefinition(jobDefinition.Id);

            // then this is accessible via the op log
            IUserOperationLogEntry userOperationLogEntry = historyService.CreateUserOperationLogQuery() /*.OrderByTimestamp()*//*.Desc()*//*.ListPage(0, 1)*/.First();

            Assert.NotNull(userOperationLogEntry);

            Assert.AreEqual(EntityTypes.JobDefinition, userOperationLogEntry.EntityType);
            Assert.AreEqual(jobDefinition.Id, userOperationLogEntry.JobDefinitionId);

            Assert.AreEqual(UserOperationLogEntryFields.OperationTypeSetPriority, userOperationLogEntry.OperationType);

            Assert.AreEqual("overridingPriority", userOperationLogEntry.Property);
            Assert.IsNull(userOperationLogEntry.NewValue);
            Assert.AreEqual("42", userOperationLogEntry.OrgValue);

            Assert.AreEqual(USER_ID, userOperationLogEntry.UserId);

            Assert.AreEqual(jobDefinition.ProcessDefinitionId, userOperationLogEntry.ProcessDefinitionId);
            Assert.AreEqual(jobDefinition.ProcessDefinitionKey, userOperationLogEntry.ProcessDefinitionKey);
            Assert.AreEqual(DeploymentId, userOperationLogEntry.DeploymentId);
        }
コード例 #6
0
        /// <summary>
        /// Execute the required action on the handler registered that matches the given definition
        /// </summary>
        /// <param name="definition">The definition to match and use</param>
        public void Execute(IJobDefinition definition)
        {
            _jobEx foundEx = null;

            try
            {
                foreach (var _ex in _lstJobsExs)
                {
                    var def = _ex.FuncCheck();
                    if (def.Match(definition))
                    {
                        foundEx = _ex;
                        break;
                    }
                }

                if (foundEx == null)
                {
                    throw new ApplicationException(string.Format("Couldn't execute job of definition '{0}' no handler was registered for this type", definition.Name));
                }
                else
                {
                    foundEx.Act();
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Failed to execute action for given definition", ex);
            }
        }
コード例 #7
0
ファイル: JobFactory.cs プロジェクト: ckpearson/distrib
 public IJob CreateJob(IJobInputTracker inputTracker, IJobOutputTracker outputTracker, IJobDefinition jobDefinition)
 {
     return _ioc.Get<IJob>(new []
     {
         new IOCConstructorArgument("inputTracker", inputTracker),
         new IOCConstructorArgument("outputTracker", outputTracker),
         new IOCConstructorArgument("jobDefinition", jobDefinition),
     });
 }
コード例 #8
0
ファイル: BatchHelper.cs プロジェクト: zf321/ESS.FW.Bpm
 public virtual IJob GetJobForDefinition(IJobDefinition jobDefinition)
 {
     if (jobDefinition != null)
     {
         return(ManagementService.CreateJobQuery(c => c.JobDefinitionId == jobDefinition.Id)
                .First());
     }
     return(null);
 }
コード例 #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="JobRequest"/> class.
        /// </summary>
        /// <param name="job">The <see cref="IJobDefinition"/> containing the
        /// details of the job.</param>
        /// <exception cref="ArgumentNullException">job is null.</exception>
        public JobRequest(IJobDefinition job)
        {
            if (job == null)
            {
                throw new ArgumentNullException("job");
            }

            Job = job;
        }
コード例 #10
0
        protected internal virtual void InitHistoricJobLogEvent(HistoricJobLogEventEntity evt, IJob job, HistoryEventTypes eventType)
        {
            evt.TimeStamp = ClockUtil.CurrentTime;

            JobEntity jobEntity = (JobEntity)job;

            evt.JobId       = jobEntity.Id;
            evt.JobDueDate  = jobEntity.Duedate;
            evt.JobRetries  = jobEntity.Retries;
            evt.JobPriority = jobEntity.Priority;

            IJobDefinition jobDefinition = jobEntity.JobDefinition;

            if (jobDefinition != null)
            {
                evt.JobDefinitionId            = jobDefinition.Id;
                evt.JobDefinitionType          = jobDefinition.JobType;
                evt.JobDefinitionConfiguration = jobDefinition.JobConfiguration;
            }
            else
            {
                // in case of async signal there does not exist a job definition
                // but we use the jobHandlerType as jobDefinitionType
                evt.JobDefinitionType = jobEntity.JobHandlerType;
            }

            evt.ActivityId           = jobEntity.ActivityId;
            evt.ExecutionId          = jobEntity.ExecutionId;
            evt.ProcessInstanceId    = jobEntity.ProcessInstanceId;
            evt.ProcessDefinitionId  = jobEntity.ProcessDefinitionId;
            evt.ProcessDefinitionKey = jobEntity.ProcessDefinitionKey;
            evt.DeploymentId         = jobEntity.DeploymentId;
            evt.TenantId             = jobEntity.TenantId;

            // initialize sequence counter
            InitSequenceCounter(jobEntity, evt);

            IJobState state = null;

            if (HistoryEventTypes.JobCreate.Equals(eventType))
            {
                state = JobStateFields.Created;
            }
            else if (HistoryEventTypes.JobFail.Equals(eventType))
            {
                state = JobStateFields.Failed;
            }
            else if (HistoryEventTypes.JobSuccess.Equals(eventType))
            {
                state = JobStateFields.Successful;
            }
            else if (HistoryEventTypes.JobDelete.Equals(eventType))
            {
                state = JobStateFields.Deleted;
            }
            evt.State = state.StateCode;
        }
コード例 #11
0
        [Test]   public virtual void testPropagateTenantIdToStartTimerJobDefinition()
        {
            DeploymentForTenant(TENANT_ID, ESS.FW.Bpm.Model.Bpmn.Bpmn.CreateExecutableProcess(PROCESS_DEFINITION_KEY).StartEvent().TimerWithDuration("PT1M").EndEvent().Done());

            // the job definition is created on deployment
            IJobDefinition jobDefinition = managementService.CreateJobDefinitionQuery().First();

            Assert.NotNull(jobDefinition);
            // inherit the tenant id from process definition
            Assert.That(jobDefinition.TenantId, Is.EqualTo(TENANT_ID));
        }
コード例 #12
0
//JAVA TO C# CONVERTER TODO Resources.Task: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testSetOverridingJobPriorityWithCascadeAndDisabledTenantCheck()
        [Test]   public virtual void testSetOverridingJobPriorityWithCascadeAndDisabledTenantCheck()
        {
            IJobDefinition jobDefinition = managementService.CreateJobDefinitionQuery().ToList().First();

            identityService.SetAuthentication("aUserId", null);
            engineRule.ProcessEngineConfiguration.SetTenantCheckEnabled(false);

            managementService.SetOverridingJobPriorityForJobDefinition(jobDefinition.Id, 1701, true);
            // then
            Assert.That(managementService.CreateJobDefinitionQuery(c => c.Id == jobDefinition.Id).First().OverridingJobPriority, Is.EqualTo(1701L));
        }
コード例 #13
0
//JAVA TO C# CONVERTER TODO Resources.Task: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testSetOverridingJobPriorityWithNoAuthenticatedTenant()
        [Test]   public virtual void testSetOverridingJobPriorityWithNoAuthenticatedTenant()
        {
            IJobDefinition jobDefinition = managementService.CreateJobDefinitionQuery().ToList().First();

            identityService.SetAuthentication("aUserId", null);

            // then
            //thrown.Expect(typeof(ProcessEngineException));
            //thrown.ExpectMessage("Cannot update the process definition '" + jobDefinition.ProcessDefinitionId + "' because it belongs to no authenticated tenant.");
            managementService.SetOverridingJobPriorityForJobDefinition(jobDefinition.Id, 1701);
        }
コード例 #14
0
ファイル: SendHelixJob.cs プロジェクト: natemcmaster/arcade
        private IJobDefinition AddCorrelationPayload(IJobDefinition def, ITaskItem correlationPayload)
        {
            string path = correlationPayload.GetMetadata("FullPath");

            if (!Directory.Exists(path))
            {
                Log.LogError($"Correlation Payload Directory '{path}' not found.");
                return(def);
            }

            return(def.WithCorrelationPayloadDirectory(path));
        }
コード例 #15
0
        public StandardProcessJob(
            [IOC(false)] IJobInputTracker inputTracker,
            [IOC(false)] IJobOutputTracker outputTracker,
            [IOC(false)] IJobDefinition jobDefinition)
        {
            if (inputTracker == null) throw Ex.ArgNull(() => inputTracker);
            if (outputTracker == null) throw Ex.ArgNull(() => outputTracker);
            if (jobDefinition == null) throw Ex.ArgNull(() => jobDefinition);

            _inputTracker = inputTracker;
            _outputTracker = outputTracker;
            _jobDefinition = jobDefinition;
        }
コード例 #16
0
//JAVA TO C# CONVERTER TODO Resources.Task: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testSetJobRetriesDefinitionWithDisabledTenantCheck()
        [Test]   public virtual void testSetJobRetriesDefinitionWithDisabledTenantCheck()
        {
            IJobDefinition jobDefinition = managementService.CreateJobDefinitionQuery().ToList().First();

            string jobId = selectJobByProcessInstanceId(processInstance.Id).Id;

            managementService.SetJobRetries(jobId, 0);
            identityService.SetAuthentication("aUserId", null);
            engineRule.ProcessEngineConfiguration.SetTenantCheckEnabled(false);

            managementService.SetJobRetriesByJobDefinitionId(jobDefinition.Id, 1);
            // then
            Assert.AreEqual(1, selectJobByProcessInstanceId(processInstance.Id).Retries);
        }
コード例 #17
0
        // setOverridingJobPriority with cascade
//JAVA TO C# CONVERTER TODO Resources.Task: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testSetOverridingJobPriorityWithCascadeAndAuthenticatedTenant()
        [Test]   public virtual void testSetOverridingJobPriorityWithCascadeAndAuthenticatedTenant()
        {
            IJobDefinition jobDefinition = managementService.CreateJobDefinitionQuery().ToList().First();

            identityService.SetAuthentication("aUserId", null, new List <string>()
            {
                TENANT_ONE
            });

            managementService.SetOverridingJobPriorityForJobDefinition(jobDefinition.Id, 1701, true);

            // then
            Assert.That(managementService.CreateJobDefinitionQuery(c => c.Id == jobDefinition.Id).First().OverridingJobPriority, Is.EqualTo(1701L));
        }
コード例 #18
0
ファイル: HelixTestBase.cs プロジェクト: zdpdev/mono
    protected HelixTestBase(string helixType) : base()
    {
        var build = _api.Job.Define()
                    .WithSource(GetEnvironmentVariable("MONO_HELIX_SOURCE"))
                    .WithType(helixType)
                    .WithBuild(GetEnvironmentVariable("MONO_HELIX_BUILD_MONIKER"));

        _job = build
               .WithTargetQueue(GetEnvironmentVariable("MONO_HELIX_TARGET_QUEUE"))
               .WithCorrelationPayloadDirectory(GetEnvironmentVariable("MONO_HELIX_TEST_PAYLOAD_DIRECTORY"))
               .WithCorrelationPayloadFiles(GetEnvironmentVariable("MONO_HELIX_XUNIT_REPORTER_PATH"))
               // these are well-known properties used by Mission Control
               .WithProperty("architecture", GetEnvironmentVariable("MONO_HELIX_ARCHITECTURE"))
               .WithProperty("operatingSystem", GetEnvironmentVariable("MONO_HELIX_OPERATINGSYSTEM"));
    }
コード例 #19
0
        private IJobDefinition AddBuildVariableProperty(IJobDefinition def, string key, string azdoVariableName)
        {
            string envName = FromAzdoVariableNameToEnvironmentVariableName(azdoVariableName);

            var value = Environment.GetEnvironmentVariable(envName);

            if (string.IsNullOrEmpty(value))
            {
                return(def);
            }

            def.WithProperty(key, value);
            Log.LogMessage($"Added build variable property '{key}' (value: '{value}') to job definition.");
            return(def);
        }
コード例 #20
0
//JAVA TO C# CONVERTER TODO Resources.Task: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testSetJobRetriesDefinitionWithNoAuthenticatedTenant()
        [Test]   public virtual void testSetJobRetriesDefinitionWithNoAuthenticatedTenant()
        {
            IJobDefinition jobDefinition = managementService.CreateJobDefinitionQuery().ToList().First();

            string jobId = selectJobByProcessInstanceId(processInstance.Id).Id;

            managementService.SetJobRetries(jobId, 0);
            identityService.SetAuthentication("aUserId", null);

            // then
            //thrown.Expect(typeof(ProcessEngineException));
            //thrown.ExpectMessage("Cannot update the process definition '" + jobDefinition.ProcessDefinitionId + "' because it belongs to no authenticated tenant.");
            // when
            managementService.SetJobRetriesByJobDefinitionId(jobDefinition.Id, 1);
        }
コード例 #21
0
        protected override async Task ExecuteCore()
        {
            using (_commandPayload = new CommandPayload(this))
            {
                IJobDefinition def = HelixApi.Job.Define()
                                     .WithSource(Source)
                                     .WithType(Type)
                                     .WithBuild(Build)
                                     .WithTargetQueue(TargetQueue);

                if (CorrelationPayloads != null)
                {
                    foreach (ITaskItem correlationPayload in CorrelationPayloads)
                    {
                        def = AddCorrelationPayload(def, correlationPayload);
                    }
                }

                if (WorkItems != null)
                {
                    foreach (ITaskItem workItem in WorkItems)
                    {
                        def = AddWorkItem(def, workItem);
                    }
                }
                else
                {
                    Log.LogError("SendHelixJob given no WorkItems to send.");
                }

                if (_commandPayload.TryGetPayloadDirectory(out string directory))
                {
                    def = def.WithCorrelationPayloadDirectory(directory);
                }

                // don't send the job if we have errors
                if (Log.HasLoggedErrors)
                {
                    return;
                }

                Log.LogMessage(MessageImportance.Normal, "Sending Job...");

                ISentJob job = await def.SendAsync();

                JobCorrelationId = job.CorrelationId;
            }
        }
コード例 #22
0
ファイル: SendHelixJob.cs プロジェクト: terrajobst/arcade
        private IJobDefinition AddProperty(IJobDefinition def, ITaskItem property)
        {
            if (!property.GetRequiredMetadata(Log, "Identity", out string key))
            {
                return(def);
            }

            if (!property.GetRequiredMetadata(Log, "Value", out string value))
            {
                return(def);
            }

            def.WithProperty(key, value);
            Log.LogMessage($"Added property '{key}' (value: '{value}') to job definition.");
            return(def);
        }
コード例 #23
0
        public virtual void testSetJobDefinitionPriority()
        {
            // given
            IJobDefinition jobDefinition = engineRule.ManagementService.CreateJobDefinitionQuery().First();

            // when
            authRule.Init(scenario).WithUser("userId").BindResource("processDefinitionKey", "process").Start();

            engineRule.ManagementService.SetOverridingJobPriorityForJobDefinition(jobDefinition.Id, 42);

            // then
            if (authRule.AssertScenario(scenario))
            {
                IJobDefinition updatedJobDefinition = engineRule.ManagementService.CreateJobDefinitionQuery().First();
                Assert.AreEqual(42, (long)updatedJobDefinition.OverridingJobPriority);
            }
        }
コード例 #24
0
        public virtual void testCompletingUpdateJobDefinitionPriorityDuringExecution()
        {
            testRule.Deploy(SIMPLE_ASYNC_PROCESS);

            // given
            // two running instances
            runtimeService.StartProcessInstanceByKey("simpleAsyncProcess");
            runtimeService.StartProcessInstanceByKey("simpleAsyncProcess");

            // and a job definition
            IJobDefinition jobDefinition = managementService.CreateJobDefinitionQuery().First();

            // and two jobs
            IList <IJob> jobs = managementService.CreateJobQuery().ToList();

            // when the first job is executed but has not yet committed
            JobExecutionThread executionThread = new JobExecutionThread(this, jobs[0].Id);

            executionThread.startAndWaitUntilControlIsReturned();

            // and the job priority is updated
            JobDefinitionPriorityThread priorityThread = new JobDefinitionPriorityThread(this, jobDefinition.Id, 42L, true);

            priorityThread.startAndWaitUntilControlIsReturned();

            // and the priority threads commits first
            priorityThread.proceedAndWaitTillDone();

            // then both jobs priority has changed
            IList <IJob> currentJobs = managementService.CreateJobQuery().ToList();

            foreach (IJob job in currentJobs)
            {
                Assert.AreEqual(42, job.Priority);
            }

            // and the execution thread can nevertheless successfully finish job execution
            executionThread.proceedAndWaitTillDone();

            Assert.IsNull(executionThread.exception);

            // and ultimately only one job with an updated priority is left
            IJob remainingJob = managementService.CreateJobQuery().First();

            Assert.NotNull(remainingJob);
        }
コード例 #25
0
        public static bool Match(IJobDefinition left, IJobDefinition right, bool matchConfig = true)
        {
            return AllCChain<bool>
                .If(false, () => left.Name == right.Name, true)
                .ThenIf(() => left.Description == right.Description, true)
                .ThenIf(() => left.InputFields != right && right.InputFields != null, true)
                .ThenIf(() => left.InputFields.Count == right.InputFields.Count, true)
                .ThenIf(() =>
                {
                    bool match = true;
                    for (int i = 0; i < left.InputFields.Count; i++)
                    {
                        var leftField = left.InputFields[i];
                        var rightField = right.InputFields[i];

                        if (!leftField.Match(rightField, matchConfig))
                        {
                            match = false;
                            break;
                        }
                    }

                    return match;
                }, true)
                .ThenIf(() => left.OutputFields != null && right.OutputFields != null, true)
                .ThenIf(() => left.OutputFields.Count == right.OutputFields.Count, true)
                .ThenIf(() =>
                {
                    bool match = true;
                    for (int i = 0; i < left.OutputFields.Count; i++)
                    {
                        var leftField = left.OutputFields[i];
                        var rightField = right.OutputFields[i];

                        if (!leftField.Match(rightField, matchConfig))
                        {
                            match = false;
                            break;
                        }
                    }

                    return match;
                }, true)
                .Result;
        }
コード例 #26
0
        [Test]   public virtual void testBatchJobDefinitionsTenantId()
        {
            // given
            IBatch batch = batchHelper.MigrateProcessInstanceAsync(tenant1Definition, tenant1Definition);

            // then
            IJobDefinition migrationJobDefinition = batchHelper.GetExecutionJobDefinition(batch);

            Assert.AreEqual(TENANT_ONE, migrationJobDefinition.TenantId);

            IJobDefinition monitorJobDefinition = batchHelper.GetMonitorJobDefinition(batch);

            Assert.AreEqual(TENANT_ONE, monitorJobDefinition.TenantId);

            IJobDefinition seedJobDefinition = batchHelper.GetSeedJobDefinition(batch);

            Assert.AreEqual(TENANT_ONE, seedJobDefinition.TenantId);
        }
コード例 #27
0
        // set Jobretries based on job definition
//JAVA TO C# CONVERTER TODO Resources.Task: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testSetJobRetriesDefinitionWithAuthenticatedTenant()
        [Test]   public virtual void testSetJobRetriesDefinitionWithAuthenticatedTenant()
        {
            IJobDefinition jobDefinition = managementService.CreateJobDefinitionQuery().ToList().First();

            string jobId = selectJobByProcessInstanceId(processInstance.Id).Id;

            managementService.SetJobRetries(jobId, 0);

            identityService.SetAuthentication("aUserId", null, new List <string>()
            {
                TENANT_ONE
            });
            // sets the retries for failed jobs - That's the reason why job retries are made 0 in the above step
            managementService.SetJobRetriesByJobDefinitionId(jobDefinition.Id, 1);

            // then
            Assert.AreEqual(1, selectJobByProcessInstanceId(processInstance.Id).Retries);
        }
コード例 #28
0
ファイル: SendHelixJob.cs プロジェクト: natemcmaster/arcade
        private IJobDefinition AddWorkItem(IJobDefinition def, ITaskItem workItem)
        {
            if (!GetRequiredMetadata(workItem, "Identity", out string name))
            {
                return(def);
            }

            if (!GetRequiredMetadata(workItem, "Command", out string command))
            {
                return(def);
            }

            IWorkItemDefinitionWithPayload wiWithPayload = def.DefineWorkItem(name)
                                                           .WithCommand(command);

            string payload = workItem.GetMetadata("PayloadDirectory");
            IWorkItemDefinition wi;

            if (!string.IsNullOrEmpty(payload))
            {
                wi = wiWithPayload.WithDirectoryPayload(payload);
            }
            else
            {
                wi = wiWithPayload.WithEmptyPayload();
            }

            string timeoutString = workItem.GetMetadata("Timeout");

            if (!string.IsNullOrEmpty(timeoutString))
            {
                if (TimeSpan.TryParse(timeoutString, CultureInfo.InvariantCulture, out TimeSpan timeout))
                {
                    wi = wi.WithTimeout(timeout);
                }
                else
                {
                    Log.LogWarning($"Timeout value '{timeoutString}' could not be parsed.");
                }
            }

            return(wi.AttachToJob());
        }
コード例 #29
0
        /// <summary>
        /// Runs the job specified by the definition
        /// </summary>
        /// <param name="job">The definition of the job to run</param>
        private void _runJob(IJobDefinition job)
        {
            PipelineDefinition d = job.GetAlgorithms();

            Pipeline.Pipeline pipeline = _currentArgs.PipelineFactory.CreatePipeline(d);
            foreach (JobInput input in job.GetInputs())
            {
                if (_handleNextInput(pipeline, input) == false)
                {
                    return;
                }
            }

            var results = _currentArgs.Persister.Load(_ticket.JobID);

            _ticket.Result = new JobResult(results);
            _ticket.State  = JobState.Complete;
            _ticket.OnJobCompleted();
        }
コード例 #30
0
        public virtual void testSetOverridingPriorityCascadeToJobs()
        {
            // given a job definition and job
            runtimeService.StartProcessInstanceByKey("asyncTaskProcess");
            IJobDefinition jobDefinition = managementService.CreateJobDefinitionQuery().First();
            IJob           job           = managementService.CreateJobQuery().First();

            // when I set an overriding priority with cascade=true
            managementService.SetOverridingJobPriorityForJobDefinition(jobDefinition.Id, 42, true);

            // then there are two op log entries
            Assert.AreEqual(2, historyService.CreateUserOperationLogQuery().Count());

            // (1): One for the job definition priority
            IUserOperationLogEntry jobDefOpLogEntry = historyService.CreateUserOperationLogQuery(c => c.EntityType == EntityTypes.JobDefinition).First();

            Assert.NotNull(jobDefOpLogEntry);

            // (2): and another one for the job priorities
            IUserOperationLogEntry jobOpLogEntry = historyService.CreateUserOperationLogQuery(c => c.EntityType == EntityTypes.Job).First();

            Assert.NotNull(jobOpLogEntry);

            Assert.AreEqual("both entries should be part of the same operation", jobDefOpLogEntry.OperationId, jobOpLogEntry.OperationId);

            Assert.AreEqual(EntityTypes.Job, jobOpLogEntry.EntityType);
            Assert.IsNull("id should null because it is a bulk update operation", jobOpLogEntry.JobId);

            Assert.AreEqual(UserOperationLogEntryFields.OperationTypeSetPriority, jobOpLogEntry.OperationType);

            Assert.AreEqual("priority", jobOpLogEntry.Property);
            Assert.AreEqual("42", jobOpLogEntry.NewValue);
            Assert.IsNull("Original Value should be null because it is not known for bulk operations", jobOpLogEntry.OrgValue);

            Assert.AreEqual(USER_ID, jobOpLogEntry.UserId);

            // these properties should be there to narrow down the bulk update (like a SQL WHERE clasue)
            Assert.AreEqual(job.JobDefinitionId, jobOpLogEntry.JobDefinitionId);
            Assert.IsNull("an unspecified set of process instances was affected by the operation", jobOpLogEntry.ProcessInstanceId);
            Assert.AreEqual(job.ProcessDefinitionId, jobOpLogEntry.ProcessDefinitionId);
            Assert.AreEqual(job.ProcessDefinitionKey, jobOpLogEntry.ProcessDefinitionKey);
            Assert.AreEqual(DeploymentId, jobOpLogEntry.DeploymentId);
        }
コード例 #31
0
ファイル: JobEntity.cs プロジェクト: zf321/ESS.FW.Bpm
 protected internal virtual void EnsureActivityIdInitialized()
 {
     if (activityId == null)
     {
         IJobDefinition jobDefinition = JobDefinition;
         if (jobDefinition != null)
         {
             activityId = jobDefinition.ActivityId;
         }
         else
         {
             ExecutionEntity execution = Execution;
             if (execution != null)
             {
                 activityId = execution.ActivityId;
             }
         }
     }
 }
コード例 #32
0
        private IJobDefinition AddCorrelationPayload(IJobDefinition def, ITaskItem correlationPayload)
        {
            string path = correlationPayload.GetMetadata("FullPath");

            if (Directory.Exists(path))
            {
                Log.LogMessage(MessageImportance.Low, $"Adding Correlation Payload Directory '{path}'");
                return(def.WithCorrelationPayloadDirectory(path));
            }
            else if (File.Exists(path))
            {
                Log.LogMessage(MessageImportance.Low, $"Adding Correlation Payload Archive '{path}'");
                return(def.WithCorrelationPayloadArchive(path));
            }
            else
            {
                Log.LogError($"Correlation Payload '{path}' not found.");
                return(def);
            }
        }
コード例 #33
0
ファイル: SendHelixJob.cs プロジェクト: terrajobst/arcade
        private IJobDefinition AddCorrelationPayload(IJobDefinition def, ITaskItem correlationPayload)
        {
            string path        = correlationPayload.GetMetadata("FullPath");
            string uri         = correlationPayload.GetMetadata("Uri");
            string destination = correlationPayload.GetMetadata("Destination") ?? "";

            if (!string.IsNullOrEmpty(uri))
            {
                Log.LogMessage(MessageImportance.Low, $"Adding Correlation Payload URI '{uri}', destination '{destination}'");

                if (!string.IsNullOrEmpty(destination))
                {
                    return(def.WithCorrelationPayloadUris(new Dictionary <Uri, string>()
                    {
                        { new Uri(uri), destination }
                    }));
                }
                else
                {
                    return(def.WithCorrelationPayloadUris(new Uri(uri)));
                }
            }

            if (Directory.Exists(path))
            {
                string includeDirectoryNameStr = correlationPayload.GetMetadata("IncludeDirectoryName");
                bool.TryParse(includeDirectoryNameStr, out bool includeDirectoryName);

                Log.LogMessage(MessageImportance.Low, $"Adding Correlation Payload Directory '{path}', destination '{destination}'");
                return(def.WithCorrelationPayloadDirectory(path, includeDirectoryName, destination));
            }

            if (File.Exists(path))
            {
                Log.LogMessage(MessageImportance.Low, $"Adding Correlation Payload Archive '{path}', destination '{destination}'");
                return(def.WithCorrelationPayloadArchive(path, destination));
            }

            Log.LogError(FailureCategory.Build, $"Correlation Payload '{path}' not found.");
            return(def);
        }
コード例 #34
0
ファイル: SendHelixJob.cs プロジェクト: natemcmaster/arcade
        protected override async Task ExecuteCore()
        {
            IJobDefinition def = HelixApi.Job.Define()
                                 .WithSource(Source)
                                 .WithType(Type)
                                 .WithBuild(Build)
                                 .WithTargetQueue(TargetQueue);

            if (CorrelationPayloads != null)
            {
                foreach (ITaskItem correlationPayload in CorrelationPayloads)
                {
                    def = AddCorrelationPayload(def, correlationPayload);
                }
            }

            if (WorkItems != null)
            {
                foreach (ITaskItem workItem in WorkItems)
                {
                    def = AddWorkItem(def, workItem);
                }
            }
            else
            {
                Log.LogError("SendHelixJob given no WorkItems to send.");
            }

            // don't send the job if we have errors
            if (Log.HasLoggedErrors)
            {
                return;
            }

            ISentJob job = await def.SendAsync();

            JobCorrelationId = job.CorrelationId;
        }
コード例 #35
0
 public DistribJobDefinition(IJobDefinition definition)
 {
     _definition = definition;
 }
コード例 #36
0
        public bool Match(IJobDefinition definition)
        {
            return JobMatchingService.Match(this, definition, true);

            //return AllCChain<bool>
            //    .If(false, () => this.Name == definition.Name, true)
            //    .ThenIf(() => this.Description == definition.Description, true)
            //    .ThenIf(() => this.InputFields != null && definition.InputFields != null, true)
            //    .ThenIf(() => this.InputFields.Count == definition.InputFields.Count, true)
            //    .ThenIf(() =>
            //        {
            //            bool match = true;
            //            for (int i = 0; i < this.InputFields.Count; i++)
            //            {
            //                var leftField = this.InputFields[i];
            //                var rightField = definition.InputFields[i];

            //                if (!leftField.Match(rightField))
            //                {
            //                    match = false;
            //                    break;
            //                }
            //            }

            //            return match;
            //        }, true)
            //    .ThenIf(() => this.OutputFields != null && definition.OutputFields != null, true)
            //    .ThenIf(() => this.OutputFields.Count == definition.OutputFields.Count, true)
            //    .ThenIf(() =>
            //    {
            //        bool match = true;
            //        for (int i = 0; i < this.OutputFields.Count; i++)
            //        {
            //            var leftField = this.OutputFields[i];
            //            var rightField = definition.OutputFields[i];

            //            if (!leftField.Match(rightField))
            //            {
            //                match = false;
            //                break;
            //            }
            //        }

            //        return match;
            //    }, true)
            //    .Result;
        }