Esempio n. 1
0
 @Override
 public void mousePressed(MouseEvent e) {
   // Get the Main Frame.
   ReportMainFrame mainFrame = ReportGuiPackage.getInstance().getMainFrame();
   // Close any Main Menu that is open
   mainFrame.closeMenu();
   int selRow = tree.getRowForLocation(e.getX(), e.getY());
   if (tree.getPathForLocation(e.getX(), e.getY()) != null) {
     log.debug("mouse pressed, updating currentPath");
     currentPath = tree.getPathForLocation(e.getX(), e.getY());
   }
   if (selRow != -1) {
     // updateMainMenu(((JMeterGUIComponent)
     // getCurrentNode().getUserObject()).createPopupMenu());
     if (isRightClick(e)) {
       if (tree.getSelectionCount() < 2) {
         tree.setSelectionPath(currentPath);
       }
       if (getCurrentNode() != null) {
         log.debug("About to display pop-up");
         displayPopUp(e);
       }
     }
   }
 }
  private void resolveInstallByDependency() {
    // resolve dependencies
    boolean hasModifications = true;
    while (hasModifications) {
      log.debug("Check install dependencies: " + additions);
      hasModifications = false;
      for (Plugin plugin : additions) {
        for (String pluginID : plugin.getDepends()) {
          Plugin depend = getPluginByID(pluginID);

          if (!depend.isInstalled() || deletions.contains(depend)) {
            if (!additions.contains(depend)) {
              log.debug("Add to install: " + depend);
              additions.add(depend);
              hasModifications = true;
            }
          }
        }

        if (hasModifications) {
          break; // prevent ConcurrentModificationException
        }
      }
    }
  }
  private void resolveDeleteByDependency() {
    // delete by depend
    boolean hasModifications = true;
    while (hasModifications) {
      log.debug("Check uninstall dependencies");
      hasModifications = false;
      for (Plugin plugin : deletions) {
        if (!additions.contains(plugin)) {
          for (Plugin dep : getDependants(plugin)) {
            if (!deletions.contains(dep) && dep.isInstalled()) {
              log.debug("Add to deletions: " + dep);
              deletions.add(dep);
              hasModifications = true;
            }
            if (additions.contains(dep)) {
              log.debug("Remove from additions: " + dep);
              additions.remove(dep);
              hasModifications = true;
            }
          }
        }

        if (hasModifications) {
          break; // prevent ConcurrentModificationException
        }
      }
    }
  }
Esempio n. 4
0
 /**
  * parseLine calls the other parse methods to parse the given text.
  *
  * @param line
  */
 protected int parseLine(String line, TestElement el) {
   int count = 0;
   // we clean the line to get
   // rid of extra stuff
   String cleanedLine = this.cleanURL(line);
   log.debug("parsing line: " + line);
   // now we set request method
   el.setProperty(HTTPSamplerBase.METHOD, RMETHOD);
   if (FILTER != null) {
     log.debug("filter is not null");
     if (!FILTER.isFiltered(line, el)) {
       log.debug("line was not filtered");
       // increment the current count
       count++;
       // we filter the line first, before we try
       // to separate the URL into file and
       // parameters.
       line = FILTER.filter(cleanedLine);
       if (line != null) {
         createUrl(line, el);
       }
     } else {
       log.debug("Line was filtered");
     }
   } else {
     log.debug("filter was null");
     // increment the current count
     count++;
     // in the case when the filter is not set, we
     // parse all the lines
     createUrl(cleanedLine, el);
   }
   return count;
 }
 @Override
 public void run() {
   try {
     supplyActiveThreads();
   } catch (InterruptedException e) {
     log.debug("Interrupted", e);
   }
   log.debug("Thread starter has done its job");
 }
Esempio n. 6
0
 /** Tests that JMeterVariables contain inputVal_<count>, if not we can stop iterating */
 private boolean endOfArguments() {
   JMeterContext context = getThreadContext();
   String inputVariable = getInputVal() + getSeparator() + (loopCount + 1);
   if (context.getVariables().getObject(inputVariable) != null) {
     log.debug("ForEach resultstring eofArgs= false");
     return false;
   }
   log.debug("ForEach resultstring eofArgs= true");
   return true;
 }
