internal StageDetails(StageExecution execution, VmPauseTimeAccumulator vmPauseTimeAccumulator)
 {
     this.Execution = execution;
     this.VmPauseTimeAccumulator = vmPauseTimeAccumulator;
     this.BaseVmPauseTime        = vmPauseTimeAccumulator.PauseTime;
     this.StartTime = currentTimeMillis();
 }
Example #2
0
            private void saturate(StageExecution execution)
            {
                if (processors == 0)
                {
                    return;
                }

                Random random       = ThreadLocalRandom.current();
                int    maxThisCheck = random.Next(processors - 1) + 1;

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: for (Step<?> step : execution.steps())
                foreach (Step <object> step in execution.Steps())
                {
                    int before = step.Processors(0);
                    if (random.nextBoolean() && step.Processors(-1) < before)
                    {
                        processors--;
                        if (--maxThisCheck == 0)
                        {
                            return;
                        }
                    }
                }
            }
Example #3
0
        private void RemoveProcessorFromPotentialIdleStep(StageExecution execution)
        {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: for (org.neo4j.helpers.collection.Pair<Step<?>,float> fast : execution.stepsOrderedBy(org.neo4j.unsafe.impl.batchimport.stats.Keys.avg_processing_time, true))
            foreach (Pair <Step <object>, float> fast in execution.StepsOrderedBy(Keys.avg_processing_time, true))
            {
                int numberOfProcessors = fast.First().processors(0);
                if (numberOfProcessors == 1)
                {
                    continue;
                }

                // Translate the factor compared to the next (slower) step and see if this step would still
                // be faster if we decremented the processor count, with a slight conservative margin as well
                // (0.8 instead of 1.0 so that we don't decrement and immediately become the bottleneck ourselves).
                float factorWithDecrementedProcessorCount = fast.Other() * numberOfProcessors / (numberOfProcessors - 1);
                if (factorWithDecrementedProcessorCount < 0.8f)
                {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: Step<?> fastestStep = fast.first();
                    Step <object> fastestStep = fast.First();
                    long          doneBatches = Batches(fastestStep);
                    if (BatchesPassedSinceLastChange(fastestStep, doneBatches) >= _config.movingAverageSize())
                    {
                        int before = fastestStep.Processors(0);
                        if (fastestStep.Processors(-1) < before)
                        {
                            _lastChangedProcessors[fastestStep] = doneBatches;
                            return;
                        }
                    }
                }
            }
        }
Example #4
0
 public override void Start(StageExecution execution)
 {
     foreach (ExecutionMonitor monitor in _monitors)
     {
         monitor.Start(execution);
     }
 }
Example #5
0
 public override void End(StageExecution execution, long totalTimeMillis)
 {
     foreach (ExecutionMonitor monitor in _monitors)
     {
         monitor.End(execution, totalTimeMillis);
     }
 }
Example #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRemoveCPUsFromWayTooFastStep()
        public virtual void ShouldRemoveCPUsFromWayTooFastStep()
        {
            // GIVEN
            Configuration config = config(10, 3);
            // available processors = 2 is enough because it will see the fast step as only using 20% of a processor
            // and it rounds down. So there's room for assigning one more.
            DynamicProcessorAssigner assigner = new DynamicProcessorAssigner(config);

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: ControlledStep<?> slowStep = spy(stepWithStats("slow", 1, avg_processing_time, 6L, done_batches, 10L).setProcessors(2));
            ControlledStep <object> slowStep = spy(stepWithStats("slow", 1, avg_processing_time, 6L, done_batches, 10L).setProcessors(2));
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: ControlledStep<?> fastStep = spy(stepWithStats("fast", 0, avg_processing_time, 2L, done_batches, 10L).setProcessors(2));
            ControlledStep <object> fastStep = spy(stepWithStats("fast", 0, avg_processing_time, 2L, done_batches, 10L).setProcessors(2));

            StageExecution execution = ExecutionOf(config, slowStep, fastStep);

            assigner.Start(execution);

            // WHEN checking
            assigner.Check(execution);

            // THEN one processor should be removed from the fast step
            verify(fastStep, times(1)).processors(-1);
        }
