use of alluxio.grpc.MountPOptions in project alluxio by Alluxio.
the class DefaultFileSystemMaster method getUfsInfo.
@Override
public UfsInfo getUfsInfo(long mountId) {
MountInfo info = mMountTable.getMountInfo(mountId);
if (info == null) {
return new UfsInfo();
}
MountPOptions options = info.getOptions();
return new UfsInfo().setUri(info.getUfsUri()).setMountOptions(MountContext.mergeFrom(MountPOptions.newBuilder().putAllProperties(options.getPropertiesMap()).setReadOnly(options.getReadOnly()).setShared(options.getShared())).getOptions().build());
}
use of alluxio.grpc.MountPOptions 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.grpc.MountPOptions in project alluxio by Alluxio.
the class BaseFileSystem method mount.
@Override
public void mount(AlluxioURI alluxioPath, AlluxioURI ufsPath, final MountPOptions options) throws IOException, AlluxioException {
checkUri(alluxioPath);
rpc(client -> {
MountPOptions mergedOptions = FileSystemOptions.mountDefaults(mFsContext.getPathConf(alluxioPath)).toBuilder().mergeFrom(options).build();
// TODO(calvin): Make this fail on the master side
client.mount(alluxioPath, ufsPath, mergedOptions);
LOG.debug("Mount {} to {}", ufsPath, alluxioPath.getPath());
return null;
});
}
use of alluxio.grpc.MountPOptions in project alluxio by Alluxio.
the class MountTable method add.
/**
* Mounts the given UFS path at the given Alluxio path. The Alluxio path should not be nested
* under an existing mount point.
*
* @param journalContext the journal context
* @param alluxioUri an Alluxio path URI
* @param ufsUri a UFS path URI
* @param mountId the mount id
* @param options the mount options
* @throws FileAlreadyExistsException if the mount point already exists
* @throws InvalidPathException if an invalid path is encountered
*/
public void add(Supplier<JournalContext> journalContext, AlluxioURI alluxioUri, AlluxioURI ufsUri, long mountId, MountPOptions options) throws FileAlreadyExistsException, InvalidPathException {
String alluxioPath = alluxioUri.getPath().isEmpty() ? "/" : alluxioUri.getPath();
LOG.info("Mounting {} at {}", ufsUri, alluxioPath);
try (LockResource r = new LockResource(mWriteLock)) {
if (mState.getMountTable().containsKey(alluxioPath)) {
throw new FileAlreadyExistsException(ExceptionMessage.MOUNT_POINT_ALREADY_EXISTS.getMessage(alluxioPath));
}
// or suffix of any existing mount path.
for (Map.Entry<String, MountInfo> entry : mState.getMountTable().entrySet()) {
AlluxioURI mountedUfsUri = entry.getValue().getUfsUri();
if ((ufsUri.getScheme() == null || ufsUri.getScheme().equals(mountedUfsUri.getScheme())) && (ufsUri.getAuthority().toString().equals(mountedUfsUri.getAuthority().toString()))) {
String ufsPath = ufsUri.getPath().isEmpty() ? "/" : ufsUri.getPath();
String mountedUfsPath = mountedUfsUri.getPath().isEmpty() ? "/" : mountedUfsUri.getPath();
if (PathUtils.hasPrefix(ufsPath, mountedUfsPath)) {
throw new InvalidPathException(ExceptionMessage.MOUNT_POINT_PREFIX_OF_ANOTHER.getMessage(mountedUfsUri.toString(), ufsUri.toString()));
}
if (PathUtils.hasPrefix(mountedUfsPath, ufsPath)) {
throw new InvalidPathException(ExceptionMessage.MOUNT_POINT_PREFIX_OF_ANOTHER.getMessage(ufsUri.toString(), mountedUfsUri.toString()));
}
}
}
Map<String, String> properties = options.getPropertiesMap();
mState.applyAndJournal(journalContext, AddMountPointEntry.newBuilder().addAllProperties(properties.entrySet().stream().map(entry -> StringPairEntry.newBuilder().setKey(entry.getKey()).setValue(entry.getValue()).build()).collect(Collectors.toList())).setAlluxioPath(alluxioPath).setMountId(mountId).setReadOnly(options.getReadOnly()).setShared(options.getShared()).setUfsPath(ufsUri.toString()).build());
}
}
use of alluxio.grpc.MountPOptions in project alluxio by Alluxio.
the class MountContext method mergeFrom.
/**
* Merges and embeds the given {@link MountPOptions} with the corresponding master options.
*
* @param optionsBuilder Builder for proto {@link MountPOptions} to embed
* @return the instance of {@link MountContext} with default values for master
*/
public static MountContext mergeFrom(MountPOptions.Builder optionsBuilder) {
MountPOptions masterOptions = FileSystemOptions.mountDefaults(ServerConfiguration.global());
MountPOptions.Builder mergedOptionsBuilder = masterOptions.toBuilder().mergeFrom(optionsBuilder.build());
return create(mergedOptionsBuilder);
}
Aggregations