use of alluxio.proto.journal.File.AddMountPointEntry in project alluxio by Alluxio.
the class FileSystemMaster method mountAndJournal.
/**
* Mounts a UFS path onto an Alluxio path.
* <p>
* Writes to the journal.
*
* @param inodePath the Alluxio path to mount to
* @param ufsPath the UFS path to mount
* @param options the mount options
* @param journalContext the journal context
* @throws InvalidPathException if an invalid path is encountered
* @throws FileAlreadyExistsException if the path to be mounted to already exists
* @throws FileDoesNotExistException if the parent of the path to be mounted to does not exist
* @throws IOException if an I/O error occurs
* @throws AccessControlException if the permission check fails
*/
private void mountAndJournal(LockedInodePath inodePath, AlluxioURI ufsPath, MountOptions options, JournalContext journalContext) throws InvalidPathException, FileAlreadyExistsException, FileDoesNotExistException, IOException, AccessControlException {
// Check that the Alluxio Path does not exist
if (inodePath.fullPathExists()) {
// TODO(calvin): Add a test to validate this (ALLUXIO-1831)
throw new InvalidPathException(ExceptionMessage.MOUNT_POINT_ALREADY_EXISTS.getMessage(inodePath.getUri()));
}
mountInternal(inodePath, ufsPath, false, /* not replayed */
options);
boolean loadMetadataSucceeded = false;
try {
// This will create the directory at alluxioPath
loadDirectoryMetadataAndJournal(inodePath, LoadMetadataOptions.defaults().setCreateAncestors(false), journalContext);
loadMetadataSucceeded = true;
} finally {
if (!loadMetadataSucceeded) {
unmountInternal(inodePath.getUri());
}
}
// For proto, build a list of String pairs representing the properties map.
Map<String, String> properties = options.getProperties();
List<StringPairEntry> protoProperties = new ArrayList<>(properties.size());
for (Map.Entry<String, String> entry : properties.entrySet()) {
protoProperties.add(StringPairEntry.newBuilder().setKey(entry.getKey()).setValue(entry.getValue()).build());
}
AddMountPointEntry addMountPoint = AddMountPointEntry.newBuilder().setAlluxioPath(inodePath.getUri().toString()).setUfsPath(ufsPath.toString()).setReadOnly(options.isReadOnly()).addAllProperties(protoProperties).setShared(options.isShared()).build();
appendJournalEntry(JournalEntry.newBuilder().setAddMountPoint(addMountPoint).build(), journalContext);
}
use of alluxio.proto.journal.File.AddMountPointEntry 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