Package org.apache.jmeter.threads

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


                + " threads " + numThreads);
      
            long now = System.currentTimeMillis(); // needs to be same time for all threads in the group
            final JMeterContext context = JMeterContextService.getContext();
            for (int i = 0; running && i < numThreads; i++) {
                JMeterThread jmThread = makeThread(groupCount, notifier, threadGroupTree, engine, i, context);
                scheduleThread(jmThread, now); // set start and end time
                Thread newThread = new Thread(jmThread, jmThread.getThreadName());
                registerStartedThread(jmThread, newThread);
                newThread.start();
            }

        log.info("Started thread group number "+groupCount);
View Full Code Here


        boolean onErrorStopTest = getOnErrorStopTest();
        boolean onErrorStopTestNow = getOnErrorStopTestNow();
        boolean onErrorStopThread = getOnErrorStopThread();
        boolean onErrorStartNextLoop = getOnErrorStartNextLoop();
        String groupName = getName();
        final JMeterThread jmeterThread = new JMeterThread(cloneTree(threadGroupTree), this, notifier);
        jmeterThread.setThreadNum(i);
        jmeterThread.setThreadGroup(this);
        jmeterThread.setInitialContext(context);
        final String threadName = groupName + " " + (groupCount) + "-" + (i + 1);
        jmeterThread.setThreadName(threadName);
        jmeterThread.setEngine(engine);
        jmeterThread.setOnErrorStopTest(onErrorStopTest);
        jmeterThread.setOnErrorStopTestNow(onErrorStopTestNow);
        jmeterThread.setOnErrorStopThread(onErrorStopThread);
        jmeterThread.setOnErrorStartNextLoop(onErrorStartNextLoop);
        return jmeterThread;
    }
View Full Code Here

    }

    @Override
    public boolean stopThread(String threadName, boolean now) {
        for(Entry<JMeterThread, Thread> entry : 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

    @Override
    public void tellThreadsToStop() {
        running = false;
        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

    @Test
    public void testScheduleThread() {
        System.out.println("scheduleThread");
        HashTree hashtree = new HashTree();
        hashtree.add(new LoopController());
        JMeterThread thread = new JMeterThread(hashtree, null, null);

        CollectionProperty prop = JMeterPluginsUtils.tableModelRowsToCollectionProperty(dataModel, UltimateThreadGroup.DATA_PROPERTY);
        instance.setData(prop);
        instance.testStarted();

        instance.scheduleThread(thread);

        assertTrue(thread.getStartTime() > 0);
        assertTrue(thread.getEndTime() > thread.getStartTime());
    }
View Full Code Here

        CollectionProperty prop = JMeterPluginsUtils.tableModelRowsToCollectionProperty(dataModel, UltimateThreadGroup.DATA_PROPERTY);
        instance.setData(prop);
        instance.testStarted();

        for (int n = 0; n < instance.getNumThreads(); n++) {
            JMeterThread thread = new JMeterThread(hashtree, null, null);
            thread.setThreadNum(n);
            instance.scheduleThread(thread);
        }
    }
View Full Code Here

    @Test
    public void testScheduleThread() {
        System.out.println("scheduleThread");
        HashTree hashtree = new HashTree();
        hashtree.add(new LoopController());
        JMeterThread thread = new JMeterThread(hashtree, null, null);
        SteppingThreadGroup instance = new SteppingThreadGroup();
        instance.setNumThreads(15);
        instance.setInUserCount("5");
        instance.setInUserCountBurst("10");
        instance.setInUserPeriod("30");
        instance.setRampUp("10");
        instance.setThreadGroupDelay("5");
        instance.setFlightTime("60");

        long s1 = -1, s2;
        for (int n = 0; n < 10; n++) {
            thread.setThreadNum(n);
            instance.scheduleThread(thread);
            s2 = thread.getStartTime();
            if (s1 >= 0) {
                assertEquals(1000, s2 - s1);
            }
            s1 = s2;
        }

        thread.setThreadNum(10);
        instance.scheduleThread(thread);
        s2 = thread.getStartTime();
        assertEquals(31000, s2 - s1);
        s1 = s2;

        for (int n = 11; n < 15; n++) {
            thread.setThreadNum(n);
            instance.scheduleThread(thread);
            s2 = thread.getStartTime();
            if (s1 >= 0) {
                assertEquals(2000, s2 - s1);
            }
            s1 = s2;
        }
View Full Code Here

    @Test
    public void testScheduleThreadIntegerOverflow() {
        System.out.println("scheduleThreadIntegerOverflow");
        HashTree hashtree = new HashTree();
        hashtree.add(new LoopController());
        JMeterThread thread = new JMeterThread(hashtree, null, null);
        SteppingThreadGroup instance = new SteppingThreadGroup();
        int numThreads = 3;
        instance.setNumThreads(numThreads);
        int inUserCount = 1;
        instance.setInUserCount("" + inUserCount);
        instance.setInUserCountBurst("0");
        int inUserPeriod = 224985600;
        instance.setInUserPeriod("" + inUserPeriod);
        instance.setRampUp("0");
        instance.setThreadGroupDelay("0");
        int flightTime = 33;
        instance.setFlightTime("" + flightTime);

        thread.setThreadNum(0);
        instance.scheduleThread(thread);

        assertEquals(1000L * ((inUserCount + 1) * inUserPeriod + inUserCount * flightTime), thread.getEndTime() - thread.getStartTime());

    }
View Full Code Here

        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

TOP

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

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.