use of diskCacheV111.util.PnfsId 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);
}
use of diskCacheV111.util.PnfsId in project dcache by dCache.
the class DcacheResourceFactory method deleteDirectory.
/**
* Deletes a directory.
*/
public void deleteDirectory(PnfsId pnfsid, FsPath path) throws CacheException {
PnfsHandler pnfs = roleAwarePnfsHandler();
pnfs.deletePnfsEntry(pnfsid, path.toString(), EnumSet.of(DIR), EnumSet.noneOf(FileAttribute.class));
}
use of diskCacheV111.util.PnfsId in project dcache by dCache.
the class DefaultInaccessibleFileHandler method handleNoLocationsForFile.
@Override
protected Type handleNoLocationsForFile(FileOperation operation) {
PnfsId pnfsId = operation.getPnfsId();
LOGGER.error(AlarmMarkerFactory.getMarker(PredefinedAlarm.LOST_RESILIENT_FILE, pnfsId.toString()), MISSING_LOCATIONS_MESSAGE, pnfsId);
String error = String.format("%s has no locations.", pnfsId);
CacheException exception = CacheExceptionUtils.getCacheException(CacheException.PANIC, FileTaskCompletionHandler.VERIFY_FAILURE_MESSAGE, pnfsId, Type.VOID, error, null);
completionHandler.taskFailed(pnfsId, exception);
return Type.VOID;
}
use of diskCacheV111.util.PnfsId in project dcache by dCache.
the class FileOperationHandler method handleStaging.
/**
* <p>Called when there are no available replicas, but the file
* can be retrieved from an HSM.</p>
*
* <p>Issues a fire and forget request. Task is considered complete at
* that point.</p>
*
* <p>When staging actually completes on the PoolManager end, the new
* cache location message should be processed by Resilience as a new FileOperation.</p>
*
* <p>Should staging not complete before the pool is once again scanned,
* PoolManager should collapse the repeated staging request.</p>
*/
public void handleStaging(PnfsId pnfsId, ResilientFileTask task) {
try {
FileOperation operation = fileOpMap.getOperation(pnfsId);
FileAttributes attributes = namespace.getRequiredAttributesForStaging(pnfsId);
String poolGroup = poolInfoMap.getGroup(operation.getPoolGroup());
LOGGER.trace("handleStaging {}, pool group {}.", pnfsId, poolGroup);
migrationTaskService.schedule(() -> {
try {
PoolMgrSelectReadPoolMsg msg = new PoolMgrSelectReadPoolMsg(attributes, getProtocolInfo(), null);
msg.setSubject(Subjects.ROOT);
msg.setPoolGroup(poolGroup);
CellMessage cellMessage = new CellMessage(new CellPath(poolManagerAddress), msg);
ACTIVITY_LOGGER.info("Staging {}", pnfsId);
endpoint.sendMessage(cellMessage);
LOGGER.trace("handleStaging, sent select read pool message " + "for {} to poolManager.", pnfsId);
completionHandler.taskCompleted(pnfsId);
} catch (URISyntaxException e) {
completionHandler.taskFailed(pnfsId, CacheExceptionUtils.getCacheException(CacheException.INVALID_ARGS, "could not construct HTTP protocol: %s.", pnfsId, Type.WAIT_FOR_STAGE, e.getMessage(), null));
}
}, 0, TimeUnit.MILLISECONDS);
} catch (CacheException ce) {
completionHandler.taskFailed(pnfsId, ce);
}
}
use of diskCacheV111.util.PnfsId in project dcache by dCache.
the class FileOperationHandler method handleStagingReply.
/**
* <p>If the reply from the Pool Manager indicates that the file has
* been staged to a pool outside the pool group, resend the message with refreshed attributes to
* trigger a p2p by the Pool Manager to a readable resilient pool in the correct group.
* Otherwise, discard the message.</p>
*/
public void handleStagingReply(PoolMgrSelectReadPoolMsg reply) {
PnfsId pnfsId = reply.getPnfsId();
try {
if (reply.getReturnCode() == CacheException.OUT_OF_DATE) {
FileAttributes attributes = namespace.getRequiredAttributesForStaging(pnfsId);
/*
* Check to see if one of the new locations is not resilient.
*/
Collection<String> locations = attributes.getLocations();
List<String> valid = poolInfoMap.getReadableLocations(locations).stream().filter(poolInfoMap::isResilientPool).collect(Collectors.toList());
LOGGER.trace("{}, handleStagingReply, readable resilience " + "locations are now {}.", valid);
if (valid.size() == 0) {
LOGGER.trace("{}, handleStagingReply, " + "PoolManager staged to" + " a non-resilient pool, " + "requesting p2p.", pnfsId);
/*
* Figure out on which pool group this should be.
*
* It's possible that the file was "resilient" when the
* stage request was sent and a subsequently configuration
* change has resulted in the file no longer being
* "resilient". If this happens, the file may have no
* corresponding resilient pool group.
*
* Another possibility is the lack of resilient pool group
* is due to a bug somewhere.
*/
Integer gIndex = null;
for (String loc : locations) {
Integer pIndex = poolInfoMap.getPoolIndex(loc);
gIndex = poolInfoMap.getResilientPoolGroup(pIndex);
if (gIndex != null) {
break;
}
}
if (gIndex == null) {
LOGGER.warn("{}, handleStagingReply, file no longer" + " hosted on resilient pool group", pnfsId);
return;
}
final String poolGroup = poolInfoMap.getGroup(gIndex);
LOGGER.trace("{}, handleStagingReply, resilient pool group " + "for p2p request: {}.", pnfsId, poolGroup);
migrationTaskService.schedule(() -> {
PoolMgrSelectReadPoolMsg msg = new PoolMgrSelectReadPoolMsg(attributes, reply.getProtocolInfo(), reply.getContext(), reply.getAllowedStates());
msg.setSubject(reply.getSubject());
msg.setPoolGroup(poolGroup);
CellMessage cellMessage = new CellMessage(new CellPath(poolManagerAddress), msg);
ACTIVITY_LOGGER.info("Selecting read pool for file {}" + " staged to a non-resilient pool", pnfsId);
endpoint.sendMessage(cellMessage);
LOGGER.trace("handleStagingReply, resent select read pool " + "message for {} to poolManager.", pnfsId);
}, 0, TimeUnit.MILLISECONDS);
return;
}
}
LOGGER.trace("{} handleStagingReply {}, nothing to do.", pnfsId, reply);
} catch (CacheException ce) {
LOGGER.error("handleStagingReply failed: {}.", ce.toString());
}
}
Aggregations