Search in sources :

Example 1 with CoreMasterContext

use of alluxio.master.CoreMasterContext 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 2 with CoreMasterContext

use of alluxio.master.CoreMasterContext 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 3 with CoreMasterContext

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

the class JournalSinkTest method startMasters.

private void startMasters(MasterRegistry registry, JournalSystem journalSystem, JournalSink sink, boolean leader) throws Exception {
    CoreMasterContext masterContext = MasterTestUtils.testMasterContext(journalSystem);
    new MetricsMasterFactory().create(registry, masterContext);
    new BlockMasterFactory().create(registry, masterContext);
    new FileSystemMasterFactory().create(registry, masterContext);
    if (sink != null) {
        // add journal sink
        journalSystem.addJournalSink(registry.get(FileSystemMaster.class), sink);
    }
    journalSystem.start();
    if (leader) {
        journalSystem.gainPrimacy();
    }
    registry.start(leader);
}
Also used : BlockMasterFactory(alluxio.master.block.BlockMasterFactory) CoreMasterContext(alluxio.master.CoreMasterContext) FileSystemMasterFactory(alluxio.master.file.FileSystemMasterFactory) FileSystemMaster(alluxio.master.file.FileSystemMaster) MetricsMasterFactory(alluxio.master.metrics.MetricsMasterFactory)

Example 4 with CoreMasterContext

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

the class AlluxioMasterRestServiceHandlerTest method before.

@Before
public void before() throws Exception {
    mMasterProcess = mock(AlluxioMasterProcess.class);
    ServletContext context = mock(ServletContext.class);
    mRegistry = new MasterRegistry();
    CoreMasterContext masterContext = MasterTestUtils.testMasterContext();
    mMetricsMaster = new MetricsMasterFactory().create(mRegistry, masterContext);
    mRegistry.add(MetricsMaster.class, mMetricsMaster);
    registerMockUfs();
    mBlockMaster = new BlockMasterFactory().create(mRegistry, masterContext);
    mFileSystemMaster = new FileSystemMasterFactory().create(mRegistry, masterContext);
    mRegistry.start(true);
    when(mMasterProcess.getMaster(BlockMaster.class)).thenReturn(mBlockMaster);
    when(mMasterProcess.getMaster(FileSystemMaster.class)).thenReturn(mFileSystemMaster);
    when(context.getAttribute(MasterWebServer.ALLUXIO_MASTER_SERVLET_RESOURCE_KEY)).thenReturn(mMasterProcess);
    mHandler = new AlluxioMasterRestServiceHandler(context);
    // Register two workers
    long worker1 = mBlockMaster.getWorkerId(NET_ADDRESS_1);
    long worker2 = mBlockMaster.getWorkerId(NET_ADDRESS_2);
    List<String> tiers = Arrays.asList(Constants.MEDIUM_MEM, Constants.MEDIUM_SSD);
    mBlockMaster.workerRegister(worker1, tiers, WORKER1_TOTAL_BYTES_ON_TIERS, WORKER1_USED_BYTES_ON_TIERS, NO_BLOCKS_ON_LOCATIONS, NO_LOST_STORAGE, RegisterWorkerPOptions.getDefaultInstance());
    mBlockMaster.workerRegister(worker2, tiers, WORKER2_TOTAL_BYTES_ON_TIERS, WORKER2_USED_BYTES_ON_TIERS, NO_BLOCKS_ON_LOCATIONS, NO_LOST_STORAGE, RegisterWorkerPOptions.getDefaultInstance());
    String filesPinnedProperty = MetricKey.MASTER_FILES_PINNED.getName();
    MetricsSystem.METRIC_REGISTRY.remove(filesPinnedProperty);
}
Also used : BlockMasterFactory(alluxio.master.block.BlockMasterFactory) AlluxioMasterProcess(alluxio.master.AlluxioMasterProcess) CoreMasterContext(alluxio.master.CoreMasterContext) FileSystemMasterFactory(alluxio.master.file.FileSystemMasterFactory) ServletContext(javax.servlet.ServletContext) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) MasterRegistry(alluxio.master.MasterRegistry) MetricsMasterFactory(alluxio.master.metrics.MetricsMasterFactory) Before(org.junit.Before)

Example 5 with CoreMasterContext

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

the class PermissionCheckTest method before.

@Before
public void before() throws Exception {
    ServerConfiguration.set(PropertyKey.MASTER_MOUNT_TABLE_ROOT_UFS, mTestFolder.newFolder());
    GroupMappingServiceTestUtils.resetCache();
    mRegistry = new MasterRegistry();
    mRegistry.add(MetricsMaster.class, mMetricsMaster);
    CoreMasterContext masterContext = MasterTestUtils.testMasterContext(new NoopJournalSystem(), new TestUserState(TEST_USER_ADMIN.getUser(), ServerConfiguration.global()));
    mMetricsMaster = new MetricsMasterFactory().create(mRegistry, masterContext);
    new BlockMasterFactory().create(mRegistry, masterContext);
    mFileSystemMaster = new FileSystemMasterFactory().create(mRegistry, masterContext);
    mRegistry.start(true);
    createDirAndFileForTest();
}
Also used : BlockMasterFactory(alluxio.master.block.BlockMasterFactory) CoreMasterContext(alluxio.master.CoreMasterContext) TestUserState(alluxio.security.user.TestUserState) MasterRegistry(alluxio.master.MasterRegistry) NoopJournalSystem(alluxio.master.journal.noop.NoopJournalSystem) MetricsMasterFactory(alluxio.master.metrics.MetricsMasterFactory) Before(org.junit.Before)

Aggregations

CoreMasterContext (alluxio.master.CoreMasterContext)12 MetricsMasterFactory (alluxio.master.metrics.MetricsMasterFactory)11 MasterRegistry (alluxio.master.MasterRegistry)10 BlockMasterFactory (alluxio.master.block.BlockMasterFactory)9 Before (org.junit.Before)5 JournalSystem (alluxio.master.journal.JournalSystem)4 FileSystemMasterFactory (alluxio.master.file.FileSystemMasterFactory)3 JobMasterClient (alluxio.client.job.JobMasterClient)2 ManualClock (alluxio.clock.ManualClock)2 BlockMaster (alluxio.master.block.BlockMaster)2 MountInfo (alluxio.master.file.meta.options.MountInfo)2 NoopJournalSystem (alluxio.master.journal.noop.NoopJournalSystem)2 TestUserState (alluxio.security.user.TestUserState)2 UfsManager (alluxio.underfs.UfsManager)2 StorageList (alluxio.grpc.StorageList)1 AlluxioMasterProcess (alluxio.master.AlluxioMasterProcess)1 SafeModeManager (alluxio.master.SafeModeManager)1 TestSafeModeManager (alluxio.master.TestSafeModeManager)1 FileSystemMaster (alluxio.master.file.FileSystemMaster)1 InodeDirectoryIdGenerator (alluxio.master.file.meta.InodeDirectoryIdGenerator)1