Package org.apache.jmeter.samplers

Examples of org.apache.jmeter.samplers.Sampler


  public void run() {
    try {
      initRun();
      while (running) {
        Sampler sam;
        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
              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
                            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());
View Full Code Here


            }
            transactionSampler = new TransactionSampler(this, getName());
        }

        // Sample the children of the transaction
        Sampler subSampler = super.next();
        transactionSampler.setSubSampler(subSampler);
        // If we do not get any sub samplers, the transaction is done
        if (subSampler == null) {
            transactionSampler.setTransactionDone();
        }
View Full Code Here

    @Override
    protected Sampler nextIsAController(Controller controller) throws NextIsNullException {
        if (!isParent()) {
            return super.nextIsAController(controller);
        }
        Sampler returnValue;
        Sampler sampler = controller.next();
        if (sampler == null) {
            currentReturnedNull(controller);
            // We need to call the super.next, instead of this.next, which is done in GenericController,
            // because if we call this.next(), it will return the TransactionSampler, and we do not want that.
            // We need to get the next real sampler or controller
View Full Code Here

            res.sampleStart();
            prevEndTime = res.getStartTime();//???
            pauseTime = 0;
        }
        boolean isLast = current==super.subControllersAndSamplers.size();
        Sampler returnValue = super.next();
        if (returnValue == null && isLast) // Must be the end of the controller
        {
            if (res != null) {
                res.setIdleTime(pauseTime+res.getIdleTime());
                res.sampleEnd();
View Full Code Here

        bindings.put("props", props);
        // For use in debugging:
        bindings.put("OUT", System.out);

        // Most subclasses will need these:
        Sampler sampler = jmctx.getCurrentSampler();
        bindings.put("sampler", sampler);
        SampleResult prev = jmctx.getPreviousResult();
        bindings.put("prev", prev);
    }
View Full Code Here

        if (entry == null)
        {
          running = false;
          break;
        }
        Sampler sampler = null;
        try
        {
          sampler = getSampler(entry);
        }
        catch (Exception ex)
        {
          ex.printStackTrace();
          running = false;
        }
        SampleResult result = sampler.sample(entry);
        notifyListeners(result);
      }
    }
  }
View Full Code Here

  }

  private Sampler getSampler(Entry entry) throws Exception
  {
    Class sClass = entry.getSamplerClass();
    Sampler sampler = (Sampler)samplers.get(sClass);
    if (sampler == null)
    {
      sampler = (Sampler)sClass.newInstance();
      samplers.put(sClass, sampler);
    }
View Full Code Here

  public void run() {
    try {
      initRun();
      while (running) {
        Sampler sam;
        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);
View Full Code Here

  public void run() {
    try {
      initRun();
      while (running) {
        Sampler sam;
        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);
View Full Code Here

     * Modifies an entry object to replace the value of any url parameter that
     * matches a defined mask.
     *
     */
    public void process() {
        Sampler sam = getThreadContext().getCurrentSampler();
        HTTPSamplerBase sampler = null;
        if (!(sam instanceof HTTPSamplerBase)) {
            return;
        } else {
            sampler = (HTTPSamplerBase) sam;
View Full Code Here

TOP

Related Classes of org.apache.jmeter.samplers.Sampler

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.