Esempio n. 7
0
  /** {@inheritDoc} */
  @Override
  public synchronized String execute(SampleResult previousResult, Sampler currentSampler)
      throws InvalidVariableException {

    if (bshInterpreter == null) // did we find BeanShell?
    {
      throw new InvalidVariableException("BeanShell not found");
    }

    JMeterContext jmctx = JMeterContextService.getContext();
    JMeterVariables vars = jmctx.getVariables();

    String script = ((CompoundVariable) values[0]).execute();
    String varName = ""; // $NON-NLS-1$
    if (values.length > 1) {
      varName = ((CompoundVariable) values[1]).execute().trim();
    }

    String resultStr = ""; // $NON-NLS-1$

    log.debug("Script=" + script);

    try {

      // Pass in some variables
      if (currentSampler != null) {
        bshInterpreter.set("Sampler", currentSampler); // $NON-NLS-1$
      }

      if (previousResult != null) {
        bshInterpreter.set("SampleResult", previousResult); // $NON-NLS-1$
      }

      // Allow access to context and variables directly
      bshInterpreter.set("ctx", jmctx); // $NON-NLS-1$
      bshInterpreter.set("vars", vars); // $NON-NLS-1$
      bshInterpreter.set("props", JMeterUtils.getJMeterProperties()); // $NON-NLS-1$
      bshInterpreter.set("threadName", Thread.currentThread().getName()); // $NON-NLS-1$

      // Execute the script
      Object bshOut = bshInterpreter.eval(script);
      if (bshOut != null) {
        resultStr = bshOut.toString();
      }
      if (vars != null && varName.length() > 0) { // vars will be null on TestPlan
        vars.put(varName, resultStr);
      }
    } catch (Exception ex) // Mainly for bsh.EvalError
    {
      log.warn("Error running BSH script", ex);
    }

    log.debug("Output=" + resultStr);
    return resultStr;
  }
Esempio n. 8
0
 public static boolean checkSign(
     String qstring, String signature, String securityKey, String charset) {
   logger.debug("Request signature: " + signature);
   if (null == signature) {
     return false;
   }
   String generateSignature = md5(qstring + md5(securityKey, charset), charset);
   logger.debug("request to be signatured: " + qstring);
   logger.debug("Generate signature: " + generateSignature);
   return signature.equals(generateSignature);
 }
Esempio n. 9
0
  @Override
  public void testStarted() {
    if (log.isDebugEnabled()) {
      log.debug(getTitle() + " testStarted");
    }

    MongoClientOptions.Builder builder =
        MongoClientOptions.builder()
            .autoConnectRetry(getAutoConnectRetry())
            .connectTimeout(getConnectTimeout())
            .connectionsPerHost(getConnectionsPerHost())
            .maxAutoConnectRetryTime(getMaxAutoConnectRetryTime())
            .maxWaitTime(getMaxWaitTime())
            .socketKeepAlive(getSocketKeepAlive())
            .socketTimeout(getSocketTimeout())
            .threadsAllowedToBlockForConnectionMultiplier(
                getThreadsAllowedToBlockForConnectionMultiplier());

    if (getSafe()) {
      builder.writeConcern(WriteConcern.SAFE);
    } else {
      builder.writeConcern(
          new WriteConcern(
              getWriteOperationNumberOfServers(),
              getWriteOperationTimeout(),
              getFsync(),
              getWaitForJournaling(),
              getContinueOnInsertError()));
    }
    MongoClientOptions mongoOptions = builder.build();

    if (log.isDebugEnabled()) {
      log.debug("options : " + mongoOptions.toString());
    }

    if (getThreadContext().getVariables().getObject(getSource()) != null) {
      if (log.isWarnEnabled()) {
        log.warn(getSource() + " has already been defined.");
      }
    } else {
      if (log.isDebugEnabled()) {
        log.debug(getSource() + "  is being defined.");
      }
      try {
        getThreadContext()
            .getVariables()
            .putObject(
                getSource(),
                new MongoDB(MongoUtils.toServerAddresses(getConnection()), mongoOptions));
      } catch (UnknownHostException e) {
        throw new IllegalStateException(e);
      }
    }
  }
