Search in sources :

Example 6 with MasterRegistry

use of alluxio.master.MasterRegistry in project alluxio by Alluxio.

the class PermissionCheckerTest method beforeClass.

@BeforeClass
public static void beforeClass() throws Exception {
    sFileContext = CreateFileContext.mergeFrom(CreateFilePOptions.newBuilder().setBlockSizeBytes(Constants.KB).setMode(TEST_NORMAL_MODE.toProto())).setOwner(TEST_USER_2.getUser()).setGroup(TEST_USER_2.getGroup());
    sWeirdFileContext = CreateFileContext.mergeFrom(CreateFilePOptions.newBuilder().setBlockSizeBytes(Constants.KB).setMode(TEST_WEIRD_MODE.toProto())).setOwner(TEST_USER_1.getUser()).setGroup(TEST_USER_1.getGroup());
    sNestedFileContext = CreateFileContext.mergeFrom(CreateFilePOptions.newBuilder().setBlockSizeBytes(Constants.KB).setMode(TEST_NORMAL_MODE.toProto()).setRecursive(true)).setOwner(TEST_USER_1.getUser()).setGroup(TEST_USER_1.getGroup());
    // setup an InodeTree
    sRegistry = new MasterRegistry();
    CoreMasterContext masterContext = MasterTestUtils.testMasterContext();
    sMetricsMaster = new MetricsMasterFactory().create(sRegistry, masterContext);
    sRegistry.add(MetricsMaster.class, sMetricsMaster);
    BlockMaster blockMaster = new BlockMasterFactory().create(sRegistry, masterContext);
    InodeDirectoryIdGenerator directoryIdGenerator = new InodeDirectoryIdGenerator(blockMaster);
    UfsManager ufsManager = mock(UfsManager.class);
    MountTable mountTable = new MountTable(ufsManager, mock(MountInfo.class));
    InodeLockManager lockManager = new InodeLockManager();
    sInodeStore = masterContext.getInodeStoreFactory().apply(lockManager);
    sTree = new InodeTree(sInodeStore, blockMaster, directoryIdGenerator, mountTable, lockManager);
    sRegistry.start(true);
    GroupMappingServiceTestUtils.resetCache();
    ServerConfiguration.set(PropertyKey.SECURITY_GROUP_MAPPING_CLASS, FakeUserGroupsMapping.class.getName());
    ServerConfiguration.set(PropertyKey.SECURITY_AUTHENTICATION_TYPE, AuthType.SIMPLE.getAuthName());
    ServerConfiguration.set(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_ENABLED, true);
    ServerConfiguration.set(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_SUPERGROUP, TEST_SUPER_GROUP);
    sTree.initializeRoot(TEST_USER_ADMIN.getUser(), TEST_USER_ADMIN.getGroup(), TEST_NORMAL_MODE, NoopJournalContext.INSTANCE);
    // build file structure
    createAndSetPermission(TEST_DIR_FILE_URI, sNestedFileContext);
    createAndSetPermission(TEST_FILE_URI, sFileContext);
    createAndSetPermission(TEST_WEIRD_FILE_URI, sWeirdFileContext);
}
Also used : BlockMaster(alluxio.master.block.BlockMaster) InodeDirectoryIdGenerator(alluxio.master.file.meta.InodeDirectoryIdGenerator) BlockMasterFactory(alluxio.master.block.BlockMasterFactory) UfsManager(alluxio.underfs.UfsManager) CoreMasterContext(alluxio.master.CoreMasterContext) InodeLockManager(alluxio.master.file.meta.InodeLockManager) MasterRegistry(alluxio.master.MasterRegistry) MountTable(alluxio.master.file.meta.MountTable) MountInfo(alluxio.master.file.meta.options.MountInfo) InodeTree(alluxio.master.file.meta.InodeTree) MetricsMasterFactory(alluxio.master.metrics.MetricsMasterFactory) BeforeClass(org.junit.BeforeClass)

Example 7 with MasterRegistry

use of alluxio.master.MasterRegistry in project alluxio by Alluxio.

the class ReplicationCheckerTest method before.

