Package org.apache.jmeter.threads

Examples of org.apache.jmeter.threads.JMeterThread$IterationListener


        if (engine == null) {
            return false;// e.g. not yet started
        }
        // ConcurrentHashMap does not need synch. here
        for(Entry<JMeterThread, Thread> entry : engine.allThreads.entrySet()){
            JMeterThread thrd = entry.getKey();
            if (thrd.getThreadName().equals(threadName)){
                thrd.stop();
                thrd.interrupt();
                if (now) {
                    Thread t = entry.getValue();
                    if (t != null) {
                        t.interrupt();
                    }
View Full Code Here


                log.info("Thread will continue on error");
            }
            ListedHashTree threadGroupTree = (ListedHashTree) searcher.getSubTree(group);
            threadGroupTree.add(group, testLevelElements);
            for (int i = 0; running && i < numThreads; i++) {
                final JMeterThread jmeterThread = new JMeterThread(cloneTree(threadGroupTree), this, notifier);
                jmeterThread.setThreadNum(i);
                jmeterThread.setThreadGroup(group);
                jmeterThread.setInitialContext(JMeterContextService.getContext());
                final String threadName = groupName + " " + (groupCount) + "-" + (i + 1);
                jmeterThread.setThreadName(threadName);
                jmeterThread.setEngine(this);
                jmeterThread.setOnErrorStopTest(onErrorStopTest);
                jmeterThread.setOnErrorStopTestNow(onErrorStopTestNow);
                jmeterThread.setOnErrorStopThread(onErrorStopThread);
                jmeterThread.setOnErrorStartNextLoop(onErrorStartNextLoop);

                group.scheduleThread(jmeterThread);

                Thread newThread = new Thread(jmeterThread);
                newThread.setName(threadName);
View Full Code Here

     * </ul>
     */
    private void tellThreadsToStop() {
        // ConcurrentHashMap does not need protecting
        for (Entry<JMeterThread, Thread> entry : allThreads.entrySet()) {
            JMeterThread item = entry.getKey();
            item.stop(); // set stop flag
            item.interrupt(); // interrupt sampler if possible
            Thread t = entry.getValue();
            if (t != null ) { // Bug 49734
                t.interrupt(); // also interrupt JVM thread
            }
        }
View Full Code Here

      return stopThread(threadName,true);
    }
    private static boolean stopThread(String threadName, boolean now)
    {
      if (allThreadNames == null) return false;// e.g. not yet started
      JMeterThread thrd;
    try {
          thrd = (JMeterThread)allThreadNames.get(threadName);
      } catch (Exception e) {
        log.warn("stopThread: "+e);
        return false;
      }
      if (thrd!= null)
      {
        thrd.stop();
        if (now)
        {
            Thread t = (Thread) allThreadsSave.get(thrd);
            if (t != null)
            {
View Full Code Here

            {
                ListedHashTree threadGroupTree =
                    (ListedHashTree) searcher.getSubTree(group);
                threadGroupTree.add(group, testLevelElements);
                threads[i] =
                    new JMeterThread(
                        cloneTree(threadGroupTree),
                        this,
                        notifier);
                threads[i].setThreadNum(i);
                threads[i].setInitialContext(JMeterContextService.getContext());
View Full Code Here

    private void tellThreadsToStop()
    {
        Iterator iter = new HashSet(allThreads.keySet()).iterator();
        while (iter.hasNext())
        {
            JMeterThread item = (JMeterThread) iter.next();
            item.stop();
            Thread t = (Thread) allThreads.get(item);
            if (t != null)
            {
                t.interrupt();
            }
            else
            {
                log.warn("Lost thread: " + item.getThreadName());
                allThreads.remove(item);
            }
        }
    }
View Full Code Here

  private void stopAllThreads()
  {
    Iterator iter = new HashSet(allThreads.keySet()).iterator();
    while (iter.hasNext())
    {
      JMeterThread item = (JMeterThread) iter.next();
      item.stop();
    }
  }
View Full Code Here

    // variables to store the ThreadGroups LoopController values so
    // that they can be reset later
    int lcLoops = 0;
    boolean lcContinueForever = false;
    running = true;
    JMeterThread jMeterThread;
    Iterator iter = threadGroups.iterator();
    ThreadGroup thisThreadGroup = null;
    boolean runThis = false;
    while(iter.hasNext())
    {
      // look for threadGroup with MethodConfig element
      thisThreadGroup = (ThreadGroup)iter.next();
      GenericController control = (GenericController)
    thisThreadGroup.getSamplerController().clone();
      List subControllerList = control.getSubControllers();
      List configElementList = control.getConfigElements();
      Iterator subControllersIterator = subControllerList.iterator();
      if(catClass.isDebugEnabled())
      {
        catClass.debug("runTest1 : thisThreadGroup - " + thisThreadGroup);
        catClass.debug("runTest1 : controller - " + control);
        catClass.debug("runTest1 : configElementList - " + configElementList);
        catClass.debug("runTest1 : subControllerList - " + subControllerList);
      }
      while(subControllersIterator.hasNext())
      {
        SamplerController samplerController = (SamplerController)
    subControllersIterator.next();
        if(catClass.isDebugEnabled())
        {
          catClass.debug("runTest1 : samplerController type - "
    + samplerController.getClass());
        }
        if(samplerController instanceof JndiTestSample)
        {
          runThis = true;
        }
      }
      if(runThis)
      {
        catClass.debug("runTest1 : running ThreadGroup with JndiTestSample");
        // Change the ThreadGroup looping to 1 'cos you only need to
        // run the JNDISampler once to do reflection
        // Ensure that sampleController of ThreadGroup is a LoopController
        // which is a certainty but still in case things change in the future
        // this should flag it
        LoopController lc = null;
        if(control instanceof LoopController)
        {
          lc = (LoopController)control;
          lcLoops = lc.getLoops();
          lcContinueForever = lc.getContinueForever();
          lc.setContinueForever(false);
    lc.setLoops(1);
          thisThreadGroup.setSamplerController(lc);
        }
        runThis = false;
        jMeterThread = new JMeterThread(thisThreadGroup);
        Thread newThread = new Thread(jMeterThread);
        newThread.start();
        try
        {
          newThread.join();
View Full Code Here

        }
        threads = new JMeterThread[threadCount];
        threadList = new Thread[threadCount];
        for(int i = 0; i < threads.length; i++)
        {
          threads[i] = new JMeterThread(group);
          threadList[i] = new Thread(threads[i],
            "Total Thread : " + threadCount + " ; Thead No. : " + i);
          allThreads.add(threads[i]);
          threadList[i].start();
        }
View Full Code Here

      ThreadGroup group = (ThreadGroup)iter.next();
      group.resetThreadCount();
      threads = new JMeterThread[group.getNumThreads()];
      for(int i = 0; i < threads.length; i++)
      {
        threads[i] = new JMeterThread(group);
        Thread newThread = new Thread(threads[i]);
        allThreads.add(threads[i]);
        newThread.start();
      }
    }
View Full Code Here

TOP

Related Classes of org.apache.jmeter.threads.JMeterThread$IterationListener

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.