Search in sources :

Example 66 with NoRouteToCellException

use of dmg.cells.nucleus.NoRouteToCellException in project dcache by dCache.

the class SrmHandler method toGetRequestSummaryResponse.

private SrmGetRequestSummaryResponse toGetRequestSummaryResponse(Map<String, ListenableFuture<TRequestSummary>> futureMap) throws InterruptedException, CacheException, NoRouteToCellException {
    boolean hasFailure = false;
    boolean hasSuccess = false;
    List<TRequestSummary> summaries = new ArrayList<>();
    for (Map.Entry<String, ListenableFuture<TRequestSummary>> entry : futureMap.entrySet()) {
        try {
            summaries.add(entry.getValue().get());
            hasSuccess = true;
        } catch (ExecutionException e) {
            Throwable cause = e.getCause();
            if (cause instanceof SRMException) {
                summaries.add(createRequestSummaryFailure(entry.getKey(), ((SRMException) cause).getStatusCode(), cause.getMessage()));
                hasFailure = true;
            } else {
                Throwables.throwIfInstanceOf(cause, CacheException.class);
                Throwables.throwIfInstanceOf(cause, NoRouteToCellException.class);
                Throwables.throwIfUnchecked(e);
                throw new RuntimeException(e);
            }
        }
    }
    TReturnStatus status;
    if (!hasFailure) {
        status = new TReturnStatus(SRM_SUCCESS, "All request statuses have been retrieved.");
    } else if (hasSuccess) {
        status = new TReturnStatus(SRM_PARTIAL_SUCCESS, "Some request statuses have been retrieved.");
    } else {
        status = new TReturnStatus(SRM_FAILURE, "No request statuses have been retrieved.");
    }
    return new SrmGetRequestSummaryResponse(status, new ArrayOfTRequestSummary(summaries.toArray(TRequestSummary[]::new)));
}
Also used : TRequestSummary(org.dcache.srm.v2_2.TRequestSummary) ArrayOfTRequestSummary(org.dcache.srm.v2_2.ArrayOfTRequestSummary) ArrayOfTRequestSummary(org.dcache.srm.v2_2.ArrayOfTRequestSummary) CacheException(diskCacheV111.util.CacheException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) ArrayList(java.util.ArrayList) SrmGetRequestSummaryResponse(org.dcache.srm.v2_2.SrmGetRequestSummaryResponse) ArrayOfString(org.dcache.srm.v2_2.ArrayOfString) SRMException(org.dcache.srm.SRMException) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) ExecutionException(java.util.concurrent.ExecutionException) Map(java.util.Map) Collectors.toMap(java.util.stream.Collectors.toMap) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap)

Example 67 with NoRouteToCellException

use of dmg.cells.nucleus.NoRouteToCellException in project dcache by dCache.

the class NettyTransferService method executeMover.

@Override
public Cancellable executeMover(final NettyMover<P> mover, CompletionHandler<Void, Void> completionHandler) throws IOException, CacheException, NoRouteToCellException {
    return new TryCatchTemplate<Void, Void>(completionHandler) {

        @Override
        public void execute() throws Exception {
            UUID uuid = mover.getUuid();
            NettyMoverChannel channel = autoclose(new NettyMoverChannel(uuid, mover.open(), connectTimeoutUnit.toMillis(connectTimeout), this, mover::addChecksumType, mover::addExpectedChecksum));
            if (uuids.putIfAbsent(uuid, channel) != null) {
                throw new IllegalStateException("UUID conflict");
            }
            conditionallyStartServer();
            setCancellable(channel);
            sendAddressToDoor(mover, getServerAddress().getPort());
        }

        @Override
        public void onFailure(Throwable t, Void attachment) throws CacheException {
            if (t instanceof NoRouteToCellException) {
                throw new CacheException("Failed to send redirect message to door: " + t.getMessage(), t);
            }
        }
    };
}
Also used : TryCatchTemplate(org.dcache.util.TryCatchTemplate) TimeoutCacheException(diskCacheV111.util.TimeoutCacheException) CacheException(diskCacheV111.util.CacheException) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) UUID(java.util.UUID)

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