Search in sources :

Example 1 with RocksBlockStore

use of alluxio.master.metastore.rocks.RocksBlockStore in project alluxio by Alluxio.

the class BackupManagerTest method rocksBlockStoreIteratorClosed.

@Test
public void rocksBlockStoreIteratorClosed() throws Exception {
    // Prepare some data for the iterator
    List<BlockStore.Block> blocks = new ArrayList<>();
    blocks.add(createNewBlock(1L));
    blocks.add(createNewBlock(2L));
    blocks.add(createNewBlock(3L));
    // When RocksBlockStore.iterator(), return mock iterator
    AtomicBoolean blockIteratorClosed = new AtomicBoolean(false);
    CloseableIterator<BlockStore.Block> testBlockIter = CloseableIterator.create(blocks.iterator(), (whatever) -> blockIteratorClosed.set(true));
    RocksBlockStore mockBlockStore = mock(RocksBlockStore.class);
    when(mockBlockStore.iterator()).thenReturn(testBlockIter);
    // Prepare the BlockMaster for the backup operation
    CoreMasterContext masterContext = MasterTestUtils.testMasterContext(new NoopJournalSystem(), null, () -> mockBlockStore, x -> new HeapInodeStore());
    mMetricsMaster = new MetricsMasterFactory().create(mRegistry, masterContext);
    mBlockMaster = new DefaultBlockMaster(mMetricsMaster, masterContext, mClock, ExecutorServiceFactories.constantExecutorServiceFactory(mExecutorService));
    mRegistry.add(BlockMaster.class, mBlockMaster);
    mRegistry.start(true);
    // Perform the backup operation
    BackupManager manager = new BackupManager(mRegistry);
    File backupDir = AlluxioTestDirectory.createTemporaryDirectory("backup-dir");
    File backupFile = new File(backupDir, "1.backup");
    AtomicLong counter = new AtomicLong(0L);
    manager.backup(new FileOutputStream(backupFile), counter);
    // verify iterators all closed properly
    assertTrue(blockIteratorClosed.get());
}
Also used : DefaultBlockMaster(alluxio.master.block.DefaultBlockMaster) ArrayList(java.util.ArrayList) NoopJournalSystem(alluxio.master.journal.noop.NoopJournalSystem) RocksBlockStore(alluxio.master.metastore.rocks.RocksBlockStore) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) AtomicLong(java.util.concurrent.atomic.AtomicLong) FileOutputStream(java.io.FileOutputStream) Block(alluxio.proto.meta.Block) File(java.io.File) MutableInodeFile(alluxio.master.file.meta.MutableInodeFile) HeapInodeStore(alluxio.master.metastore.heap.HeapInodeStore) MetricsMasterFactory(alluxio.master.metrics.MetricsMasterFactory) Test(org.junit.Test)

Aggregations

DefaultBlockMaster (alluxio.master.block.DefaultBlockMaster)1 MutableInodeFile (alluxio.master.file.meta.MutableInodeFile)1 NoopJournalSystem (alluxio.master.journal.noop.NoopJournalSystem)1 HeapInodeStore (alluxio.master.metastore.heap.HeapInodeStore)1 RocksBlockStore (alluxio.master.metastore.rocks.RocksBlockStore)1 MetricsMasterFactory (alluxio.master.metrics.MetricsMasterFactory)1 Block (alluxio.proto.meta.Block)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 ArrayList (java.util.ArrayList)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 Test (org.junit.Test)1