Example #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRemoveCPUsFromTooFastStepEvenIfThereIsAWayFaster()
        public virtual void ShouldRemoveCPUsFromTooFastStepEvenIfThereIsAWayFaster()
        {
            // The point is that not only the fastest step is subject to have processors removed,
            // it's the relationship between all pairs of steps. This is important since the DPA has got
            // a max permit count of processors to assign, so reclaiming unnecessary assignments can
            // have those be assigned to a more appropriate step instead, where it will benefit the Stage more.

            // GIVEN
            Configuration            config   = config(10, 3);
            DynamicProcessorAssigner assigner = new DynamicProcessorAssigner(config);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: Step<?> wayFastest = stepWithStats("wayFastest", 0, avg_processing_time, 50L, done_batches, 20L);
            Step <object> wayFastest = stepWithStats("wayFastest", 0, avg_processing_time, 50L, done_batches, 20L);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: Step<?> fast = spy(stepWithStats("fast", 0, avg_processing_time, 100L, done_batches, 20L).setProcessors(3));
            Step <object> fast = spy(stepWithStats("fast", 0, avg_processing_time, 100L, done_batches, 20L).setProcessors(3));
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: Step<?> slow = stepWithStats("slow", 1, avg_processing_time, 220L, done_batches, 20L);
            Step <object>  slow      = stepWithStats("slow", 1, avg_processing_time, 220L, done_batches, 20L);
            StageExecution execution = ExecutionOf(config, slow, wayFastest, fast);

            assigner.Start(execution);

            // WHEN
            assigner.Check(execution);

            // THEN
            verify(fast).processors(-1);
        }
Example #8
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());
        }
        private long DoneBatches(StageExecution execution)
        {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: Step<?> step = org.neo4j.helpers.collection.Iterables.last(execution.steps());
            Step <object> step = Iterables.last(execution.Steps());

            return(step.Stats().stat(Keys.done_batches).asLong());
        }
 public override void Check(StageExecution execution)
 {
     ReprintProgressIfNecessary();
     if (IncludeStage(execution))
     {
         UpdateProgress(ProgressOf(execution));
     }
 }
Example #11
0
        private StageExecution Execution(long doneBatches, Configuration config)
        {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: Step<?> step = ControlledStep.stepWithStats("Test", 0, done_batches, doneBatches);
            Step <object>  step      = ControlledStep.StepWithStats("Test", 0, done_batches, doneBatches);
            StageExecution execution = new StageExecution("Test", null, config, Collections.singletonList(step), 0);

            return(execution);
        }
Example #12
0
        public static void PrintSpectrum(StringBuilder builder, StageExecution execution, int width, DetailLevel additionalStatsLevel)
        {
            long[] values = values(execution);
            long   total  = total(values);

            // reduce the width with the known extra characters we know we'll print in and around the spectrum
            width -= 2 + PROGRESS_WIDTH;

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.helpers.collection.Pair<Step<?>,float> bottleNeck = execution.stepsOrderedBy(org.neo4j.unsafe.impl.batchimport.stats.Keys.avg_processing_time, false).iterator().next();
            Pair <Step <object>, float> bottleNeck = execution.StepsOrderedBy(Keys.avg_processing_time, false).GetEnumerator().next();
            QuantizedProjection         projection = new QuantizedProjection(total, width);
            long lastDoneBatches = 0;
            int  stepIndex       = 0;
            bool hasProgressed   = false;

            builder.Append('[');
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: for (Step<?> step : execution.steps())
            foreach (Step <object> step in execution.Steps())
            {
                StepStats stats = step.Stats();
                if (!projection.Next(values[stepIndex]))
                {
                    break;                              // odd though
                }
                long stepWidth = total == 0 && stepIndex == 0 ? width : projection.Step();
                if (stepWidth > 0)
                {
                    if (hasProgressed)
                    {
                        stepWidth--;
                        builder.Append('|');
                    }
                    bool   isBottleNeck   = bottleNeck.First() == step;
                    string name           = (isBottleNeck ? "*" : "") + stats.ToString(additionalStatsLevel) + (step.Processors(0) > 1 ? "(" + step.Processors(0) + ")" : "");
                    int    charIndex      = 0;                      // negative value "delays" the text, i.e. pushes it to the right
                    char   backgroundChar = step.Processors(0) > 1 ? '=' : '-';
                    for (int i = 0; i < stepWidth; i++, charIndex++)
                    {
                        char ch = backgroundChar;
                        if (charIndex >= 0 && charIndex < name.Length && charIndex < stepWidth)
                        {
                            ch = name[charIndex];
                        }
                        builder.Append(ch);
                    }
                    hasProgressed = true;
                }
                lastDoneBatches = stats.Stat(Keys.done_batches).asLong();
                stepIndex++;
            }

            long progress = lastDoneBatches * execution.Config.batchSize();

            builder.Append("]").Append(FitInProgress(progress));
        }
