You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2019/05/06 18:40:35 UTC

[GitHub] [bookkeeper] karanmehta93 commented on issue #2087: Update lastLogMark when replaying journal

karanmehta93 commented on issue #2087: Update lastLogMark when replaying journal
URL: https://github.com/apache/bookkeeper/issues/2087#issuecomment-489729288
 
 
   I wrote up this test for `BookieInitializationTest` class to corroborate my understanding of the code. There are 3 different lines that print the checkpoint to console.
   
   ```
       @Test
       public void someTest() throws Exception {
           File tmpDir = createTempDir("DiskCheck", "test");
   
           final ServerConfiguration conf = newServerConfiguration()
                   .setJournalDirName(tmpDir.getPath())
                   .setLedgerDirNames(new String[] { tmpDir.getPath() })
                   .setDiskCheckInterval(1000)
                   .setLedgerStorageClass(SortedLedgerStorage.class.getName())
                   .setAutoRecoveryDaemonEnabled(false)
                   .setZkTimeout(5000);
   
           BookieServer server = new MockBookieServer(conf);
           server.start();
           Checkpoint checkpoint = server.getBookie().journals.get(0).newCheckpoint();
           System.out.println("Checkpoint: " + checkpoint);
           ClientConfiguration clientConf = new ClientConfiguration();
           clientConf.setMetadataServiceUri(metadataServiceUri);
           BookKeeper bkClient = new BookKeeper(clientConf);
           LedgerHandle lh = bkClient.createLedger(1, 1, 1, DigestType.CRC32, "passwd".getBytes());
           long entryId = -1;
           long numOfEntries = 5;
           for (int i = 0; i < numOfEntries; i++) {
               entryId = lh.addEntry("data".getBytes());
           }
           checkpoint = server.getBookie().journals.get(0).newCheckpoint();
           System.out.println("Checkpoint: " + checkpoint);
           assertTrue("EntryId of the recently added entry should be 0", entryId == (numOfEntries - 1));
           // We want to simulate the scenario where Bookie is killed abruptly, so
           // SortedLedgerStorage's EntryMemTable and IndexInMemoryPageManager are
           // not flushed and hence when bookie is restarted it will replay the
           // journal. Since there is no easy way to kill the Bookie abruptly, we
           // are injecting no-op shutdown.
           server.shutdown();
   
           conf.setDiskUsageThreshold(0.001f)
                   .setDiskUsageWarnThreshold(0.0f).setReadOnlyModeEnabled(true).setIsForceGCAllowWhenNoSpace(true)
                   .setMinUsableSizeForIndexFileCreation(5 * 1024);
           server = new BookieServer(conf);
           // This should have completed journal replay and force flush
           server.start();
           checkpoint = server.getBookie().journals.get(0).newCheckpoint();
           System.out.println("Checkpoint: " + checkpoint);
           server.shutdown();
           bkClient.close();
       }
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services