示例#1
0
        //we cannot use waitForExecutor... method since there will always be one job left
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void moveByHours(int hours) throws Exception
        private void moveByHours(int hours)
        {
            ClockUtil.CurrentTime = new DateTime(ClockUtil.CurrentTime.Ticks + ((hours * 60 * 1000 * 60) + 5000));
            JobExecutor jobExecutor = processEngineConfiguration.JobExecutor;

            jobExecutor.start();
            Thread.Sleep(1000);
            jobExecutor.shutdown();
        }
示例#2
0
        public virtual void waitForJobExecutorToProcessAllJobs(long maxMillisToWait)
        {
            ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl)processEngine.ProcessEngineConfiguration;
            JobExecutor jobExecutor = processEngineConfiguration.JobExecutor;

            jobExecutor.start();
            long intervalMillis = 1000;

            int jobExecutorWaitTime = jobExecutor.WaitTimeInMillis * 2;

            if (maxMillisToWait < jobExecutorWaitTime)
            {
                maxMillisToWait = jobExecutorWaitTime;
            }

            try
            {
                Timer         timer = new Timer();
                InterruptTask task  = new InterruptTask(Thread.CurrentThread);
                timer.schedule(task, maxMillisToWait);
                bool areJobsAvailable = true;
                try
                {
                    while (areJobsAvailable && !task.TimeLimitExceeded)
                    {
                        Thread.Sleep(intervalMillis);
                        try
                        {
                            areJobsAvailable = areJobsAvailable();
                        }
                        catch (Exception)
                        {
                            // Ignore, possible that exception occurs due to locking/updating of table on MSSQL when
                            // isolation level doesn't allow READ of the table
                        }
                    }
                }
                catch (InterruptedException)
                {
                }
                finally
                {
                    timer.cancel();
                }
                if (areJobsAvailable)
                {
                    throw new AssertionError("time limit of " + maxMillisToWait + " was exceeded");
                }
            }
            finally
            {
                jobExecutor.shutdown();
            }
        }
示例#3
0
        public virtual void waitForJobExecutorOnCondition(long maxMillisToWait, Callable <bool> condition)
        {
            JobExecutor jobExecutor = processEngineConfiguration.JobExecutor;

            jobExecutor.start();
            long intervalMillis = 500;

            if (maxMillisToWait < (jobExecutor.WaitTimeInMillis * 2))
            {
                maxMillisToWait = (jobExecutor.WaitTimeInMillis * 2);
            }

            try
            {
                Timer         timer = new Timer();
                InterruptTask task  = new InterruptTask(Thread.CurrentThread);
                timer.schedule(task, maxMillisToWait);
                bool conditionIsViolated = true;
                try
                {
                    while (conditionIsViolated && !task.TimeLimitExceeded)
                    {
                        Thread.Sleep(intervalMillis);
                        conditionIsViolated = !condition.call();
                    }
                }
                catch (InterruptedException)
                {
                }
                catch (Exception e)
                {
                    throw new ProcessEngineException("Exception while waiting on condition: " + e.Message, e);
                }
                finally
                {
                    timer.cancel();
                }
                if (conditionIsViolated)
                {
                    throw new ProcessEngineException("time limit of " + maxMillisToWait + " was exceeded");
                }
            }
            finally
            {
                jobExecutor.shutdown();
            }
        }
示例#4
0
        //////////////////////// copied from AbstractActivitiTestcase

        public virtual void waitForJobExecutorToProcessAllJobs(long maxMillisToWait, long intervalMillis)
        {
            JobExecutor jobExecutor = processEngineConfiguration.JobExecutor;

            jobExecutor.start();

            try
            {
                Timer        timer = new Timer();
                InteruptTask task  = new InteruptTask(Thread.CurrentThread);
                timer.schedule(task, maxMillisToWait);
                bool areJobsAvailable = true;
                try
                {
                    while (areJobsAvailable && !task.TimeLimitExceeded)
                    {
                        Thread.Sleep(intervalMillis);
                        areJobsAvailable = areJobsAvailable();
                    }
                }
                catch (InterruptedException)
                {
                }
                finally
                {
                    timer.cancel();
                }
                if (areJobsAvailable)
                {
                    throw new ProcessEngineException("time limit of " + maxMillisToWait + " was exceeded");
                }
            }
            finally
            {
                jobExecutor.shutdown();
            }
        }