예제 #1
0
        public void Start(int groupCount, ListenerNotifier notifier, OrderedHashTree threadGroupTree, StandardEngine engine)
        {
            int threadNumber = GetThreadsNumber();
            // TODO : log

            Int32           now     = System.DateTime.Now.Millisecond;
            NetMeterContext context = NetMeterContextManager.GetContext();

            for (int i = 0; running && i < threadNumber; i++)
            {
                NetMeterThread nmThread  = CreateThread(groupCount, notifier, threadGroupTree, engine, i, context);
                Thread         newThread = new Thread(nmThread.Run);
                RegisterStartedThread(nmThread, newThread);
                newThread.Start();
            }

            // TODO : log
        }
예제 #2
0
        private static sealed Boolean reversePostProcessors = false; // $NON-NLS-1$

        public void Run()
        {
            // threadContext is not thread-safe, so keep within thread
            NetMeterContext       threadContext     = NetMeterContextManager.GetContext();
            LoopIterationListener iterationListener = null;

            try
            {
                iterationListener = InitRun(threadContext);
                while (running)
                {
                    TestAgent sam = (TestAgent)controller.next();
                    while (running && sam != null)
                    {
                        ProcessTestAgent(sam, null, threadContext);
                        threadContext.CleanAfterExecute();
                        if (onErrorStartNextLoop || threadContext.restartNextLoop)
                        {
                            if (threadContext.restartNextLoop)
                            {
                                TriggerEndOfLoopOnParentControllers(sam, threadContext);
                                sam = null;
                                threadContext.GetVariables().Add(LAST_SAMPLE_OK, TRUE);
                                threadContext.restartNextLoop = false;
                            }
                            else
                            {
                                Boolean lastSampleFailed = !TRUE.Equals(threadContext.GetVariables().Get(LAST_SAMPLE_OK));
                                if (lastSampleFailed)
                                {
//                                  if(log.isDebugEnabled())
//                                    {
//                                      log.debug("StartNextLoop option is on, Last sample failed, starting next loop");
//                                  }
                                    TriggerEndOfLoopOnParentControllers(sam, threadContext);
                                    sam = null;
                                    threadContext.GetVariables().Add(LAST_SAMPLE_OK, TRUE);
                                }
                                else
                                {
                                    sam = (TestAgent)controller.next();
                                }
                            }
                        }
                        else
                        {
                            sam = (TestAgent)controller.next();
                        }
                    }
                    if (controller.isDone())
                    {
                        running = false;
                    }
                }
            }
            // Might be found by contoller.next()
            //catch (NetMeterStopTestException e)
            //{
            //    log.info("Stopping Test: " + e.toString());
            //    stopTest();
            //}
            //catch (JMeterStopTestNowException e)
            //{
            //    log.info("Stopping Test Now: " + e.toString());
            //    stopTestNow();
            //}
            //catch (JMeterStopThreadException e)
            //{
            //    log.info("Stop Thread seen: " + e.toString());
            //}
            catch (Exception ex)
            {
                log.Error("Test failed!", ex);
            }
            //catch (ThreadDeath e)
            //{
            //    throw e; // Must not ignore this one
            //}
            finally
            {
                currentSampler = null; // prevent any further interrupts
                try
                {
                    Monitor.Enter(interruptLock);  // make sure current interrupt is finished, prevent another starting yet
                    threadContext.Clear();
//                    log.info("Thread finished: " + threadName);
                    ThreadFinished(iterationListener);
                    monitor.ThreadFinished(this);           // Tell the monitor we are done
                    NetMeterContextManager.RemoveContext(); // Remove the ThreadLocal entry
                }
                finally
                {
                    Monitor.Exit(interruptLock); // Allow any pending interrupt to complete (OK because currentSampler == null)
                }
            }
        }