Search in sources :

Example 1 with BlockMaster

use of alluxio.master.block.BlockMaster in project alluxio by Alluxio.

the class PermissionCheckerTest method beforeClass.

@BeforeClass
public static void beforeClass() throws Exception {
    sFileOptions = CreateFileOptions.defaults().setBlockSizeBytes(Constants.KB).setOwner(TEST_USER_2.getUser()).setGroup(TEST_USER_2.getGroup()).setMode(TEST_NORMAL_MODE);
    sWeirdFileOptions = CreateFileOptions.defaults().setBlockSizeBytes(Constants.KB).setOwner(TEST_USER_1.getUser()).setGroup(TEST_USER_1.getGroup()).setMode(TEST_WEIRD_MODE);
    sNestedFileOptions = CreateFileOptions.defaults().setBlockSizeBytes(Constants.KB).setOwner(TEST_USER_1.getUser()).setGroup(TEST_USER_1.getGroup()).setMode(TEST_NORMAL_MODE).setRecursive(true);
    // setup an InodeTree
    JournalFactory journalFactory = new JournalFactory.ReadWrite(sTestFolder.newFolder().getAbsolutePath());
    BlockMaster blockMaster = new BlockMaster(journalFactory);
    InodeDirectoryIdGenerator directoryIdGenerator = new InodeDirectoryIdGenerator(blockMaster);
    MountTable mountTable = new MountTable();
    sTree = new InodeTree(blockMaster, directoryIdGenerator, mountTable);
    blockMaster.start(true);
    GroupMappingServiceTestUtils.resetCache();
    Configuration.set(PropertyKey.SECURITY_GROUP_MAPPING_CLASS, FakeUserGroupsMapping.class.getName());
    Configuration.set(PropertyKey.SECURITY_AUTHENTICATION_TYPE, AuthType.SIMPLE.getAuthName());
    Configuration.set(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_ENABLED, "true");
    Configuration.set(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_SUPERGROUP, TEST_SUPER_GROUP);
    sTree.initializeRoot(TEST_USER_ADMIN.getUser(), TEST_USER_ADMIN.getGroup(), TEST_NORMAL_MODE);
    // build file structure
    createAndSetPermission(TEST_DIR_FILE_URI, sNestedFileOptions);
    createAndSetPermission(TEST_FILE_URI, sFileOptions);
    createAndSetPermission(TEST_WEIRD_FILE_URI, sWeirdFileOptions);
}
Also used : JournalFactory(alluxio.master.journal.JournalFactory) BlockMaster(alluxio.master.block.BlockMaster) InodeDirectoryIdGenerator(alluxio.master.file.meta.InodeDirectoryIdGenerator) MountTable(alluxio.master.file.meta.MountTable) InodeTree(alluxio.master.file.meta.InodeTree) BeforeClass(org.junit.BeforeClass)

Example 2 with BlockMaster

use of alluxio.master.block.BlockMaster in project alluxio by Alluxio.

the class AlluxioMasterRestServiceHandlerTest method before.

@Before
public void before() throws Exception {
    mMaster = mock(AlluxioMasterService.class);
    mContext = mock(ServletContext.class);
    JournalFactory journalFactory = new JournalFactory.ReadWrite(mTestFolder.newFolder().getAbsolutePath());
    mClock = new ManualClock();
    mExecutorService = Executors.newFixedThreadPool(2, ThreadFactoryUtils.build("TestBlockMaster-%d", true));
    mBlockMaster = new BlockMaster(journalFactory, mClock, ExecutorServiceFactories.constantExecutorServiceFactory(mExecutorService));
    mBlockMaster.start(true);
    when(mMaster.getBlockMaster()).thenReturn(mBlockMaster);
    when(mContext.getAttribute(MasterWebServer.ALLUXIO_MASTER_SERVLET_RESOURCE_KEY)).thenReturn(mMaster);
    registerFileSystemMock();
    mHandler = new AlluxioMasterRestServiceHandler(mContext);
    // Register two workers
    long worker1 = mBlockMaster.getWorkerId(NET_ADDRESS_1);
    long worker2 = mBlockMaster.getWorkerId(NET_ADDRESS_2);
    List<String> tiers = Arrays.asList("MEM", "SSD");
    mBlockMaster.workerRegister(worker1, tiers, WORKER1_TOTAL_BYTES_ON_TIERS, WORKER1_USED_BYTES_ON_TIERS, NO_BLOCKS_ON_TIERS);
    mBlockMaster.workerRegister(worker2, tiers, WORKER2_TOTAL_BYTES_ON_TIERS, WORKER2_USED_BYTES_ON_TIERS, NO_BLOCKS_ON_TIERS);
}
Also used : JournalFactory(alluxio.master.journal.JournalFactory) BlockMaster(alluxio.master.block.BlockMaster) ManualClock(alluxio.clock.ManualClock) ServletContext(javax.servlet.ServletContext) Matchers.anyString(org.mockito.Matchers.anyString) Before(org.junit.Before)

Example 3 with BlockMaster

use of alluxio.master.block.BlockMaster in project alluxio by Alluxio.

the class InodeTreeTest method before.

/**
   * Sets up all dependencies before a test runs.
   */
@Before
public void before() throws Exception {
    JournalFactory journalFactory = new JournalFactory.ReadWrite(mTestFolder.newFolder().getAbsolutePath());
    BlockMaster blockMaster = new BlockMaster(journalFactory);
    InodeDirectoryIdGenerator directoryIdGenerator = new InodeDirectoryIdGenerator(blockMaster);
    MountTable mountTable = new MountTable();
    mTree = new InodeTree(blockMaster, directoryIdGenerator, mountTable);
    blockMaster.start(true);
    Configuration.set(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_ENABLED, "true");
    Configuration.set(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_SUPERGROUP, "test-supergroup");
    mTree.initializeRoot(TEST_OWNER, TEST_GROUP, TEST_DIR_MODE);
}
Also used : JournalFactory(alluxio.master.journal.JournalFactory) BlockMaster(alluxio.master.block.BlockMaster) Before(org.junit.Before)

