use of diskCacheV111.util.TimeoutCacheException in project dcache by dCache.
the class DelegationHandler method login.
private Subject login() throws DelegationException {
try {
Subject subject = new Subject();
X509Certificate[] chain = Axis.getCertificateChain().orElseThrow(() -> new DelegationException("User supplied no certificate."));
subject.getPublicCredentials().add(cf.generateCertPath(asList(chain)));
subject.getPrincipals().add(new Origin(InetAddresses.forUriString(Axis.getRemoteAddress())));
return loginStrategy.login(subject).getSubject();
} catch (CertificateException e) {
throw new DelegationException("Failed to process certificate chain.");
} catch (PermissionDeniedCacheException e) {
throw new DelegationException("User is not authorized.");
} catch (TimeoutCacheException e) {
throw new DelegationException("Internal timeout.");
} catch (CacheException e) {
throw new DelegationException(e.getMessage());
}
}
use of diskCacheV111.util.TimeoutCacheException in project dcache by dCache.
the class WriteHandleImpl method commit.
@Override
public synchronized void commit() throws IllegalStateException, InterruptedException, CacheException {
if (_state != HandleState.OPEN) {
throw new IllegalStateException("Handle is closed");
}
try {
_entry.setLastAccessTime((_atime == null) ? System.currentTimeMillis() : _atime);
_fileAttributes.setCreationTime(System.currentTimeMillis());
_fileAttributes.setAccessTime(System.currentTimeMillis());
long length = _entry.getReplicaSize();
verifyFileSize(length);
_fileAttributes.setSize(length);
boolean namespaceUpdated = false;
do {
/*
* We may run into timeout if PnfsManager or network is down.
* (NOTICE, that PnfsHandler converts NoRouteToCell into Timeout exception)
* In such situations we should re-try the request. If timeout exception
* is propagated, then file will be stored in error state, to recover it
* during the next restart.
*/
try {
registerFileAttributesInNameSpace();
namespaceUpdated = true;
} catch (TimeoutCacheException e) {
LOGGER.warn("Failed to update namespace: {}. Retrying in 15 s", e.getMessage());
TimeUnit.SECONDS.sleep(15);
}
} while (!namespaceUpdated);
_entry.update("Committing new file", r -> {
r.setFileAttributes(_fileAttributes);
/* In several situations, dCache requests a CACHED file
* without having any sticky flags on it. Such files are
* subject to immediate garbage collection if we are short on
* disk space. Thus to give other clients time to access the
* file, we mark it sticky for a short amount of time.
*/
if (_targetState == ReplicaState.CACHED && _stickyRecords.isEmpty()) {
long now = System.currentTimeMillis();
r.setSticky("self", now + HOLD_TIME, false);
}
/* Move entry to target state.
*/
for (StickyRecord record : _stickyRecords) {
r.setSticky(record.owner(), record.expire(), false);
}
return r.setState(_targetState);
});
setState(HandleState.COMMITTED);
} catch (CacheException e) {
/* If any of the PNFS operations return FILE_NOT_FOUND,
* then we change the target state and the close method
* will take care of removing the file.
*/
if (e.getRc() == CacheException.FILE_NOT_FOUND) {
_targetState = ReplicaState.REMOVED;
}
throw e;
}
}
use of diskCacheV111.util.TimeoutCacheException in project dcache by dCache.
the class AbstractFtpDoorV1 method ftp_mkd.
@Help("MKD <SP> <path> - Create a directory.")
public void ftp_mkd(String arg) throws FTPCommandException {
/**
* MKD
* 257
* 500, 501, 502, 421, 530, 550
*/
checkLoggedIn(FORBID_ANONYMOUS_USER);
checkFTPCommand(!arg.isEmpty(), 500, "Missing path argument");
FsPath path = absolutePath(arg);
String properDirectoryStringReply = path.stripPrefix(_doorRootPath).replaceAll("\"", "\"\"");
try {
_pnfs.createPnfsDirectory(path.toString());
/*
From RFC 959
....., upon successful completion of an MKD
command, the server should return a line of the form:
257<space>"<directory-name>"<space><commentary>
That is, the server will tell the user what string to use when
referring to the created directory. The directory name can
contain any character; embedded double-quotes should be escaped by
double-quotes (the "quote-doubling" convention).
For example, a user connects to the directory /usr/dm, and creates
a subdirectory, named pathname:
CWD /usr/dm
200 directory changed to /usr/dm
MKD pathname
257 "/usr/dm/pathname" directory created
An example with an embedded double quote:
MKD foo"bar
257 "/usr/dm/foo""bar" directory created
CWD /usr/dm/foo"bar
200 directory changed to /usr/dm/foo"bar
*/
reply("257 \"" + properDirectoryStringReply + "\" directory created");
} catch (PermissionDeniedCacheException e) {
throw new FTPCommandException(550, "Permission denied");
} catch (FileExistsCacheException e) {
throw new FTPCommandException(550, "\"" + properDirectoryStringReply + "\" directory already exists");
} catch (TimeoutCacheException e) {
throw new FTPCommandException(451, "Internal timeout, reason:" + e);
} catch (CacheException e) {
throw new FTPCommandException(550, "Cannot create directory, reason:" + e);
}
}
use of diskCacheV111.util.TimeoutCacheException 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;
}
use of diskCacheV111.util.TimeoutCacheException in project dcache by dCache.
the class ReservationCaches method buildOwnerDescriptionLookupCache.
/**
* Builds a loading cache for looking up space tokens by owner and description.
*/
public static LoadingCache<GetSpaceTokensKey, long[]> buildOwnerDescriptionLookupCache(CellStub spaceManager, Executor executor) {
return CacheBuilder.newBuilder().maximumSize(1000).expireAfterWrite(30, SECONDS).refreshAfterWrite(10, SECONDS).recordStats().build(new CacheLoader<GetSpaceTokensKey, long[]>() {
@Override
public long[] load(GetSpaceTokensKey key) throws Exception {
try {
return spaceManager.sendAndWait(createRequest(key)).getSpaceTokens();
} catch (TimeoutCacheException e) {
throw new SRMInternalErrorException("Space manager timeout", e);
} catch (InterruptedException e) {
throw new SRMInternalErrorException("Operation interrupted", e);
} catch (CacheException e) {
LOGGER.warn("GetSpaceTokens failed with rc={} error={}", e.getRc(), e.getMessage());
throw new SRMException("GetSpaceTokens failed with rc=" + e.getRc() + " error=" + e.getMessage(), e);
}
}
private GetSpaceTokens createRequest(GetSpaceTokensKey key) {
GetSpaceTokens message = new GetSpaceTokens(key.description);
message.setSubject(new Subject(true, key.principals, Collections.emptySet(), Collections.emptySet()));
return message;
}
@Override
public ListenableFuture<long[]> reload(GetSpaceTokensKey key, long[] oldValue) throws Exception {
final SettableFuture<long[]> future = SettableFuture.create();
CellStub.addCallback(spaceManager.send(createRequest(key)), new AbstractMessageCallback<GetSpaceTokens>() {
@Override
public void success(GetSpaceTokens message) {
future.set(message.getSpaceTokens());
}
@Override
public void failure(int rc, Object error) {
CacheException exception = CacheExceptionFactory.exceptionOf(rc, Objects.toString(error, null));
future.setException(exception);
}
}, executor);
return future;
}
});
}
Aggregations