Search in sources :

Example 41 with TimeoutCacheException

use of diskCacheV111.util.TimeoutCacheException in project dcache by dCache.

the class Storage method performRemoteTransfer.

private String performRemoteTransfer(SRMUser srmUser, URI remoteTURL, FsPath actualFilePath, boolean store, Map<String, String> extraInfo, Long remoteCredentialId, CopyCallbacks callbacks) throws SRMException {
    DcacheUser user = asDcacheUser(srmUser);
    _log.debug("performRemoteTransfer performing {}", (store ? "store" : "restore"));
    IpProtocolInfo protocolInfo;
    InetSocketAddress remoteAddr = new InetSocketAddress(remoteTURL.getHost(), URIs.optionalPortWithDefault(remoteTURL).orElseThrow(() -> new SRMException("Unknown port number for TURL " + remoteTURL)));
    X509Credential credential = null;
    RequestCredential result = RequestCredential.getRequestCredential(remoteCredentialId);
    if (result != null) {
        credential = result.getDelegatedCredential();
    }
    switch(remoteTURL.getScheme().toLowerCase()) {
        case "gsiftp":
            if (credential == null) {
                throw new SRMAuthorizationException("Cannot authenticate " + "with remote gsiftp service; credential " + "delegation required.");
            }
            RemoteGsiftpTransferProtocolInfo gsiftpProtocolInfo = new RemoteGsiftpTransferProtocolInfo("RemoteGsiftpTransfer", 1, 1, remoteAddr, remoteTURL.toString(), getCellName(), getCellDomainName(), config.getBuffer_size(), config.getTcp_buffer_size(), credential, Optional.empty());
            gsiftpProtocolInfo.setEmode(true);
            gsiftpProtocolInfo.setNumberOfStreams(config.getParallel_streams());
            protocolInfo = gsiftpProtocolInfo;
            break;
        case "https":
            protocolInfo = new RemoteHttpsDataTransferProtocolInfo("RemoteHttpsDataTransfer", 1, 1, remoteAddr, remoteTURL.toString(), isVerifyRequired(extraInfo), httpHeaders(extraInfo), credential, Optional.empty());
            break;
        case "http":
            protocolInfo = new RemoteHttpDataTransferProtocolInfo("RemoteHttpDataTransfer", 1, 1, remoteAddr, remoteTURL.toString(), isVerifyRequired(extraInfo), httpHeaders(extraInfo), Optional.empty());
            break;
        default:
            throw new SRMException("protocol " + remoteTURL.getScheme() + " is not supported");
    }
    RemoteTransferManagerMessage request = new RemoteTransferManagerMessage(remoteTURL, actualFilePath, store, remoteCredentialId, protocolInfo);
    request.setSubject(user.getSubject());
    request.setRestriction(user.getRestriction());
    try {
        RemoteTransferManagerMessage reply = _transferManagerStub.sendAndWait(request);
        long id = reply.getId();
        _log.debug("received first RemoteGsiftpTransferManagerMessage " + "reply from transfer manager, id ={}", id);
        TransferInfo info = new TransferInfo(id, callbacks);
        _log.debug("storing info for callerId = {}", id);
        callerIdToHandler.put(id, info);
        return String.valueOf(id);
    } catch (NoRouteToCellException | TimeoutCacheException e) {
        throw new SRMInternalErrorException("Transfer manager is unavailable: " + e.getMessage(), e);
    } catch (CacheException e) {
        throw new SRMException("TransferManager error: " + e.getMessage(), e);
    } catch (InterruptedException e) {
        throw new SRMException("Request to transfer manager got interruptd", e);
    }
}
Also used : SRMAuthorizationException(org.dcache.srm.SRMAuthorizationException) RequestCredential(org.dcache.srm.request.RequestCredential) 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) InetSocketAddress(java.net.InetSocketAddress) RemoteGsiftpTransferProtocolInfo(diskCacheV111.vehicles.transferManager.RemoteGsiftpTransferProtocolInfo) SRMInternalErrorException(org.dcache.srm.SRMInternalErrorException) SRMException(org.dcache.srm.SRMException) X509Credential(eu.emi.security.authn.x509.X509Credential) RemoteHttpsDataTransferProtocolInfo(diskCacheV111.vehicles.RemoteHttpsDataTransferProtocolInfo) RemoteTransferManagerMessage(diskCacheV111.vehicles.transferManager.RemoteTransferManagerMessage) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) IpProtocolInfo(diskCacheV111.vehicles.IpProtocolInfo) RemoteHttpDataTransferProtocolInfo(diskCacheV111.vehicles.RemoteHttpDataTransferProtocolInfo) TimeoutCacheException(diskCacheV111.util.TimeoutCacheException)

