Search in sources :

Example 1 with MessageStoreHardDelete

use of com.github.ambry.store.MessageStoreHardDelete in project ambry by linkedin.

the class BlobStoreHardDeleteTest method blobStoreHardDeleteTestUtil.

private void blobStoreHardDeleteTestUtil(short[] blobVersions, BlobType[] blobTypes) throws MessageFormatException, IOException {
    MessageStoreHardDelete hardDelete = new BlobStoreHardDelete();
    StoreKeyFactory keyFactory = new MockIdFactory();
    // create log and write to it
    ReadImp readImp = new ReadImp();
    ArrayList<Long> msgOffsets = readImp.initialize(blobVersions, blobTypes);
    Iterator<HardDeleteInfo> iter = hardDelete.getHardDeleteMessages(readImp.getMessageReadSet(), keyFactory, readImp.getRecoveryInfoList());
    List<HardDeleteInfo> hardDeletedList = new ArrayList<HardDeleteInfo>();
    while (iter.hasNext()) {
        hardDeletedList.add(iter.next());
    }
    // msg1
    HardDeleteInfo hardDeleteInfo = hardDeletedList.get(0);
    Assert.assertNotNull(hardDeleteInfo);
    HardDeleteRecoveryMetadata hardDeleteRecoveryMetadata = new HardDeleteRecoveryMetadata(hardDeleteInfo.getRecoveryInfo(), keyFactory);
    Assert.assertEquals(blobTypes[1], hardDeleteRecoveryMetadata.getBlobType());
    Assert.assertEquals(blobVersions[1], hardDeleteRecoveryMetadata.getBlobRecordVersion());
    // msg2
    hardDeleteInfo = hardDeletedList.get(1);
    Assert.assertNotNull(hardDeleteInfo);
    hardDeleteRecoveryMetadata = new HardDeleteRecoveryMetadata(hardDeleteInfo.getRecoveryInfo(), keyFactory);
    Assert.assertEquals(blobTypes[2], hardDeleteRecoveryMetadata.getBlobType());
    Assert.assertEquals(blobVersions[2], hardDeleteRecoveryMetadata.getBlobRecordVersion());
    // msg5
    hardDeleteInfo = hardDeletedList.get(2);
    Assert.assertNotNull(hardDeleteInfo);
    hardDeleteRecoveryMetadata = new HardDeleteRecoveryMetadata(hardDeleteInfo.getRecoveryInfo(), keyFactory);
    Assert.assertEquals(blobTypes[3], hardDeleteRecoveryMetadata.getBlobType());
    Assert.assertEquals(blobVersions[3], hardDeleteRecoveryMetadata.getBlobRecordVersion());
    // msg6 - NULL.
    Assert.assertNull(hardDeletedList.get(3));
}
Also used : StoreKeyFactory(com.github.ambry.store.StoreKeyFactory) MockIdFactory(com.github.ambry.store.MockIdFactory) HardDeleteInfo(com.github.ambry.store.HardDeleteInfo) ArrayList(java.util.ArrayList) MessageStoreHardDelete(com.github.ambry.store.MessageStoreHardDelete)

Aggregations

HardDeleteInfo (com.github.ambry.store.HardDeleteInfo)1 MessageStoreHardDelete (com.github.ambry.store.MessageStoreHardDelete)1 MockIdFactory (com.github.ambry.store.MockIdFactory)1 StoreKeyFactory (com.github.ambry.store.StoreKeyFactory)1 ArrayList (java.util.ArrayList)1