/** {@inheritDoc} */ // TODO save hostname; save sample type (plain or http) @Override public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) { SampleEvent evt = (SampleEvent) source; Object res = evt.getResult(); context.convertAnother(res); }
/** {@inheritDoc} */ // TODO does not work yet; need to determine the sample type @Override public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { SampleEvent evt = new SampleEvent(); return evt; } }
private String[] sampleVariableValues(SampleEvent event) { int sampleVariableLength = SampleEvent.getVarCount(); String[] values = new String[sampleVariableLength]; for(int i = 0; i < sampleVariableLength; i++) { String varValue = event.getVarValue(i); values[i] = (varValue == null) ? "" : varValue; } return values; }
/** * Generates the key to be used for aggregating samples as follows:<br> * <code>sampleLabel</code> "-" <code>[threadName|threadGroup]</code> * <p> * N.B. the key should agree with the fixed items that are saved in the sample. * * @param event sample event whose key is to be calculated * @param keyOnThreadName true if key should use thread name, otherwise use thread group * @return the key to use for aggregating samples */ public static String getKey(SampleEvent event, boolean keyOnThreadName) { StringBuilder sb = new StringBuilder(80); sb.append(event.getResult().getSampleLabel()); if (keyOnThreadName){ sb.append('-').append(event.getResult().getThreadName()); } else { sb.append('-').append(event.getThreadGroup()); } return sb.toString(); } }
private String[] combineAssertionLabelsWithSampleVars() { int assertionLabelLength = this.assertionConfig.getLabels().length; int sampleVariableLength = SampleEvent.getVarCount(); int combinedLength = assertionLabelLength + sampleVariableLength; String[] returnArray = new String[combinedLength]; int returnArrayIndex = -1; //start at -1 so you can ++ when referencing it //add config first String[] configuredLabels = this.assertionConfig.getLabels(); for (int i = 0; i < assertionLabelLength; i++) { returnArray[++returnArrayIndex] = configuredLabels[i]; } //now add sample variables for (int i = 0; i < sampleVariableLength; i++) { returnArray[++returnArrayIndex] = SampleEvent.getVarName(i); } return returnArray; }
StatisticalSampleResult statResult = sampleTable.get(key); if (statResult == null) { statResult = new StatisticalSampleResult(e.getResult()); .add(new SampleEvent(statResult, e.getThreadGroup())); statResult.add(e.getResult()); sampleCount++; boolean sendNow = false;
int failedCount = 0; for (SampleEvent evt : raw) { SampleResult res = evt.getResult(); if (!threads.containsKey(evt.getHostname())) { threads.put(evt.getHostname(), 0); threads.put(evt.getHostname(), res.getAllThreads());
@Override public void sampleOccurred(SampleEvent se) { if (!isGenerateParentSample()) { // Check if we are still sampling our children if(res != null && !se.isTransactionSampleEvent()) { SampleResult sampleResult = se.getResult(); res.setThreadName(sampleResult.getThreadName()); res.setBytes(res.getBytesAsLong() + sampleResult.getBytesAsLong()); res.setSentBytes(res.getSentBytes() + sampleResult.getSentBytes()); if (!isIncludeTimers()) {// Accumulate waiting time for later pauseTime += sampleResult.getEndTime() - sampleResult.getTime() - prevEndTime; prevEndTime = sampleResult.getEndTime(); } if(!sampleResult.isSuccessful()) { res.setSuccessful(false); noFailingSamples++; } res.setAllThreads(sampleResult.getAllThreads()); res.setGroupThreads(sampleResult.getGroupThreads()); res.setLatency(res.getLatency() + sampleResult.getLatency()); res.setConnectTime(res.getConnectTime() + sampleResult.getConnectTime()); } } }
if (event != null) { if (save.saveHostname()){ writer.addAttribute(ATT_HOSTNAME, event.getHostname()); for (int i = 0; i < SampleEvent.getVarCount(); i++){ writer.addAttribute(SampleEvent.getVarName(i), ConversionHelp.encode(event.getVarValue(i)));
text.append(event.getHostname()); for (int i = 0; i < SampleEvent.getVarCount(); i++) { text.append(event.getVarValue(i));
protected void createAssertionCollector(){ if (!collectAssertions){ return; } String[] labelNames = new String[]{}; if (SampleEvent.getVarCount() > 0) { labelNames = this.combineAssertionLabelsWithSampleVars(); }else { labelNames = this.assertionConfig.getLabels(); } if(this.getSaveConfig().getAssertionClass().equals(Summary.class)) this.assertionsCollector = Summary.build().name("jmeter_assertions_total").help("Counter for assertions") .labelNames(labelNames).quantile(0.5, 0.1).quantile(0.99, 0.1) .create().register(CollectorRegistry.defaultRegistry); else if(this.getSaveConfig().getAssertionClass().equals(Counter.class)) this.assertionsCollector = Counter.build().name("jmeter_assertions_total").help("Counter for assertions") .labelNames(labelNames).create().register(CollectorRegistry.defaultRegistry); }
private String[] combineConfigLabelsWithSampleVars() { int configLabelLength = this.samplerConfig.getLabels().length; int sampleVariableLength = SampleEvent.getVarCount(); int combinedLength = configLabelLength + sampleVariableLength; String[] returnArray = new String[combinedLength]; int returnArrayIndex = -1; //start at -1 so you can ++ when referencing it //add config first String[] configuredLabels = this.samplerConfig.getLabels(); for (int i = 0; i < configLabelLength; i++) { returnArray[++returnArrayIndex] = configuredLabels[i]; } //now add sample variables for (int i = 0; i < sampleVariableLength; i++) { returnArray[++returnArrayIndex] = SampleEvent.getVarName(i); } return returnArray; }
String[] labelNames = new String[]{}; if (SampleEvent.getVarCount() > 0) { labelNames = this.combineConfigLabelsWithSampleVars(); } else {
/** * Convert a result into a string, where the fields of the result are * separated by a specified String. * * @param event * the sample event to be converted * @param delimiter * the separation string * @return the separated value representation of the result */ public static String resultToDelimitedString(SampleEvent event, final String delimiter) { return resultToDelimitedString(event, event.getResult(), event.getResult().getSaveConfig(), delimiter); }
private void notifyListeners(List<SampleListener> listeners, SampleResult result) { SampleEvent event = new SampleEvent(result, threadGroup.getName(), threadVars); notifier.notifyListeners(event, listeners); }
private void appendSampleVariable(ByteBuffer buf, SampleEvent evt, int varID) { if (SampleEvent.getVarCount() < varID + 1) { buf.put(("UNDEFINED_variable#" + varID).getBytes()); log.warn("variable#" + varID + " does not exist!"); } else { if (evt.getVarValue(varID) != null) { buf.put(evt.getVarValue(varID).getBytes()); } } }
appendFields(saveConfig.saveConnectTime(), text, delim, CSV_CONNECT_TIME); for (int i = 0; i < SampleEvent.getVarCount(); i++) { text.append(VARIABLE_NAME_QUOTE_CHAR); text.append(SampleEvent.getVarName(i)); text.append(VARIABLE_NAME_QUOTE_CHAR); text.append(delim);
public void addSample(SampleEvent res) { Long time = res.getResult().getEndTime() / 1000; if (!buffer.containsKey(time)) { // we need to create new sec list if (time <= lastAggregatedTime) { // a problem with times sequence - taking last available log.debug("Got time " + time + " <= " + lastAggregatedTime); for (Long aLong : buffer.keySet()) { time = aLong; } } buffer.put(time, new LinkedList<SampleEvent>()); } buffer.get(time).add(res); }
@Override public void generateSample(double value, String label) { PerfMonSampleResult res = new PerfMonSampleResult(); res.setSampleLabel(label); res.setValue(value); res.setSuccessful(true); SampleEvent e = new SampleEvent(res, PERFMON); super.sampleOccurred(e); }
private void appendSampleVariable(ByteBuffer buf, SampleEvent evt, int varID) { if (SampleEvent.getVarCount() < varID + 1) { buf.put(("UNDEFINED_variable#" + varID).getBytes()); log.warn("variable#" + varID + " does not exist!"); } else { if (evt.getVarValue(varID) != null) { buf.put(evt.getVarValue(varID).getBytes()); } } }