use of alluxio.underfs.UfsManager in project alluxio by Alluxio.
the class DefaultFileSystemMaster method getRootMountInfo.
private static MountInfo getRootMountInfo(MasterUfsManager ufsManager) {
try (CloseableResource<UnderFileSystem> resource = ufsManager.getRoot().acquireUfsResource()) {
boolean shared = resource.get().isObjectStorage() && ServerConfiguration.getBoolean(PropertyKey.UNDERFS_OBJECT_STORE_MOUNT_SHARED_PUBLICLY);
boolean readonly = ServerConfiguration.getBoolean(PropertyKey.MASTER_MOUNT_TABLE_ROOT_READONLY);
String rootUfsUri = PathUtils.normalizePath(ServerConfiguration.getString(PropertyKey.MASTER_MOUNT_TABLE_ROOT_UFS), AlluxioURI.SEPARATOR);
Map<String, String> rootUfsConf = ServerConfiguration.getNestedProperties(PropertyKey.MASTER_MOUNT_TABLE_ROOT_OPTION).entrySet().stream().filter(entry -> entry.getValue() != null).collect(Collectors.toMap(Map.Entry::getKey, entry -> String.valueOf(entry.getValue())));
MountPOptions mountOptions = MountContext.mergeFrom(MountPOptions.newBuilder().setShared(shared).setReadOnly(readonly).putAllProperties(rootUfsConf)).getOptions().build();
return new MountInfo(new AlluxioURI(MountTable.ROOT), new AlluxioURI(rootUfsUri), IdUtils.ROOT_MOUNT_ID, mountOptions);
}
}
use of alluxio.underfs.UfsManager in project alluxio by Alluxio.
the class AccessTimeUpdaterTest method before.
@Before
public final void before() throws Exception {
mFileSystemMaster = Mockito.mock(FileSystemMaster.class);
when(mFileSystemMaster.getName()).thenReturn(Constants.FILE_SYSTEM_MASTER_NAME);
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.SECURITY_AUTHORIZATION_PERMISSION_ENABLED, true);
ServerConfiguration.set(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_SUPERGROUP, "test-supergroup");
mInodeTree.initializeRoot(TEST_OWNER, TEST_GROUP, TEST_MODE, NoopJournalContext.INSTANCE);
mScheduler = new ControllableScheduler();
}
use of alluxio.underfs.UfsManager in project alluxio by Alluxio.
the class InodeTreeTest method before.
/**
* Sets up all dependencies before a test runs.
*/
@Before
public void before() throws Exception {
mRegistry = new MasterRegistry();
CoreMasterContext context = MasterTestUtils.testMasterContext();
mMetricsMaster = new MetricsMasterFactory().create(mRegistry, context);
mRegistry.add(MetricsMaster.class, mMetricsMaster);
BlockMaster blockMaster = new BlockMasterFactory().create(mRegistry, context);
InodeDirectoryIdGenerator directoryIdGenerator = new InodeDirectoryIdGenerator(blockMaster);
UfsManager ufsManager = mock(UfsManager.class);
MountTable mountTable = new MountTable(ufsManager, mock(MountInfo.class));
InodeLockManager lockManager = new InodeLockManager();
mInodeStore = context.getInodeStoreFactory().apply(lockManager);
mTree = new InodeTree(mInodeStore, blockMaster, directoryIdGenerator, mountTable, lockManager);
mRegistry.start(true);
mTree.initializeRoot(TEST_OWNER, TEST_GROUP, TEST_DIR_MODE, NoopJournalContext.INSTANCE);
}
use of alluxio.underfs.UfsManager 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);
}
use of alluxio.underfs.UfsManager in project alluxio by Alluxio.
the class PlanCoordinatorTest method before.
@Before
public void before() throws Exception {
mCommandManager = new CommandManager();
// Create mock JobServerContext
FileSystem fs = mock(FileSystem.class);
FileSystemContext fsCtx = PowerMockito.mock(FileSystemContext.class);
UfsManager ufsManager = Mockito.mock(UfsManager.class);
mJobServerContext = new JobServerContext(fs, fsCtx, ufsManager);
// Create mock job info.
mJobconfig = Mockito.mock(JobConfig.class, Mockito.withSettings().serializable());
Mockito.when(mJobconfig.getName()).thenReturn("mock");
mJobId = 1;
// Create mock job definition.
@SuppressWarnings("unchecked") PlanDefinition<JobConfig, Serializable, Serializable> mockPlanDefinition = Mockito.mock(PlanDefinition.class);
PlanDefinitionRegistry singleton = PowerMockito.mock(PlanDefinitionRegistry.class);
Whitebox.setInternalState(PlanDefinitionRegistry.class, "INSTANCE", singleton);
Mockito.when(singleton.getJobDefinition(mJobconfig)).thenReturn(mockPlanDefinition);
mPlanDefinition = mockPlanDefinition;
// Create test worker.
mWorkerInfo = new WorkerInfo();
mWorkerInfo.setId(0);
mWorkerInfoList = Lists.newArrayList(mWorkerInfo);
}
Aggregations