use of org.dcache.pool.nearline.json.NearlineData 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);
}
}
Aggregations