Exemplo n.º 1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void shouldBeAbleToProgressUnderStressfulProcessorChanges(int orderingGuarantees) throws Exception
        private void ShouldBeAbleToProgressUnderStressfulProcessorChanges(int orderingGuarantees)
        {
            // given
            int            batches    = 100;
            int            processors = Runtime.Runtime.availableProcessors() * 10;
            Configuration  config     = new Configuration_OverriddenAnonymousInnerClass(this, Configuration.DEFAULT, processors);
            Stage          stage      = new StressStage(config, orderingGuarantees, batches);
            StageExecution execution  = stage.Execute();
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.List<Step<?>> steps = asList(execution.steps());
            IList <Step <object> > steps = new IList <Step <object> > {
                execution.Steps()
            };

            steps[1].Processors(processors / 3);

            // when
            ThreadLocalRandom random = ThreadLocalRandom.current();

            while (execution.StillExecuting())
            {
                steps[2].Processors(random.Next(-2, 5));
                Thread.Sleep(1);
            }
            execution.AssertHealthy();

            // then
            assertEquals(batches, steps[steps.Count - 1].Stats().stat(Keys.done_batches).asLong());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Executes a number of stages simultaneously, letting the given {@code monitor} get insight into the
        /// execution.
        /// </summary>
        /// <param name="monitor"> <seealso cref="ExecutionMonitor"/> to get insight into the execution. </param>
        /// <param name="stage"> <seealso cref="Stage stages"/> to execute. </param>
        public static void SuperviseExecution(ExecutionMonitor monitor, Stage stage)
        {
            ExecutionSupervisor supervisor = new ExecutionSupervisor(Clocks.systemClock(), monitor);
            StageExecution      execution  = null;

            try
            {
                execution = stage.Execute();
                supervisor.Supervise(execution);
            }
            finally
            {
                stage.Close();
                if (execution != null)
                {
                    execution.AssertHealthy();
                }
            }
        }