@@ -16,16 +16,14 @@ public class KafkaLoadGenerator {
16
16
17
17
private static final Logger LOGGER = LoggerFactory .getLogger (KafkaLoadGenerator .class );
18
18
19
- private static final long SEED = 0xd966c7902a8716f9L ;
19
+ private final int executionTimeMs ;
20
20
21
21
private final String seedString ;
22
22
23
23
private final String kafkaBootstrapServers ;
24
24
25
25
private final String kafkaTopic ;
26
26
27
- private final int executionTimeMs ;
28
-
29
27
private final int numSources ;
30
28
private final int recordsPerSecondAndSource ;
31
29
@@ -36,16 +34,23 @@ public class KafkaLoadGenerator {
36
34
private final List <KafkaSender > openKafkaSenders = new ArrayList <>();
37
35
private final List <RecordSource > openRecordSources = new ArrayList <>();
38
36
39
- public KafkaLoadGenerator () {
40
- final Config config = ConfigProvider .getConfig ();
41
- executionTimeMs = config .getValue ("execution.time.ms" , Integer .class );
42
- seedString = config .getValue ("seed.string" , String .class );
43
- kafkaBootstrapServers = config .getValue ("kafka.bootstrap.servers" , String .class );
44
- kafkaTopic = config .getValue ("kafka.topic" , String .class );
45
- numSources = config .getValue ("num.sources" , Integer .class );
46
- recordsPerSecondAndSource = config .getValue ("num.records.per.source.second" , Integer .class );
47
- recordSizeInBytes = config .getValue ("record.size.bytes" , Integer .class );
48
- final int threadPoolSize = config .getValue ("thread.pool.size" , Integer .class );
37
+ public KafkaLoadGenerator (
38
+ int executionTimeMs ,
39
+ String seedString ,
40
+ String kafkaBootstrapServers ,
41
+ String kafkaTopic ,
42
+ int numSources ,
43
+ int recordsPerSecondAndSource ,
44
+ int recordSizeInBytes ,
45
+ int threadPoolSize
46
+ ) {
47
+ this .executionTimeMs = executionTimeMs ;
48
+ this .seedString = seedString ;
49
+ this .kafkaBootstrapServers = kafkaBootstrapServers ;
50
+ this .kafkaTopic = kafkaTopic ;
51
+ this .numSources = numSources ;
52
+ this .recordsPerSecondAndSource = recordsPerSecondAndSource ;
53
+ this .recordSizeInBytes = recordSizeInBytes ;
49
54
this .executor = new ScheduledThreadPoolExecutor (threadPoolSize );
50
55
}
51
56
@@ -80,7 +85,17 @@ public void stop() throws InterruptedException, IOException {
80
85
}
81
86
82
87
public static void main (String [] args ) throws InterruptedException , IOException {
83
- final KafkaLoadGenerator kafkaLoadGenerator = new KafkaLoadGenerator ();
88
+ final Config config = ConfigProvider .getConfig ();
89
+ final KafkaLoadGenerator kafkaLoadGenerator = new KafkaLoadGenerator (
90
+ config .getValue ("execution.time.ms" , Integer .class ),
91
+ config .getValue ("seed.string" , String .class ),
92
+ config .getValue ("kafka.bootstrap.servers" , String .class ),
93
+ config .getValue ("kafka.topic" , String .class ),
94
+ config .getValue ("num.sources" , Integer .class ),
95
+ config .getValue ("num.records.per.source.second" , Integer .class ),
96
+ config .getValue ("record.size.bytes" , Integer .class ),
97
+ config .getValue ("thread.pool.size" , Integer .class )
98
+ );
84
99
Runtime .getRuntime ().addShutdownHook (new Thread (() -> {
85
100
LOGGER .info ("Shut down load generator." );
86
101
try {
0 commit comments