Search in sources :

Example 26 with NoRouteToCellException

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

the class Storage method putDone.

@Override
public void putDone(SRMUser user, String localTransferPath, URI surl, boolean overwrite) throws SRMException {
    try {
        Subject subject = asDcacheUser(user).getSubject();
        Restriction restriction = asDcacheUser(user).getRestriction();
        FsPath fullPath = getPath(surl);
        checkNonBrokenUpload(localTransferPath);
        EnumSet<CreateOption> options = EnumSet.noneOf(CreateOption.class);
        if (overwrite) {
            options.add(CreateOption.OVERWRITE_EXISTING);
        }
        PnfsCommitUpload msg = new PnfsCommitUpload(subject, restriction, FsPath.create(localTransferPath), fullPath, options, EnumSet.of(PNFSID, SIZE, STORAGEINFO));
        msg = _pnfsStub.sendAndWait(msg);
        DoorRequestInfoMessage infoMsg = new DoorRequestInfoMessage(getCellAddress());
        infoMsg.setSubject(subject);
        infoMsg.setBillingPath(fullPath.toString());
        infoMsg.setTransferPath(localTransferPath);
        infoMsg.setTransaction(CDC.getSession());
        infoMsg.setPnfsId(msg.getFileAttributes().getPnfsId());
        infoMsg.setResult(0, "");
        infoMsg.setFileSize(msg.getFileAttributes().getSizeIfPresent().orElse(0L));
        infoMsg.setStorageInfo(msg.getFileAttributes().getStorageInfo());
        Origin origin = Subjects.getOrigin(subject);
        if (origin != null) {
            infoMsg.setClient(origin.getAddress().getHostAddress());
        }
        _billingStub.notify(infoMsg);
    } catch (FileNotFoundCacheException e) {
        throw new SRMInvalidPathException(e.getMessage(), e);
    } catch (FileIsNewCacheException | FileCorruptedCacheException e) {
        throw new SRMException(e.getMessage(), e);
    } catch (PermissionDeniedCacheException e) {
        throw new SRMAuthorizationException("Permission denied.", e);
    } catch (FileExistsCacheException e) {
        throw new SRMDuplicationException(surl + " exists.", e);
    } catch (CacheException e) {
        throw new SRMInternalErrorException(e.getMessage(), e);
    } catch (InterruptedException e) {
        throw new SRMInternalErrorException("Operation interrupted", e);
    } catch (NoRouteToCellException e) {
        throw new SRMInternalErrorException("Internal communication failure", e);
    }
}
Also used : DoorRequestInfoMessage(diskCacheV111.vehicles.DoorRequestInfoMessage) Origin(org.dcache.auth.Origin) SRMAuthorizationException(org.dcache.srm.SRMAuthorizationException) FileIsNewCacheException(diskCacheV111.util.FileIsNewCacheException) FileExistsCacheException(diskCacheV111.util.FileExistsCacheException) NotDirCacheException(diskCacheV111.util.NotDirCacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) TimeoutCacheException(diskCacheV111.util.TimeoutCacheException) CacheException(diskCacheV111.util.CacheException) FileCorruptedCacheException(diskCacheV111.util.FileCorruptedCacheException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) SRMInvalidPathException(org.dcache.srm.SRMInvalidPathException) Subject(javax.security.auth.Subject) SRMInternalErrorException(org.dcache.srm.SRMInternalErrorException) Restriction(org.dcache.auth.attributes.Restriction) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) SRMException(org.dcache.srm.SRMException) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) FileCorruptedCacheException(diskCacheV111.util.FileCorruptedCacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) FileIsNewCacheException(diskCacheV111.util.FileIsNewCacheException) CreateOption(org.dcache.namespace.CreateOption) PnfsCommitUpload(diskCacheV111.vehicles.PnfsCommitUpload) FileExistsCacheException(diskCacheV111.util.FileExistsCacheException) SRMDuplicationException(org.dcache.srm.SRMDuplicationException) FsPath(diskCacheV111.util.FsPath)

Example 27 with NoRouteToCellException

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

the class Storage method srmGetSpaceMetaData.

/**
 * @param spaceTokens
 * @return
 * @throws SRMException
 */