Example #13
0
            protected internal virtual void RegisterProcessorCount(StageExecution execution)
            {
                IDictionary <string, int> byStage = new Dictionary <string, int>();

                Processors[execution.Name()] = byStage;
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: for (Step<?> step : execution.steps())
                foreach (Step <object> step in execution.Steps())
                {
                    byStage[step.Name()] = step.Processors(0);
                }
            }
Example #14
0
        public override void Check(StageExecution execution)
        {
            long currentTimeMillis = _clock.millis();

            for (int i = 0; i < _monitors.Length; i++)
            {
                if (currentTimeMillis >= _endTimes[i])
                {
                    _monitors[i].check(execution);
                    _endTimes[i] = _monitors[i].nextCheckTime();
                }
            }
        }
Example #15
0
        private static long[] Values(StageExecution execution)
        {
            long[] values = new long[execution.Size()];
            int    i      = 0;

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: for (Step<?> step : execution.steps())
            foreach (Step <object> step in execution.Steps())
            {
                values[i++] = Avg(step.Stats());
            }
            return(values);
        }
        private void Update(StageExecution execution)
        {
            long diff        = 0;
            long doneBatches = doneBatches(execution);

            diff            += doneBatches - _prevDoneBatches;
            _prevDoneBatches = doneBatches;

            if (diff > 0)
            {
                _totalReportedBatches += diff;
                Progress(diff);
            }
        }
Example #17
0
 public override void Check(StageExecution execution)
 {
     if (execution.StillExecuting())
     {
         int permits = _availableProcessors - CountActiveProcessors(execution);
         if (permits > 0)
         {
             // Be swift at assigning processors to slow steps, i.e. potentially multiple per round
             AssignProcessorsToPotentialBottleNeck(execution, permits);
         }
         // Be a little more conservative removing processors from too fast steps
         RemoveProcessorFromPotentialIdleStep(execution);
     }
 }
Example #18
0
        /// <summary>
        /// Supervises <seealso cref="StageExecution"/>, provides continuous information to the <seealso cref="ExecutionMonitor"/>
        /// and returns when the execution is done or an error occurs, in which case an exception is thrown.
        ///
        /// Made synchronized to ensure that only one set of executions take place at any given time
        /// and also to make sure the calling thread goes through a memory barrier (useful both before and after execution).
        /// </summary>
        /// <param name="execution"> <seealso cref="StageExecution"/> instances to supervise simultaneously. </param>
        public virtual void Supervise(StageExecution execution)
        {
            lock (this)
            {
                long startTime = CurrentTimeMillis();
                Start(execution);

                while (execution.StillExecuting())
                {
                    FinishAwareSleep(execution);
                    _monitor.check(execution);
                }
                End(execution, CurrentTimeMillis() - startTime);
            }
        }
        private static long ProgressOf(StageExecution execution)
        {
            // First see if there's a "progress" stat
            Stat progressStat = FindProgressStat(execution.Steps());

            if (progressStat != null)
            {
                return(Weighted(execution.StageName, progressStat.AsLong()));
            }

            // No, then do the generic progress calculation by looking at "done_batches"
            long doneBatches = last(execution.Steps()).stats().stat(Keys.done_batches).asLong();
            int  batchSize   = execution.Config.batchSize();

            return(Weighted(execution.StageName, doneBatches * batchSize));
        }
