Fixing Prefetch publisher cache restart issue
This commit is contained in:
parent
db2c22e046
commit
d4f3c0b14a
2 changed files with 12 additions and 4 deletions
|
|
@ -230,12 +230,12 @@ public class PrefetchRecordsPublisher implements RecordsPublisher {
|
|||
if (executorService.isShutdown()) {
|
||||
throw new IllegalStateException("ExecutorService has been shutdown.");
|
||||
}
|
||||
|
||||
publisherSession.init(extendedSequenceNumber, initialPositionInStreamExtended);
|
||||
|
||||
if (!started) {
|
||||
log.info("{} : Starting prefetching thread.", streamAndShardId);
|
||||
publisherSession.init(extendedSequenceNumber, initialPositionInStreamExtended);
|
||||
log.info("{} : Starting prefetching thread and initializing publisher session.", streamAndShardId);
|
||||
executorService.execute(defaultGetRecordsCacheDaemon);
|
||||
} else {
|
||||
log.info("{} : Skipping publisher start as it was already started.", streamAndShardId);
|
||||
}
|
||||
started = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -145,6 +145,14 @@ public class PrefetchRecordsPublisherTest {
|
|||
when(getRecordsRetrievalStrategy.getRecords(eq(MAX_RECORDS_PER_CALL))).thenReturn(getRecordsResponse);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDataFetcherIsNotReInitializedOnMultipleCacheStarts() {
|
||||
getRecordsCache.start(sequenceNumber, initialPosition);
|
||||
getRecordsCache.start(sequenceNumber, initialPosition);
|
||||
getRecordsCache.start(sequenceNumber, initialPosition);
|
||||
verify(dataFetcher, times(1)).initialize(any(ExtendedSequenceNumber.class), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRecords() {
|
||||
record = Record.builder().data(createByteBufferWithSize(SIZE_512_KB)).build();
|
||||
|
|
|
|||
Loading…
Reference in a new issue