Search in sources :

Example 1 with AddMountPointEntry

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);
}
Also used : AddMountPointEntry(alluxio.proto.journal.File.AddMountPointEntry) StringPairEntry(alluxio.proto.journal.File.StringPairEntry) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) InvalidPathException(alluxio.exception.InvalidPathException)

Example 2 with AddMountPointEntry

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);
    }
}
Also used : AddMountPointEntry(alluxio.proto.journal.File.AddMountPointEntry) ArrayList(java.util.ArrayList) Journal(alluxio.proto.journal.Journal) MountInfo(alluxio.master.file.meta.options.MountInfo) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

AddMountPointEntry (alluxio.proto.journal.File.AddMountPointEntry)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 InvalidPathException (alluxio.exception.InvalidPathException)1 MountInfo (alluxio.master.file.meta.options.MountInfo)1 StringPairEntry (alluxio.proto.journal.File.StringPairEntry)1 Journal (alluxio.proto.journal.Journal)1