use of alluxio.underfs.MasterUfsManager 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.MasterUfsManager in project alluxio by Alluxio.
the class LazyUfsBlockLocationCacheTest method before.
/**
* Sets up a new {@link AsyncUfsAbsentPathCache} before a test runs.
*/
@Before
public void before() throws Exception {
mLocalUfsPath = Files.createTempDir().getAbsolutePath();
mLocalUfs = UnderFileSystem.Factory.create(mLocalUfsPath, UnderFileSystemConfiguration.defaults(ServerConfiguration.global()));
mMountId = IdUtils.getRandomNonNegativeLong();
mUfsManager = new MasterUfsManager();
MountPOptions options = MountContext.defaults().getOptions().build();
mUfsManager.addMount(mMountId, new AlluxioURI(mLocalUfsPath), UnderFileSystemConfiguration.defaults(ServerConfiguration.global()).setReadOnly(options.getReadOnly()).setShared(options.getShared()).createMountSpecificConf(Collections.<String, String>emptyMap()));
mMountTable = new MountTable(mUfsManager, new MountInfo(new AlluxioURI("/"), new AlluxioURI("/ufs"), 1, MountContext.defaults().getOptions().build()));
mMountTable.add(NoopJournalContext.INSTANCE, new AlluxioURI("/mnt"), new AlluxioURI(mLocalUfsPath), mMountId, options);
mUfsBlockLocationCache = new LazyUfsBlockLocationCache(mMountTable);
}
use of alluxio.underfs.MasterUfsManager in project alluxio by Alluxio.
the class AsyncUfsAbsentPathCacheTest method before.
/**
* Sets up a new {@link AsyncUfsAbsentPathCache} before a test runs.
*/
@Before
public void before() throws Exception {
mLocalUfsPath = mTemp.getRoot().getAbsolutePath();
mUfsManager = new MasterUfsManager();
mMountTable = new MountTable(mUfsManager, new MountInfo(new AlluxioURI("/"), new AlluxioURI("/ufs"), 1, MountContext.defaults().getOptions().build()));
mUfsAbsentPathCache = new AsyncUfsAbsentPathCache(mMountTable, THREADS);
mMountId = IdUtils.getRandomNonNegativeLong();
MountPOptions options = MountContext.defaults().getOptions().build();
mUfsManager.addMount(mMountId, new AlluxioURI(mLocalUfsPath), UnderFileSystemConfiguration.defaults(ConfigurationTestUtils.defaults()).setReadOnly(options.getReadOnly()).setShared(options.getShared()).createMountSpecificConf(Collections.<String, String>emptyMap()));
mMountTable.add(NoopJournalContext.INSTANCE, new AlluxioURI("/mnt"), new AlluxioURI(mLocalUfsPath), mMountId, options);
}
use of alluxio.underfs.MasterUfsManager 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());
}
use of alluxio.underfs.MasterUfsManager in project alluxio by Alluxio.
the class MasterTestUtils method createFileSystemMasterFromJournal.
/**
* Creates a new {@link FileSystemMaster} from journal along with its dependencies, and returns
* the master registry and the journal system.
*
* @param isLeader whether to start as a leader
* @param userState the user state for the server. if null, will use ServerUserState.global()
* @param journalFolder the folder of the master journal
* @return a resource that contains the master registry and the journal system
*/
private static FsMasterResource createFileSystemMasterFromJournal(boolean isLeader, UserState userState, String journalFolder) throws Exception {
String masterJournal = journalFolder;
MasterRegistry registry = new MasterRegistry();
SafeModeManager safeModeManager = new TestSafeModeManager();
long startTimeMs = System.currentTimeMillis();
int port = ServerConfiguration.getInt(PropertyKey.MASTER_RPC_PORT);
String baseDir = ServerConfiguration.getString(PropertyKey.MASTER_METASTORE_DIR);
JournalSystem journalSystem = JournalTestUtils.createJournalSystem(masterJournal);
if (userState == null) {
userState = ServerUserState.global();
}
CoreMasterContext masterContext = CoreMasterContext.newBuilder().setJournalSystem(journalSystem).setSafeModeManager(safeModeManager).setBackupManager(mock(BackupManager.class)).setBlockStoreFactory(MasterUtils.getBlockStoreFactory(baseDir)).setInodeStoreFactory(MasterUtils.getInodeStoreFactory(baseDir)).setStartTimeMs(startTimeMs).setUserState(userState).setPort(port).setUfsManager(new MasterUfsManager()).build();
new MetricsMasterFactory().create(registry, masterContext);
new BlockMasterFactory().create(registry, masterContext);
new FileSystemMasterFactory().create(registry, masterContext);
journalSystem.start();
if (isLeader) {
journalSystem.gainPrimacy();
}
registry.start(isLeader);
return new FsMasterResource(registry, journalSystem);
}
Aggregations