4040import org .apache .bookkeeper .mledger .impl .cache .RangeEntryCacheManagerImpl ;
4141import org .apache .bookkeeper .test .MockedBookKeeperTestCase ;
4242import org .awaitility .Awaitility ;
43- import org .awaitility .reflect .WhiteboxImpl ;
4443import org .mockito .Mockito ;
4544import org .mockito .stubbing .Answer ;
4645import org .testng .Assert ;
@@ -142,8 +141,8 @@ public void testPreciseLimitation(String missingCase) throws Exception {
142141 SimpleReadEntriesCallback cb0 = new SimpleReadEntriesCallback ();
143142 entryCache .asyncReadEntry (spyCurrentLedger , 125 , 125 , true , cb0 , ctx );
144143 cb0 .entries .join ();
145- Long sizePerEntry1 = WhiteboxImpl . getInternalState ( entryCache , "estimatedEntrySize" );
146- Assert .assertEquals (sizePerEntry1 , 1 );
144+ Long sizePerEntry1 = entryCache . getEstimatedEntrySize ( );
145+ Assert .assertEquals (sizePerEntry1 , 1 + RangeEntryCacheImpl . BOOKKEEPER_READ_OVERHEAD_PER_ENTRY );
147146 Awaitility .await ().untilAsserted (() -> {
148147 long remainingBytes =limiter .getRemainingBytes ();
149148 Assert .assertEquals (remainingBytes , totalCapacity );
@@ -179,8 +178,8 @@ public void testPreciseLimitation(String missingCase) throws Exception {
179178 Thread .sleep (3000 );
180179 readCompleteSignal1 .countDown ();
181180 cb1 .entries .join ();
182- Long sizePerEntry2 = WhiteboxImpl . getInternalState ( entryCache , "estimatedEntrySize" );
183- Assert .assertEquals (sizePerEntry2 , 1 );
181+ Long sizePerEntry2 = entryCache . getEstimatedEntrySize ( );
182+ Assert .assertEquals (sizePerEntry2 , 1 + RangeEntryCacheImpl . BOOKKEEPER_READ_OVERHEAD_PER_ENTRY );
184183 long bytesAcquired2 = calculateBytesSizeBeforeFirstReading (readCount2 , 1 );
185184 long remainingBytesExpected2 = totalCapacity - bytesAcquired2 ;
186185 log .info ("acquired : {}" , bytesAcquired2 );
@@ -192,8 +191,8 @@ public void testPreciseLimitation(String missingCase) throws Exception {
192191
193192 readCompleteSignal2 .countDown ();
194193 cb2 .entries .join ();
195- Long sizePerEntry3 = WhiteboxImpl . getInternalState ( entryCache , "estimatedEntrySize" );
196- Assert .assertEquals (sizePerEntry3 , 1 );
194+ Long sizePerEntry3 = entryCache . getEstimatedEntrySize ( );
195+ Assert .assertEquals (sizePerEntry3 , 1 + RangeEntryCacheImpl . BOOKKEEPER_READ_OVERHEAD_PER_ENTRY );
197196 Awaitility .await ().untilAsserted (() -> {
198197 long remainingBytes = limiter .getRemainingBytes ();
199198 log .info ("remainingBytes 2: {}" , remainingBytes );
0 commit comments