Example #20
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldOrderStepsDescending()
        public virtual void ShouldOrderStepsDescending()
        {
            // GIVEN
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Collection<Step<?>> steps = new java.util.ArrayList<>();
            ICollection <Step <object> > steps = new List <Step <object> >();

            steps.Add(stepWithAverageOf("step1", 0, 10));
            steps.Add(stepWithAverageOf("step2", 0, 5));
            steps.Add(stepWithAverageOf("step3", 0, 30));
            steps.Add(stepWithAverageOf("step4", 0, 5));
            StageExecution execution = new StageExecution("Test", null, DEFAULT, steps, ORDER_SEND_DOWNSTREAM);

            // WHEN
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Iterator<org.neo4j.helpers.collection.Pair<Step<?>,float>> ordered = execution.stepsOrderedBy(org.neo4j.unsafe.impl.batchimport.stats.Keys.avg_processing_time, false).iterator();
            IEnumerator <Pair <Step <object>, float> > ordered = execution.StepsOrderedBy(Keys.avg_processing_time, false).GetEnumerator();

            // THEN
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.helpers.collection.Pair<Step<?>,float> slowest = ordered.next();
            Pair <Step <object>, float> slowest = ordered.next();

            assertEquals(3f, slowest.Other(), 0f);
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.helpers.collection.Pair<Step<?>,float> slower = ordered.next();
            Pair <Step <object>, float> slower = ordered.next();

            assertEquals(2f, slower.Other(), 0f);
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.helpers.collection.Pair<Step<?>,float> slow = ordered.next();
            Pair <Step <object>, float> slow = ordered.next();

            assertEquals(1f, slow.Other(), 0f);
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.helpers.collection.Pair<Step<?>,float> alsoSlow = ordered.next();
            Pair <Step <object>, float> alsoSlow = ordered.next();

            assertEquals(1f, alsoSlow.Other(), 0f);
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertFalse(ordered.hasNext());
        }
        public override void Start(StageExecution execution)
        {
            // Divide into 4 progress stages:
            if (execution.StageName.Equals(DataImporter.NODE_IMPORT_NAME))
            {
                // Import nodes:
                // - import nodes
                // - prepare id mapper
                InitializeNodeImport(_dependencyResolver.resolveDependency(typeof(Input_Estimates)), _dependencyResolver.resolveDependency(typeof(IdMapper)), _dependencyResolver.resolveDependency(typeof(BatchingNeoStores)));
            }
            else if (execution.StageName.Equals(DataImporter.RELATIONSHIP_IMPORT_NAME))
            {
                EndPrevious();

                // Import relationships:
                // - import relationships
                InitializeRelationshipImport(_dependencyResolver.resolveDependency(typeof(Input_Estimates)), _dependencyResolver.resolveDependency(typeof(IdMapper)), _dependencyResolver.resolveDependency(typeof(BatchingNeoStores)));
            }
            else if (execution.StageName.Equals(NodeDegreeCountStage.NAME))
            {
                EndPrevious();

                // Link relationships:
                // - read node degrees
                // - backward linking
                // - node relationship linking
                // - forward linking
                InitializeLinking(_dependencyResolver.resolveDependency(typeof(BatchingNeoStores)), _dependencyResolver.resolveDependency(typeof(NodeRelationshipCache)), _dependencyResolver.resolveDependency(typeof(DataStatistics)));
            }
            else if (execution.StageName.Equals(CountGroupsStage.NAME))
            {
                EndPrevious();

                // Misc:
                // - relationship group defragmentation
                // - counts store
                InitializeMisc(_dependencyResolver.resolveDependency(typeof(BatchingNeoStores)), _dependencyResolver.resolveDependency(typeof(DataStatistics)));
            }
            else if (IncludeStage(execution))
            {
                _stashedProgress += _progress;
                _progress         = 0;
                _newInternalStage = true;
            }
            _lastReportTime = currentTimeMillis();
        }