Example 4 with BlockMaster

use of alluxio.master.block.BlockMaster in project alluxio by Alluxio.

the class PermissionCheckTest method before.

@Before
public void before() throws Exception {
    GroupMappingServiceTestUtils.resetCache();
    JournalFactory journalFactory = new JournalFactory.ReadWrite(mTestFolder.newFolder().getAbsolutePath());
    mBlockMaster = new BlockMaster(journalFactory);
    mFileSystemMaster = new FileSystemMaster(mBlockMaster, journalFactory);
    mBlockMaster.start(true);
    mFileSystemMaster.start(true);
    createDirAndFileForTest();
    mInodeTree = Mockito.mock(InodeTree.class);
    Mockito.when(mInodeTree.getRootUserName()).thenReturn(TEST_USER_ADMIN.getUser());
}
Also used : JournalFactory(alluxio.master.journal.JournalFactory) BlockMaster(alluxio.master.block.BlockMaster) InodeTree(alluxio.master.file.meta.InodeTree) Before(org.junit.Before)

Example 5 with BlockMaster

use of alluxio.master.block.BlockMaster in project alluxio by Alluxio.

the class FreeAndDeleteIntegrationTest method freeAndDeleteIntegration.

@Test
public void freeAndDeleteIntegration() throws Exception {
    HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 5, TimeUnit.SECONDS);
    HeartbeatScheduler.await(HeartbeatContext.MASTER_LOST_FILES_DETECTION, 5, TimeUnit.SECONDS);
    AlluxioURI filePath = new AlluxioURI(PathUtils.uniqPath());
    FileOutStream os = mFileSystem.createFile(filePath, mWriteBoth);
    os.write((byte) 0);
    os.write((byte) 1);
    os.close();
    URIStatus status = mFileSystem.getStatus(filePath);
    Assert.assertEquals(PersistenceState.PERSISTED.toString(), status.getPersistenceState());
    final Long blockId = status.getBlockIds().get(0);
    BlockMaster bm = mLocalAlluxioClusterResource.get().getMaster().getInternalMaster().getBlockMaster();
    BlockInfo blockInfo = bm.getBlockInfo(blockId);
    Assert.assertEquals(2, blockInfo.getLength());
    Assert.assertFalse(blockInfo.getLocations().isEmpty());
    final BlockWorker bw = mLocalAlluxioClusterResource.get().getWorker().getBlockWorker();
    Assert.assertTrue(bw.hasBlockMeta(blockId));
    Assert.assertTrue(bm.getLostBlocks().isEmpty());
    mFileSystem.free(filePath);
    IntegrationTestUtils.waitForBlocksToBeFreed(bw, blockId);
    status = mFileSystem.getStatus(filePath);
    // Verify block metadata in master is still present after block freed.
    Assert.assertEquals(1, status.getBlockIds().size());
    blockInfo = bm.getBlockInfo(status.getBlockIds().get(0));
    Assert.assertEquals(2, blockInfo.getLength());
    // Verify the block has been removed from all workers.
    Assert.assertTrue(blockInfo.getLocations().isEmpty());
    Assert.assertFalse(bw.hasBlockMeta(blockId));
    // Verify the removed block is added to LostBlocks list.
    Assert.assertTrue(bm.getLostBlocks().contains(blockInfo.getBlockId()));
    mFileSystem.delete(filePath);
    try {
        // File is immediately gone after delete.
        mFileSystem.getStatus(filePath);
        Assert.fail(String.format("Expected file %s being deleted but it was not.", filePath));
    } catch (FileDoesNotExistException e) {
    // expected
    }
    // Execute the lost files detection.
    HeartbeatScheduler.execute(HeartbeatContext.MASTER_LOST_FILES_DETECTION);
    // Verify the blocks are not in mLostBlocks.
    Assert.assertTrue(bm.getLostBlocks().isEmpty());
}
Also used : BlockMaster(alluxio.master.block.BlockMaster) FileDoesNotExistException(alluxio.exception.FileDoesNotExistException) BlockInfo(alluxio.wire.BlockInfo) FileOutStream(alluxio.client.file.FileOutStream) URIStatus(alluxio.client.file.URIStatus) AlluxioURI(alluxio.AlluxioURI) BlockWorker(alluxio.worker.block.BlockWorker) Test(org.junit.Test)

Aggregations

BlockMaster (alluxio.master.block.BlockMaster)11 JournalFactory (alluxio.master.journal.JournalFactory)7 FileSystemMaster (alluxio.master.file.FileSystemMaster)3 Before (org.junit.Before)3 Test (org.junit.Test)3 InodeTree (alluxio.master.file.meta.InodeTree)2 AlluxioURI (alluxio.AlluxioURI)1 FileOutStream (alluxio.client.file.FileOutStream)1 URIStatus (alluxio.client.file.URIStatus)1 ManualClock (alluxio.clock.ManualClock)1 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)1 InodeDirectoryIdGenerator (alluxio.master.file.meta.InodeDirectoryIdGenerator)1 MountTable (alluxio.master.file.meta.MountTable)1 LineageMaster (alluxio.master.lineage.LineageMaster)1 BlockInfo (alluxio.wire.BlockInfo)1 WorkerNetAddress (alluxio.wire.WorkerNetAddress)1 BlockWorker (alluxio.worker.block.BlockWorker)1 ImmutableList (com.google.common.collect.ImmutableList)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1