@Override
public TMetaDataSpace[] srmGetSpaceMetaData(SRMUser user, String[] spaceTokens) throws SRMException {
    guardSpaceManagerEnabled();
    GetSpaceMetaData getSpaces = new GetSpaceMetaData(spaceTokens);
    try {
        getSpaces = _spaceManagerStub.sendAndWait(getSpaces);
    } catch (TimeoutCacheException e) {
        throw new SRMInternalErrorException("Space manager timeout", e);
    } catch (NoRouteToCellException e) {
        throw new SRMNotSupportedException("Space manager is unavailable", e);
    } catch (InterruptedException e) {
        throw new SRMInternalErrorException("Operation interrupted", e);
    } catch (CacheException e) {
        _log.warn("GetSpaceMetaData failed with rc={} error={}", e.getRc(), e.getMessage());
        throw new SRMException("Space manager failure: " + e.getMessage(), e);
    }
    Space[] spaces = getSpaces.getSpaces();
    TMetaDataSpace[] spaceMetaDatas = new TMetaDataSpace[spaces.length];
    for (int i = 0; i < spaceMetaDatas.length; ++i) {
        Space space = spaces[i];
        TMetaDataSpace metaDataSpace = new TMetaDataSpace();
        TReturnStatus status;
        if (space != null) {
            Long expirationTime = space.getExpirationTime();
            if (expirationTime == null) {
                metaDataSpace.setLifetimeAssigned(-1);
                metaDataSpace.setLifetimeLeft(-1);
            } else {
                long lifetimeleft = Math.max(0, MILLISECONDS.toSeconds(expirationTime - System.currentTimeMillis()));
                metaDataSpace.setLifetimeAssigned((int) MILLISECONDS.toSeconds(expirationTime - space.getCreationTime()));
                metaDataSpace.setLifetimeLeft((int) lifetimeleft);
            }
            RetentionPolicy retentionPolicy = space.getRetentionPolicy();
            TRetentionPolicy policy = retentionPolicy.equals(RetentionPolicy.CUSTODIAL) ? TRetentionPolicy.CUSTODIAL : retentionPolicy.equals(RetentionPolicy.OUTPUT) ? TRetentionPolicy.OUTPUT : TRetentionPolicy.REPLICA;
            AccessLatency accessLatency = space.getAccessLatency();
            TAccessLatency latency = accessLatency.equals(AccessLatency.ONLINE) ? TAccessLatency.ONLINE : TAccessLatency.NEARLINE;
            UnsignedLong totalSize = new UnsignedLong(space.getSizeInBytes());
            UnsignedLong unusedSize = new UnsignedLong(space.getSizeInBytes() - space.getUsedSizeInBytes());
            metaDataSpace.setRetentionPolicyInfo(new TRetentionPolicyInfo(policy, latency));
            metaDataSpace.setTotalSize(totalSize);
            metaDataSpace.setGuaranteedSize(totalSize);
            metaDataSpace.setUnusedSize(unusedSize);
            SpaceState spaceState = space.getState();
            switch(spaceState) {
                case RESERVED:
                    status = new TReturnStatus(TStatusCode.SRM_SUCCESS, null);
                    break;
                case EXPIRED:
                    status = new TReturnStatus(TStatusCode.SRM_SPACE_LIFETIME_EXPIRED, "The lifetime on the space that is associated with the spaceToken has expired already");
                    break;
                default:
                    status = new TReturnStatus(TStatusCode.SRM_FAILURE, "Space has been released");
                    break;
            }
            metaDataSpace.setOwner("VoGroup=" + space.getVoGroup() + " VoRole=" + space.getVoRole());
        } else {
            status = new TReturnStatus(TStatusCode.SRM_INVALID_REQUEST, "No such space");
        }
        metaDataSpace.setStatus(status);
        metaDataSpace.setSpaceToken(spaceTokens[i]);
        spaceMetaDatas[i] = metaDataSpace;
    }
    return spaceMetaDatas;
}
Also used : GetSpaceMetaData(diskCacheV111.services.space.message.GetSpaceMetaData) Space(diskCacheV111.services.space.Space) TMetaDataSpace(org.dcache.srm.v2_2.TMetaDataSpace) SRMNotSupportedException(org.dcache.srm.SRMNotSupportedException) TAccessLatency(org.dcache.srm.v2_2.TAccessLatency) AccessLatency(diskCacheV111.util.AccessLatency) UnsignedLong(org.apache.axis.types.UnsignedLong) FileIsNewCacheException(diskCacheV111.util.FileIsNewCacheException) FileExistsCacheException(diskCacheV111.util.FileExistsCacheException) NotDirCacheException(diskCacheV111.util.NotDirCacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) TimeoutCacheException(diskCacheV111.util.TimeoutCacheException) CacheException(diskCacheV111.util.CacheException) FileCorruptedCacheException(diskCacheV111.util.FileCorruptedCacheException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) TRetentionPolicy(org.dcache.srm.v2_2.TRetentionPolicy) RetentionPolicy(diskCacheV111.util.RetentionPolicy) TRetentionPolicy(org.dcache.srm.v2_2.TRetentionPolicy) SRMInternalErrorException(org.dcache.srm.SRMInternalErrorException) SRMException(org.dcache.srm.SRMException) TRetentionPolicyInfo(org.dcache.srm.v2_2.TRetentionPolicyInfo) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) SpaceState(diskCacheV111.services.space.SpaceState) UnsignedLong(org.apache.axis.types.UnsignedLong) AtomicLong(java.util.concurrent.atomic.AtomicLong) TAccessLatency(org.dcache.srm.v2_2.TAccessLatency) TMetaDataSpace(org.dcache.srm.v2_2.TMetaDataSpace) TimeoutCacheException(diskCacheV111.util.TimeoutCacheException)