Example #22
0
        public override void Check(StageExecution execution)
        {
            StringBuilder builder = new StringBuilder();

            PrintSpectrum(builder, execution, _width, DetailLevel.IMPORTANT);

            // add delta
            long progress     = last(execution.Steps()).stats().stat(Keys.done_batches).asLong() * execution.Config.batchSize();
            long currentDelta = progress - _lastProgress;

            builder.Append(" ∆").Append(FitInProgress(currentDelta));

            // and remember progress to compare with next check
            _lastProgress = progress;

            // print it (overwriting the previous contents on this console line)
            @out.print("\r" + builder);
        }
Example #23
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();
                }
            }
        }
Example #24
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: private void saturate(final int availableProcessor, StageExecution execution)
            private void saturate(int availableProcessor, StageExecution execution)
            {
                Random random     = ThreadLocalRandom.current();
                int    processors = availableProcessor;

                for (int rounds = 0; rounds < availableProcessor && processors > 0; rounds++)
                {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: for (Step<?> step : execution.steps())
                    foreach (Step <object> step in execution.Steps())
                    {
                        int before = step.Processors(0);
                        if (random.nextBoolean() && step.Processors(1) > before && --processors == 0)
                        {
                            return;
                        }
                    }
                }
            }
Example #25
0
        private int CountActiveProcessors(StageExecution execution)
        {
            float processors = 0;

            if (execution.StillExecuting())
            {
                long highestAverage = Avg(execution.StepsOrderedBy(Keys.avg_processing_time, false).GetEnumerator().next().first());
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: for (Step<?> step : execution.steps())
                foreach (Step <object> step in execution.Steps())
                {
                    // Calculate how active each step is so that a step that is very cheap
                    // and idles a lot counts for less than 1 processor, so that bottlenecks can
                    // "steal" some of its processing power.
                    long  avg    = avg(step);
                    float factor = ( float )avg / ( float )highestAverage;
                    processors += factor * step.Processors(0);
                }
            }
            return(( int )Math.Round(processors, MidpointRounding.AwayFromZero));
        }
Example #26
0
        private void FinishAwareSleep(StageExecution execution)
        {
            long endTime = _monitor.nextCheckTime();

            while (CurrentTimeMillis() < endTime)
            {
                if (!execution.StillExecuting())
                {
                    break;
                }

                try
                {
                    sleep(min(10, max(0, endTime - CurrentTimeMillis())));
                }
                catch (InterruptedException e)
                {
                    execution.Panic(e);
                    break;
                }
            }
        }
Example #27
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReceiveBatchesInOrder()
        public virtual void ShouldReceiveBatchesInOrder()
        {
            // GIVEN
            Configuration config  = new Configuration_OverriddenAnonymousInnerClass(this, DEFAULT);
            Stage         stage   = new Stage("Test stage", null, config, ORDER_SEND_DOWNSTREAM);
            long          batches = 1000;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final long items = batches * config.batchSize();
            long items = batches * config.BatchSize();

            stage.Add(new PullingProducerStepAnonymousInnerClass(this, stage.Control(), config, items));

            for (int i = 0; i < 3; i++)
            {
                stage.Add(new ReceiveOrderAssertingStep(stage.Control(), "Step" + i, config, i, false));
            }
            stage.Add(new ReceiveOrderAssertingStep(stage.Control(), "Final step", config, 0, true));

            // WHEN
            StageExecution execution = stage.Execute();

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: for (Step<?> step : execution.steps())
            foreach (Step <object> step in execution.Steps())
            {
                // we start off with two in each step
                step.Processors(1);
            }
            (new ExecutionSupervisor(ExecutionMonitors.Invisible())).supervise(execution);

            // THEN
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: for (Step<?> step : execution.steps())
            foreach (Step <object> step in execution.Steps())
            {
                assertEquals("For " + step, batches, step.Stats().stat(Keys.done_batches).asLong());
            }
            stage.Close();
        }
