Search in sources :

Example 51 with UnderFileSystem

use of alluxio.underfs.UnderFileSystem in project alluxio by Alluxio.

the class DefaultFileSystemMaster method checkUfsMode.

/**
 * Check if the specified operation type is allowed to the ufs.
 *
 * @param alluxioPath the Alluxio path
 * @param opType the operation type
 */
private void checkUfsMode(AlluxioURI alluxioPath, OperationType opType) throws AccessControlException, InvalidPathException {
    MountTable.Resolution resolution = mMountTable.resolve(alluxioPath);
    try (CloseableResource<UnderFileSystem> ufsResource = resolution.acquireUfsResource()) {
        UnderFileSystem ufs = ufsResource.get();
        UfsMode ufsMode = ufs.getOperationMode(mUfsManager.getPhysicalUfsState(ufs.getPhysicalStores()));
        switch(ufsMode) {
            case NO_ACCESS:
                throw new AccessControlException(ExceptionMessage.UFS_OP_NOT_ALLOWED.getMessage(opType, resolution.getUri(), UfsMode.NO_ACCESS));
            case READ_ONLY:
                if (opType == OperationType.WRITE) {
                    throw new AccessControlException(ExceptionMessage.UFS_OP_NOT_ALLOWED.getMessage(opType, resolution.getUri(), UfsMode.READ_ONLY));
                }
                break;
            default:
                // All operations are allowed
                break;
        }
    }
}
Also used : AccessControlException(alluxio.exception.AccessControlException) MountTable(alluxio.master.file.meta.MountTable) UnderFileSystem(alluxio.underfs.UnderFileSystem) UfsMode(alluxio.underfs.UfsMode)

Example 52 with UnderFileSystem

