Search in sources :

Example 1 with GetFileSpaceTokensMessage

use of diskCacheV111.services.space.message.GetFileSpaceTokensMessage in project dcache by dCache.

the class Storage method getFileMetaData.

private FileMetaData getFileMetaData(DcacheUser user, boolean checkReadPermissions, FsPath path) throws SRMException {
    PnfsHandler handler = new PnfsHandler(_pnfs, user.getSubject(), user.getRestriction());
    try {
        /* Fetch file attributes.
             */
        Set<FileAttribute> requestedAttributes = EnumSet.of(TYPE, LOCATIONS);
        requestedAttributes.addAll(DcacheFileMetaData.getKnownAttributes());
        requestedAttributes.addAll(PoolMonitorV5.getRequiredAttributesForFileLocality());
        Set<AccessMask> accessMask = checkReadPermissions ? EnumSet.of(AccessMask.READ_DATA) : EnumSet.noneOf(AccessMask.class);
        FileAttributes attributes = handler.getFileAttributes(path.toString(), requestedAttributes, accessMask, false);
        FileMetaData fmd = new DcacheFileMetaData(attributes);
        /* Determine file locality.
             */
        if (attributes.getFileType() != FileType.DIR) {
            FileLocality locality = _poolMonitor.getFileLocality(attributes, config.getSrmHost());
            fmd.locality = locality.toTFileLocality();
            fmd.isCached = locality.isCached();
        }
        /* Determine space tokens.
             */
        if (_isSpaceManagerEnabled) {
            try {
                GetFileSpaceTokensMessage msg = new GetFileSpaceTokensMessage(attributes.getPnfsId());
                msg = _spaceManagerStub.sendAndWait(msg);
                if (msg.getSpaceTokens() != null) {
                    fmd.spaceTokens = new long[msg.getSpaceTokens().length];
                    System.arraycopy(msg.getSpaceTokens(), 0, fmd.spaceTokens, 0, msg.getSpaceTokens().length);
                }
            } catch (NoRouteToCellException e) {
                /* SpaceManager is optional, so we don't classify this
                     * as an error.
                     */
                _log.info(e.getMessage());
            }
        }
        return fmd;
    } catch (TimeoutCacheException e) {
        throw new SRMInternalErrorException(e.getMessage(), e);
    } catch (PermissionDeniedCacheException e) {
        throw new SRMAuthorizationException(e.getMessage(), e);
    } catch (FileNotFoundCacheException e) {
        throw new SRMInvalidPathException(e.getMessage(), e);
    } catch (CacheException e) {
        throw new SRMException("Could not get storage info by path: " + e.getMessage(), e);
    } catch (InterruptedException e) {
        throw new SRMInternalErrorException("Operation interrupted", e);
    }
}
Also used : SRMAuthorizationException(org.dcache.srm.SRMAuthorizationException) FileIsNewCacheException(diskCacheV111.util.FileIsNewCacheException) FileExistsCacheException(diskCacheV111.util.FileExistsCacheException) NotDirCacheException(diskCacheV111.util.NotDirCacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) TimeoutCacheException(diskCacheV111.util.TimeoutCacheException) CacheException(diskCacheV111.util.CacheException) FileCorruptedCacheException(diskCacheV111.util.FileCorruptedCacheException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) SRMInvalidPathException(org.dcache.srm.SRMInvalidPathException) PnfsHandler(diskCacheV111.util.PnfsHandler) AccessMask(org.dcache.acl.enums.AccessMask) SRMInternalErrorException(org.dcache.srm.SRMInternalErrorException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) SRMException(org.dcache.srm.SRMException) GetFileSpaceTokensMessage(diskCacheV111.services.space.message.GetFileSpaceTokensMessage) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) FileAttributes(org.dcache.vehicles.FileAttributes) FileLocality(diskCacheV111.util.FileLocality) FileMetaData(org.dcache.srm.FileMetaData) FileAttribute(org.dcache.namespace.FileAttribute) TimeoutCacheException(diskCacheV111.util.TimeoutCacheException)

Example 2 with GetFileSpaceTokensMessage

use of diskCacheV111.services.space.message.GetFileSpaceTokensMessage in project dcache by dCache.

the class SpaceManagerService method getFileSpaceTokens.

private void getFileSpaceTokens(GetFileSpaceTokensMessage getFileTokens) throws DataAccessException {
    PnfsId pnfsId = getFileTokens.getPnfsId();
    List<File> files = db.get(db.files().wherePnfsIdIs(pnfsId), null);
    getFileTokens.setSpaceToken(Longs.toArray(transform(files, File::getSpaceId)));
}
Also used : PnfsId(diskCacheV111.util.PnfsId)

Aggregations

GetFileSpaceTokensMessage (diskCacheV111.services.space.message.GetFileSpaceTokensMessage)1 CacheException (diskCacheV111.util.CacheException)1 FileCorruptedCacheException (diskCacheV111.util.FileCorruptedCacheException)1 FileExistsCacheException (diskCacheV111.util.FileExistsCacheException)1 FileIsNewCacheException (diskCacheV111.util.FileIsNewCacheException)1 FileLocality (diskCacheV111.util.FileLocality)1 FileNotFoundCacheException (diskCacheV111.util.FileNotFoundCacheException)1 NotDirCacheException (diskCacheV111.util.NotDirCacheException)1 PermissionDeniedCacheException (diskCacheV111.util.PermissionDeniedCacheException)1 PnfsHandler (diskCacheV111.util.PnfsHandler)1 PnfsId (diskCacheV111.util.PnfsId)1 TimeoutCacheException (diskCacheV111.util.TimeoutCacheException)1 NoRouteToCellException (dmg.cells.nucleus.NoRouteToCellException)1 AccessMask (org.dcache.acl.enums.AccessMask)1 FileAttribute (org.dcache.namespace.FileAttribute)1 FileMetaData (org.dcache.srm.FileMetaData)1 SRMAuthorizationException (org.dcache.srm.SRMAuthorizationException)1 SRMException (org.dcache.srm.SRMException)1 SRMInternalErrorException (org.dcache.srm.SRMInternalErrorException)1 SRMInvalidPathException (org.dcache.srm.SRMInvalidPathException)1