Search in sources :

Example 1 with PnfsHandler

use of diskCacheV111.util.PnfsHandler in project dcache by dCache.

the class ALRPStorageUnitQoSProvider method pnfsHandler.

private PnfsHandler pnfsHandler() {
    PnfsHandler pnfsHandler = new PnfsHandler(pnfsManager);
    pnfsHandler.setSubject(Subjects.ROOT);
    pnfsHandler.setRestriction(Restrictions.none());
    return pnfsHandler;
}
Also used : PnfsHandler(diskCacheV111.util.PnfsHandler)

Example 2 with PnfsHandler

use of diskCacheV111.util.PnfsHandler in project dcache by dCache.

the class XrootdDoor method deleteFile.

/**
 * Delete the file denoted by path from the namespace
 *
 * @param path The path of the file that is going to be deleted
 * @throws CacheException                 Deletion of the file failed
 * @throws PermissionDeniedCacheException Caller does not have permission to delete the file
 */
public void deleteFile(FsPath path, Subject subject, Restriction restriction) throws PermissionDeniedCacheException, CacheException {
    PnfsHandler pnfsHandler = new PnfsHandler(_pnfs, subject, restriction);
    if (!isWriteAllowed(path)) {
        throw new PermissionDeniedCacheException("Write permission denied");
    }
    Set<FileType> allowedSet = EnumSet.of(FileType.REGULAR);
    PnfsId pnfsId = pnfsHandler.deletePnfsEntry(path.toString(), allowedSet);
    sendRemoveInfoToBilling(pnfsId, path, subject);
}
Also used : PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) FileType(org.dcache.namespace.FileType) PnfsId(diskCacheV111.util.PnfsId) PnfsHandler(diskCacheV111.util.PnfsHandler)

Example 3 with PnfsHandler

use of diskCacheV111.util.PnfsHandler in project dcache by dCache.

the class XrootdDoor method deleteDirectory.

/**
 * Delete the directory denoted by path from the namespace
 *
 * @param path The path of the directory that is going to be deleted
 * @throws CacheException
 */
public void deleteDirectory(FsPath path, Subject subject, Restriction restriction) throws CacheException {
    PnfsHandler pnfsHandler = new PnfsHandler(_pnfs, subject, restriction);
    if (!isWriteAllowed(path)) {
        throw new PermissionDeniedCacheException("Write permission denied");
    }
    Set<FileType> allowedSet = EnumSet.of(FileType.DIR);
    pnfsHandler.deletePnfsEntry(path.toString(), allowedSet);
}
Also used : PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) FileType(org.dcache.namespace.FileType) PnfsHandler(diskCacheV111.util.PnfsHandler)

Example 4 with PnfsHandler

use of diskCacheV111.util.PnfsHandler in project dcache by dCache.

the class XrootdDoor method listPath.

/**
 * List the contents of a path, usually a directory. In order to make fragmented responses, as
 * supported by the xroot protocol, possible and not block the processing thread in the door,
 * this will register the passed callback along with the UUID of the message that is sent to
 * PNFS-manager.
 * <p>
 * Once PNFS-manager replies to the message, that callback is retrieved and the response is
 * processed by the callback.
 *
 * @param path        The path that is listed
 * @param restriction The Restriction in effect
 * @param subject     Representation of user that request listing
 * @param callback    The callback that will process the response
 */
public void listPath(FsPath path, Subject subject, Restriction restriction, MessageCallback<PnfsListDirectoryMessage> callback, EnumSet<FileAttribute> attributes) {
    PnfsHandler pnfsHandler = new PnfsHandler(_pnfs, subject, restriction);
    PnfsListDirectoryMessage msg = new PnfsListDirectoryMessage(path.toString(), null, Range.<Integer>all(), attributes);
    UUID uuid = msg.getUUID();
    try {
        DirlistRequestHandler requestHandler = new DirlistRequestHandler(uuid, pnfsHandler.getPnfsTimeout(), callback);
        _requestHandlers.put(uuid, requestHandler);
        pnfsHandler.send(msg);
        requestHandler.resetTimeout();
    } catch (RejectedExecutionException ree) {
        _requestHandlers.remove(uuid);
        callback.failure(CacheException.UNEXPECTED_SYSTEM_EXCEPTION, ree.getMessage());
    }
}
Also used : PnfsListDirectoryMessage(org.dcache.vehicles.PnfsListDirectoryMessage) PnfsHandler(diskCacheV111.util.PnfsHandler) UUID(java.util.UUID) RejectedExecutionException(java.util.concurrent.RejectedExecutionException)

Example 5 with PnfsHandler

use of diskCacheV111.util.PnfsHandler in project dcache by dCache.

the class XrootdDoor method getMultipleFileStatuses.

public int[] getMultipleFileStatuses(FsPath[] allPaths, Subject subject, Restriction restriction) throws CacheException {
    PnfsHandler pnfsHandler = new PnfsHandler(_pnfs, subject, restriction);
    int[] flags = new int[allPaths.length];
    // TODO: Use SpreadAndWait
    for (int i = 0; i < allPaths.length; i++) {
        try {
            Set<FileAttribute> requestedAttributes = EnumSet.of(TYPE);
            requestedAttributes.addAll(_pdp.getRequiredAttributes());
            FileAttributes attributes = pnfsHandler.getFileAttributes(allPaths[i].toString(), requestedAttributes);
            flags[i] = getFileStatusFlags(subject, restriction, allPaths[i], attributes);
        } catch (CacheException e) {
            if (e.getRc() != CacheException.FILE_NOT_FOUND) {
                throw e;
            }
            flags[i] = kXR_other;
        }
    }
    return flags;
}
Also used : FileExistsCacheException(diskCacheV111.util.FileExistsCacheException) CacheException(diskCacheV111.util.CacheException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) PnfsHandler(diskCacheV111.util.PnfsHandler) FileAttributes(org.dcache.vehicles.FileAttributes) FileAttribute(org.dcache.namespace.FileAttribute)

Aggregations

PnfsHandler (diskCacheV111.util.PnfsHandler)45 CacheException (diskCacheV111.util.CacheException)19 PermissionDeniedCacheException (diskCacheV111.util.PermissionDeniedCacheException)17 FileAttributes (org.dcache.vehicles.FileAttributes)15 FileNotFoundCacheException (diskCacheV111.util.FileNotFoundCacheException)13 FsPath (diskCacheV111.util.FsPath)12 FileAttribute (org.dcache.namespace.FileAttribute)12 TimeoutCacheException (diskCacheV111.util.TimeoutCacheException)11 FileExistsCacheException (diskCacheV111.util.FileExistsCacheException)9 NotDirCacheException (diskCacheV111.util.NotDirCacheException)9 FileCorruptedCacheException (diskCacheV111.util.FileCorruptedCacheException)8 FileIsNewCacheException (diskCacheV111.util.FileIsNewCacheException)7 NoRouteToCellException (dmg.cells.nucleus.NoRouteToCellException)7 SRMAuthorizationException (org.dcache.srm.SRMAuthorizationException)7 SRMException (org.dcache.srm.SRMException)7 SRMInternalErrorException (org.dcache.srm.SRMInternalErrorException)7 SRMInvalidPathException (org.dcache.srm.SRMInvalidPathException)7 PnfsId (diskCacheV111.util.PnfsId)5 PnfsCreateEntryMessage (diskCacheV111.vehicles.PnfsCreateEntryMessage)4 ApiOperation (io.swagger.annotations.ApiOperation)4