Example 28 with NoRouteToCellException

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

the class Storage method abortPut.

@Override
public void abortPut(SRMUser user, String localTransferPath, URI surl, String reason) throws SRMException {
    try {
        if (localTransferPath.startsWith("/")) {
            // safe-guard against incompatible file id from earlier versions
            Subject subject = (user == null) ? Subjects.ROOT : asDcacheUser(user).getSubject();
            Restriction restriction = (user == null) ? Restrictions.none() : asDcacheUser(user).getRestriction();
            FsPath actualPnfsPath = getPath(surl);
            PnfsCancelUpload msg = new PnfsCancelUpload(subject, restriction, FsPath.create(localTransferPath), actualPnfsPath, EnumSet.noneOf(FileAttribute.class), "SRM upload aborted: " + reason);
            _pnfsStub.sendAndWait(msg);
            DoorRequestInfoMessage infoMsg = new DoorRequestInfoMessage(getCellAddress());
            infoMsg.setSubject(subject);
            infoMsg.setBillingPath(actualPnfsPath.toString());
            infoMsg.setTransaction(CDC.getSession());
            infoMsg.setPnfsId(msg.getPnfsId());
            infoMsg.setResult(CacheException.DEFAULT_ERROR_CODE, reason);
            Origin origin = Subjects.getOrigin(subject);
            if (origin != null) {
                infoMsg.setClient(origin.getAddress().getHostAddress());
            }
            _billingStub.notify(infoMsg);
        }
    } catch (PermissionDeniedCacheException e) {
        throw new SRMAuthorizationException("Permission denied.", e);
    } catch (CacheException e) {
        throw new SRMInternalErrorException(e.getMessage(), e);
    } catch (InterruptedException e) {
        throw new SRMInternalErrorException("Operation interrupted", e);
    } catch (NoRouteToCellException e) {
        throw new SRMInternalErrorException("Communication failure", e);
    }
}
Also used : DoorRequestInfoMessage(diskCacheV111.vehicles.DoorRequestInfoMessage) Origin(org.dcache.auth.Origin) SRMAuthorizationException(org.dcache.srm.SRMAuthorizationException) PnfsCancelUpload(diskCacheV111.vehicles.PnfsCancelUpload) FileIsNewCacheException(diskCacheV111.util.FileIsNewCacheException) FileExistsCacheException(diskCacheV111.util.FileExistsCacheException) NotDirCacheException(diskCacheV111.util.NotDirCacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) TimeoutCacheException(diskCacheV111.util.TimeoutCacheException) CacheException(diskCacheV111.util.CacheException) FileCorruptedCacheException(diskCacheV111.util.FileCorruptedCacheException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) Subject(javax.security.auth.Subject) SRMInternalErrorException(org.dcache.srm.SRMInternalErrorException) Restriction(org.dcache.auth.attributes.Restriction) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) FsPath(diskCacheV111.util.FsPath) FileAttribute(org.dcache.namespace.FileAttribute)