Example #28
0
        private void AssignProcessorsToPotentialBottleNeck(StageExecution execution, int permits)
        {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.helpers.collection.Pair<Step<?>,float> bottleNeck = execution.stepsOrderedBy(org.neo4j.unsafe.impl.batchimport.stats.Keys.avg_processing_time, false).iterator().next();
            Pair <Step <object>, float> bottleNeck = execution.StepsOrderedBy(Keys.avg_processing_time, false).GetEnumerator().next();
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: Step<?> bottleNeckStep = bottleNeck.first();
            Step <object> bottleNeckStep = bottleNeck.First();
            long          doneBatches    = Batches(bottleNeckStep);

            if (bottleNeck.Other() > 1.0f && BatchesPassedSinceLastChange(bottleNeckStep, doneBatches) >= _config.movingAverageSize())
            {
                // Assign 1/10th of the remaining permits. This will have processors being assigned more
                // aggressively in the beginning of the run
                int optimalProcessorIncrement = min(max(1, ( int )bottleNeck.Other() - 1), permits);
                int before = bottleNeckStep.Processors(0);
                int after  = bottleNeckStep.Processors(max(optimalProcessorIncrement, permits / 10));
                if (after > before)
                {
                    _lastChangedProcessors[bottleNeckStep] = doneBatches;
                }
            }
        }
Example #29
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRemoveCPUsFromTooFastStepEvenIfNotAllPermitsAreUsed()
        public virtual void ShouldRemoveCPUsFromTooFastStepEvenIfNotAllPermitsAreUsed()
        {
            // GIVEN
            Configuration            config   = config(10, 20);
            DynamicProcessorAssigner assigner = new DynamicProcessorAssigner(config);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: Step<?> wayFastest = spy(stepWithStats("wayFastest", 0, avg_processing_time, 50L, done_batches, 20L).setProcessors(5));
            Step <object> wayFastest = spy(stepWithStats("wayFastest", 0, avg_processing_time, 50L, done_batches, 20L).setProcessors(5));
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: Step<?> fast = spy(stepWithStats("fast", 0, avg_processing_time, 100L, done_batches, 20L).setProcessors(3));
            Step <object> fast = spy(stepWithStats("fast", 0, avg_processing_time, 100L, done_batches, 20L).setProcessors(3));
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: Step<?> slow = stepWithStats("slow", 1, avg_processing_time, 220L, done_batches, 20L);
            Step <object>  slow      = stepWithStats("slow", 1, avg_processing_time, 220L, done_batches, 20L);
            StageExecution execution = ExecutionOf(config, slow, wayFastest, fast);

            assigner.Start(execution);

            // WHEN
            assigner.Check(execution);

            // THEN
            verify(wayFastest).processors(-1);
        }
Example #30
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAssignAdditionalCPUToBottleNeckStep()
        public virtual void ShouldAssignAdditionalCPUToBottleNeckStep()
        {
            // GIVEN
            Configuration            config   = config(10, 5);
            DynamicProcessorAssigner assigner = new DynamicProcessorAssigner(config);

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: ControlledStep<?> slowStep = stepWithStats("slow", 0, avg_processing_time, 10L, done_batches, 10L);
            ControlledStep <object> slowStep = stepWithStats("slow", 0, avg_processing_time, 10L, done_batches, 10L);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: ControlledStep<?> fastStep = stepWithStats("fast", 0, avg_processing_time, 2L, done_batches, 10L);
            ControlledStep <object> fastStep = stepWithStats("fast", 0, avg_processing_time, 2L, done_batches, 10L);

            StageExecution execution = ExecutionOf(config, slowStep, fastStep);

            assigner.Start(execution);

            // WHEN
            assigner.Check(execution);

            // THEN
            assertEquals(5, slowStep.Processors(0));
            assertEquals(1, fastStep.Processors(0));
        }