Search in sources :

Example 96 with CacheException

use of diskCacheV111.util.CacheException 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 97 with CacheException

use of diskCacheV111.util.CacheException in project dcache by dCache.

the class RestoresInfoServiceImpl method update.

@Override
protected void update(List<RestoreHandlerInfo> refreshed) {
    Map<String, RestoreInfo> newInfo = new HashMap<>();
    try {
        for (RestoreHandlerInfo restore : refreshed) {
            RestoreInfo info = new RestoreInfo(restore);
            collector.setPath(info);
            newInfo.put(info.getKey(), info);
        }
    } catch (CacheException e) {
        Throwable t = e.getCause();
        LOGGER.warn("Update could not complete: {}, {}.", e.getMessage(), t == null ? "" : t.toString());
    }
    access.refresh(newInfo);
}
Also used : RestoreInfo(org.dcache.restful.providers.restores.RestoreInfo) HashMap(java.util.HashMap) CacheException(diskCacheV111.util.CacheException) RestoreHandlerInfo(diskCacheV111.vehicles.RestoreHandlerInfo)

Example 98 with CacheException

use of diskCacheV111.util.CacheException in project dcache by dCache.

the class PoolInfoResources method getNearlineQueues.

@GET
@ApiOperation("Get nearline activity information for a specific pool.")
@ApiResponses({ @ApiResponse(code = 400, message = "unrecognized queue type"), @ApiResponse(code = 403, message = "Pool command only accessible to admin users."), @ApiResponse(code = 500, message = "Internal Server Error") })
@Path("/{pool}/nearline/queues")
@Produces(MediaType.APPLICATION_JSON)
public List<NearlineData> getNearlineQueues(@ApiParam("The pool to be described.") @PathParam("pool") String pool, @ApiParam("Select transfers of a specific type " + "(flush, stage, remove).") @QueryParam("type") String typeList, @ApiParam("The number of items to skip.") @DefaultValue("0") @QueryParam("offset") int offset, @ApiParam("The maximum number of items to return.") @QueryParam("limit") Integer limit, @ApiParam("Select only operations affecting this PNFS-ID.") @QueryParam("pnfsid") String pnfsid, @ApiParam("Select only operations in this state.") @QueryParam("state") String state, @ApiParam("Select only operations of this storage class.") @QueryParam("storageClass") String storageClass, @ApiParam("How the returned values should be sorted.") @DefaultValue("class,created") @QueryParam("sort") String sort) {
    if (!RequestUser.canViewFileOperations(unlimitedOperationVisibility)) {
        throw new ForbiddenException("Pool command only accessible to admin users.");
    }
    limit = limit == null ? Integer.MAX_VALUE : limit;
    List<NearlineData> list = new ArrayList<>();
    PagedList<NearlineData> pagedList;
    int count = 0;
    try {
        String[] types = typeList == null ? new String[0] : typeList.split(",");
        for (String type : types) {
            switch(type) {
                case "flush":
                    pagedList = service.getFlush(pool, offset, limit, pnfsid, state, storageClass, sort);
                    list.addAll(pagedList.contents);
                    count += pagedList.total;
                    break;
                case "stage":
                    pagedList = service.getStage(pool, offset, limit, pnfsid, state, storageClass, sort);
                    list.addAll(pagedList.contents);
                    count += pagedList.total;
                    break;
                case "remove":
                    pagedList = service.getRemove(pool, offset, limit, pnfsid, state, storageClass, sort);
                    list.addAll(pagedList.contents);
                    count += pagedList.total;
                    break;
                default:
                    throw new BadRequestException("unrecognized queue type: " + type);
            }
        }
        response.addIntHeader(TOTAL_COUNT_HEADER, count);
        return list;
    } catch (InterruptedException | NoRouteToCellException | CacheException e) {
        LOGGER.warn(Exceptions.meaningfulMessage(e));
        throw new InternalServerErrorException(e);
    }
}
Also used : ForbiddenException(javax.ws.rs.ForbiddenException) CacheException(diskCacheV111.util.CacheException) ArrayList(java.util.ArrayList) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) BadRequestException(javax.ws.rs.BadRequestException) InternalServerErrorException(javax.ws.rs.InternalServerErrorException) NearlineData(org.dcache.pool.nearline.json.NearlineData) Path(javax.ws.rs.Path) CellPath(dmg.cells.nucleus.CellPath) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 99 with CacheException

