use of alluxio.master.file.meta.options.MountInfo 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 alluxioUri an Alluxio path URI
* @param ufsUri a UFS path URI
* @param options the mount options
* @throws FileAlreadyExistsException if the mount point already exists
* @throws InvalidPathException if an invalid path is encountered
*/
public void add(AlluxioURI alluxioUri, AlluxioURI ufsUri, MountOptions options) throws FileAlreadyExistsException, InvalidPathException {
String alluxioPath = alluxioUri.getPath();
LOG.info("Mounting {} at {}", ufsUri, alluxioPath);
try (LockResource r = new LockResource(mWriteLock)) {
if (mMountTable.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 : mMountTable.entrySet()) {
String mountedAlluxioPath = entry.getKey();
AlluxioURI mountedUfsUri = entry.getValue().getUfsUri();
if (!mountedAlluxioPath.equals(ROOT) && PathUtils.hasPrefix(alluxioPath, mountedAlluxioPath)) {
throw new InvalidPathException(ExceptionMessage.MOUNT_POINT_PREFIX_OF_ANOTHER.getMessage(mountedAlluxioPath, alluxioPath));
}
if ((ufsUri.getScheme() == null || ufsUri.getScheme().equals(mountedUfsUri.getScheme())) && (ufsUri.getAuthority() == null || ufsUri.getAuthority().equals(mountedUfsUri.getAuthority()))) {
String ufsPath = ufsUri.getPath();
String mountedUfsPath = 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()));
}
}
}
mMountTable.put(alluxioPath, new MountInfo(ufsUri, options));
}
}
use of alluxio.master.file.meta.options.MountInfo in project alluxio by Alluxio.
the class MountTable method streamToJournalCheckpoint.
@Override
public void streamToJournalCheckpoint(JournalOutputStream outputStream) throws IOException {
for (Map.Entry<String, MountInfo> entry : mMountTable.entrySet()) {
String alluxioPath = entry.getKey();
MountInfo info = entry.getValue();
// do not journal the root mount point
if (alluxioPath.equals(ROOT)) {
continue;
}
Map<String, String> properties = info.getOptions().getProperties();
List<File.StringPairEntry> protoProperties = new ArrayList<>(properties.size());
for (Map.Entry<String, String> property : properties.entrySet()) {
protoProperties.add(File.StringPairEntry.newBuilder().setKey(property.getKey()).setValue(property.getValue()).build());
}
AddMountPointEntry addMountPoint = AddMountPointEntry.newBuilder().setAlluxioPath(alluxioPath).setUfsPath(info.getUfsUri().toString()).setReadOnly(info.getOptions().isReadOnly()).addAllProperties(protoProperties).setShared(info.getOptions().isShared()).build();
Journal.JournalEntry journalEntry = Journal.JournalEntry.newBuilder().setAddMountPoint(addMountPoint).build();
outputStream.writeEntry(journalEntry);
}
}
Aggregations