use of org.dcache.acl.enums.AccessMask in project dcache by dCache.
the class DCacheAwareJdbcFs method getFileLocality.
/**
* Callout to get pool monitor and check for live (network) status of a file instead of simply
* its status as recorded in the Chimera database.
*/
private String getFileLocality(PnfsId pnfsId) throws ChimeraFsException {
FileLocality locality = FileLocality.UNAVAILABLE;
try {
Set<FileAttribute> requestedAttributes = EnumSet.of(FileAttribute.TYPE, FileAttribute.SIZE, FileAttribute.STORAGEINFO, FileAttribute.LOCATIONS);
Set<AccessMask> accessMask = EnumSet.of(AccessMask.READ_DATA);
FileAttributes attributes = pnfsHandler.getFileAttributes(pnfsId, requestedAttributes, accessMask, false);
/*
* TODO improve code to pass in the actual InetAddress of the
* client so that link net masks do not interfere; note that SRM uses
* "localhost", so it is not a deviation from existing behavior.
*/
locality = poolMonitor.getFileLocality(attributes, "localhost");
} catch (CacheException t) {
throw new ChimeraFsException("getFileLocality", t);
}
return locality.toString();
}
use of org.dcache.acl.enums.AccessMask in project dcache by dCache.
the class Transfer method readNameSpaceEntryAsync.
private ListenableFuture<Void> readNameSpaceEntryAsync(boolean allowWrite, long timeout) {
Set<FileAttribute> attr = EnumSet.of(PNFSID, TYPE, STORAGEINFO, SIZE);
attr.addAll(_additionalAttributes);
attr.addAll(PoolMgrSelectReadPoolMsg.getRequiredAttributes());
Set<AccessMask> mask;
if (allowWrite) {
mask = EnumSet.of(AccessMask.READ_DATA, AccessMask.WRITE_DATA);
} else {
mask = EnumSet.of(AccessMask.READ_DATA);
}
PnfsId pnfsId = getPnfsId();
PnfsGetFileAttributes request;
if (pnfsId != null) {
request = new PnfsGetFileAttributes(pnfsId, attr);
if (_path != null) {
// Needed for restriction check.
request.setPnfsPath(_path.toString());
}
} else {
request = new PnfsGetFileAttributes(_path.toString(), attr);
}
request.setAccessMask(mask);
request.setUpdateAtime(true);
ListenableFuture<PnfsGetFileAttributes> reply = _pnfs.requestAsync(request, timeout);
setStatusUntil("PnfsManager: Fetching storage info", reply);
return CellStub.transformAsync(reply, msg -> {
FileAttributes attributes = msg.getFileAttributes();
/* We can only transfer regular files.
*/
FileType type = attributes.getFileType();
if (type == FileType.DIR || type == FileType.SPECIAL) {
throw new NotFileCacheException("Not a regular file");
}
/* I/O mode must match completeness of the file.
*/
if (!attributes.getStorageInfo().isCreatedOnly()) {
setWrite(false);
} else if (allowWrite) {
setWrite(true);
} else {
throw new FileIsNewCacheException();
}
setFileAttributes(attributes);
return immediateFuture(null);
});
}
use of org.dcache.acl.enums.AccessMask 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);
}
}
Aggregations