use of diskCacheV111.util.CacheException in project dcache by dCache.

the class PoolPreferenceResources method match.

@GET
@ApiOperation("Describe the pools selected by a particular request.")
@ApiResponses({ @ApiResponse(code = 400, message = "Bad Request"), @ApiResponse(code = 500, message = "Internal Server Error") })
@Produces(MediaType.APPLICATION_JSON)
public List<PreferenceResult> match(@ApiParam(value = "The operation type.", allowableValues = "READ,CACHE,WRITE,P2P,ANY") @DefaultValue("READ") @QueryParam("type") String type, @ApiParam("The name of the matching store unit.") @DefaultValue("*") @QueryParam("store") String store, @ApiParam("The name of the matching dcache unit.") @DefaultValue("*") @QueryParam("dcache") String dcache, @DefaultValue("*") @ApiParam("The name of the matching net unit.") @QueryParam("net") String net, @DefaultValue("*") @ApiParam("The matching protocol unit.") @QueryParam("protocol") String protocol, @ApiParam("The linkgroup unit, or 'none' for a request outside of a linkgroup.") @DefaultValue("none") @QueryParam("linkGroup") String linkGroup) {
    try {
        String command = "psux match " + type + " " + store + " " + dcache + " " + net + " " + protocol + (linkGroup.equals("none") ? "" : " -linkGroup=" + linkGroup);
        PoolPreferenceLevel[] poolPreferenceLevels = poolManager.sendAndWait(command, PoolPreferenceLevel[].class);
        List<PreferenceResult> results = new ArrayList<>();
        for (PoolPreferenceLevel level : poolPreferenceLevels) {
            results.add(new PreferenceResult(level));
        }
        return results;
    } catch (JSONException | IllegalArgumentException e) {
        throw new BadRequestException(e);
    } catch (CacheException | InterruptedException | NoRouteToCellException e) {
        LOGGER.warn(Exceptions.meaningfulMessage(e));
        throw new InternalServerErrorException(e);
    }
}
Also used : PoolPreferenceLevel(diskCacheV111.poolManager.PoolPreferenceLevel) CacheException(diskCacheV111.util.CacheException) ArrayList(java.util.ArrayList) JSONException(org.json.JSONException) PreferenceResult(org.dcache.restful.providers.selection.PreferenceResult) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) BadRequestException(javax.ws.rs.BadRequestException) InternalServerErrorException(javax.ws.rs.InternalServerErrorException) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 100 with CacheException

use of diskCacheV111.util.CacheException in project dcache by dCache.

the class BillingInfoServiceImpl method updateCache.

private void updateCache(String key, Exception exception) {
    ErrorData data = new ErrorData();
    if (exception instanceof CacheException) {
        data.exception = (CacheException) exception;
    } else {
        data.exception = new CacheException("Could not retrieve data", exception);
    }
    cachedData.put(key, data);
}
Also used : CacheException(diskCacheV111.util.CacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException)

Aggregations

CacheException (diskCacheV111.util.CacheException)301 PermissionDeniedCacheException (diskCacheV111.util.PermissionDeniedCacheException)144 FileNotFoundCacheException (diskCacheV111.util.FileNotFoundCacheException)133 PnfsId (diskCacheV111.util.PnfsId)96 FileAttributes (org.dcache.vehicles.FileAttributes)87 NotDirCacheException (diskCacheV111.util.NotDirCacheException)85 TimeoutCacheException (diskCacheV111.util.TimeoutCacheException)84 FileExistsCacheException (diskCacheV111.util.FileExistsCacheException)74 FsPath (diskCacheV111.util.FsPath)61 NoRouteToCellException (dmg.cells.nucleus.NoRouteToCellException)58 InvalidMessageCacheException (diskCacheV111.util.InvalidMessageCacheException)53 IOException (java.io.IOException)52 FileIsNewCacheException (diskCacheV111.util.FileIsNewCacheException)50 NotFileCacheException (diskCacheV111.util.NotFileCacheException)50 FileCorruptedCacheException (diskCacheV111.util.FileCorruptedCacheException)47 FileAttribute (org.dcache.namespace.FileAttribute)44 MissingResourceCacheException (diskCacheV111.util.MissingResourceCacheException)43 Subject (javax.security.auth.Subject)38 PnfsHandler (diskCacheV111.util.PnfsHandler)37 ArrayList (java.util.ArrayList)31