@@ -60,6 +60,7 @@ public class MulticastSet {
6060 private ThreadingHandler threadingHandler = new DefaultThreadingHandler ();
6161 private final ValueIndicator <Float > rateIndicator ;
6262 private final ValueIndicator <Integer > messageSizeIndicator ;
63+ private final ValueIndicator <Long > consumerLatencyIndicator ;
6364 private final ConnectionCreator connectionCreator ;
6465
6566 public MulticastSet (Stats stats , ConnectionFactory factory ,
@@ -102,6 +103,18 @@ public MulticastSet(Stats stats, ConnectionFactory factory,
102103 params .getMessageSizes (), scheduledExecutorService , input -> Integer .valueOf (input )
103104 );
104105 }
106+
107+ if (this .params .getConsumerLatencies () == null || this .params .getConsumerLatencies ().isEmpty ()) {
108+ this .consumerLatencyIndicator = new FixedValueIndicator <>(params .getConsumerLatencyInMicroseconds ());
109+ } else {
110+ ScheduledExecutorService scheduledExecutorService = this .threadingHandler .scheduledExecutorService (
111+ "perf-test-variable-consumer-latency-scheduler" , 1
112+ );
113+ this .consumerLatencyIndicator = new VariableValueIndicator <>(
114+ params .getConsumerLatencies (), scheduledExecutorService , input -> Long .valueOf (input )
115+ );
116+ }
117+
105118 this .connectionCreator = new ConnectionCreator (this .factory , this .uris );
106119 }
107120
@@ -297,7 +310,10 @@ private Function<Integer, ExecutorService> createConsumersExecutorsFactory() {
297310 return consumersExecutorsFactory ;
298311 }
299312
300- private void createConsumers (boolean announceStartup , Runnable [] consumerRunnables , Connection [] consumerConnections , Function <Integer , ExecutorService > consumersExecutorsFactory ) throws URISyntaxException , NoSuchAlgorithmException , KeyManagementException , IOException , TimeoutException {
313+ private void createConsumers (boolean announceStartup ,
314+ Runnable [] consumerRunnables ,
315+ Connection [] consumerConnections ,
316+ Function <Integer , ExecutorService > consumersExecutorsFactory ) throws URISyntaxException , NoSuchAlgorithmException , KeyManagementException , IOException , TimeoutException {
301317 for (int i = 0 ; i < consumerConnections .length ; i ++) {
302318 if (announceStartup ) {
303319 System .out .println ("id: " + testID + ", starting consumer #" + i );
@@ -311,12 +327,12 @@ private void createConsumers(boolean announceStartup, Runnable[] consumerRunnabl
311327 if (announceStartup ) {
312328 System .out .println ("id: " + testID + ", starting consumer #" + i + ", channel #" + j );
313329 }
314- consumerRunnables [(i * params .getConsumerChannelCount ()) + j ] = params .createConsumer (consumerConnection , stats , this .completionHandler , executorService );
330+ consumerRunnables [(i * params .getConsumerChannelCount ()) + j ] = params .createConsumer (consumerConnection , stats , this .consumerLatencyIndicator , this . completionHandler , executorService );
315331 }
316332 }
317333 }
318334
319- private void createProducers (boolean announceStartup , AgentState [] producerStates , Connection [] producerConnections ) throws URISyntaxException , NoSuchAlgorithmException , KeyManagementException , IOException , TimeoutException {
335+ private void createProducers (boolean announceStartup , AgentState [] producerStates , Connection [] producerConnections ) throws IOException , TimeoutException {
320336 for (int i = 0 ; i < producerConnections .length ; i ++) {
321337 if (announceStartup ) {
322338 System .out .println ("id: " + testID + ", starting producer #" + i );
@@ -338,6 +354,7 @@ private void createProducers(boolean announceStartup, AgentState[] producerState
338354 }
339355
340356 private void startConsumers (Runnable [] consumerRunnables ) throws InterruptedException {
357+ this .consumerLatencyIndicator .start ();
341358 for (Runnable runnable : consumerRunnables ) {
342359 runnable .run ();
343360 if (params .getConsumerSlowStart ()) {
0 commit comments