use of dmg.cells.nucleus.NoRouteToCellException in project dcache by dCache.
the class HttpPoolMgrEngineV3 method runRestoreCollector.
private void runRestoreCollector() throws NoRouteToCellException, InterruptedException {
List<RestoreHandlerInfo> infos = _receiver.getAllRequests();
List<Object[]> agedList = new ArrayList<>();
for (RestoreHandlerInfo info : infos) {
try {
Object[] a = new Object[3];
a[0] = info;
String name = info.getName();
String pnfsId = name.substring(0, name.indexOf('@'));
//
// collect the paths
//
String path = (String) _pnfsPathMap.get(pnfsId);
if (path == null) {
path = getPathByPnfsId(pnfsId);
}
if (path == null) {
a[1] = pnfsId;
} else {
_pnfsPathMap.put(pnfsId, a[1] = path);
}
//
if (_addStorageInfo) {
FileAttributes fileAttributes = (FileAttributes) _fileAttributesMap.get(pnfsId);
if (fileAttributes == null) {
fileAttributes = getFileAttributesByPnfsId(pnfsId);
}
if (fileAttributes != null) {
StorageInfo storageInfo = fileAttributes.getStorageInfo();
if (_siDetails != null) {
// allows to select items
if (fileAttributes.isDefined(FileAttribute.SIZE)) {
storageInfo.setKey("size", String.valueOf(fileAttributes.getSize()));
}
storageInfo.setKey("new", String.valueOf(storageInfo.isCreatedOnly()));
storageInfo.setKey("stored", String.valueOf(storageInfo.isStored()));
storageInfo.setKey("sClass", fileAttributes.getStorageClass());
storageInfo.setKey("cClass", fileAttributes.getCacheClass());
storageInfo.setKey("hsm", fileAttributes.getHsm());
}
_fileAttributesMap.put(pnfsId, a[2] = storageInfo);
}
}
agedList.add(a);
} catch (Exception e) {
LOGGER.warn(e.toString(), e);
}
}
_lazyRestoreList = agedList;
}
use of dmg.cells.nucleus.NoRouteToCellException in project dcache by dCache.
the class UpdateQoSJob method doRun.
@Override
protected void doRun() {
if (arguments == null) {
setError(new IllegalArgumentException("no target qos given."));
return;
}
String targetQos = arguments.get(TARGET_QOS.getName());
if (targetQos == null) {
setError(new IllegalArgumentException("no target qos given."));
return;
}
QoSTransitionEngine engine = new QoSTransitionEngine(poolManager, poolMonitor, pnfsHandler, pinManager);
replyHandler = new QoSJobReplyHandler(executorService);
engine.setReplyHandler(replyHandler);
try {
engine.adjustQoS(path, targetQos, NetworkUtils.getCanonicalHostName());
} catch (URISyntaxException | CacheException | NoRouteToCellException e) {
setError(e);
return;
} catch (InterruptedException e) {
errorObject = e;
setState(State.CANCELLED);
completionHandler.jobInterrupted(this);
LOGGER.trace("doRun interrupted.");
return;
}
if (replyHandler.done()) {
setState(State.COMPLETED);
} else {
setState(State.WAITING);
}
}
use of dmg.cells.nucleus.NoRouteToCellException in project dcache by dCache.
the class SrmHandler method handleRequest.
public Object handleRequest(String requestName, Object request) throws RemoteException {
long startTimeStamp = System.currentTimeMillis();
// requestName values all start "srm". This is redundant, so may
// be removed when creating the session id. The initial character is
// converted to lowercase, so "srmPrepareToPut" becomes "prepareToPut".
String session = "srm2:" + Character.toLowerCase(requestName.charAt(3)) + requestName.substring(4);
try (JDC ignored = JDC.createSession(session)) {
for (RequestLogger logger : loggers) {
logger.request(requestName, request);
}
Subject user = Subject.getSubject(AccessController.getContext());
Object response;
if (requestName.equals("srmPing")) {
// Ping is special as it isn't authenticated and unable to return a failure
response = new SrmPingResponse("v2.2", pingExtraInfo);
} else {
try {
response = dispatch(user, requestName, request);
} catch (SRMInternalErrorException e) {
LOGGER.error(e.getMessage());
response = getFailedResponse(requestName, e.getStatusCode(), "Authentication failed (server log contains additional information).");
} catch (SRMAuthorizationException e) {
LOGGER.info(e.getMessage());
response = getFailedResponse(requestName, e.getStatusCode(), "Permission denied.");
} catch (SRMAuthenticationException e) {
LOGGER.warn(e.getMessage());
response = getFailedResponse(requestName, e.getStatusCode(), "Authentication failed (server log contains additional information).");
} catch (SRMException e) {
response = getFailedResponse(requestName, e.getStatusCode(), e.getMessage());
} catch (PermissionDeniedCacheException e) {
response = getFailedResponse(requestName, TStatusCode.SRM_AUTHORIZATION_FAILURE, e.getMessage());
} catch (CacheException e) {
response = getFailedResponse(requestName, TStatusCode.SRM_INTERNAL_ERROR, e.getMessage());
} catch (InterruptedException e) {
response = getFailedResponse(requestName, TStatusCode.SRM_FATAL_INTERNAL_ERROR, "Server shutdown.");
} catch (NoRouteToCellException e) {
LOGGER.error(e.getMessage());
response = getFailedResponse(requestName, TStatusCode.SRM_INTERNAL_ERROR, "SRM backend serving this request is currently offline.");
}
}
long time = System.currentTimeMillis() - startTimeStamp;
for (RequestLogger logger : loggers) {
logger.response(requestName, request, response, user, time);
}
return response;
}
}
use of dmg.cells.nucleus.NoRouteToCellException in project dcache by dCache.
the class SrmHandler method dispatch.
private Object dispatch(Subject subject, String requestName, Object request) throws CacheException, InterruptedException, SRMException, NoRouteToCellException {
X509Credential credential = Axis.getDelegatedCredential().orElse(null);
String remoteIP = Axis.getRemoteAddress();
String remoteHost = isClientDNSLookup ? InetAddresses.forUriString(remoteIP).getCanonicalHostName() : remoteIP;
Set<LoginAttribute> loginAttributes = AuthenticationHandler.getLoginAttributes(Axis.getHttpServletRequest());
Function<Object, SrmRequest> toMessage = req -> new SrmRequest(subject, loginAttributes, credential, remoteHost, requestName, req);
try {
switch(requestName) {
case "srmGetRequestTokens":
return dispatch((SrmGetRequestTokensRequest) request, toMessage);
case "srmGetRequestSummary":
return dispatch((SrmGetRequestSummaryRequest) request, toMessage);
case "srmReleaseFiles":
return dispatch((SrmReleaseFilesRequest) request, toMessage);
case "srmExtendFileLifeTime":
// special processing.
return dispatch(request, toMessage);
default:
return dispatch(request, toMessage);
}
} catch (ExecutionException e) {
Throwables.propagateIfInstanceOf(e.getCause(), SRMException.class);
Throwables.propagateIfInstanceOf(e.getCause(), CacheException.class);
Throwables.propagateIfInstanceOf(e.getCause(), NoRouteToCellException.class);
Throwables.throwIfUnchecked(e);
throw new RuntimeException(e);
}
}
use of dmg.cells.nucleus.NoRouteToCellException in project dcache by dCache.
the class ProbeResponseEngine method queryUrl.
@Override
public void queryUrl(HttpRequest request) throws HttpException {
try {
String[] urlItems = request.getRequestTokens();
if (urlItems.length < 2) {
throw new HttpException(404, "No such property");
}
/* urlItems[0] is the mount point.
*/
BeanQueryMessage queryMessage = (urlItems.length == 3) ? new BeanQuerySinglePropertyMessage(urlItems[2]) : new BeanQueryAllPropertiesMessage();
BeanQueryMessage queryReply = stub.sendAndWait(new CellPath(urlItems[1]), queryMessage);
request.setContentType("application/json; charset=utf-8");
Writer writer = new OutputStreamWriter(request.getOutputStream(), UTF_8);
writer.append(new GsonBuilder().serializeSpecialFloatingPointValues().setPrettyPrinting().disableHtmlEscaping().create().toJson(queryReply.getResult()));
writer.flush();
} catch (NoRouteToCellException e) {
throw new HttpException(503, "The cell was unreachable, suspect trouble.");
} catch (TimeoutCacheException e) {
throw new HttpException(503, "The cell took too long to reply, suspect trouble.");
} catch (InvalidMessageCacheException e) {
throw new HttpException(404, "No such property");
} catch (CacheException | IOException e) {
throw new HttpException(500, e.getMessage());
} catch (InterruptedException e) {
throw new HttpException(503, "Received interrupt whilst processing data. Please try again later.");
}
}
Aggregations