Search in sources :

Example 16 with NoRouteToCellException

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);
    }
}
Also used : CacheException(diskCacheV111.util.CacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) NotFoundException(javax.ws.rs.NotFoundException) DoorTransferRecord(org.dcache.restful.providers.billing.DoorTransferRecord) 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 17 with NoRouteToCellException

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);
    }
}
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 18 with NoRouteToCellException

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);
    }
}
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 19 with NoRouteToCellException

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);
    }
}
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 20 with NoRouteToCellException

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);
}
Also used : CellMessage(dmg.cells.nucleus.CellMessage) PnfsRemoveExtendedAttributesMessage(diskCacheV111.vehicles.PnfsRemoveExtendedAttributesMessage) CellMessage(dmg.cells.nucleus.CellMessage) PnfsRenameMessage(diskCacheV111.vehicles.PnfsRenameMessage) PnfsCreateSymLinkMessage(org.dcache.vehicles.PnfsCreateSymLinkMessage) PnfsManagerGetQuotaMessage(org.dcache.vehicles.quota.PnfsManagerGetQuotaMessage) PnfsManagerSetQuotaMessage(org.dcache.vehicles.quota.PnfsManagerSetQuotaMessage) PnfsFlagMessage(diskCacheV111.vehicles.PnfsFlagMessage) PnfsListExtendedAttributesMessage(diskCacheV111.vehicles.PnfsListExtendedAttributesMessage) PnfsCreateEntryMessage(diskCacheV111.vehicles.PnfsCreateEntryMessage) PnfsReadExtendedAttributesMessage(diskCacheV111.vehicles.PnfsReadExtendedAttributesMessage) PnfsListDirectoryMessage(org.dcache.vehicles.PnfsListDirectoryMessage) PnfsManagerRemoveQuotaMessage(org.dcache.vehicles.quota.PnfsManagerRemoveQuotaMessage) PnfsRemoveLabelsMessage(diskCacheV111.vehicles.PnfsRemoveLabelsMessage) PnfsMapPathMessage(diskCacheV111.vehicles.PnfsMapPathMessage) PnfsWriteExtendedAttributesMessage(diskCacheV111.vehicles.PnfsWriteExtendedAttributesMessage) PnfsManagerQuotaMessage(org.dcache.vehicles.quota.PnfsManagerQuotaMessage) PnfsGetParentMessage(diskCacheV111.vehicles.PnfsGetParentMessage) PnfsGetCacheLocationsMessage(diskCacheV111.vehicles.PnfsGetCacheLocationsMessage) PnfsClearCacheLocationMessage(diskCacheV111.vehicles.PnfsClearCacheLocationMessage) PnfsDeleteEntryMessage(diskCacheV111.vehicles.PnfsDeleteEntryMessage) PnfsMessage(diskCacheV111.vehicles.PnfsMessage) Message(diskCacheV111.vehicles.Message) PoolFileFlushedMessage(diskCacheV111.vehicles.PoolFileFlushedMessage) PnfsRemoveChecksumMessage(org.dcache.vehicles.PnfsRemoveChecksumMessage) DoorCancelledUploadNotificationMessage(diskCacheV111.vehicles.DoorCancelledUploadNotificationMessage) PnfsAddCacheLocationMessage(diskCacheV111.vehicles.PnfsAddCacheLocationMessage) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) ArrayList(java.util.ArrayList)

Aggregations

NoRouteToCellException (dmg.cells.nucleus.NoRouteToCellException)67 CacheException (diskCacheV111.util.CacheException)55 TimeoutCacheException (diskCacheV111.util.TimeoutCacheException)25 PermissionDeniedCacheException (diskCacheV111.util.PermissionDeniedCacheException)22 FileNotFoundCacheException (diskCacheV111.util.FileNotFoundCacheException)19 ArrayList (java.util.ArrayList)15 ApiOperation (io.swagger.annotations.ApiOperation)14 ApiResponses (io.swagger.annotations.ApiResponses)14 Produces (javax.ws.rs.Produces)14 BadRequestException (javax.ws.rs.BadRequestException)13 InternalServerErrorException (javax.ws.rs.InternalServerErrorException)13 Path (javax.ws.rs.Path)13 CellPath (dmg.cells.nucleus.CellPath)11 ExecutionException (java.util.concurrent.ExecutionException)11 ForbiddenException (javax.ws.rs.ForbiddenException)11 GET (javax.ws.rs.GET)11 FsPath (diskCacheV111.util.FsPath)10 PnfsId (diskCacheV111.util.PnfsId)10 SRMException (org.dcache.srm.SRMException)10 SRMInternalErrorException (org.dcache.srm.SRMInternalErrorException)10