Search in sources :

Example 26 with FileNotFoundCacheException

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);
    }
}
Also used : ForbiddenException(javax.ws.rs.ForbiddenException) CacheException(diskCacheV111.util.CacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) NotFoundException(javax.ws.rs.NotFoundException) HSMTransferRecord(org.dcache.restful.providers.billing.HSMTransferRecord) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) InternalServerErrorException(javax.ws.rs.InternalServerErrorException) BadRequestException(javax.ws.rs.BadRequestException) ParseException(java.text.ParseException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 27 with FileNotFoundCacheException

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);
    }
}
Also used : MissingResourceCacheException(diskCacheV111.util.MissingResourceCacheException) NotDirCacheException(diskCacheV111.util.NotDirCacheException) InvalidMessageCacheException(diskCacheV111.util.InvalidMessageCacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) CacheException(diskCacheV111.util.CacheException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) PnfsId(diskCacheV111.util.PnfsId) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) Subject(javax.security.auth.Subject) PnfsFlagMessage(diskCacheV111.vehicles.PnfsFlagMessage)

Example 28 with FileNotFoundCacheException

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");
    }
}
Also used : MissingResourceCacheException(diskCacheV111.util.MissingResourceCacheException) NotDirCacheException(diskCacheV111.util.NotDirCacheException) InvalidMessageCacheException(diskCacheV111.util.InvalidMessageCacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) CacheException(diskCacheV111.util.CacheException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) PnfsId(diskCacheV111.util.PnfsId) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) Subject(javax.security.auth.Subject)

Example 29 with FileNotFoundCacheException

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);
    }
}
Also used : MissingResourceCacheException(diskCacheV111.util.MissingResourceCacheException) NotDirCacheException(diskCacheV111.util.NotDirCacheException) InvalidMessageCacheException(diskCacheV111.util.InvalidMessageCacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) CacheException(diskCacheV111.util.CacheException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) PnfsId(diskCacheV111.util.PnfsId) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) PnfsSetFileAttributes(org.dcache.vehicles.PnfsSetFileAttributes) PnfsGetFileAttributes(org.dcache.vehicles.PnfsGetFileAttributes) FileAttributes(org.dcache.vehicles.FileAttributes)

Example 30 with FileNotFoundCacheException

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());
}
Also used : TransientDataAccessException(org.springframework.dao.TransientDataAccessException) TimeoutCacheException(diskCacheV111.util.TimeoutCacheException) CacheException(diskCacheV111.util.CacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) FileAttributes(org.dcache.vehicles.FileAttributes) CellEndpoint(dmg.cells.nucleus.CellEndpoint) TransientDataAccessException(org.springframework.dao.TransientDataAccessException) EmptyResultDataAccessException(org.springframework.dao.EmptyResultDataAccessException) DataAccessException(org.springframework.dao.DataAccessException) DeadlockLoserDataAccessException(org.springframework.dao.DeadlockLoserDataAccessException) RecoverableDataAccessException(org.springframework.dao.RecoverableDataAccessException) FileAttribute(org.dcache.namespace.FileAttribute) TimeoutCacheException(diskCacheV111.util.TimeoutCacheException)

Aggregations

FileNotFoundCacheException (diskCacheV111.util.FileNotFoundCacheException)85 CacheException (diskCacheV111.util.CacheException)80 PermissionDeniedCacheException (diskCacheV111.util.PermissionDeniedCacheException)61 NotDirCacheException (diskCacheV111.util.NotDirCacheException)51 FileExistsCacheException (diskCacheV111.util.FileExistsCacheException)44 FileIsNewCacheException (diskCacheV111.util.FileIsNewCacheException)34 FileAttributes (org.dcache.vehicles.FileAttributes)34 NotFileCacheException (diskCacheV111.util.NotFileCacheException)33 FileCorruptedCacheException (diskCacheV111.util.FileCorruptedCacheException)31 FsPath (diskCacheV111.util.FsPath)31 InvalidMessageCacheException (diskCacheV111.util.InvalidMessageCacheException)28 TimeoutCacheException (diskCacheV111.util.TimeoutCacheException)27 NoAttributeCacheException (diskCacheV111.util.NoAttributeCacheException)24 FileNotFoundChimeraFsException (org.dcache.chimera.FileNotFoundChimeraFsException)24 AttributeExistsCacheException (diskCacheV111.util.AttributeExistsCacheException)23 PnfsId (diskCacheV111.util.PnfsId)21 LockedCacheException (diskCacheV111.util.LockedCacheException)20 MissingResourceCacheException (diskCacheV111.util.MissingResourceCacheException)19 FileAttribute (org.dcache.namespace.FileAttribute)18 IOException (java.io.IOException)17