19
19
import org .slf4j .Logger ;
20
20
import org .slf4j .LoggerFactory ;
21
21
import tech .ydb .core .grpc .GrpcTransport ;
22
- import tech .ydb .examples .SimpleExample ;
23
22
import tech .ydb .topic .TopicClient ;
24
23
import tech .ydb .topic .description .Codec ;
25
24
import tech .ydb .topic .read .AsyncReader ;
40
39
/**
41
40
* @author Nikolay Perfilov
42
41
*/
43
- public class ReadWriteWorkload extends SimpleExample {
42
+ public class ReadWriteWorkload extends SimpleTopicExample {
44
43
private static final Logger logger = LoggerFactory .getLogger (ReadWriteWorkload .class );
45
44
private static final int WRITE_TIMEOUT_SECONDS = 60 ;
46
45
private static final int MESSAGE_LENGTH_BYTES = 10_000_000 ; // 10 Mb
@@ -53,12 +52,11 @@ public class ReadWriteWorkload extends SimpleExample {
53
52
private final AtomicInteger messagesReceived = new AtomicInteger (0 );
54
53
private final AtomicInteger messagesCommitted = new AtomicInteger (0 );
55
54
private final AtomicLong bytesWritten = new AtomicLong (0 );
56
- private long lastSeqNo = -1 ;
57
55
CountDownLatch writeFinishedLatch = new CountDownLatch (1 );
58
56
CountDownLatch readFinishedLatch = new CountDownLatch (1 );
59
57
60
58
@ Override
61
- protected void run (GrpcTransport transport , String pathPrefix ) {
59
+ protected void run (GrpcTransport transport ) {
62
60
63
61
ExecutorService compressionExecutor = Executors .newFixedThreadPool (10 );
64
62
AtomicBoolean timeToStopWriting = new AtomicBoolean (false );
@@ -154,9 +152,8 @@ protected void run(GrpcTransport transport, String pathPrefix) {
154
152
};
155
153
156
154
Runnable readingThread = () -> {
157
- String consumerName = "consumer1" ;
158
155
ReaderSettings readerSettings = ReaderSettings .newBuilder ()
159
- .setConsumerName (consumerName )
156
+ .setConsumerName (CONSUMER_NAME )
160
157
.addTopic (TopicReadSettings .newBuilder ()
161
158
.setPath (TOPIC_NAME )
162
159
.setReadFrom (Instant .now ().minus (Duration .ofHours (24 )))
@@ -274,12 +271,6 @@ public void onMessages(DataReceivedEvent event) {
274
271
} else {
275
272
logger .debug ("Message received. SeqNo={}, offset={}" , message .getSeqNo (), message .getOffset ());
276
273
}
277
- if (lastSeqNo > message .getSeqNo ()) {
278
- logger .error ("Received a message with seqNo {}. Previously got a message with seqNo {}" ,
279
- message .getSeqNo (), lastSeqNo );
280
- } else {
281
- lastSeqNo = message .getSeqNo ();
282
- }
283
274
message .commit ().thenRun (() -> {
284
275
logger .trace ("Message committed" );
285
276
unreadMessagesCount .decrementAndGet ();
0 commit comments