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);
}
}
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);
}
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);
}
}
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);
}
}
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);
}
Aggregations