nicoloboschi commented on a change in pull request #3110:
URL: https://github.com/apache/bookkeeper/pull/3110#discussion_r827780856
##########
File path:
bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestParallelRead.java
##########
@@ -238,4 +247,59 @@ public void testParallelReadFailureWithFailedBookies()
throws Exception {
newBk.close();
}
+ @Test
+ public void testLedgerEntryRequestComplete() throws Exception {
+ LedgerHandle lh = mock(LedgerHandle.class);
+ LedgerMetadata ledgerMetadata = mock(LedgerMetadata.class);
+ ClientContext clientContext = mock(ClientContext.class);
+ ClientInternalConf clientInternalConf = mock(ClientInternalConf.class);
+ doReturn(clientInternalConf).when(clientContext).getConf();
+ BookKeeperClientStats bookKeeperClientStats =
mock(BookKeeperClientStats.class);
+ doReturn(bookKeeperClientStats).when(clientContext).getClientStats();
+ OpStatsLogger opStatsLogger = mock(OpStatsLogger.class);
+ doReturn(opStatsLogger).when(bookKeeperClientStats).getReadOpLogger();
+ doReturn(ledgerMetadata).when(lh).getLedgerMetadata();
+ doReturn(2).when(ledgerMetadata).getWriteQuorumSize();
+ doReturn(1).when(ledgerMetadata).getAckQuorumSize();
+ doReturn(new TreeMap<>()).when(ledgerMetadata).getAllEnsembles();
+ DistributionSchedule.WriteSet writeSet =
mock(DistributionSchedule.WriteSet.class);
+ doReturn(writeSet).when(lh).getWriteSetForReadOperation(anyLong());
+ PendingReadOp pendingReadOp = new PendingReadOp(lh, clientContext, 1,
2, false);
+ pendingReadOp.parallelRead(true);
+ pendingReadOp.initiate();
+ PendingReadOp.LedgerEntryRequest first = pendingReadOp.seq.get(0);
+ PendingReadOp.LedgerEntryRequest second = pendingReadOp.seq.get(1);
+
+ pendingReadOp.submitCallback(-105);
+
+ // pendingReadOp.submitCallback(-105) will close all ledgerEntryImpl
+ assertEquals(-1, first.entryImpl.getEntryId());
+ assertEquals(-1, first.entryImpl.getLedgerId());
+ assertEquals(-1, first.entryImpl.getLength());
+ assertNull(first.entryImpl.getEntryBuffer());
+ assertTrue(first.complete.get());
+
+ assertEquals(-1, second.entryImpl.getEntryId());
+ assertEquals(-1, second.entryImpl.getLedgerId());
+ assertEquals(-1, second.entryImpl.getLength());
+ assertNull(second.entryImpl.getEntryBuffer());
+ assertTrue(second.complete.get());
+
+ // Mock ledgerEntryImpl reuse
+ Method method =
PendingReadOp.class.getDeclaredMethod("createReadContext",
Review comment:
what about making `ReadContext` class visibility to default and
instantiate the object in the test ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]