Search in sources :

Example 6 with NoopJournalSystem

use of alluxio.master.journal.noop.NoopJournalSystem in project alluxio by Alluxio.

the class TableMasterFactoryTest method before.

@Before
public void before() {
    mContext = CoreMasterContext.newBuilder().setJournalSystem(new NoopJournalSystem()).setSafeModeManager(new TestSafeModeManager()).setBackupManager(mock(BackupManager.class)).setBlockStoreFactory(HeapBlockStore::new).setInodeStoreFactory(x -> new HeapInodeStore()).setUfsManager(new MasterUfsManager()).build();
    ServerConfiguration.set(PropertyKey.MASTER_JOURNAL_FOLDER, sTemp.getRoot().getAbsolutePath());
}
Also used : ServerConfiguration(alluxio.conf.ServerConfiguration) MasterUfsManager(alluxio.underfs.MasterUfsManager) NoopJournalSystem(alluxio.master.journal.noop.NoopJournalSystem) Assert.assertTrue(org.junit.Assert.assertTrue) Server(alluxio.Server) Set(java.util.Set) Test(org.junit.Test) BackupManager(alluxio.master.BackupManager) HeapBlockStore(alluxio.master.metastore.heap.HeapBlockStore) PropertyKey(alluxio.conf.PropertyKey) Collectors(java.util.stream.Collectors) HeapInodeStore(alluxio.master.metastore.heap.HeapInodeStore) Constants(alluxio.Constants) Assert.assertFalse(org.junit.Assert.assertFalse) TestSafeModeManager(alluxio.master.TestSafeModeManager) After(org.junit.After) CoreMasterContext(alluxio.master.CoreMasterContext) MasterRegistry(alluxio.master.MasterRegistry) ClassRule(org.junit.ClassRule) MasterUtils(alluxio.master.MasterUtils) TemporaryFolder(org.junit.rules.TemporaryFolder) Mockito.mock(org.mockito.Mockito.mock) Before(org.junit.Before) TestSafeModeManager(alluxio.master.TestSafeModeManager) HeapBlockStore(alluxio.master.metastore.heap.HeapBlockStore) NoopJournalSystem(alluxio.master.journal.noop.NoopJournalSystem) MasterUfsManager(alluxio.underfs.MasterUfsManager) HeapInodeStore(alluxio.master.metastore.heap.HeapInodeStore) Before(org.junit.Before)

Example 7 with NoopJournalSystem

use of alluxio.master.journal.noop.NoopJournalSystem in project alluxio by Alluxio.

the class AlluxioMasterProcessTest method startMastersThrowsUnavailableException.

@Test
public void startMastersThrowsUnavailableException() throws InterruptedException, IOException {
    ControllablePrimarySelector primarySelector = new ControllablePrimarySelector();
    primarySelector.setState(PrimarySelector.State.PRIMARY);
    ServerConfiguration.set(PropertyKey.MASTER_JOURNAL_EXIT_ON_DEMOTION, true);
    FaultTolerantAlluxioMasterProcess master = new FaultTolerantAlluxioMasterProcess(new NoopJournalSystem(), primarySelector);
    FaultTolerantAlluxioMasterProcess spy = PowerMockito.spy(master);
    PowerMockito.doAnswer(invocation -> {
        throw new UnavailableException("unavailable");
    }).when(spy).startMasters(true);
    AtomicBoolean success = new AtomicBoolean(true);
    Thread t = new Thread(() -> {
        try {
            spy.start();
        } catch (UnavailableException ue) {
            success.set(false);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    });
    t.start();
    // in ms
    final int WAIT_TIME_TO_THROW_EXC = 500;
    t.join(WAIT_TIME_TO_THROW_EXC);
    t.interrupt();
    Assert.assertTrue(success.get());
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) UnavailableException(alluxio.exception.status.UnavailableException) NoopJournalSystem(alluxio.master.journal.noop.NoopJournalSystem) TimeoutException(java.util.concurrent.TimeoutException) BindException(java.net.BindException) ConnectException(java.net.ConnectException) ExpectedException(org.junit.rules.ExpectedException) IOException(java.io.IOException) UnavailableException(alluxio.exception.status.UnavailableException) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 8 with NoopJournalSystem

use of alluxio.master.journal.noop.NoopJournalSystem in project alluxio by Alluxio.

the class AlluxioMasterProcessTest method startStopPrimary.

@Test
public void startStopPrimary() throws Exception {
    AlluxioMasterProcess master = new AlluxioMasterProcess(new NoopJournalSystem());
    Thread t = new Thread(() -> {
        try {
            master.start();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    });
    t.start();
    startStopTest(master);
}
Also used : NoopJournalSystem(alluxio.master.journal.noop.NoopJournalSystem) TimeoutException(java.util.concurrent.TimeoutException) BindException(java.net.BindException) ConnectException(java.net.ConnectException) ExpectedException(org.junit.rules.ExpectedException) IOException(java.io.IOException) UnavailableException(alluxio.exception.status.UnavailableException) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 9 with NoopJournalSystem

use of alluxio.master.journal.noop.NoopJournalSystem 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)

Example 10 with NoopJournalSystem

use of alluxio.master.journal.noop.NoopJournalSystem 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

NoopJournalSystem (alluxio.master.journal.noop.NoopJournalSystem)10 Test (org.junit.Test)7 UnavailableException (alluxio.exception.status.UnavailableException)4 MetricsMasterFactory (alluxio.master.metrics.MetricsMasterFactory)4 IOException (java.io.IOException)4 BindException (java.net.BindException)4 ConnectException (java.net.ConnectException)4 TimeoutException (java.util.concurrent.TimeoutException)4 Before (org.junit.Before)4 ExpectedException (org.junit.rules.ExpectedException)4 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4 CoreMasterContext (alluxio.master.CoreMasterContext)3 MasterRegistry (alluxio.master.MasterRegistry)3 DefaultBlockMaster (alluxio.master.block.DefaultBlockMaster)2 MutableInodeFile (alluxio.master.file.meta.MutableInodeFile)2 HeapBlockStore (alluxio.master.metastore.heap.HeapBlockStore)2 HeapInodeStore (alluxio.master.metastore.heap.HeapInodeStore)2 File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2 ArrayList (java.util.ArrayList)2