1 17 package org.apache.activemq.tool.sampler; 18 19 import org.apache.activemq.tool.reports.AbstractPerfReportWriter; 20 21 import java.util.ArrayList ; 22 import java.util.Iterator ; 23 import java.util.List ; 24 25 public class ThroughputSamplerTask extends AbstractPerformanceSampler { 26 27 private final Object mutex = new Object (); 28 private List clients = new ArrayList (); 29 30 public void registerClient(MeasurableClient client) { 31 synchronized (mutex) { 32 clients.add(client); 33 } 34 } 35 36 public void sampleData() { 37 for (Iterator i = clients.iterator(); i.hasNext();) { 38 MeasurableClient client = (MeasurableClient) i.next(); 39 if (perfReportWriter != null) { 40 perfReportWriter.writeCsvData(AbstractPerfReportWriter.REPORT_PLUGIN_THROUGHPUT, 41 "index=" + sampleIndex + ",clientName=" + client.getClientName() + 42 ",throughput=" + client.getThroughput()); 43 } 44 client.reset(); 45 } 46 } 47 48 protected void onSamplerStart() { 49 for (Iterator i = clients.iterator(); i.hasNext();) { 51 MeasurableClient client = (MeasurableClient) i.next(); 52 client.reset(); 53 } 54 } 55 } 56 | Popular Tags |