Example 42 with TimeoutCacheException

use of diskCacheV111.util.TimeoutCacheException in project dcache by dCache.

the class Storage method extendPinLifetime.

/**
 * @param user           User ID
 * @param pinId          Id of a valid pin
 * @param newPinLifetime new lifetime in millis to assign to pin
 * @return long lifetime left for pin in millis
 */
@Override
public long extendPinLifetime(SRMUser user, String fileId, String pinId, long newPinLifetime) throws SRMException {
    try {
        if (PinCompanion.isFakePinId(pinId)) {
            return newPinLifetime;
        }
        PnfsId pnfsId = new PnfsId(fileId);
        PinManagerExtendPinMessage extendLifetime = new PinManagerExtendPinMessage(FileAttributes.ofPnfsId(pnfsId), Long.parseLong(pinId), newPinLifetime);
        extendLifetime.setSubject(asDcacheUser(user).getSubject());
        extendLifetime = _pinManagerStub.sendAndWait(extendLifetime);
        return extendLifetime.getLifetime();
    } catch (IllegalArgumentException e) {
        throw new SRMException("Invalid PNFS ID: " + fileId, e);
    } catch (NoRouteToCellException | TimeoutCacheException e) {
        throw new SRMInternalErrorException("PinManager is unavailable: " + e.getMessage(), e);
    } catch (CacheException e) {
        throw new SRMException("extendPinLifetime failed, PinManagerExtendLifetimeMessage.returnCode=" + e.getRc() + " errorObject = " + e.getMessage());
    } catch (InterruptedException e) {
        throw new SRMInternalErrorException("Request to PinManager got interrupted", e);
    }
}
Also used : SRMInternalErrorException(org.dcache.srm.SRMInternalErrorException) SRMException(org.dcache.srm.SRMException) 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) PnfsId(diskCacheV111.util.PnfsId) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) PinManagerExtendPinMessage(org.dcache.pinmanager.PinManagerExtendPinMessage) TimeoutCacheException(diskCacheV111.util.TimeoutCacheException)

Example 43 with TimeoutCacheException

use of diskCacheV111.util.TimeoutCacheException in project dcache by dCache.

the class Storage method localCopy.

@Override
public void localCopy(SRMUser srmUser, URI fromSurl, String localTransferPath) throws SRMException {
    DcacheUser user = asDcacheUser(srmUser);
    FsPath actualFromFilePath = getPath(fromSurl);
    FsPath actualToFilePath = FsPath.create(localTransferPath);
    long id = getNextMessageID();
    _log.debug("localCopy for user {} from actualFromFilePath to actualToFilePath", user);
    try {
        CopyManagerMessage copyRequest = new CopyManagerMessage(actualFromFilePath.toString(), actualToFilePath.toString(), id, config.getBuffer_size(), config.getTcp_buffer_size());
        copyRequest.setSubject(user.getSubject());
        copyRequest.setRestriction(user.getRestriction());
        _transferManagerStub.sendAndWait(copyRequest);
    } catch (NoRouteToCellException | TimeoutCacheException e) {
        _log.error("CopyManager is unavailable");
        throw new SRMInternalErrorException("CopyManager is unavailable: " + e.getMessage(), e);
    } catch (CacheException e) {
        String msg = " local copy failed with code =" + e.getRc() + " details: " + e.getMessage();
        _log.warn(msg);
        throw new SRMException(msg, e);
    } catch (InterruptedException e) {
        throw new SRMException("Request to CopyManager was interrupted", e);
    }
}
Also used : SRMInternalErrorException(org.dcache.srm.SRMInternalErrorException) SRMException(org.dcache.srm.SRMException) 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) CopyManagerMessage(diskCacheV111.vehicles.CopyManagerMessage) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) FsPath(diskCacheV111.util.FsPath) TimeoutCacheException(diskCacheV111.util.TimeoutCacheException)

