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);
}
}
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)));
}
Aggregations