Search in sources :

Example 1 with RocksInodeStore

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

the class AbstractJournalDumper method readRocksCheckpoint.

private void readRocksCheckpoint(CheckpointInputStream checkpoint, Path path) throws IOException {
    // An empty dir for storing the db.
    Path dbPath = Paths.get(path.toFile().getPath() + "-rocks-db");
    // Create RocksInodeStore over checkpoint stream for extracting the inodes.
    try (PrintStream out = new PrintStream(new BufferedOutputStream(new FileOutputStream(path.toFile())));
        RocksInodeStore inodeStore = new RocksInodeStore(dbPath.toAbsolutePath().toString())) {
        // Create and restore RocksInodeStore from the checkpoint.
        inodeStore.restoreFromCheckpoint(checkpoint);
        // Dump entries.
        final String ENTRY_SEPARATOR = Strings.repeat("-", 80);
        try (CloseableIterator<InodeView> iterator = inodeStore.getCloseableIterator()) {
            for (; iterator.hasNext(); ) {
                InodeView inode = iterator.next();
                out.println(ENTRY_SEPARATOR);
                out.println(inode.toProto());
            }
        }
    } finally {
        // Remove the temp db directory.
        FileUtils.deletePathRecursively(dbPath.toFile().getPath());
    }
}
Also used : Path(java.nio.file.Path) PrintStream(java.io.PrintStream) RocksInodeStore(alluxio.master.metastore.rocks.RocksInodeStore) InodeView(alluxio.master.file.meta.InodeView) FileOutputStream(java.io.FileOutputStream) BufferedOutputStream(java.io.BufferedOutputStream)

Example 2 with RocksInodeStore

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

the class InodeStoreBench method main.

public static void main(String[] args) throws Exception {
    // Enable logging to stdout.
    Layout layout = new PatternLayout("%d [%t] %-5p %c %x - %m%n");
    Logger.getRootLogger().addAppender(new ConsoleAppender(layout));
    System.out.printf("Running benchmarks for rocks inode store%n");
    sStore = new RocksInodeStore(ServerConfiguration.getString(PropertyKey.MASTER_METASTORE_DIR));
    runBenchmarks();
    System.out.printf("%nRunning benchmarks for heap inode store%n");
    sStore = new HeapInodeStore();
    runBenchmarks();
}
Also used : ConsoleAppender(org.apache.log4j.ConsoleAppender) RocksInodeStore(alluxio.master.metastore.rocks.RocksInodeStore) Layout(org.apache.log4j.Layout) PatternLayout(org.apache.log4j.PatternLayout) PatternLayout(org.apache.log4j.PatternLayout) HeapInodeStore(alluxio.master.metastore.heap.HeapInodeStore)

Example 3 with RocksInodeStore

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

the class BackupManagerTest method rocksInodeStoreIteratorNotUsed.

@Test
public void rocksInodeStoreIteratorNotUsed() throws Exception {
    // Prepare some data for the iterator
    List<InodeView> inodes = new ArrayList<>();
    inodes.add(createRootDir(99L));
    inodes.add(createNewFile(100L));
    inodes.add(createNewFile(101L));
    inodes.add(createNewFile(102L));
    // When RocksInodeStore.iterator(), return mock iterator
    RocksInodeStore mockInodeStore = mock(RocksInodeStore.class);
    // Make sure the iterator is not used in the backup operation
    when(mockInodeStore.getCloseableIterator()).thenThrow(new UnsupportedOperationException());
    // When the root inode is asked for, return the directory
    InodeView dir = inodes.get(0);
    when(mockInodeStore.get(eq(0L))).thenReturn(Optional.of(new InodeDirectory((InodeDirectoryView) dir)));
    CoreMasterContext masterContext = MasterTestUtils.testMasterContext(new NoopJournalSystem(), null, () -> new HeapBlockStore(), x -> mockInodeStore);
    mMetricsMaster = new MetricsMasterFactory().create(mRegistry, masterContext);
    mBlockMaster = new DefaultBlockMaster(mMetricsMaster, masterContext, mClock, ExecutorServiceFactories.constantExecutorServiceFactory(mExecutorService));
    mRegistry.add(BlockMaster.class, mBlockMaster);
    // Prepare the FileSystemMaster for the backup operation
    FileSystemMaster fsMaster = new DefaultFileSystemMaster(mBlockMaster, masterContext, ExecutorServiceFactories.constantExecutorServiceFactory(mExecutorService));
    mRegistry.add(FileSystemMaster.class, fsMaster);
    mRegistry.start(true);
    // Finish 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);
    // No exception means the RocksInodeStore iterator is not used
    manager.backup(new FileOutputStream(backupFile), counter);
}
Also used : RocksInodeStore(alluxio.master.metastore.rocks.RocksInodeStore) InodeView(alluxio.master.file.meta.InodeView) DefaultBlockMaster(alluxio.master.block.DefaultBlockMaster) ArrayList(java.util.ArrayList) HeapBlockStore(alluxio.master.metastore.heap.HeapBlockStore) DefaultFileSystemMaster(alluxio.master.file.DefaultFileSystemMaster) FileSystemMaster(alluxio.master.file.FileSystemMaster) NoopJournalSystem(alluxio.master.journal.noop.NoopJournalSystem) MutableInodeDirectory(alluxio.master.file.meta.MutableInodeDirectory) InodeDirectory(alluxio.master.file.meta.InodeDirectory) AtomicLong(java.util.concurrent.atomic.AtomicLong) DefaultFileSystemMaster(alluxio.master.file.DefaultFileSystemMaster) FileOutputStream(java.io.FileOutputStream) File(java.io.File) MutableInodeFile(alluxio.master.file.meta.MutableInodeFile) MetricsMasterFactory(alluxio.master.metrics.MetricsMasterFactory) Test(org.junit.Test)

Aggregations

RocksInodeStore (alluxio.master.metastore.rocks.RocksInodeStore)3 InodeView (alluxio.master.file.meta.InodeView)2 FileOutputStream (java.io.FileOutputStream)2 DefaultBlockMaster (alluxio.master.block.DefaultBlockMaster)1 DefaultFileSystemMaster (alluxio.master.file.DefaultFileSystemMaster)1 FileSystemMaster (alluxio.master.file.FileSystemMaster)1 InodeDirectory (alluxio.master.file.meta.InodeDirectory)1 MutableInodeDirectory (alluxio.master.file.meta.MutableInodeDirectory)1 MutableInodeFile (alluxio.master.file.meta.MutableInodeFile)1 NoopJournalSystem (alluxio.master.journal.noop.NoopJournalSystem)1 HeapBlockStore (alluxio.master.metastore.heap.HeapBlockStore)1 HeapInodeStore (alluxio.master.metastore.heap.HeapInodeStore)1 MetricsMasterFactory (alluxio.master.metrics.MetricsMasterFactory)1 BufferedOutputStream (java.io.BufferedOutputStream)1 File (java.io.File)1 PrintStream (java.io.PrintStream)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 ConsoleAppender (org.apache.log4j.ConsoleAppender)1