@Before
public void before() throws Exception {
    ServerConfiguration.set(PropertyKey.MASTER_JOURNAL_TYPE, "UFS");
    MasterRegistry registry = new MasterRegistry();
    JournalSystem journalSystem = JournalTestUtils.createJournalSystem(mTestFolder);
    mContext = MasterTestUtils.testMasterContext(journalSystem);
    new MetricsMasterFactory().create(registry, mContext);
    mBlockMaster = new BlockMasterFactory().create(registry, mContext);
    InodeDirectoryIdGenerator directoryIdGenerator = new InodeDirectoryIdGenerator(mBlockMaster);
    UfsManager manager = mock(UfsManager.class);
    MountTable mountTable = new MountTable(manager, mock(MountInfo.class));
    InodeLockManager lockManager = new InodeLockManager();
    mInodeStore = mContext.getInodeStoreFactory().apply(lockManager);
    mInodeTree = new InodeTree(mInodeStore, mBlockMaster, directoryIdGenerator, mountTable, lockManager);
    journalSystem.start();
    journalSystem.gainPrimacy();
    mBlockMaster.start(true);
    ServerConfiguration.set(PropertyKey.TEST_MODE, true);
    ServerConfiguration.set(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_ENABLED, true);
    ServerConfiguration.set(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_SUPERGROUP, "test-supergroup");
    mInodeTree.initializeRoot(TEST_OWNER, TEST_GROUP, TEST_MODE, NoopJournalContext.INSTANCE);
    mMockReplicationHandler = new MockHandler();
    mReplicationChecker = new ReplicationChecker(mInodeTree, mBlockMaster, mContext.getSafeModeManager(), mMockReplicationHandler);
}
Also used : InodeDirectoryIdGenerator(alluxio.master.file.meta.InodeDirectoryIdGenerator) BlockMasterFactory(alluxio.master.block.BlockMasterFactory) UfsManager(alluxio.underfs.UfsManager) InodeLockManager(alluxio.master.file.meta.InodeLockManager) JournalSystem(alluxio.master.journal.JournalSystem) MasterRegistry(alluxio.master.MasterRegistry) MountTable(alluxio.master.file.meta.MountTable) MountInfo(alluxio.master.file.meta.options.MountInfo) InodeTree(alluxio.master.file.meta.InodeTree) MetricsMasterFactory(alluxio.master.metrics.MetricsMasterFactory) Before(org.junit.Before)

Example 8 with MasterRegistry

use of alluxio.master.MasterRegistry in project alluxio by Alluxio.

the class JournalContextTest method before.

@Before
public void before() throws Exception {
    ServerConfiguration.set(PropertyKey.MASTER_JOURNAL_TYPE, mJournalType);
    mRegistry = new MasterRegistry();
    mJournalSystem = JournalTestUtils.createJournalSystem(mTemporaryFolder);
    mJournalSystem.format();
    mMasterContext = MasterTestUtils.testMasterContext(mJournalSystem);
    new MetricsMasterFactory().create(mRegistry, mMasterContext);
    mBlockMaster = new BlockMasterFactory().create(mRegistry, mMasterContext);
    // start
    mJournalSystem.start();
    mJournalSystem.gainPrimacy();
    mRegistry.start(true);
}
Also used : BlockMasterFactory(alluxio.master.block.BlockMasterFactory) MasterRegistry(alluxio.master.MasterRegistry) MetricsMasterFactory(alluxio.master.metrics.MetricsMasterFactory) Before(org.junit.Before)

Example 9 with MasterRegistry

use of alluxio.master.MasterRegistry in project alluxio by Alluxio.

the class PersistenceTest method startServices.

private void startServices() throws Exception {
    mRegistry = new MasterRegistry();
    JournalSystem journalSystem = JournalTestUtils.createJournalSystem(mJournalFolder.getAbsolutePath());
    CoreMasterContext context = MasterTestUtils.testMasterContext(journalSystem);
    new MetricsMasterFactory().create(mRegistry, context);
    new BlockMasterFactory().create(mRegistry, context);
    mFileSystemMaster = new FileSystemMasterFactory().create(mRegistry, context);
    journalSystem.start();
    journalSystem.gainPrimacy();
    mRegistry.start(true);
    mMockJobMasterClient = Mockito.mock(JobMasterClient.class);
    PowerMockito.mockStatic(JobMasterClient.Factory.class);
    Mockito.when(JobMasterClient.Factory.create(any(JobMasterClientContext.class))).thenReturn(mMockJobMasterClient);
}
Also used : JobMasterClient(alluxio.client.job.JobMasterClient) BlockMasterFactory(alluxio.master.block.BlockMasterFactory) CoreMasterContext(alluxio.master.CoreMasterContext) JobMasterClientContext(alluxio.worker.job.JobMasterClientContext) JournalSystem(alluxio.master.journal.JournalSystem) MasterRegistry(alluxio.master.MasterRegistry) MetricsMasterFactory(alluxio.master.metrics.MetricsMasterFactory)

