use of diskCacheV111.util.FileNotFoundCacheException in project dcache by dCache.
the class BillingResources method getStores.
@GET
@ApiOperation("Provides a list of tape writes for a specific PNFS-ID.")
@ApiResponses({ @ApiResponse(code = 400, message = "Bad request"), @ApiResponse(code = 403, message = "store records are only available to admin users."), @ApiResponse(code = 404, message = "Not Found"), @ApiResponse(code = 500, message = "Internal Server Error") })
@Produces(MediaType.APPLICATION_JSON)
@Path("stores/{pnfsid}")
public List<HSMTransferRecord> getStores(@ApiParam("The file to list.") @PathParam("pnfsid") PnfsId pnfsid, @ApiParam("Return no tape writes after this datestamp.") @QueryParam("before") String before, @ApiParam("Return no tape writes before this datestamp.") @QueryParam("after") String after, @ApiParam("Maximum number of tape writes to return.") @QueryParam("limit") Integer limit, @ApiParam("Number of tape writes to skip.") @DefaultValue("0") @QueryParam("offset") int offset, @ApiParam("Only select tape writes involving the specified pool.") @QueryParam("pool") String pool, @ApiParam("How to sort responses.") @DefaultValue("date") @QueryParam("sort") String sort) {
if (!RequestUser.canViewFileOperations(unlimitedOperationVisibility)) {
throw new ForbiddenException("Store records are only available to admin users.");
}
try {
limit = limit == null ? Integer.MAX_VALUE : limit;
PagedList<HSMTransferRecord> result = service.getStores(pnfsid, before, after, limit, offset, pool, sort);
response.addIntHeader(TOTAL_COUNT_HEADER, result.total);
return result.contents;
} catch (FileNotFoundCacheException e) {
throw new NotFoundException(e);
} catch (NoRouteToCellException | InterruptedException | CacheException e) {
LOGGER.warn(Exceptions.meaningfulMessage(e));
throw new InternalServerErrorException(e);
} catch (IllegalArgumentException | ParseException e) {
throw new BadRequestException(e.getMessage(), e);
}
}
use of diskCacheV111.util.FileNotFoundCacheException in project dcache by dCache.
the class PnfsManagerV3 method updateFlag.
private void updateFlag(PnfsFlagMessage pnfsMessage) {
PnfsId pnfsId = pnfsMessage.getPnfsId();
PnfsFlagMessage.FlagOperation operation = pnfsMessage.getOperation();
String flagName = pnfsMessage.getFlagName();
String value = pnfsMessage.getValue();
Subject subject = pnfsMessage.getSubject();
LOGGER.info("update flag " + operation + " flag=" + flagName + " value=" + value + " for " + pnfsId);
try {
// Note that dcap clients may bypass restrictions by not
// specifying a path when interacting via mounted namespace.
checkRestriction(pnfsMessage, UPDATE_METADATA);
if (operation == PnfsFlagMessage.FlagOperation.GET) {
pnfsMessage.setValue(updateFlag(subject, pnfsId, operation, flagName, value));
} else {
updateFlag(subject, pnfsId, operation, flagName, value);
}
} catch (FileNotFoundCacheException e) {
pnfsMessage.setFailed(e.getRc(), e.getMessage());
} catch (CacheException e) {
LOGGER.warn("Exception in updateFlag: " + e);
pnfsMessage.setFailed(e.getRc(), e.getMessage());
} catch (RuntimeException e) {
LOGGER.error("Exception in updateFlag", e);
pnfsMessage.setFailed(CacheException.UNEXPECTED_SYSTEM_EXCEPTION, e);
}
}
use of diskCacheV111.util.FileNotFoundCacheException in project dcache by dCache.
the class PnfsManagerV3 method getCacheLocations.
public void getCacheLocations(PnfsGetCacheLocationsMessage pnfsMessage) {
Subject subject = pnfsMessage.getSubject();
try {
checkRestriction(pnfsMessage, READ_METADATA);
PnfsId pnfsId = populatePnfsId(pnfsMessage);
LOGGER.info("get cache locations for {}", pnfsId);
checkMask(pnfsMessage);
pnfsMessage.setCacheLocations(_nameSpaceProvider.getCacheLocation(subject, pnfsId));
pnfsMessage.setSucceeded();
} catch (FileNotFoundCacheException fnf) {
pnfsMessage.setFailed(CacheException.FILE_NOT_FOUND, fnf.getMessage());
} catch (CacheException e) {
LOGGER.warn("Exception in getCacheLocations: {}", e.toString());
pnfsMessage.setFailed(e.getRc(), e.getMessage());
} catch (RuntimeException e) {
LOGGER.error("Exception in getCacheLocations", e);
pnfsMessage.setFailed(CacheException.UNEXPECTED_SYSTEM_EXCEPTION, "Pnfs lookup failed");
}
}
use of diskCacheV111.util.FileNotFoundCacheException in project dcache by dCache.
the class PnfsManagerV3 method setFileAttributes.
public void setFileAttributes(PnfsSetFileAttributes message) {
try {
checkRestriction(message, UPDATE_METADATA);
FileAttributes attr = message.getFileAttributes();
PnfsId pnfsId = populatePnfsId(message);
checkMask(message);
if (attr.isDefined(FileAttribute.LOCATIONS)) {
/*
* Save for post-processing.
*/
message.setLocations(attr.getLocations());
}
/*
* update ctime on atime update
*/
if (attr.isDefined(ACCESS_TIME) && !attr.isDefined(CHANGE_TIME)) {
attr.setChangeTime(System.currentTimeMillis());
}
FileAttributes updated = _nameSpaceProvider.setFileAttributes(message.getSubject(), pnfsId, attr, message.getAcquire());
message.setFileAttributes(updated);
message.setSucceeded();
} catch (FileNotFoundCacheException e) {
message.setFailed(e.getRc(), e);
} catch (CacheException e) {
LOGGER.warn("Error while updating file attributes: " + e.getMessage());
message.setFailed(e.getRc(), e);
} catch (RuntimeException e) {
LOGGER.error("Error while updating file attributes: " + e.getMessage(), e);
message.setFailed(CacheException.UNEXPECTED_SYSTEM_EXCEPTION, e);
}
}
use of diskCacheV111.util.FileNotFoundCacheException in project dcache by dCache.
the class SpaceManagerService method expireSpaceReservations.
private void expireSpaceReservations() throws DataAccessException {
LOGGER.trace("expireSpaceReservations()...");
/* Recover files from lost notifications. Space manager receives notifications
* on file transfer finishing (DoorTransferFinished), name space deletion
* (PnfsDeleteEntryNotification), pool location cleaning (PoolRemoveFiles),
* and flush (PoolFileFlushed). These notifications are however lossy, and we
* need to recover from lost messages in some way.
*
* We ought to do this with any kind of file reservation, but that would be rather
* expensive. This code is currently limited to reservations in the TRANSFERRING
* state: It is easy to miss the notification for such files if space manager
* or some other critical component gets restarted while having active uploads.
*/
SpaceManagerDatabase.FileCriterion oldTransfers = db.files().whereStateIsIn(FileState.TRANSFERRING).whereCreationTimeIsBefore(System.currentTimeMillis() - TimeUnit.DAYS.toMillis(1));
final int maximumNumberFilesToLoadAtOnce = 1000;
for (File file : db.get(oldTransfers, maximumNumberFilesToLoadAtOnce)) {
try {
EnumSet<FileAttribute> attributes = EnumSet.of(FileAttribute.TYPE, FileAttribute.SIZE, FileAttribute.LOCATIONS, FileAttribute.STORAGEINFO, FileAttribute.ACCESS_LATENCY);
FileAttributes fileAttributes = pnfs.getFileAttributes(file.getPnfsId(), attributes);
if (fileAttributes.getFileType() != FileType.REGULAR) {
db.removeFile(file.getId());
} else if (fileAttributes.getStorageInfo().isStored()) {
boolean isRemovable = !fileAttributes.getAccessLatency().equals(AccessLatency.ONLINE);
fileFlushed(file.getPnfsId(), fileAttributes.getSize(), isRemovable);
} else if (!fileAttributes.getLocations().isEmpty()) {
transferFinished(file.getPnfsId(), fileAttributes.getSize());
}
} catch (FileNotFoundCacheException e) {
db.removeFile(file.getId());
} catch (TransientDataAccessException e) {
LOGGER.warn("Transient data access failure while deleting expired file {}: {}", file, e.getMessage());
} catch (DataAccessException e) {
LOGGER.error("Data access failure while deleting expired file {}: {}", file, e.getMessage());
break;
} catch (TimeoutCacheException e) {
LOGGER.error("Failed to lookup file {} in name space: {}", file.getPnfsId(), e.getMessage());
break;
} catch (CacheException e) {
LOGGER.error("Failed to lookup file {} in name space: {}", file.getPnfsId(), e.getMessage());
}
}
db.expire(db.spaces().whereStateIsIn(SpaceState.RESERVED).thatExpireBefore(System.currentTimeMillis()));
db.remove(db.files().whereStateIsIn(FileState.STORED, FileState.FLUSHED).in(db.spaces().whereStateIsIn(SpaceState.EXPIRED, SpaceState.RELEASED).thatExpireBefore(System.currentTimeMillis() - perishedSpacePurgeDelay)));
db.remove(db.spaces().whereStateIsIn(SpaceState.EXPIRED, SpaceState.RELEASED).thatHaveNoFiles());
}
Aggregations