@@ -715,6 +715,44 @@ public void testBatchReadFailBackToSingleRead2() throws Exception {
715715 }
716716 }
717717
718+ @ Test
719+ public void testSanityCheckBatchReadEntriesV2 () {
720+ ClientConfiguration conf = new ClientConfiguration ().setUseV2WireProtocol (true );
721+ conf .setBatchReadEnabled (true );
722+ conf .setMetadataServiceUri (zkUtil .getMetadataServiceUri ());
723+ int numEntries = 100 ;
724+ byte [] data = "foobar" .getBytes ();
725+ try (BookKeeper bkc = new BookKeeper (conf )) {
726+ long ledgerId ;
727+ try (LedgerHandle lh = bkc .createLedger (2 , 2 , digestType , "testPasswd" .getBytes ())) {
728+ ledgerId = lh .getId ();
729+ for (int i = 0 ; i < numEntries ; i ++) {
730+ lh .addEntry (data );
731+ }
732+ } catch (BKException | InterruptedException e ) {
733+ fail ("LedgerHandle inti failed: " + e .getMessage ());
734+ return ;
735+ }
736+
737+ // startEntry < 0
738+ try (LedgerHandle lh = bkc .openLedger (ledgerId , digestType , "testPasswd" .getBytes ())) {
739+ assertEquals (numEntries - 1 , lh .readLastConfirmed ());
740+ Enumeration <LedgerEntry > entries = lh .batchReadEntries (-1 , numEntries , 5 * 1024 * 1024 );
741+ } catch (BKException | InterruptedException e ) {
742+ LOG .info (e .getMessage (), e ); // It should raise IncorrectParameterException
743+ }
744+
745+ // startEntry > lastAddConfirmed
746+ try (LedgerHandle lh = bkc .openLedger (ledgerId , digestType , "testPasswd" .getBytes ())) {
747+ Enumeration <LedgerEntry > entries = lh .batchReadEntries (numEntries , numEntries , 5 * 1024 * 1024 );
748+ } catch (BKException | InterruptedException e ) {
749+ LOG .info (e .getMessage (), e ); // It should raise IncorrectParameterException
750+ }
751+ } catch (BKException | InterruptedException | IOException e ) {
752+ fail ("BookKeeper client init failed: " + e .getMessage ());
753+ }
754+ }
755+
718756 @ Test
719757 public void testBatchReadWithV2Protocol () throws Exception {
720758 ClientConfiguration conf = new ClientConfiguration ().setUseV2WireProtocol (true );
0 commit comments