Example 10 with MasterRegistry

use of alluxio.master.MasterRegistry in project alluxio by Alluxio.

the class JournalSinkTest method replayEvents.

@Test
public void replayEvents() throws Exception {
    // start standby masters
    TestJournalSink standbySink = new TestJournalSink(new LinkedBlockingQueue<>());
    startMasters(new MasterRegistry(), JournalTestUtils.createJournalSystem(mJournalFolder), standbySink, false);
    int nextCreateId1 = 1;
    int nextCreateId2 = 1;
    int nextRenameId = 1;
    int nextDeleteId = 1;
    int completed = 0;
    while (completed < 5000) {
        switch(ThreadLocalRandom.current().nextInt(4)) {
            case 0:
                createFile("/file_for_rename" + nextCreateId1++);
                completed++;
                break;
            case 1:
                createFile("/file_for_delete" + nextCreateId2++);
                completed++;
                break;
            case 2:
                if (nextRenameId < nextCreateId1) {
                    mFileSystemMaster.rename(new AlluxioURI("/file_for_rename" + nextRenameId), new AlluxioURI("/renamed" + nextRenameId), RenameContext.defaults());
                    nextRenameId++;
                    completed++;
                }
                break;
            case 3:
                if (nextDeleteId < nextCreateId2) {
                    mFileSystemMaster.delete(new AlluxioURI("/file_for_delete" + nextDeleteId), DeleteContext.create(DeletePOptions.newBuilder().setRecursive(true)));
                    nextDeleteId++;
                    completed++;
                }
                break;
            default:
        }
    }
    // Stop and restart the default masters
    stopMasters(mRegistry, mJournalSystem);
    mJournalSystem.removeJournalSink(mRegistry.get(FileSystemMaster.class), mJournalSink);
    TestJournalSink restartSink = new TestJournalSink(new LinkedBlockingQueue<>());
    startMasters(mRegistry, mJournalSystem, restartSink, true);
    CommonUtils.waitFor("leader receives all entries", () -> mJournalSink.getEntries().size() == restartSink.getEntries().size(), WaitForOptions.defaults().setTimeoutMs(5000));
    CommonUtils.waitFor("standby receives all entries", () -> mJournalSink.getEntries().size() == standbySink.getEntries().size(), WaitForOptions.defaults().setTimeoutMs(5000));
    // Need to strip out the sequence number because
    List<JournalEntry> masterEntries = stripSeqNo(mJournalSink.getEntries());
    List<JournalEntry> restartEntries = stripSeqNo(restartSink.getEntries());
    List<JournalEntry> standbyEntries = stripSeqNo(standbySink.getEntries());
    assertFalse(masterEntries.isEmpty());
    assertEquals("leader restart failed to see all entries", masterEntries, restartEntries);
    assertEquals("standby failed to see all entries", masterEntries, standbyEntries);
}
Also used : FileSystemMaster(alluxio.master.file.FileSystemMaster) MasterRegistry(alluxio.master.MasterRegistry) JournalEntry(alluxio.proto.journal.Journal.JournalEntry) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Aggregations

MasterRegistry (alluxio.master.MasterRegistry)20 MetricsMasterFactory (alluxio.master.metrics.MetricsMasterFactory)15 BlockMasterFactory (alluxio.master.block.BlockMasterFactory)11 Before (org.junit.Before)11 CoreMasterContext (alluxio.master.CoreMasterContext)10 JournalSystem (alluxio.master.journal.JournalSystem)6 ManualClock (alluxio.clock.ManualClock)5 MountInfo (alluxio.master.file.meta.options.MountInfo)4 UfsManager (alluxio.underfs.UfsManager)4 InodeDirectoryIdGenerator (alluxio.master.file.meta.InodeDirectoryIdGenerator)3 InodeLockManager (alluxio.master.file.meta.InodeLockManager)3 InodeTree (alluxio.master.file.meta.InodeTree)3 MountTable (alluxio.master.file.meta.MountTable)3 Test (org.junit.Test)3 BlockMaster (alluxio.master.block.BlockMaster)2 FileSystemMaster (alluxio.master.file.FileSystemMaster)2 FileSystemMasterFactory (alluxio.master.file.FileSystemMasterFactory)2 NoopJournalSystem (alluxio.master.journal.noop.NoopJournalSystem)2 TestUserState (alluxio.security.user.TestUserState)2 AlluxioURI (alluxio.AlluxioURI)1