Beispiel #1
0
        private void ThreadFinished(LoopIterationListener iterationListener)
        {
            ThreadListenerTraverser shut = new ThreadListenerTraverser(false);

            testTree.Traverse(shut); // call ThreadListener.threadFinished()
            NetMeterContextManager.DecrNumberOfThreads();
            threadGroup.DecrNumberOfThreads();
            if (iterationListener != null)
            { // probably not possible, but check anyway
                controller.RemoveIterationListener(iterationListener);
            }
        }
        //public override Boolean AddTestElementOnce(TestElement child)
        //{
        //    if (children.putIfAbsent(child, DUMMY) == null)
        //    {
        //        AddTestElement(child);
        //        return true;
        //    }
        //    return false;
        //}

        public override void AddIterationListener(LoopIterationListener lis)
        {
            GetSamplerController().AddIterationListener(lis);
        }
 public override void RemoveIterationListener(LoopIterationListener iterationListener)
 {
     GetSamplerController().RemoveIterationListener(iterationListener);
 }
Beispiel #4
0
 //public override Boolean AddTestElementOnce(TestElement child)
 //{
 //    if (children.putIfAbsent(child, DUMMY) == null)
 //    {
 //        AddTestElement(child);
 //        return true;
 //    }
 //    return false;
 //}
 public override void AddIterationListener(LoopIterationListener lis)
 {
     GetSamplerController().AddIterationListener(lis);
 }
Beispiel #5
0
 public override void RemoveIterationListener(LoopIterationListener iterationListener)
 {
     GetSamplerController().RemoveIterationListener(iterationListener);
 }
Beispiel #6
0
 private void ThreadFinished(LoopIterationListener iterationListener)
 {
     ThreadListenerTraverser shut = new ThreadListenerTraverser(false);
     testTree.Traverse(shut); // call ThreadListener.threadFinished()
     NetMeterContextManager.DecrNumberOfThreads();
     threadGroup.DecrNumberOfThreads();
     if (iterationListener != null)
     { // probably not possible, but check anyway
         controller.RemoveIterationListener(iterationListener);
     }
 }
Beispiel #7
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)
                }
            }
        }