Esempio n. 10
0
  public static boolean checkSign(Map<String, String> req, String securityKey) {
    String signature = (String) req.get("signature");
    logger.debug("Request signature: " + signature);
    if (null == signature) {
      return false;
    }

    Map<String, String> filterReq = paraRailwayFilter(req);
    String generateSignature = buildSignature(filterReq, securityKey);
    logger.debug("Generate signature: " + generateSignature);
    return signature.equals(generateSignature);
  }
 private void shutdownConnectors() {
   log.debug("Shutting down connectors");
   Iterator<Object> it = connectors.keySet().iterator();
   while (it.hasNext()) {
     Object key = it.next();
     final AWSMonAgentConnector conn = connectors.get(key);
     log.debug("Shutting down " + conn.toString());
     // Fix ConcurrentModificationException if more than one host
     // connectors.remove(key);
     it.remove();
     conn.disconnect();
   }
 }
  /* (non-Javadoc)
   * @see com.microstrategy.mfloadtest.jdbcwriter.BaseTestListener#sampleOccurred(org.apache.jmeter.samplers.SampleEvent)
   */
  @Override
  public void sampleOccurred(SampleEvent event) {

    // multi threads will be accessing this
    // with different callstacks

    // do not check for the mSession==null,
    // all the objects here are safe without a db connection

    // will obtain the entities in order:
    // action, transaction, errors
    final BaseSampleEntity[] lEntities = mTranslator.translate(event);

    if (LOGGER.isDebugEnabled()) {
      LOGGER.debug("Sending entries to aggregator");
    }

    final ArrayList<BaseSampleEntity> lErrors = new ArrayList<BaseSampleEntity>();

    // make sure to populate all the aggregators
    // in the same interval
    // within the same interval
    synchronized (mTrendLineAggregator) {
      for (BaseSampleEntity lEntity : lEntities) {
        if (lEntity instanceof ActionSampleEntity) {
          sendActionToAggregator((ActionSampleEntity) lEntity);
        } else if (lEntity instanceof SampleEntity) {
          sendTransactionToAggregator((SampleEntity) lEntity);
        } else if (lEntity instanceof ErrorSampleEntity) {
          if (!mLimitErrorSamples || mErrorSampleLimitCountDown.decrementAndGet() >= 0) {
            lErrors.add(lEntity);
          } else if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Error not logged, because limit was reached");
          }
          sendErrorToAggregator((ErrorSampleEntity) lEntity);
        }
      }
    }

    if (LOGGER.isDebugEnabled()) { // be careful about performance
      LOGGER.debug(String.format("entries commited %s", mTrendLineAggregator));
      LOGGER.debug("sending entities to writer");
    }

    if (mCollectRawData) {
      // this has to happen at the end, because the transactions are lost
      mSWriter.write(lEntities);
    } else {
      mSWriter.write(lErrors.toArray(new BaseSampleEntity[0]));
    }
  }
  /**
   * Stores sample events untill either a time or sample threshold is breached. Both thresholds are
   * reset if one fires. If only one threshold is set it becomes the only value checked against.
   * When a threhold is breached the list of sample events is sent to a listener where the event are
   * fired locally.
   *
   * @param e a Sample Event
   */
  public void sampleOccurred(SampleEvent e) {
    synchronized (sampleStore) {
      // Locate the statistical sample colector
      String key = StatisticalSampleResult.getKey(e);
      StatisticalSampleResult statResult = (StatisticalSampleResult) sampleTable.get(key);
      if (statResult == null) {
        statResult = new StatisticalSampleResult(e.getResult());
        // store the new statistical result collector
        sampleTable.put(key, statResult);
        // add a new wrapper samplevent
        sampleStore.add(new SampleEvent(statResult, e.getThreadGroup()));
      }
      statResult.add(e.getResult());
      sampleCount++;
      if (numSamplesThreshold != -1) {
        if (sampleCount >= numSamplesThreshold) {
          try {
            if (log.isDebugEnabled()) {
              log.debug("Firing sample");
            }
            sendBatch();
          } catch (RemoteException err) {
            log.warn("sampleOccurred", err);
          }
        }
      }

      if (timeThreshold != -1) {
        long now = System.currentTimeMillis();
        // Checking for and creating initial timestamp to cheak against
        if (batchSendTime == -1) {
          this.batchSendTime = now + timeThreshold;
        }

        if (batchSendTime < now) {
          try {
            if (log.isDebugEnabled()) {
              log.debug("Firing time");
            }
            sendBatch();
            this.batchSendTime = now + timeThreshold;
          } catch (RemoteException err) {
            log.warn("sampleOccurred", err);
          }
        }
      }
    }
  }
