Package org.apache.jmeter.threads

Examples of org.apache.jmeter.threads.JMeterThread


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


  }

  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) {
          t.interrupt();
        }
View Full Code Here

      }

            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());
        jmeterThread.setInitialDelay((int) (perThreadDelay * i));
        jmeterThread.setThreadName(groupName + " " + (groupCount) + "-" + (i + 1));

        scheduleThread(jmeterThread, group);

        // Set up variables for stop handling
        jmeterThread.setEngine(this);
        jmeterThread.setOnErrorStopTest(onErrorStopTest);
        jmeterThread.setOnErrorStopThread(onErrorStopThread);

        Thread newThread = new Thread(jmeterThread);
        newThread.setName(jmeterThread.getThreadName());
        allThreads.put(jmeterThread, newThread);
        if (serialized && !iter.hasNext() && i == numThreads - 1) // last thread
        {
          serialized = false;
        }
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

        row.setMarkerSize(AbstractGraphRow.MARKER_SIZE_NONE);
        row.setDrawThickLines(true);

        final HashTree hashTree = new HashTree();
        hashTree.add(new LoopController());
        JMeterThread thread = new JMeterThread(hashTree, null, null);

        long now = System.currentTimeMillis();

        chart.setxAxisLabelRenderer(new DateTimeRenderer(DateTimeRenderer.HHMMSS, now - 1)); //-1 because row.add(thread.getStartTime() - 1, 0)
        chart.setForcedMinX(now);

        row.add(now, 0);

        // users in
        int numThreads = tg.getNumThreads();
        log.debug("Num Threads: " + numThreads);
        for (int n = 0; n < numThreads; n++) {
            thread.setThreadNum(n);
            thread.setThreadName(Integer.toString(n));
            tg.scheduleThread(thread, now);
            row.add(thread.getStartTime() - 1, 0);
            row.add(thread.getStartTime(), 1);
        }

        tg.testStarted();
        // users out
        for (int n = 0; n < tg.getNumThreads(); n++) {
            thread.setThreadNum(n);
            thread.setThreadName(Integer.toString(n));
            tg.scheduleThread(thread, now);
            row.add(thread.getEndTime() - 1, 0);
            row.add(thread.getEndTime(), -1);
        }

        model.put("Expected parallel users count", row);
        chart.invalidateCache();
        chart.repaint();
View Full Code Here

    * Test of scheduleThread method, of class AbstractSimpleThreadGroup.
    */
   @Test
   public void testScheduleThread_JMeterThread_long() {
      System.out.println("scheduleThread");
      JMeterThread thread = null;
      long now = 0L;
      AbstractSimpleThreadGroup instance = new AbstractSimpleThreadGroupImpl();
      instance.scheduleThread(thread, now);
   }
View Full Code Here

    * Test of scheduleThread method, of class AbstractSimpleThreadGroup.
    */
   @Test
   public void testScheduleThread_JMeterThread() {
      System.out.println("scheduleThread");
      JMeterThread thread = null;
      AbstractSimpleThreadGroup instance = new AbstractSimpleThreadGroupImpl();
      instance.scheduleThread(thread);
   }
View Full Code Here

   @Test
   public void testThreadFinished() {
      System.out.println("threadFinished");
      HashTree hashtree = new HashTree();
      hashtree.add(new LoopController());
      JMeterThread thread = new JMeterThread(hashtree, null, null);
      AbstractSimpleThreadGroup instance = new AbstractSimpleThreadGroupImpl();
      instance.threadFinished(thread);
   }
View Full Code Here

        row.setMarkerSize(AbstractGraphRow.MARKER_SIZE_NONE);
        row.setDrawThickLines(true);

        final HashTree hashTree = new HashTree();
        hashTree.add(new LoopController());
        JMeterThread thread = new JMeterThread(hashTree, null, null);

        long now = System.currentTimeMillis();

        // test start
        chart.setxAxisLabelRenderer(new DateTimeRenderer(DateTimeRenderer.HHMMSS, now - 1)); //-1 because row.add(thread.getStartTime() - 1, 0)
        row.add(now, 0);
        row.add(now + tg.getThreadGroupDelayAsInt(), 0);

        int numThreads = tg.getNumThreads();

        // users in
        for (int n = 0; n < numThreads; n++) {
            thread.setThreadNum(n);
            tg.scheduleThread(thread, now);
            row.add(thread.getStartTime() - 1, 0);
            row.add(thread.getStartTime(), 1);
        }

        // users out
        for (int n = 0; n < numThreads; n++) {
            thread.setThreadNum(n);
            tg.scheduleThread(thread, now);
            row.add(thread.getEndTime() - 1, 0);
            row.add(thread.getEndTime(), -1);
        }

        model.put("Expected Active Users Count", row);
        chart.invalidateCache();
        chart.repaint();
View Full Code Here

TOP

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

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.