예제 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testHistoryConfigurationWithinBatchWindow() throws java.text.ParseException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual void testHistoryConfigurationWithinBatchWindow()
        {
            ProcessEngineConfigurationImpl processEngineConfigurationImplMock = mock(typeof(ProcessEngineConfigurationImpl));
            DateTime startDate = HistoryCleanupHelper.parseTimeConfiguration("22:00+0200");
            DateTime endDate   = HistoryCleanupHelper.parseTimeConfiguration("23:00+0200");

            when(processEngine.ProcessEngineConfiguration).thenReturn(processEngineConfigurationImplMock);
            when(processEngineConfigurationImplMock.HistoryCleanupBatchWindowStartTime).thenReturn("22:00+0200");
            when(processEngineConfigurationImplMock.HistoryCleanupBatchWindowEndTime).thenReturn("23:00+0200");
            when(processEngineConfigurationImplMock.BatchWindowManager).thenReturn(new DefaultBatchWindowManager());

            SimpleDateFormat sdf = new SimpleDateFormat(JacksonConfigurator.dateFormatString);
            DateTime         now = sdf.parse("2017-09-01T22:00:00.000+0200");

            ClockUtil.CurrentTime = now;

            DateTime today = new DateTime();

            today = new DateTime(now);

            DateTime dateToday    = DateTimeUtils.updateTime(today, startDate);
            DateTime dateTomorrow = DateTimeUtils.updateTime(today, endDate);

            given().contentType(ContentType.JSON).then().expect().statusCode(Status.OK.StatusCode).body("batchWindowStartTime", containsString(sdf.format(dateToday))).body("batchWindowEndTime", containsString(sdf.format(dateTomorrow))).when().get(CONFIGURATION_URL);
        }
예제 #2
0
 private void initEndTimeAsDate()
 {
     try
     {
         endTimeAsDate = HistoryCleanupHelper.parseTimeConfiguration(endTime);
     }
     catch (ParseException)
     {
         throw LOG.invalidPropertyValue("endTime", endTime);
     }
 }
예제 #3
0
        public virtual void testHistoryCleanupJob()
        {
            var historyCleanupJob = historyService.FindHistoryCleanupJob();

            Assert.NotNull(historyCleanupJob);
            var historyCleanupBatchWindowStartTime =
                ((ProcessEngineConfigurationImpl)engineRule.ProcessEngine.ProcessEngineConfiguration)
                .HistoryCleanupBatchWindowStartTimeAsDate;

            Assert.AreEqual(
                HistoryCleanupHelper.GetNextRunWithinBatchWindow(ClockUtil.CurrentTime,
                                                                 historyCleanupBatchWindowStartTime), historyCleanupJob.Duedate);
        }
예제 #4
0
        public virtual Job execute(CommandContext commandContext)
        {
            AuthorizationManager           authorizationManager       = commandContext.AuthorizationManager;
            ProcessEngineConfigurationImpl processEngineConfiguration = commandContext.ProcessEngineConfiguration;

            authorizationManager.checkCamundaAdmin();

            //validate
            if (!willBeScheduled())
            {
                LOG.debugHistoryCleanupWrongConfiguration();
            }

            //find job instance
            IList <Job> historyCleanupJobs = HistoryCleanupJobs;

            int degreeOfParallelism = processEngineConfiguration.HistoryCleanupDegreeOfParallelism;

            int[][] minuteChunks = HistoryCleanupHelper.listMinuteChunks(degreeOfParallelism);

            if (shouldCreateJobs(historyCleanupJobs))
            {
                historyCleanupJobs = createJobs(degreeOfParallelism, minuteChunks);
            }
            else if (shouldReconfigureJobs(historyCleanupJobs))
            {
                historyCleanupJobs = reconfigureJobs(historyCleanupJobs, degreeOfParallelism, minuteChunks);
            }
            else if (shouldSuspendJobs(historyCleanupJobs))
            {
                suspendJobs(historyCleanupJobs);
            }

            writeUserOperationLog(commandContext);

            return(historyCleanupJobs.Count > 0 ? historyCleanupJobs[0] : null);
        }
예제 #5
0
        protected internal virtual bool willBeScheduled()
        {
            CommandContext commandContext = Context.CommandContext;

            return(immediatelyDue || HistoryCleanupHelper.isBatchWindowConfigured(commandContext));
        }