Esempio n. 14
0
  public JMXMetric(MetricParams params, JMXConnectorHelper jmxHelper) {
    super(null);
    String url = "localhost:4711";
    String user = "";
    String pwd = "";

    for (int i = 0; i < params.params.length; i++) {
      if (params.params[i].startsWith("url=")) {
        url = MetricParams.getParamValue(params.params[i]);
      } else if (params.params[i].startsWith("user="******"password="******"'url' parameter required for metric type 'jmx'");
    }

    MBeanServerConnection mBeanServerConn = jmxHelper.getServerConnection(url, user, pwd);

    try {
      dataProvider = AbstractJMXDataProvider.getProvider(mBeanServerConn, params.type);
    } catch (Exception ex) {
      log.debug("Failed to get MX Bean data provider", ex);
      throw new RuntimeException("Failed to get MX Bean data provider", ex);
    }

    dividingFactor = getUnitDividingFactor(params.getUnit());
  }
  private void resolveDeleteLibs() {
    for (Plugin plugin : deletions) {
      if (additions.contains(plugin)) { // skip upgrades
        continue;
      }

      Map<String, String> libs = plugin.getLibs(plugin.getInstalledVersion());
      for (String lib : libs.keySet()) {
        if (Plugin.getLibInstallPath(lib) != null) {
          libDeletions.add(lib);
        } else {
          log.warn("Did not find library to uninstall it: " + lib);
        }
      }
    }

    for (Plugin plugin : allPlugins.keySet()) {
      if (additions.contains(plugin) || (plugin.isInstalled() && !deletions.contains(plugin))) {
        String ver =
            additions.contains(plugin)
                ? plugin.getCandidateVersion()
                : plugin.getInstalledVersion();
        // log.debug("Affects " + plugin + " v" + ver);
        Map<String, String> libs = plugin.getLibs(ver);
        for (String lib : libs.keySet()) {
          if (libDeletions.contains(lib)) {
            log.debug("Won't delete lib " + lib + " since it is used by " + plugin);
            libDeletions.remove(lib);
          }
        }
      }
    }
  }
  private NodeList load()
      throws IOException, FileNotFoundException, ParserConfigurationException, SAXException,
          TransformerException {
    InputStream fis = null;
    NodeList nl = null;
    try {
      DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();

      fis = new FileInputStream(fileName);
      nl = XPathAPI.selectNodeList(builder.parse(fis), xpath);
      log.debug("found " + nl.getLength());

    } catch (FileNotFoundException e) {
      log.warn(e.toString());
      throw e;
    } catch (IOException e) {
      log.warn(e.toString());
      throw e;
    } catch (ParserConfigurationException e) {
      log.warn(e.toString());
      throw e;
    } catch (SAXException e) {
      log.warn(e.toString());
      throw e;
    } catch (TransformerException e) {
      log.warn(e.toString());
      throw e;
    } finally {
      JOrphanUtils.closeQuietly(fis);
    }
    return nl;
  }
Esempio n. 17
0
 @Override
 public void testEnded() {
   if (log.isDebugEnabled()) {
     log.debug(getTitle() + " testEnded");
   }
   ((MongoDB) getThreadContext().getVariables().getObject(getSource())).clear();
 }
Esempio n. 18
0
 /**
  * Dump a list of the parameters in this context to the debug log. Should only be called if debug
  * is enabled.
  *
  * @param context the context which contains the initialization parameters.
  */
 private void listParameters(JavaSamplerContext context) {
   Iterator<String> argsIt = context.getParameterNamesIterator();
   while (argsIt.hasNext()) {
     String name = argsIt.next();
     LOG.debug(name + "=" + context.getParameter(name));
   }
 }
Esempio n. 19
0
 /**
  * Do any initialization required by this client.
  *
  * <p>There is none, as it is done in runTest() in order to be able to vary the data for each
  * sample.
  *
  * @param context the context to run with. This provides access to initialization parameters.
  */
 @Override
 public void setupTest(JavaSamplerContext context) {
   if (LOG.isDebugEnabled()) {
     LOG.debug(whoAmI() + "\tsetupTest()");
     listParameters(context);
   }
 }
Esempio n. 20
0
  private List<MatchResult> processMatches(
      Pattern pattern, String regex, SampleResult result, int matchNumber, JMeterVariables vars) {
    if (log.isDebugEnabled()) {
      log.debug("Regex = " + regex);
    }

    Perl5Matcher matcher = JMeterUtils.getMatcher();
    List<MatchResult> matches = new ArrayList<MatchResult>();
    int found = 0;

    if (isScopeVariable()) {
      String inputString = vars.get(getVariableName());
      if (inputString == null) {
        log.warn(
            "No variable '"
                + getVariableName()
                + "' found to process by RegexExtractor '"
                + getName()
                + "', skipping processing");
        return Collections.emptyList();
      }
      matchStrings(matchNumber, matcher, pattern, matches, found, inputString);
    } else {
      List<SampleResult> sampleList = getSampleList(result);
      for (SampleResult sr : sampleList) {
        String inputString = getInputString(sr);
        found = matchStrings(matchNumber, matcher, pattern, matches, found, inputString);
        if (matchNumber > 0 && found == matchNumber) { // no need to process further
          break;
        }
      }
    }
    return matches;
  }
  private synchronized String readNextChunk(int capacity) throws IOException {
    if (capacity == 0) {
      throw new EndOfFileException("Zero chunk size, possibly end of file reached.");
    }

    ByteBuffer buf = ByteBuffer.allocateDirect(capacity);
    byte[] dst = new byte[capacity];

    int cnt = file.read(buf);
    // log.debug("Read " + cnt);
    if (cnt != capacity) {
      throw new IOException(
          "Expected chunk size (" + capacity + ") differs from read bytes count (" + cnt + ")");
    }

    buf.flip();
    buf.get(dst);
    if (log.isDebugEnabled()) {
      log.debug("Chunk : " + new String(dst));
    }

    if (isHexEncode()) {
      return JOrphanUtils.baToHexString(dst);
    } else {
      return new String(dst, binaryCharset);
    }
  }
 /**
  * Input (hex) string is converted to binary and written to the output stream.
  *
  * @param os output stream
  * @param hexEncodedBinary hex-encoded binary
  */
 public void write(OutputStream os, String hexEncodedBinary) throws IOException {
   os.write(hexStringToByteArray(hexEncodedBinary));
   os.flush();
   if (log.isDebugEnabled()) {
     log.debug("Wrote: " + hexEncodedBinary);
   }
 }
 /** {@inheritDoc} */
 @Override
 public void write(OutputStream os, String s) throws IOException {
   os.write(intToByteArray(s.length() / 2, lengthPrefixLen));
   if (log.isDebugEnabled()) {
     log.debug("Wrote: " + s.length() / 2 + " bytes");
   }
   this.tcpClient.write(os, s);
 }
 /**
  * ************************************************************************* ModDN the data in the
  * ldap directory for the given search base
  *
  * <p>************************************************************************
  */
 public static void moddnOp(DirContext dirContext, String ddn, String newdn)
     throws NamingException {
   log.debug("ddn and newDn= " + ddn + "@@@@" + newdn);
   if (dirContext == null) {
     throw new NamingException(CONTEXT_IS_NULL);
   }
   dirContext.rename(ddn, newdn);
 }
 public XPathFileContainer(String file, String xpath)
     throws FileNotFoundException, IOException, ParserConfigurationException, SAXException,
         TransformerException {
   log.debug("XPath(" + file + ") xpath " + xpath + "");
   fileName = file;
   this.xpath = xpath;
   nextRow = 0;
   nodeList = load();
 }
 /**
  * Invoked when the target of the listener has changed its state. This implementation assumes that
  * the target is the FilePanel, and will update the result collector for the new filename.
  *
  * @param e the event that has occurred
  */
 @Override
 public void stateChanged(ChangeEvent e) {
   log.debug("getting new collector");
   collector = (CorrectedResultCollector) createTestElement();
   if (collector instanceof CorrectedResultCollector) {
     setUpFiltering((CorrectedResultCollector) collector);
   }
   collector.loadExistingFile();
 }
 @Override
 public void process() {
   if (log.isDebugEnabled()) {
     log.debug(Thread.currentThread().getName() + " process " + isPerIteration()); // $NON-NLS-1$
   }
   if (!isPerIteration()) {
     setValues();
   }
 }
  private void sendErrorToAggregator(ErrorSampleEntity lEntity) {
    LOGGER.debug("sending error to aggregator");
    final AggregationKey lKey =
        new AggregationKey(
            AggregationKey.Type.ERROR, lEntity.getThreadGroup(), lEntity.getTransaction());

    // just add 1, what we need is the count
    mTrendLineAggregator.getMetric(MetricID.COUNT, lKey).addSample(1L);
  }
Esempio n. 29
0
 private String generateResult(MatchResult match) {
   StringBuilder result = new StringBuilder();
   for (Object obj : template) {
     if (log.isDebugEnabled()) {
       log.debug(
           "RegexExtractor: Template piece " + obj + " (" + obj.getClass().getSimpleName() + ")");
     }
     if (obj instanceof Integer) {
       result.append(match.group(((Integer) obj).intValue()));
     } else {
       result.append(obj);
     }
   }
   if (log.isDebugEnabled()) {
     log.debug("Regex Extractor result = " + result.toString());
   }
   return result.toString();
 }
 /** @see LoopIterationListener#iterationStart(LoopIterationEvent) */
 @Override
 public void iterationStart(LoopIterationEvent event) {
   if (log.isDebugEnabled()) {
     log.debug(
         Thread.currentThread().getName() + " iteration start " + isPerIteration()); // $NON-NLS-1$
   }
   if (isPerIteration()) {
     setValues();
   }
 }