use of dmg.cells.nucleus.NoRouteToCellException in project dcache by dCache.
the class BillingResources method getWrites.
@GET
@ApiOperation("Provides a list of write transfers for a specific PNFS-ID.")
@ApiResponses({ @ApiResponse(code = 400, message = "Bad request"), @ApiResponse(code = 404, message = "Not Found"), @ApiResponse(code = 500, message = "Internal Server Error") })
@Produces(MediaType.APPLICATION_JSON)
@Path("writes/{pnfsid}")
public List<DoorTransferRecord> getWrites(@ApiParam("The file to list.") @PathParam("pnfsid") PnfsId pnfsid, @ApiParam("Return no writes after this datestamp.") @QueryParam("before") String before, @ApiParam("Return no writes before this datestamp.") @QueryParam("after") String after, @ApiParam("Maximum number of writes to return.") @QueryParam("limit") Integer limit, @ApiParam("Number of writes to skip.") @DefaultValue("0") @QueryParam("offset") int offset, @ApiParam("Only select writes from the specified pool.") @QueryParam("pool") String pool, @ApiParam("Only select writes initiated by the specified door.") @QueryParam("door") String door, @ApiParam("Only select writes requested by the client.") @QueryParam("client") String client, @ApiParam("How to sort responses.") @DefaultValue("date") @QueryParam("sort") String sort) {
try {
limit = limit == null ? Integer.MAX_VALUE : limit;
Long suid = RequestUser.getSubjectUidForFileOperations(unlimitedOperationVisibility);
PagedList<DoorTransferRecord> result = service.getWrites(pnfsid, before, after, limit, offset, suid, pool, door, client, 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 dmg.cells.nucleus.NoRouteToCellException in project dcache by dCache.
the class PoolInfoResources method getMovers.
@GET
@ApiOperation(value = "Get mover information for a specific pool.", responseHeaders = { @ResponseHeader(name = "X-Total-Count", description = "Total " + "number of potential responses. This may be greater " + "than the number of response if offset or limit are " + "specified") })
@ApiResponses({ @ApiResponse(code = 403, message = "Pool command only accessible to admin users."), @ApiResponse(code = 500, message = "Internal Server Error") })
@Path("/{pool}/movers")
@Produces(MediaType.APPLICATION_JSON)
public List<MoverData> getMovers(@ApiParam("The pool to be described.") @PathParam("pool") String pool, @ApiParam("A comma-seperated list of mover types. " + "Currently, either 'p2p-client,p2p-server' " + "or none (meaning all) is supported.") @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 movers operating on a specific PNFS-ID.") @QueryParam("pnfsid") String pnfsid, @ApiParam("Select movers with a specific queue.") @QueryParam("queue") String queue, @ApiParam("Select movers in a particular state.") @QueryParam("state") String state, @ApiParam("Select movers with a specific mode.") @QueryParam("mode") String mode, @ApiParam("Select movers initiated by a specific door.") @QueryParam("door") String door, @ApiParam("Select movers with a specific storage class.") @QueryParam("storageClass") String storageClass, @ApiParam("How returned items should be sorted.") @DefaultValue("door,startTime") @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;
String[] type = typeList == null ? new String[0] : typeList.split(",");
PagedList<MoverData> pagedList;
try {
if (type.length == 0) {
pagedList = service.getMovers(pool, offset, limit, pnfsid, queue, state, mode, door, storageClass, sort);
response.addIntHeader(TOTAL_COUNT_HEADER, pagedList.total);
return pagedList.contents;
} else if (type.length == 2) {
if ((type[0].equals("p2p-client") && type[1].equals("p2p-server")) || (type[1].equals("p2p-client") && type[0].equals("p2p-server"))) {
pagedList = service.getP2p(pool, offset, limit, pnfsid, queue, state, storageClass, sort);
response.addIntHeader(TOTAL_COUNT_HEADER, pagedList.total);
return pagedList.contents;
}
}
} catch (InterruptedException | NoRouteToCellException | CacheException e) {
LOGGER.warn(Exceptions.meaningfulMessage(e));
throw new InternalServerErrorException(e);
}
String error = String.format(TYPE_ERROR, typeList);
throw new InternalServerErrorException(error, NOT_IMPLEMENTED);
}
use of dmg.cells.nucleus.NoRouteToCellException in project dcache by dCache.
the class PoolInfoResources method updateMode.
@PATCH
@ApiOperation("Modify a pool's mode. Requires admin role.")
@ApiResponses({ @ApiResponse(code = 400, message = "Bad Request"), @ApiResponse(code = 403, message = "Pool command only accessible to admin users."), @ApiResponse(code = 500, message = "Internal Server Error") })
@Path("/{pool}/usage/mode")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response updateMode(@ApiParam(value = "The pool affected by the mode change.", required = true) @PathParam("pool") String pool, @ApiParam(value = "JSON object describing how the " + "pool should be modified. " + "(Corresponds to PoolModeUpdate.)", required = true) String requestPayload) {
if (!RequestUser.isAdmin()) {
throw new ForbiddenException("Pool command only accessible to admin users.");
}
try {
PoolModeUpdate update = new ObjectMapper().readValue(requestPayload, PoolModeUpdate.class);
PoolV2Mode mode = new PoolV2Mode(update.mode());
mode.setResilienceEnabled(update.isResilience());
Message message = new PoolModifyModeMessage(pool, mode);
poolStub.sendAndWait(new CellPath(pool), message);
} catch (JSONException | IllegalArgumentException | IOException e) {
throw new BadRequestException(e);
} catch (InterruptedException | NoRouteToCellException | CacheException e) {
LOGGER.warn(Exceptions.meaningfulMessage(e));
throw new InternalServerErrorException(e);
}
return successfulResponse(Response.Status.OK);
}
use of dmg.cells.nucleus.NoRouteToCellException in project dcache by dCache.
the class PoolInfoResources method killMovers.
@DELETE
@ApiOperation("Kill a mover. Requires admin role.")
@ApiResponses({ @ApiResponse(code = 400, message = "Bad Request"), @ApiResponse(code = 403, message = "Pool command only accessible to admin users."), @ApiResponse(code = 500, message = "Internal Server Error") })
@Path("/{pool}/movers/{id : [0-9]+}")
@Produces(MediaType.APPLICATION_JSON)
public Response killMovers(@ApiParam(value = "The pool with the mover to be killed.", required = true) @PathParam("pool") String pool, @ApiParam(value = "The id of the mover to be killed.", required = true) @PathParam("id") int id) {
if (!RequestUser.isAdmin()) {
throw new ForbiddenException("Pool command only accessible to admin users.");
}
try {
poolStub.sendAndWait(new CellPath(pool), new PoolMoverKillMessage(pool, id, "Killed by user."));
transferInfoService.setCancelled(pool, id);
} catch (IllegalArgumentException e) {
throw new BadRequestException(e);
} catch (CacheException e) {
if (e.getRc() == CacheException.MOVER_NOT_FOUND) {
transferInfoService.setCancelled(pool, id);
} else {
LOGGER.warn(Exceptions.meaningfulMessage(e));
throw new InternalServerErrorException(e);
}
} catch (InterruptedException | NoRouteToCellException e) {
LOGGER.warn(Exceptions.meaningfulMessage(e));
throw new InternalServerErrorException(e);
}
return successfulResponse(Response.Status.OK);
}
use of dmg.cells.nucleus.NoRouteToCellException in project dcache by dCache.
the class BillingInfoServiceImpl method getDoorTransfers.
private PagedList<DoorTransferRecord> getDoorTransfers(Type type, PnfsId pnfsid, String before, String after, Integer limit, int offset, String door, String pool, String client, String sort, Long suid) throws FileNotFoundCacheException, ParseException, CacheException, NoRouteToCellException, InterruptedException {
if (Strings.isNullOrEmpty(sort)) {
sort = "date";
}
TransferRecordRequestMessage message = new TransferRecordRequestMessage(pnfsid, getDate(before), getDate(after), type, door, null, pool, client, limit == null ? Integer.MAX_VALUE : limit, offset, sort);
message = collector.sendRecordRequest(message);
Predicate<TransferRecord> matchesSubject = r -> suid == null || r.getMappedUid() == null || suid.intValue() == r.getMappedUid();
List<DoorTransferRecord> list = message.getRecords().stream().filter(matchesSubject).map(DoorTransferRecord::new).collect(Collectors.toList());
return new PagedList<>(list, list.size());
}
Aggregations