use of alluxio.underfs.UnderFileSystem 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);
    }
}
Also used : SystemClock(alluxio.clock.SystemClock) OK(alluxio.master.file.InodeSyncStream.SyncStatus.OK) Server(alluxio.Server) PropertyKey(alluxio.conf.PropertyKey) StringUtils(org.apache.commons.lang3.StringUtils) CloseableResource(alluxio.resource.CloseableResource) Map(java.util.Map) LockedInodePathList(alluxio.master.file.meta.LockedInodePathList) WorkerHeartbeatContext(alluxio.master.file.contexts.WorkerHeartbeatContext) InodeDirectory(alluxio.master.file.meta.InodeDirectory) ClientContext(alluxio.ClientContext) ReadOnlyInodeStore(alluxio.master.metastore.ReadOnlyInodeStore) UfsSyncPathCache(alluxio.master.file.meta.UfsSyncPathCache) ConnectionFailedException(alluxio.exception.ConnectionFailedException) ProtobufUtils(alluxio.master.ProtobufUtils) UpdateInodeFileEntry(alluxio.proto.journal.File.UpdateInodeFileEntry) Stream(java.util.stream.Stream) InodeTree(alluxio.master.file.meta.InodeTree) OperationContext(alluxio.master.file.contexts.OperationContext) SetAclAction(alluxio.grpc.SetAclAction) GetStatusPOptions(alluxio.grpc.GetStatusPOptions) InternalOperationContext(alluxio.master.file.contexts.InternalOperationContext) InodeFile(alluxio.master.file.meta.InodeFile) PersistConfig(alluxio.job.plan.persist.PersistConfig) AuthType(alluxio.security.authentication.AuthType) Supplier(java.util.function.Supplier) UnderFileSystemUtils(alluxio.util.UnderFileSystemUtils) LockedInodePath(alluxio.master.file.meta.LockedInodePath) GrpcUtils(alluxio.grpc.GrpcUtils) MountInfo(alluxio.master.file.meta.options.MountInfo) AlluxioURI(alluxio.AlluxioURI) MountPOptions(alluxio.grpc.MountPOptions) MetricsSystem(alluxio.metrics.MetricsSystem) UpdateInodeEntry(alluxio.proto.journal.File.UpdateInodeEntry) RetryPolicy(alluxio.retry.RetryPolicy) PersistFile(alluxio.wire.PersistFile) IdUtils(alluxio.util.IdUtils) PersistenceState(alluxio.master.file.meta.PersistenceState) IOException(java.io.IOException) UfsAbsentPathCache(alluxio.master.file.meta.UfsAbsentPathCache) TreeMap(java.util.TreeMap) UfsStatus(alluxio.underfs.UfsStatus) UfsFileStatus(alluxio.underfs.UfsFileStatus) Preconditions(com.google.common.base.Preconditions) FreeContext(alluxio.master.file.contexts.FreeContext) AclEntry(alluxio.security.authorization.AclEntry) Reconfigurable(alluxio.conf.Reconfigurable) MountTable(alluxio.master.file.meta.MountTable) CommonUtils(alluxio.util.CommonUtils) InodeLockManager(alluxio.master.file.meta.InodeLockManager) InodePathPair(alluxio.master.file.meta.InodePathPair) FailedPreconditionException(alluxio.exception.status.FailedPreconditionException) Fingerprint(alluxio.underfs.Fingerprint) AclEntryType(alluxio.security.authorization.AclEntryType) DeleteContext(alluxio.master.file.contexts.DeleteContext) LoadMetadataContext(alluxio.master.file.contexts.LoadMetadataContext) RenameEntry(alluxio.proto.journal.File.RenameEntry) HeartbeatThread(alluxio.heartbeat.HeartbeatThread) InvalidPathException(alluxio.exception.InvalidPathException) ListStatusContext(alluxio.master.file.contexts.ListStatusContext) MetricKey(alluxio.metrics.MetricKey) SyncPointInfo(alluxio.wire.SyncPointInfo) FileSystemMasterCommonPOptions(alluxio.grpc.FileSystemMasterCommonPOptions) Journaled(alluxio.master.journal.Journaled) ImmutableSet(com.google.common.collect.ImmutableSet) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) CheckpointName(alluxio.master.journal.checkpoint.CheckpointName) Collectors(java.util.stream.Collectors) MkdirsOptions(alluxio.underfs.options.MkdirsOptions) InodeStore(alluxio.master.metastore.InodeStore) SecurityUtils(alluxio.util.SecurityUtils) CoreMasterContext(alluxio.master.CoreMasterContext) CommandType(alluxio.wire.CommandType) SetAttributeContext(alluxio.master.file.contexts.SetAttributeContext) FileAlreadyCompletedException(alluxio.exception.FileAlreadyCompletedException) Function(java.util.function.Function) Stack(java.util.Stack) MetricInfo(alluxio.metrics.MetricInfo) ExistsContext(alluxio.master.file.contexts.ExistsContext) HashSet(java.util.HashSet) Constants(alluxio.Constants) FileSystemMasterView(alluxio.master.file.meta.FileSystemMasterView) NOT_NEEDED(alluxio.master.file.InodeSyncStream.SyncStatus.NOT_NEEDED) ExecutorService(java.util.concurrent.ExecutorService) AuthenticatedClientUser(alluxio.security.authentication.AuthenticatedClientUser) SetAclEntry(alluxio.proto.journal.File.SetAclEntry) Logger(org.slf4j.Logger) Pair(alluxio.collections.Pair) AsyncUserAccessAuditLogWriter(alluxio.master.audit.AsyncUserAccessAuditLogWriter) NotFoundException(alluxio.exception.status.NotFoundException) LockResource(alluxio.resource.LockResource) UnexpectedAlluxioException(alluxio.exception.UnexpectedAlluxioException) CallTracker(alluxio.master.file.contexts.CallTracker) UfsBlockLocationCache(alluxio.master.file.meta.UfsBlockLocationCache) CreateDirectoryContext(alluxio.master.file.contexts.CreateDirectoryContext) CreateFileContext(alluxio.master.file.contexts.CreateFileContext) Arrays(java.util.Arrays) BlockInfo(alluxio.wire.BlockInfo) PersistCommandOptions(alluxio.wire.PersistCommandOptions) GrpcService(alluxio.grpc.GrpcService) TimeSeries(alluxio.metrics.TimeSeries) WorkerInfo(alluxio.wire.WorkerInfo) DelegatingJournaled(alluxio.master.journal.DelegatingJournaled) PreconditionMessage(alluxio.exception.PreconditionMessage) AuditContext(alluxio.master.audit.AuditContext) DescendantType(alluxio.file.options.DescendantType) ActiveSyncManager(alluxio.master.file.activesync.ActiveSyncManager) Set(java.util.Set) AlluxioException(alluxio.exception.AlluxioException) GetStatusContext(alluxio.master.file.contexts.GetStatusContext) UnderFileSystem(alluxio.underfs.UnderFileSystem) JobInfo(alluxio.job.wire.JobInfo) ServiceType(alluxio.grpc.ServiceType) Iterables(com.google.common.collect.Iterables) CountingRetry(alluxio.retry.CountingRetry) UnderFileSystemConfiguration(alluxio.underfs.UnderFileSystemConfiguration) Callable(java.util.concurrent.Callable) InodeDirectoryView(alluxio.master.file.meta.InodeDirectoryView) Mode(alluxio.security.authorization.Mode) Metric(alluxio.metrics.Metric) ArrayList(java.util.ArrayList) ReconfigurableRegistry(alluxio.conf.ReconfigurableRegistry) BlockInfoException(alluxio.exception.BlockInfoException) InodeDirectoryIdGenerator(alluxio.master.file.meta.InodeDirectoryIdGenerator) Builder(alluxio.proto.journal.File.UpdateInodeFileEntry.Builder) Nullable(javax.annotation.Nullable) LoadDescendantPType(alluxio.grpc.LoadDescendantPType) MountContext(alluxio.master.file.contexts.MountContext) MetricRegistry(com.codahale.metrics.MetricRegistry) FileAlreadyExistsException(alluxio.exception.FileAlreadyExistsException) RenameContext(alluxio.master.file.contexts.RenameContext) FileSystemCommandOptions(alluxio.wire.FileSystemCommandOptions) JobMasterClientPool(alluxio.client.job.JobMasterClientPool) FileSystemCommand(alluxio.wire.FileSystemCommand) ExecutorServiceFactory(alluxio.util.executor.ExecutorServiceFactory) UfsInfo(alluxio.wire.UfsInfo) JournaledGroup(alluxio.master.journal.JournaledGroup) ExecutorServiceFactories(alluxio.util.executor.ExecutorServiceFactories) NotThreadSafe(javax.annotation.concurrent.NotThreadSafe) ServerInterceptors(io.grpc.ServerInterceptors) MasterUfsManager(alluxio.underfs.MasterUfsManager) ScheduleAsyncPersistenceContext(alluxio.master.file.contexts.ScheduleAsyncPersistenceContext) LoggerFactory(org.slf4j.LoggerFactory) FileBlockInfo(alluxio.wire.FileBlockInfo) NewBlockEntry(alluxio.proto.journal.File.NewBlockEntry) LogUtils(alluxio.util.LogUtils) ResourceExhaustedException(alluxio.exception.status.ResourceExhaustedException) Counter(com.codahale.metrics.Counter) JobMasterClient(alluxio.client.job.JobMasterClient) CheckConsistencyContext(alluxio.master.file.contexts.CheckConsistencyContext) InvalidArgumentException(alluxio.exception.status.InvalidArgumentException) LockPattern(alluxio.master.file.meta.InodeTree.LockPattern) TtlAction(alluxio.grpc.TtlAction) ServerConfiguration(alluxio.conf.ServerConfiguration) ImmutableMap(com.google.common.collect.ImmutableMap) CompleteFileContext(alluxio.master.file.contexts.CompleteFileContext) TimeSeriesStore(alluxio.master.metrics.TimeSeriesStore) PermissionDeniedException(alluxio.exception.status.PermissionDeniedException) LoadMetadataPOptions(alluxio.grpc.LoadMetadataPOptions) Streams(com.google.common.collect.Streams) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) Sets(com.google.common.collect.Sets) FileNotFoundException(java.io.FileNotFoundException) DelegatingReadOnlyInodeStore(alluxio.master.metastore.DelegatingReadOnlyInodeStore) AccessControlException(alluxio.exception.AccessControlException) File(alluxio.proto.journal.File) List(java.util.List) InvalidFileSizeException(alluxio.exception.InvalidFileSizeException) FileDoesNotExistException(alluxio.exception.FileDoesNotExistException) LoadMetadataPType(alluxio.grpc.LoadMetadataPType) ModeUtils(alluxio.util.ModeUtils) Gauge(com.codahale.metrics.Gauge) UFS_OP_SAVED_PREFIX(alluxio.metrics.MetricInfo.UFS_OP_SAVED_PREFIX) UfsManager(alluxio.underfs.UfsManager) JournalContext(alluxio.master.journal.JournalContext) SortedMap(java.util.SortedMap) UnavailableException(alluxio.exception.status.UnavailableException) MountPointInfo(alluxio.wire.MountPointInfo) JobMasterClientContext(alluxio.worker.job.JobMasterClientContext) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) HashMap(java.util.HashMap) SetAttributePOptions(alluxio.grpc.SetAttributePOptions) BlockId(alluxio.master.block.BlockId) BlockMaster(alluxio.master.block.BlockMaster) CheckAccessContext(alluxio.master.file.contexts.CheckAccessContext) JournalEntry(alluxio.proto.journal.Journal.JournalEntry) DeletePOptions(alluxio.grpc.DeletePOptions) PathUtils(alluxio.util.io.PathUtils) DirectoryNotEmptyException(alluxio.exception.DirectoryNotEmptyException) ClientIpAddressInjector(alluxio.security.authentication.ClientIpAddressInjector) PrefixList(alluxio.collections.PrefixList) SetAclContext(alluxio.master.file.contexts.SetAclContext) CoreMaster(alluxio.master.CoreMaster) HeartbeatContext(alluxio.heartbeat.HeartbeatContext) Iterator(java.util.Iterator) ExceptionMessage(alluxio.exception.ExceptionMessage) ThreadFactoryUtils(alluxio.util.ThreadFactoryUtils) ProtoUtils(alluxio.util.proto.ProtoUtils) TimeUnit(java.util.concurrent.TimeUnit) BlockLocation(alluxio.wire.BlockLocation) FAILED(alluxio.master.file.InodeSyncStream.SyncStatus.FAILED) LockingScheme(alluxio.master.file.meta.LockingScheme) FileInfo(alluxio.wire.FileInfo) VisibleForTesting(com.google.common.annotations.VisibleForTesting) UfsMode(alluxio.underfs.UfsMode) Collections(java.util.Collections) Inode(alluxio.master.file.meta.Inode) MountPOptions(alluxio.grpc.MountPOptions) UnderFileSystem(alluxio.underfs.UnderFileSystem) MountInfo(alluxio.master.file.meta.options.MountInfo) Map(java.util.Map) TreeMap(java.util.TreeMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ImmutableMap(com.google.common.collect.ImmutableMap) SortedMap(java.util.SortedMap) HashMap(java.util.HashMap) AlluxioURI(alluxio.AlluxioURI)

Example 53 with UnderFileSystem

use of alluxio.underfs.UnderFileSystem in project alluxio by Alluxio.

the class DefaultFileSystemMaster method completeFileInternal.

/**
 * Completes a file. After a file is completed, it cannot be written to.
 *
 * @param rpcContext the rpc context
 * @param inodePath the {@link LockedInodePath} to complete
 * @param context the method context
 */
void completeFileInternal(RpcContext rpcContext, LockedInodePath inodePath, CompleteFileContext context) throws InvalidPathException, FileDoesNotExistException, BlockInfoException, FileAlreadyCompletedException, InvalidFileSizeException, UnavailableException {
    Inode inode = inodePath.getInode();
    if (!inode.isFile()) {
        throw new FileDoesNotExistException(ExceptionMessage.PATH_MUST_BE_FILE.getMessage(inodePath.getUri()));
    }
    InodeFile fileInode = inode.asFile();
    List<Long> blockIdList = fileInode.getBlockIds();
    List<BlockInfo> blockInfoList = mBlockMaster.getBlockInfoList(blockIdList);
    if (!fileInode.isPersisted() && blockInfoList.size() != blockIdList.size()) {
        throw new BlockInfoException("Cannot complete a file without all the blocks committed");
    }
    // Iterate over all file blocks committed to Alluxio, computing the length and verify that all
    // the blocks (except the last one) is the same size as the file block size.
    long inAlluxioLength = 0;
    long fileBlockSize = fileInode.getBlockSizeBytes();
    for (int i = 0; i < blockInfoList.size(); i++) {
        BlockInfo blockInfo = blockInfoList.get(i);
        inAlluxioLength += blockInfo.getLength();
        if (i < blockInfoList.size() - 1 && blockInfo.getLength() != fileBlockSize) {
            throw new BlockInfoException("Block index " + i + " has a block size smaller than the file block size (" + fileInode.getBlockSizeBytes() + ")");
        }
    }
    // If the file is persisted, its length is determined by UFS. Otherwise, its length is
    // determined by its size in Alluxio.
    long length = fileInode.isPersisted() ? context.getOptions().getUfsLength() : inAlluxioLength;
    String ufsFingerprint = Constants.INVALID_UFS_FINGERPRINT;
    if (fileInode.isPersisted()) {
        UfsStatus ufsStatus = context.getUfsStatus();
        // Retrieve the UFS fingerprint for this file.
        MountTable.Resolution resolution = mMountTable.resolve(inodePath.getUri());
        AlluxioURI resolvedUri = resolution.getUri();
        try (CloseableResource<UnderFileSystem> ufsResource = resolution.acquireUfsResource()) {
            UnderFileSystem ufs = ufsResource.get();
            if (ufsStatus == null) {
                ufsFingerprint = ufs.getFingerprint(resolvedUri.toString());
            } else {
                ufsFingerprint = Fingerprint.create(ufs.getUnderFSType(), ufsStatus).serialize();
            }
        }
    }
    completeFileInternal(rpcContext, inodePath, length, context.getOperationTimeMs(), ufsFingerprint);
}
Also used : FileDoesNotExistException(alluxio.exception.FileDoesNotExistException) UfsStatus(alluxio.underfs.UfsStatus) BlockInfoException(alluxio.exception.BlockInfoException) InodeFile(alluxio.master.file.meta.InodeFile) MountTable(alluxio.master.file.meta.MountTable) Fingerprint(alluxio.underfs.Fingerprint) Inode(alluxio.master.file.meta.Inode) BlockInfo(alluxio.wire.BlockInfo) FileBlockInfo(alluxio.wire.FileBlockInfo) UnderFileSystem(alluxio.underfs.UnderFileSystem) AlluxioURI(alluxio.AlluxioURI)

Example 54 with UnderFileSystem

use of alluxio.underfs.UnderFileSystem in project alluxio by Alluxio.

the class InodeSyncStream method loadFileMetadataInternal.

/**
 * Loads metadata for the file identified by the given path from UFS into Alluxio.
 *
 * This method doesn't require any specific type of locking on inodePath. If the path needs to be
 * loaded, we will acquire a write-edge lock.
 *
 * @param rpcContext the rpc context
 * @param inodePath the path for which metadata should be loaded
 * @param resolution the UFS resolution of path
 * @param context the load metadata context
 */
static void loadFileMetadataInternal(RpcContext rpcContext, LockedInodePath inodePath, MountTable.Resolution resolution, LoadMetadataContext context, DefaultFileSystemMaster fsMaster) throws BlockInfoException, FileDoesNotExistException, InvalidPathException, FileAlreadyCompletedException, InvalidFileSizeException, IOException {
    if (inodePath.fullPathExists()) {
        return;
    }
    AlluxioURI ufsUri = resolution.getUri();
    long ufsBlockSizeByte;
    long ufsLength;
    AccessControlList acl = null;
    try (CloseableResource<UnderFileSystem> ufsResource = resolution.acquireUfsResource()) {
        UnderFileSystem ufs = ufsResource.get();
        if (context.getUfsStatus() == null) {
            context.setUfsStatus(ufs.getExistingFileStatus(ufsUri.toString()));
        }
        ufsLength = ((UfsFileStatus) context.getUfsStatus()).getContentLength();
        long blockSize = ((UfsFileStatus) context.getUfsStatus()).getBlockSize();
        ufsBlockSizeByte = blockSize != UfsFileStatus.UNKNOWN_BLOCK_SIZE ? blockSize : ufs.getBlockSizeByte(ufsUri.toString());
        if (fsMaster.isAclEnabled()) {
            Pair<AccessControlList, DefaultAccessControlList> aclPair = ufs.getAclPair(ufsUri.toString());
            if (aclPair != null) {
                acl = aclPair.getFirst();
                // DefaultACL should be null, because it is a file
                if (aclPair.getSecond() != null) {
                    LOG.warn("File {} has default ACL in the UFS", inodePath.getUri());
                }
            }
        }
    }
    // Metadata loaded from UFS has no TTL set.
    CreateFileContext createFileContext = CreateFileContext.defaults();
    createFileContext.getOptions().setBlockSizeBytes(ufsBlockSizeByte);
    createFileContext.getOptions().setRecursive(context.getOptions().getCreateAncestors());
    createFileContext.getOptions().setCommonOptions(FileSystemMasterCommonPOptions.newBuilder().setTtl(context.getOptions().getCommonOptions().getTtl()).setTtlAction(context.getOptions().getCommonOptions().getTtlAction()));
    // set as through since already in UFS
    createFileContext.setWriteType(WriteType.THROUGH);
    createFileContext.setMetadataLoad(true);
    createFileContext.setOwner(context.getUfsStatus().getOwner());
    createFileContext.setGroup(context.getUfsStatus().getGroup());
    createFileContext.setXAttr(context.getUfsStatus().getXAttr());
    short ufsMode = context.getUfsStatus().getMode();
    Mode mode = new Mode(ufsMode);
    Long ufsLastModified = context.getUfsStatus().getLastModifiedTime();
    if (resolution.getShared()) {
        mode.setOtherBits(mode.getOtherBits().or(mode.getOwnerBits()));
    }
    createFileContext.getOptions().setMode(mode.toProto());
    if (acl != null) {
        createFileContext.setAcl(acl.getEntries());
    }
    if (ufsLastModified != null) {
        createFileContext.setOperationTimeMs(ufsLastModified);
    }
    try (LockedInodePath writeLockedPath = inodePath.lockFinalEdgeWrite();
        MergeJournalContext merger = new MergeJournalContext(rpcContext.getJournalContext(), writeLockedPath.getUri(), InodeSyncStream::mergeCreateComplete)) {
        // We do not want to close this wrapRpcContext because it uses elements from another context
        RpcContext wrapRpcContext = new RpcContext(rpcContext.getBlockDeletionContext(), merger, rpcContext.getOperationContext());
        fsMaster.createFileInternal(wrapRpcContext, writeLockedPath, createFileContext);
        CompleteFileContext completeContext = CompleteFileContext.mergeFrom(CompleteFilePOptions.newBuilder().setUfsLength(ufsLength)).setUfsStatus(context.getUfsStatus());
        if (ufsLastModified != null) {
            completeContext.setOperationTimeMs(ufsLastModified);
        }
        fsMaster.completeFileInternal(wrapRpcContext, writeLockedPath, completeContext);
    } catch (FileAlreadyExistsException e) {
        // This may occur if a thread created or loaded the file before we got the write lock.
        // The file already exists, so nothing needs to be loaded.
        LOG.debug("Failed to load file metadata: {}", e.toString());
    }
    // Re-traverse the path to pick up any newly created inodes.
    inodePath.traverse();
}
Also used : AccessControlList(alluxio.security.authorization.AccessControlList) DefaultAccessControlList(alluxio.security.authorization.DefaultAccessControlList) UfsFileStatus(alluxio.underfs.UfsFileStatus) FileAlreadyExistsException(alluxio.exception.FileAlreadyExistsException) MergeJournalContext(alluxio.master.journal.MergeJournalContext) Mode(alluxio.security.authorization.Mode) CompleteFileContext(alluxio.master.file.contexts.CompleteFileContext) CreateFileContext(alluxio.master.file.contexts.CreateFileContext) LockedInodePath(alluxio.master.file.meta.LockedInodePath) DefaultAccessControlList(alluxio.security.authorization.DefaultAccessControlList) UnderFileSystem(alluxio.underfs.UnderFileSystem) AlluxioURI(alluxio.AlluxioURI)

Example 55 with UnderFileSystem

use of alluxio.underfs.UnderFileSystem in project alluxio by Alluxio.

the class ActiveSyncManager method start.

/**
 * Start the polling threads.
 */
public void start() throws IOException {
    mStarted = true;
    // Initialize UFS states
    for (AlluxioURI syncPoint : mSyncPathList) {
        MountTable.Resolution resolution;
        try {
            resolution = mMountTable.resolve(syncPoint);
        } catch (InvalidPathException e) {
            LOG.info("Invalid Path encountered during start up of ActiveSyncManager, " + "path {}, exception {}", syncPoint, e);
            continue;
        }
        try (CloseableResource<UnderFileSystem> ufsResource = resolution.acquireUfsResource()) {
            if (!ufsResource.get().supportsActiveSync()) {
                throw new UnsupportedOperationException("Active Sync is not supported on this UFS type: " + ufsResource.get().getUnderFSType());
            }
            ufsResource.get().startSync(resolution.getUri());
        }
    }
    // therefore forces a sync
    for (Map.Entry<Long, List<AlluxioURI>> entry : mFilterMap.entrySet()) {
        long mountId = entry.getKey();
        long txId = mStartingTxIdMap.getOrDefault(mountId, SyncInfo.INVALID_TXID);
        if (!entry.getValue().isEmpty()) {
            launchPollingThread(mountId, txId);
        }
        try {
            if ((txId == SyncInfo.INVALID_TXID) && ServerConfiguration.getBoolean(PropertyKey.MASTER_UFS_ACTIVE_SYNC_INITIAL_SYNC_ENABLED)) {
                mExecutorService.submit(() -> entry.getValue().parallelStream().forEach(syncPoint -> {
                    MountTable.Resolution resolution;
                    try {
                        resolution = mMountTable.resolve(syncPoint);
                    } catch (InvalidPathException e) {
                        LOG.info("Invalid Path encountered during start up of ActiveSyncManager, " + "path {}, exception {}", syncPoint, e);
                        return;
                    }
                    startInitialFullSync(syncPoint, resolution);
                }));
            }
        } catch (Exception e) {
            LOG.warn("exception encountered during initial sync: {}", e.toString());
        }
    }
}
Also used : CloseableIterator(alluxio.resource.CloseableIterator) RemoveSyncPointEntry(alluxio.proto.journal.File.RemoveSyncPointEntry) LoggerFactory(org.slf4j.LoggerFactory) PropertyKey(alluxio.conf.PropertyKey) FileSystemMaster(alluxio.master.file.FileSystemMaster) HeartbeatThread(alluxio.heartbeat.HeartbeatThread) Future(java.util.concurrent.Future) InvalidPathException(alluxio.exception.InvalidPathException) CloseableResource(alluxio.resource.CloseableResource) SyncPointInfo(alluxio.wire.SyncPointInfo) Map(java.util.Map) Journaled(alluxio.master.journal.Journaled) ServerConfiguration(alluxio.conf.ServerConfiguration) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) CheckpointName(alluxio.master.journal.checkpoint.CheckpointName) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) AddSyncPointEntry(alluxio.proto.journal.File.AddSyncPointEntry) File(alluxio.proto.journal.File) List(java.util.List) UnderFileSystem(alluxio.underfs.UnderFileSystem) RpcContext(alluxio.master.file.RpcContext) Journal(alluxio.proto.journal.Journal) UfsManager(alluxio.underfs.UfsManager) JournalContext(alluxio.master.journal.JournalContext) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ServerUserState(alluxio.security.user.ServerUserState) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) Supplier(java.util.function.Supplier) Iterators(com.google.common.collect.Iterators) ArrayList(java.util.ArrayList) JournalEntry(alluxio.proto.journal.Journal.JournalEntry) HashSet(java.util.HashSet) PathUtils(alluxio.util.io.PathUtils) SyncInfo(alluxio.SyncInfo) MountInfo(alluxio.master.file.meta.options.MountInfo) AlluxioURI(alluxio.AlluxioURI) NoSuchElementException(java.util.NoSuchElementException) ExecutorService(java.util.concurrent.ExecutorService) ProcessUtils(alluxio.ProcessUtils) Logger(org.slf4j.Logger) HeartbeatContext(alluxio.heartbeat.HeartbeatContext) Iterator(java.util.Iterator) ReentrantLock(java.util.concurrent.locks.ReentrantLock) ExceptionMessage(alluxio.exception.ExceptionMessage) IOException(java.io.IOException) ThreadFactoryUtils(alluxio.util.ThreadFactoryUtils) LockResource(alluxio.resource.LockResource) RetryUtils(alluxio.retry.RetryUtils) TimeUnit(java.util.concurrent.TimeUnit) Lock(java.util.concurrent.locks.Lock) MountTable(alluxio.master.file.meta.MountTable) NotThreadSafe(javax.annotation.concurrent.NotThreadSafe) MountTable(alluxio.master.file.meta.MountTable) InvalidPathException(alluxio.exception.InvalidPathException) InvalidPathException(alluxio.exception.InvalidPathException) NoSuchElementException(java.util.NoSuchElementException) IOException(java.io.IOException) List(java.util.List) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) UnderFileSystem(alluxio.underfs.UnderFileSystem) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) AlluxioURI(alluxio.AlluxioURI)

Aggregations

UnderFileSystem (alluxio.underfs.UnderFileSystem)123 AlluxioURI (alluxio.AlluxioURI)59 Test (org.junit.Test)44 IOException (java.io.IOException)37 MountTable (alluxio.master.file.meta.MountTable)24 URIStatus (alluxio.client.file.URIStatus)17 Mode (alluxio.security.authorization.Mode)15 UfsManager (alluxio.underfs.UfsManager)13 UfsStatus (alluxio.underfs.UfsStatus)13 InvalidPathException (alluxio.exception.InvalidPathException)12 Inode (alluxio.master.file.meta.Inode)12 OutputStream (java.io.OutputStream)12 ArrayList (java.util.ArrayList)12 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)11 FileAlreadyExistsException (alluxio.exception.FileAlreadyExistsException)9 AccessControlException (alluxio.exception.AccessControlException)8 BlockInfoException (alluxio.exception.BlockInfoException)7 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)7 InodeDirectory (alluxio.master.file.meta.InodeDirectory)7 InodeFile (alluxio.master.file.meta.InodeFile)7