mirror of https://github.com/apache/activemq.git
- Add method to wait for performance sampler to finish
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@411695 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a38f71d5b2
commit
7d049c1344
|
@ -35,6 +35,7 @@ public class PerfMeasurementTool implements PerfEventListener, Runnable {
|
|||
|
||||
private AtomicBoolean start = new AtomicBoolean(false);
|
||||
private AtomicBoolean stop = new AtomicBoolean(false);
|
||||
private AtomicBoolean isRunning = new AtomicBoolean(false);
|
||||
private Properties samplerSettings = new Properties();
|
||||
|
||||
private List perfClients = new ArrayList();
|
||||
|
@ -119,6 +120,8 @@ public class PerfMeasurementTool implements PerfEventListener, Runnable {
|
|||
public void startSampler() {
|
||||
Thread t = new Thread(this);
|
||||
t.setName("Performance Sampler");
|
||||
|
||||
isRunning.set(true);
|
||||
t.start();
|
||||
}
|
||||
|
||||
|
@ -140,6 +143,8 @@ public class PerfMeasurementTool implements PerfEventListener, Runnable {
|
|||
sampleIndex++;
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
} finally {
|
||||
isRunning.set(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -151,4 +156,13 @@ public class PerfMeasurementTool implements PerfEventListener, Runnable {
|
|||
client.reset();
|
||||
}
|
||||
}
|
||||
|
||||
public void waitForSamplerToFinish(long timeout) {
|
||||
while (isRunning.get()) {
|
||||
try {
|
||||
isRunning.wait(timeout);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue