Package org.apache.jmeter.control

Examples of org.apache.jmeter.control.TransactionSampler


            }
        }

        SamplePackage pack = new SamplePackage(configs, listeners, timers, assertions,
                posts, pres, controllers);
        pack.setSampler(new TransactionSampler(tc, tc.getName()));
        pack.setRunningVersion(true);
        transactionControllerConfigMap.put(tc, pack);
    }
View Full Code Here


                Sampler sam = firstSampler;
                while (running && sam != null) {
                    if (onErrorStartNextLoop) { // if the threadGroup option is to start next loop when it fails
                        // special case: TC as parent and last subsampler is not Ok
                        if (!TRUE.equals(threadContext.getVariables().get(LAST_SAMPLE_OK)) && sam instanceof TransactionSampler) {
                            TransactionSampler ts = (TransactionSampler) sam;
                            while (!ts.isTransactionDone()) { // go to last subsampler
                                sam = controller.next();
                                ts = (TransactionSampler) sam;
                            }
                            // process now for close transaction (not sampling)
                            process_sampler(sam, null, threadContext);
View Full Code Here

    @SuppressWarnings("deprecation") // OK to call TestBeanHelper.prepare()
    private SampleResult process_sampler(Sampler current, Sampler parent, JMeterContext threadContext) {
        SampleResult transactionResult = null;
        try {
            // Check if we are running a transaction
            TransactionSampler transactionSampler = null;
            if(current instanceof TransactionSampler) {
                transactionSampler = (TransactionSampler) current;
            }
            // Find the package for the transaction
            SamplePackage transactionPack = null;
            if(transactionSampler != null) {
                transactionPack = compiler.configureTransactionSampler(transactionSampler);

                // Check if the transaction is done
                if(transactionSampler.isTransactionDone()) {
                    // Get the transaction sample result
                    transactionResult = transactionSampler.getTransactionResult();
                    transactionResult.setThreadName(threadName);
                    transactionResult.setGroupThreads(threadGroup.getNumberOfThreads());
                    transactionResult.setAllThreads(JMeterContextService.getNumberOfThreads());

                    // Check assertions for the transaction sample
                    checkAssertions(transactionPack.getAssertions(), transactionResult, threadContext);
                    // Notify listeners with the transaction sample result
                    if (!(parent instanceof TransactionSampler)){
                        notifyListeners(transactionPack.getSampleListeners(), transactionResult);
                    }
                    compiler.done(transactionPack);
                    // Transaction is done, we do not have a sampler to sample
                    current = null;
                }
                else {
                    Sampler prev = current;
                    // It is the sub sampler of the transaction that will be sampled
                    current = transactionSampler.getSubSampler();
                    if (current instanceof TransactionSampler){
                        SampleResult res = process_sampler(current, prev, threadContext);// recursive call
                        threadContext.setCurrentSampler(prev);
                        current=null;
                        if (res!=null){
                            transactionSampler.addSubSamplerResult(res);
                        }
                    }
                }
            }

            // Check if we have a sampler to sample
            if(current != null) {
                threadContext.setCurrentSampler(current);
                // Get the sampler ready to sample
                SamplePackage pack = compiler.configureSampler(current);
                runPreProcessors(pack.getPreProcessors());

                // Hack: save the package for any transaction controllers
                threadVars.putObject(PACKAGE_OBJECT, pack);

                delay(pack.getTimers());
                Sampler sampler = pack.getSampler();
                sampler.setThreadContext(threadContext);
                sampler.setThreadName(threadName);
                TestBeanHelper.prepare(sampler);

                // Perform the actual sample
                currentSampler = sampler;
                SampleResult result = sampler.sample(null);
                currentSampler = null;
                // TODO: remove this useless Entry parameter

                // If we got any results, then perform processing on the result
                if (result != null) {
                    result.setGroupThreads(threadGroup.getNumberOfThreads());
                    result.setAllThreads(JMeterContextService.getNumberOfThreads());
                    result.setThreadName(threadName);
                    threadContext.setPreviousResult(result);
                    runPostProcessors(pack.getPostProcessors());
                    checkAssertions(pack.getAssertions(), result, threadContext);
                    // Do not send subsamples to listeners which receive the transaction sample
                    List<SampleListener> sampleListeners = getSampleListeners(pack, transactionPack, transactionSampler);
                    notifyListeners(sampleListeners, result);
                    compiler.done(pack);
                    // Add the result as subsample of transaction if we are in a transaction
                    if(transactionSampler != null) {
                        transactionSampler.addSubSamplerResult(result);
                    }

                    // Check if thread or test should be stopped
                    if (result.isStopThread() || (!result.isSuccessful() && onErrorStopThread)) {
                        stopThread();
View Full Code Here

     * @param threadContext
     */
    private void triggerEndOfLoopOnParentControllers(Sampler sam, JMeterContext threadContext) {
        // Find parent controllers of current sampler
        FindTestElementsUpToRootTraverser pathToRootTraverser=null;
        TransactionSampler transactionSampler = null;
        if(sam instanceof TransactionSampler) {
            transactionSampler = (TransactionSampler) sam;
            pathToRootTraverser = new FindTestElementsUpToRootTraverser((transactionSampler).getTransactionController());
        } else {
            pathToRootTraverser = new FindTestElementsUpToRootTraverser(sam);
View Full Code Here

    @SuppressWarnings("deprecation") // OK to call TestBeanHelper.prepare()
    private SampleResult process_sampler(Sampler current, Sampler parent, JMeterContext threadContext) {
        SampleResult transactionResult = null;
        try {
            // Check if we are running a transaction
            TransactionSampler transactionSampler = null;
            if(current instanceof TransactionSampler) {
                transactionSampler = (TransactionSampler) current;
            }
            // Find the package for the transaction
            SamplePackage transactionPack = null;
            if(transactionSampler != null) {
                transactionPack = compiler.configureTransactionSampler(transactionSampler);

                // Check if the transaction is done
                if(transactionSampler.isTransactionDone()) {
                    // Get the transaction sample result
                    transactionResult = transactionSampler.getTransactionResult();
                    transactionResult.setThreadName(threadName);
                    transactionResult.setGroupThreads(threadGroup.getNumberOfThreads());
                    transactionResult.setAllThreads(JMeterContextService.getNumberOfThreads());

                    // Check assertions for the transaction sample
                    checkAssertions(transactionPack.getAssertions(), transactionResult, threadContext);
                    // Notify listeners with the transaction sample result
                    if (!(parent instanceof TransactionSampler)){
                        notifyListeners(transactionPack.getSampleListeners(), transactionResult);
                    }
                    compiler.done(transactionPack);
                    // Transaction is done, we do not have a sampler to sample
                    current = null;
                }
                else {
                    Sampler prev = current;
                    // It is the sub sampler of the transaction that will be sampled
                    current = transactionSampler.getSubSampler();
                    if (current instanceof TransactionSampler){
                        SampleResult res = process_sampler(current, prev, threadContext);// recursive call
                        threadContext.setCurrentSampler(prev);
                        current=null;
                        if (res!=null){
                            transactionSampler.addSubSamplerResult(res);
                        }
                    }
                }
            }

            // Check if we have a sampler to sample
            if(current != null) {
                threadContext.setCurrentSampler(current);
                // Get the sampler ready to sample
                SamplePackage pack = compiler.configureSampler(current);
                runPreProcessors(pack.getPreProcessors());

                // Hack: save the package for any transaction controllers
                threadVars.putObject(PACKAGE_OBJECT, pack);

                delay(pack.getTimers());
                Sampler sampler = pack.getSampler();
                sampler.setThreadContext(threadContext);
                // TODO should this set the thread names for all the subsamples?
                // might be more efficient than fetching the name elsewehere
                sampler.setThreadName(threadName);
                TestBeanHelper.prepare(sampler);

                // Perform the actual sample
                currentSampler = sampler;
                SampleResult result = sampler.sample(null);
                currentSampler = null;
                // TODO: remove this useless Entry parameter

                // If we got any results, then perform processing on the result
                if (result != null) {
                    result.setGroupThreads(threadGroup.getNumberOfThreads());
                    result.setAllThreads(JMeterContextService.getNumberOfThreads());
                    result.setThreadName(threadName);
                    threadContext.setPreviousResult(result);
                    runPostProcessors(pack.getPostProcessors());
                    checkAssertions(pack.getAssertions(), result, threadContext);
                    // Do not send subsamples to listeners which receive the transaction sample
                    List<SampleListener> sampleListeners = getSampleListeners(pack, transactionPack, transactionSampler);
                    notifyListeners(sampleListeners, result);
                    compiler.done(pack);
                    // Add the result as subsample of transaction if we are in a transaction
                    if(transactionSampler != null) {
                        transactionSampler.addSubSamplerResult(result);
                    }

                    // Check if thread or test should be stopped
                    if (result.isStopThread() || (!result.isSuccessful() && onErrorStopThread)) {
                        stopThread();
View Full Code Here

        while (running && (sam = controller.next()) != null) {
          try {
            threadContext.setCurrentSampler(sam);
                       
                        // Check if we are running a transaction
                        TransactionSampler transactionSampler = null;
                        if(sam instanceof TransactionSampler) {
                            transactionSampler = (TransactionSampler) sam;
                        }
                        // Find the package for the transaction
                        SamplePackage transactionPack = null;
                        if(transactionSampler != null) {
                            transactionPack = compiler.configureTransactionSampler(transactionSampler);
                           
                            // Check if the transaction is done
                            if(transactionSampler.isTransactionDone()) {
                                // Get the transaction sample result
                                SampleResult transactionResult = transactionSampler.getTransactionResult();

                                // Check assertions for the transaction sample
                                transactionResult.setThreadName(threadName);
                                checkAssertions(transactionPack.getAssertions(), transactionResult);
                                // Notify listeners with the transaction sample result
                                notifyListeners(transactionPack.getSampleListeners(), transactionResult);
                                compiler.done(transactionPack);
                                // Transaction is done, we do not have a sampler to sample
                                sam = null;
                            }
                            else {
                                // It is the sub sampler of the transaction that will be sampled
                                sam = transactionSampler.getSubSampler();
                            }
                        }
                       
                        // Check if we have a sampler to sample
                        if(sam != null) {
                            // Get the sampler ready to sample
                            SamplePackage pack = compiler.configureSampler(sam);

                // Hack: save the package for any transaction
                // controllers
                threadContext.getVariables().putObject(PACKAGE_OBJECT, pack);

                            delay(pack.getTimers());
                            Sampler sampler = pack.getSampler();
                            sampler.setThreadContext(threadContext);
                            sampler.setThreadName(threadName);
                            TestBeanHelper.prepare(sampler);
                       
                            // Perform the actual sample
                            SampleResult result = sampler.sample(null);
                            // TODO: remove this useless Entry parameter
                       
                            // If we got any results, then perform processing on the result
                            if (result != null) {
                                result.setThreadName(threadName);
                                threadContext.setPreviousResult(result);
                                runPostProcessors(pack.getPostProcessors());
                                checkAssertions(pack.getAssertions(), result);
                                // Do not send subsamples to listeners which receive the transaction sample
                                List sampleListeners = getSampleListeners(pack, transactionPack, transactionSampler);
                                notifyListeners(sampleListeners, result);
                                compiler.done(pack);
                                // Add the result as subsample of transaction if we are in a transaction
                                if(transactionSampler != null) {
                                    transactionSampler.addSubSamplerResult(result);
                                }

                                // Check if thread or test should be stopped
                                if (result.isStopThread() || (!result.isSuccessful() && onErrorStopThread)) {
                                    stopThread();
View Full Code Here

                Sampler sam = firstSampler;
                while (running && sam != null) {
                    if (onErrorStartNextLoop) { // if the threadGroup option is to start next loop when it fails
                        // special case: TC as parent and last subsampler is not Ok
                        if (!TRUE.equals(threadContext.getVariables().get(LAST_SAMPLE_OK)) && sam instanceof TransactionSampler) {
                            TransactionSampler ts = (TransactionSampler) sam;
                            while (!ts.isTransactionDone()) { // go to last subsampler
                                sam = controller.next();
                                ts = (TransactionSampler) sam;
                            }
                            // process now for close transaction (not sampling)
                            process_sampler(sam, null, threadContext);
View Full Code Here

    @SuppressWarnings("deprecation") // OK to call TestBeanHelper.prepare()
    private SampleResult process_sampler(Sampler current, Sampler parent, JMeterContext threadContext) {
        SampleResult transactionResult = null;
        try {
            // Check if we are running a transaction
            TransactionSampler transactionSampler = null;
            if(current instanceof TransactionSampler) {
                transactionSampler = (TransactionSampler) current;
            }
            // Find the package for the transaction
            SamplePackage transactionPack = null;
            if(transactionSampler != null) {
                transactionPack = compiler.configureTransactionSampler(transactionSampler);

                // Check if the transaction is done
                if(transactionSampler.isTransactionDone()) {
                    // Get the transaction sample result
                    transactionResult = transactionSampler.getTransactionResult();
                    transactionResult.setThreadName(threadName);
                    transactionResult.setGroupThreads(threadGroup.getNumberOfThreads());
                    transactionResult.setAllThreads(JMeterContextService.getNumberOfThreads());

                    // Check assertions for the transaction sample
                    checkAssertions(transactionPack.getAssertions(), transactionResult, threadContext);
                    // Notify listeners with the transaction sample result
                    if (!(parent instanceof TransactionSampler)){
                        notifyListeners(transactionPack.getSampleListeners(), transactionResult);
                    }
                    compiler.done(transactionPack);
                    // Transaction is done, we do not have a sampler to sample
                    current = null;
                }
                else {
                    Sampler prev = current;
                    // It is the sub sampler of the transaction that will be sampled
                    current = transactionSampler.getSubSampler();
                    if (current instanceof TransactionSampler){
                        SampleResult res = process_sampler(current, prev, threadContext);// recursive call
                        threadContext.setCurrentSampler(prev);
                        current=null;
                        if (res!=null){
                            transactionSampler.addSubSamplerResult(res);
                        }
                    }
                }
            }

            // Check if we have a sampler to sample
            if(current != null) {
                threadContext.setCurrentSampler(current);
                // Get the sampler ready to sample
                SamplePackage pack = compiler.configureSampler(current);
                runPreProcessors(pack.getPreProcessors());

                // Hack: save the package for any transaction controllers
                threadVars.putObject(PACKAGE_OBJECT, pack);

                delay(pack.getTimers());
                Sampler sampler = pack.getSampler();
                sampler.setThreadContext(threadContext);
                sampler.setThreadName(threadName);
                TestBeanHelper.prepare(sampler);

                // Perform the actual sample
                currentSampler = sampler;
                SampleResult result = sampler.sample(null);
                currentSampler = null;
                // TODO: remove this useless Entry parameter

                // If we got any results, then perform processing on the result
                if (result != null) {
                    result.setGroupThreads(threadGroup.getNumberOfThreads());
                    result.setAllThreads(JMeterContextService.getNumberOfThreads());
                    result.setThreadName(threadName);
                    threadContext.setPreviousResult(result);
                    runPostProcessors(pack.getPostProcessors());
                    checkAssertions(pack.getAssertions(), result, threadContext);
                    // Do not send subsamples to listeners which receive the transaction sample
                    List<SampleListener> sampleListeners = getSampleListeners(pack, transactionPack, transactionSampler);
                    notifyListeners(sampleListeners, result);
                    compiler.done(pack);
                    // Add the result as subsample of transaction if we are in a transaction
                    if(transactionSampler != null) {
                        transactionSampler.addSubSamplerResult(result);
                    }

                    // Check if thread or test should be stopped
                    if (result.isStopThread() || (!result.isSuccessful() && onErrorStopThread)) {
                        stopThread();
View Full Code Here

        while (running && (sam = controller.next()) != null) {
          try {
            threadContext.setCurrentSampler(sam);
                       
                        // Check if we are running a transaction
                        TransactionSampler transactionSampler = null;
                        if(sam instanceof TransactionSampler) {
                            transactionSampler = (TransactionSampler) sam;
                        }
                        // Find the package for the transaction
                        SamplePackage transactionPack = null;
                        if(transactionSampler != null) {
                            transactionPack = compiler.configureTransactionSampler(transactionSampler);
                           
                            // Check if the transaction is done
                            if(transactionSampler.isTransactionDone()) {
                                // Get the transaction sample result
                                SampleResult transactionResult = transactionSampler.getTransactionResult();
                                transactionResult.setThreadName(threadName);
                                transactionResult.setGroupThreads(threadGroup.getNumberOfThreads());
                                transactionResult.setAllThreads(JMeterContextService.getNumberOfThreads());

                                // Check assertions for the transaction sample
                                checkAssertions(transactionPack.getAssertions(), transactionResult);
                                // Notify listeners with the transaction sample result
                                notifyListeners(transactionPack.getSampleListeners(), transactionResult);
                                compiler.done(transactionPack);
                                // Transaction is done, we do not have a sampler to sample
                                sam = null;
                            }
                            else {
                                // It is the sub sampler of the transaction that will be sampled
                                sam = transactionSampler.getSubSampler();
                            }
                        }
                       
                        // Check if we have a sampler to sample
                        if(sam != null) {
                            // Get the sampler ready to sample
                            SamplePackage pack = compiler.configureSampler(sam);

                // Hack: save the package for any transaction
                // controllers
                threadContext.getVariables().putObject(PACKAGE_OBJECT, pack);

                            delay(pack.getTimers());
                            Sampler sampler = pack.getSampler();
                            sampler.setThreadContext(threadContext);
                            sampler.setThreadName(threadName);
                            TestBeanHelper.prepare(sampler);
                       
                            // Perform the actual sample
                            SampleResult result = sampler.sample(null);
                            // TODO: remove this useless Entry parameter
                       
                            // If we got any results, then perform processing on the result
                            if (result != null) {
                              result.setGroupThreads(threadGroup.getNumberOfThreads());
                              result.setAllThreads(JMeterContextService.getNumberOfThreads());
                                result.setThreadName(threadName);
                                threadContext.setPreviousResult(result);
                                runPostProcessors(pack.getPostProcessors());
                                checkAssertions(pack.getAssertions(), result);
                                // Do not send subsamples to listeners which receive the transaction sample
                                List sampleListeners = getSampleListeners(pack, transactionPack, transactionSampler);
                                notifyListeners(sampleListeners, result);
                                compiler.done(pack);
                                // Add the result as subsample of transaction if we are in a transaction
                                if(transactionSampler != null) {
                                    transactionSampler.addSubSamplerResult(result);
                                }

                                // Check if thread or test should be stopped
                                if (result.isStopThread() || (!result.isSuccessful() && onErrorStopThread)) {
                                    stopThread();
View Full Code Here

            }
        }

        SamplePackage pack = new SamplePackage(configs, modifiers, responseModifiers, listeners, timers, assertions,
                posts, pres, controllers);
        pack.setSampler(new TransactionSampler(tc, tc.getName()));
        pack.setRunningVersion(true);
        transactionControllerConfigMap.put(tc, pack);
    }
View Full Code Here

TOP

Related Classes of org.apache.jmeter.control.TransactionSampler

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.