Пример #1
0
 private void testRecoveryWithBadMessageSize(List<Record> records, int size) throws IOException {
   LogSegment seg = this.store.log().lastSegment();
   writeToOffset(seg.file(), seg.file().length(), ByteBuffer.allocate(4).putInt(size).array());
   // now add some message bytes, but not enough
   if (size > 0)
     writeToOffset(
         seg.file(), seg.file().length(), ByteBuffer.allocate(Math.min(size - 1, 256)).array());
   this.store.close();
   this.store = new HashStore(config);
   assertEquals("Same records should be present after close and re-open", records, records(store));
 }
Пример #2
0
 @Test
 public void testRecoveryTotalCorruption() throws IOException {
   List<Record> records = StoreTestUtils.randomRecords(10);
   putAll(records);
   // mangle log file
   LogSegment seg = this.store.log().segmentFor(0);
   writeToOffset(seg.file(), 0, "Hayduke lives!".getBytes());
   this.store.close();
   this.store = new HashStore(config);
   if (!config.saveIndexOnClose())
     assertEquals(
         "No records should be present after mangling", Collections.emptyList(), records(store));
 }