use of dmg.cells.nucleus.NoRouteToCellException in project dcache by dCache.
the class BillingResources method getReads.
@GET
@ApiOperation("Provides a list of read 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("reads/{pnfsid}")
public List<DoorTransferRecord> getReads(@ApiParam("The file to list.") @PathParam("pnfsid") PnfsId pnfsid, @ApiParam("Return no reads after this datestamp.") @QueryParam("before") String before, @ApiParam("Return no reads before this datestamp.") @QueryParam("after") String after, @ApiParam("Maximum number of reads to return.") @QueryParam("limit") Integer limit, @ApiParam("Number of reads to skip.") @DefaultValue("0") @QueryParam("offset") Integer offset, @ApiParam("Only select reads from the specified pool.") @QueryParam("pool") String pool, @ApiParam("Only select reads initiated by the specified door.") @QueryParam("door") String door, @ApiParam("Only select reads 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.getReads(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 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 dmg.cells.nucleus.NoRouteToCellException 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 dmg.cells.nucleus.NoRouteToCellException 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 dmg.cells.nucleus.NoRouteToCellException in project dcache by dCache.
the class PnfsManagerV3 method drainQueue.
private void drainQueue(BlockingQueue<CellMessage> queue) {
String error = "Name space is shutting down.";
ArrayList<CellMessage> drained = new ArrayList<>();
queue.drainTo(drained);
for (CellMessage envelope : drained) {
Message msg = (Message) envelope.getMessageObject();
if (msg.getReplyRequired()) {
envelope.setMessageObject(new NoRouteToCellException(envelope, error));
envelope.revertDirection();
sendMessage(envelope);
}
}
queue.offer(SHUTDOWN_SENTINEL);
}
Aggregations