Example 44 with TimeoutCacheException

use of diskCacheV111.util.TimeoutCacheException in project dcache by dCache.

the class Storage method listDirectory.

@Override
public List<FileMetaData> listDirectory(SRMUser user, URI surl, final boolean verbose, int offset, int count) throws SRMException {
    try {
        FsPath path = getPath(surl);
        Subject subject = asDcacheUser(user).getSubject();
        Restriction restriction = asDcacheUser(user).getRestriction();
        FmdListPrinter printer = verbose ? new VerboseListPrinter() : new FmdListPrinter();
        Range<Integer> range = offset < Integer.MAX_VALUE - count ? Range.closedOpen(offset, offset + count) : Range.atLeast(offset);
        _listSource.printDirectory(subject, restriction, printer, path, null, range);
        return printer.getResult();
    } catch (TimeoutCacheException e) {
        throw new SRMInternalErrorException("Internal name space timeout", e);
    } catch (InterruptedException e) {
        throw new SRMInternalErrorException("List aborted by administrator", e);
    } catch (NotDirCacheException e) {
        throw new SRMInvalidPathException("Not a directory", e);
    } catch (FileNotFoundCacheException e) {
        throw new SRMInvalidPathException("No such file or directory", e);
    } catch (PermissionDeniedCacheException e) {
        throw new SRMAuthorizationException("Permission denied", e);
    } catch (CacheException e) {
        throw new SRMException(String.format("List failed [rc=%d,msg=%s]", e.getRc(), e.getMessage()));
    }
}
Also used : 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) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) NotDirCacheException(diskCacheV111.util.NotDirCacheException) FsPath(diskCacheV111.util.FsPath) TimeoutCacheException(diskCacheV111.util.TimeoutCacheException)

Aggregations

TimeoutCacheException (diskCacheV111.util.TimeoutCacheException)44 CacheException (diskCacheV111.util.CacheException)42 FileNotFoundCacheException (diskCacheV111.util.FileNotFoundCacheException)25 PermissionDeniedCacheException (diskCacheV111.util.PermissionDeniedCacheException)25 FileExistsCacheException (diskCacheV111.util.FileExistsCacheException)20 FileIsNewCacheException (diskCacheV111.util.FileIsNewCacheException)18 NotDirCacheException (diskCacheV111.util.NotDirCacheException)17 FileCorruptedCacheException (diskCacheV111.util.FileCorruptedCacheException)15 NoRouteToCellException (dmg.cells.nucleus.NoRouteToCellException)15 SRMException (org.dcache.srm.SRMException)15 SRMInternalErrorException (org.dcache.srm.SRMInternalErrorException)15 FsPath (diskCacheV111.util.FsPath)14 SRMAuthorizationException (org.dcache.srm.SRMAuthorizationException)11 Subject (javax.security.auth.Subject)10 SRMInvalidPathException (org.dcache.srm.SRMInvalidPathException)10 PnfsHandler (diskCacheV111.util.PnfsHandler)8 Restriction (org.dcache.auth.attributes.Restriction)7 FileAttributes (org.dcache.vehicles.FileAttributes)7 NotFileCacheException (diskCacheV111.util.NotFileCacheException)6 InetSocketAddress (java.net.InetSocketAddress)4