Example 29 with NoRouteToCellException

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

the class PoolDataRequestProcessor method process.

@Override
protected PoolInfoWrapper process(String key, PoolDataRequestMessage message, long sent) {
    Serializable errorObject = message.getErrorObject();
    if (errorObject != null) {
        LOGGER.warn("Problem with retrieval of pool data for {}: {}.", key, errorObject.toString());
        return null;
    }
    PoolData poolData = message.getData();
    CellData cellData = poolData == null ? null : poolData.getCellData();
    if (cellData != null) {
        cellData.setRoundTripTime(System.currentTimeMillis() - sent);
    }
    PoolInfoWrapper info = new PoolInfoWrapper();
    info.setKey(key);
    /*
         *  NB:  the counts histogram for file lifetime will be added
         *  by the historical data method below.
         */
    info.setInfo(poolData);
    try {
        handler.addHistoricalData(info);
    } catch (NoRouteToCellException | InterruptedException | TimeoutCacheException e) {
        LOGGER.debug("Could not add historical data for {}: {}.", key, e.getMessage());
    } catch (CacheException e) {
        LOGGER.error("Could not add historical data for {}: {}.", key, e.getMessage());
    }
    return info;
}
Also used : Serializable(java.io.Serializable) PoolInfoWrapper(org.dcache.pool.json.PoolInfoWrapper) CacheException(diskCacheV111.util.CacheException) TimeoutCacheException(diskCacheV111.util.TimeoutCacheException) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) PoolData(org.dcache.pool.json.PoolData) CellData(org.dcache.cells.json.CellData) TimeoutCacheException(diskCacheV111.util.TimeoutCacheException)

Example 30 with NoRouteToCellException

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

the class ReservationCaches method buildWriteTokenLookupCache.

/**
 * Cache queries to discover if a directory has the "WriteToken" tag set.
 */
public static LoadingCache<FsPath, java.util.Optional<String>> buildWriteTokenLookupCache(PnfsHandler pnfs, Executor executor) {
    return CacheBuilder.newBuilder().maximumSize(1000).expireAfterWrite(10, MINUTES).refreshAfterWrite(5, MINUTES).recordStats().build(new CacheLoader<FsPath, java.util.Optional<String>>() {

        private java.util.Optional<String> writeToken(FileAttributes attr) {
            StorageInfo info = attr.getStorageInfo();
            return java.util.Optional.ofNullable(info.getMap().get("writeToken"));
        }

        @Override
        public java.util.Optional<String> load(FsPath path) throws CacheException, NoRouteToCellException, InterruptedException {
            return writeToken(pnfs.getFileAttributes(path, EnumSet.of(FileAttribute.STORAGEINFO)));
        }

        @Override
        public ListenableFuture<java.util.Optional<String>> reload(FsPath path, java.util.Optional<String> old) {
            PnfsGetFileAttributes message = new PnfsGetFileAttributes(path.toString(), EnumSet.of(FileAttribute.STORAGEINFO));
            SettableFuture<java.util.Optional<String>> future = SettableFuture.create();
            CellStub.addCallback(pnfs.requestAsync(message), new AbstractMessageCallback<PnfsGetFileAttributes>() {

                @Override
                public void success(PnfsGetFileAttributes message) {
                    future.set(writeToken(message.getFileAttributes()));
                }

                @Override
                public void failure(int rc, Object error) {
                    CacheException exception = CacheExceptionFactory.exceptionOf(rc, Objects.toString(error, null));
                    future.setException(exception);
                }
            }, executor);
            return future;
        }
    });
}
Also used : SettableFuture(com.google.common.util.concurrent.SettableFuture) Optional(java.util.Optional) CacheException(diskCacheV111.util.CacheException) TimeoutCacheException(diskCacheV111.util.TimeoutCacheException) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) StorageInfo(diskCacheV111.vehicles.StorageInfo) PnfsGetFileAttributes(org.dcache.vehicles.PnfsGetFileAttributes) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) FileAttributes(org.dcache.vehicles.FileAttributes) PnfsGetFileAttributes(org.dcache.vehicles.PnfsGetFileAttributes) AbstractMessageCallback(org.dcache.cells.AbstractMessageCallback) FsPath(diskCacheV111.util.FsPath)

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