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 ) ) ; } // Make sure that the ufs path we're trying to mount is not a prefix // 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 ( ) ) ; } }
Mounts the given UFS path at the given Alluxio path . The Alluxio path should not be nested under an existing mount point .