|
1 | 1 | // SPDX-License-Identifier: Apache-2.0
|
2 | 2 | package org.hiero.otter.fixtures;
|
3 | 3 |
|
4 |
| -import edu.umd.cs.findbugs.annotations.NonNull; |
5 |
| -import java.time.Instant; |
6 |
| -import org.hiero.otter.fixtures.internal.FixedRate; |
7 |
| - |
8 | 4 | /**
|
9 | 5 | * Interface representing a transaction generator.
|
10 | 6 | *
|
11 |
| - * <p>This interface provides methods to generate random transactions and send them to the nodes. |
| 7 | + * <p>A {@link TransactionGenerator} generates a steady flow of transaction to all nodes in the |
| 8 | + * network. The generator sends 100 transactions to each node per second, which ensures there is |
| 9 | + * always at least one transaction waiting to be processed by the event creator. |
12 | 10 | */
|
13 | 11 | public interface TransactionGenerator {
|
14 | 12 |
|
15 |
| - /** |
16 |
| - * Constant representing an infinite number of transactions. |
17 |
| - */ |
18 |
| - int INFINITE = -1; |
| 13 | + int TPS = 100; |
19 | 14 |
|
20 | 15 | /**
|
21 |
| - * Generate a specified number of transactions with a given rate and distribution. |
22 |
| - * |
23 |
| - * @param count the number of transactions to generate |
24 |
| - * @param rate the rate at which to generate transactions |
25 |
| - * @param distribution the distribution of transactions across the nodes |
| 16 | + * Start the generation of transactions with the default transaction factory that uses |
| 17 | + * random {@code int} values. |
26 | 18 | */
|
27 |
| - void generateTransactions(int count, @NonNull Rate rate, @NonNull Distribution distribution); |
| 19 | + void start(); |
28 | 20 |
|
29 | 21 | /**
|
30 | 22 | * Stop the transaction generation.
|
31 | 23 | */
|
32 | 24 | void stop();
|
33 |
| - |
34 |
| - /** |
35 |
| - * Pause the transaction generation. Once paused, the transaction generation can be resumed by calling {@link #resume()}. |
36 |
| - */ |
37 |
| - void pause(); |
38 |
| - |
39 |
| - /** |
40 |
| - * Resume the transaction generation after it has been paused. |
41 |
| - */ |
42 |
| - void resume(); |
43 |
| - |
44 |
| - /** |
45 |
| - * The {@code Rate} class represents the rate at which transactions are generated. |
46 |
| - */ |
47 |
| - interface Rate { |
48 |
| - |
49 |
| - /** |
50 |
| - * Creates a rate that generates transactions at a fixed frequency. |
51 |
| - * |
52 |
| - * @param tps the number of transactions per second |
53 |
| - * @return a {@code Rate} object representing the specified rate |
54 |
| - */ |
55 |
| - @NonNull |
56 |
| - static Rate fixedRateWithTps(final int tps) { |
57 |
| - return new FixedRate(tps); |
58 |
| - } |
59 |
| - |
60 |
| - /** |
61 |
| - * Returns the duration until when the next transaction should be generated in nanoseconds. |
62 |
| - * |
63 |
| - * @param start the start time of the transaction generation |
64 |
| - * @param now the current time |
65 |
| - * @return the duration until when the next transaction should be generated |
66 |
| - */ |
67 |
| - long nextDelayNS(@NonNull Instant start, @NonNull Instant now); |
68 |
| - } |
69 |
| - |
70 |
| - /** |
71 |
| - * The {@code Distribution} enum represents the distribution of transactions across the nodes. |
72 |
| - */ |
73 |
| - enum Distribution { |
74 |
| - /** |
75 |
| - * Transactions are distributed uniformly across the nodes. |
76 |
| - */ |
77 |
| - UNIFORM |
78 |
| - } |
79 | 25 | }
|
0 commit comments