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);
}
}
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);
}
}
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);
}
}
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()));
}
}
Aggregations