use of dmg.cells.nucleus.NoRouteToCellException in project dcache by dCache.
the class PoolHistoriesHandler method getAggregateFileLifetime.
/*
* First try to fetch the stored aggregate histogram.
* Failing that, do the aggregation here.
*/
public CountingHistogram getAggregateFileLifetime(String poolGroup, List<PoolInfoWrapper> pools) {
AggregateFileLifetimeRequestMessage message = new AggregateFileLifetimeRequestMessage(poolGroup);
try {
message = historyService.sendAndWait(message, historyService.getTimeoutInMillis());
} catch (NoRouteToCellException | InterruptedException | TimeoutCacheException e) {
LOGGER.debug("Could not fetch aggregated lifetime data for {}: {}.", poolGroup, e.getMessage());
} catch (CacheException e) {
LOGGER.warn("Could not fetch aggregated lifetime data for {}: {}.", poolGroup, e.getMessage());
}
Serializable error = message.getErrorObject();
if (error != null) {
LOGGER.warn("Could not fetch aggregated lifetime data for {}: {}.", message.getPoolGroup(), error);
}
CountingHistogram histogram = message.getAggregateLifetime();
/*
* If missing, try to merge here.
*/
if (histogram == null) {
LOGGER.info("Fetch of aggregated lifetime histogram unsuccessful; " + "merging data here.");
histogram = PoolInfoCollectorUtils.mergeLastAccess(pools);
}
return histogram;
}
use of dmg.cells.nucleus.NoRouteToCellException in project dcache by dCache.
the class MovePinRequestProcessor method messageArrived.
public PinManagerExtendPinMessage messageArrived(PinManagerExtendPinMessage message) throws CacheException, InterruptedException {
try {
Pin pin = _dao.get(_dao.where().pnfsId(message.getFileAttributes().getPnfsId()).id(message.getPinId()));
if (pin == null) {
throw new InvalidMessageCacheException("Pin does not exist");
} else if (!_pdp.canExtend(message.getSubject(), pin)) {
throw new PermissionDeniedCacheException("Access denied");
} else if (pin.getState() == PINNING) {
throw new InvalidMessageCacheException("File is not pinned yet");
} else if (pin.getState() == READY_TO_UNPIN || pin.getState() == UNPINNING || pin.getState() == FAILED_TO_UNPIN) {
throw new InvalidMessageCacheException("Pin is no longer valid");
}
if (_maxLifetime > -1) {
message.setLifetime(Math.min(_maxLifetimeUnit.toMillis(_maxLifetime), message.getLifetime()));
}
long lifetime = message.getLifetime();
if (pin.hasRemainingLifetimeLessThan(lifetime)) {
long now = System.currentTimeMillis();
Date date = (lifetime == -1) ? null : new Date(now + lifetime);
move(pin, pin.getPool(), date);
message.setExpirationTime(date);
} else {
message.setExpirationTime(pin.getExpirationTime());
}
LOGGER.info("Extended pin for {} ({})", pin.getPnfsId(), pin.getPinId());
return message;
} catch (NoRouteToCellException e) {
throw new CacheException("Failed to extend pin due to communication failure: " + e.getDestinationPath(), e);
}
}
use of dmg.cells.nucleus.NoRouteToCellException in project dcache by dCache.
the class LegacyAdminShellCommand method runAsciiMode.
private void runAsciiMode() throws IOException {
Ansi.setEnabled(_console.getTerminal().isAnsiSupported() && _useColors);
while (!_adminShellThread.isInterrupted()) {
String prompt = Ansi.ansi().bold().a(_shell.getPrompt()).boldOff().toString();
String str = _console.readLine(prompt);
Object result;
try {
if (str == null) {
throw new CommandExitException();
}
if (_useColors) {
String trimmed = str.trim();
if (trimmed.startsWith("help ")) {
str = "help -format=" + HelpFormat.ANSI + trimmed.substring(4);
} else if (trimmed.equals("help")) {
str = "help -format=" + HelpFormat.ANSI;
}
}
result = _shell.executeCommand(str);
} catch (IllegalArgumentException e) {
result = e.getMessage() + " (Please check the spelling of your command or your config file(s)!)";
} catch (SerializationException e) {
result = "There is a bug here, please report to support@dcache.org";
LOGGER.error("This must be a bug, please report to support@dcache.org.", e);
} catch (CommandSyntaxException e) {
result = e;
} catch (CommandEvaluationException e) {
result = e.getMessage();
} catch (CommandExitException e) {
break;
} catch (CommandPanicException e) {
result = "Command '" + str + "' triggered a bug (" + e.getTargetException() + "); the service log file contains additional information. Please " + "contact support@dcache.org.";
} catch (CommandException e) {
result = e.getMessage();
} catch (NoRouteToCellException e) {
result = "Cell name does not exist or cell is not started: " + e.getMessage();
LOGGER.warn("The cell the command was sent to is no " + "longer there: {}", e.getMessage());
} catch (InterruptedException e) {
result = e.getMessage();
} catch (RuntimeException e) {
result = String.format("Command '%s' triggered a bug (%s); please" + " locate this message in the log file of the admin service and" + " send an email to support@dcache.org with this line and the" + " following stack-trace", str, e);
LOGGER.error((String) result, e);
} catch (Exception e) {
result = e.getMessage();
if (result == null) {
result = e.getClass().getSimpleName() + ": (null)";
}
}
if (result != null) {
String s;
if (result instanceof CommandSyntaxException) {
CommandSyntaxException e = (CommandSyntaxException) result;
Ansi sb = Ansi.ansi();
sb.fg(RED).a("Syntax error: ").a(e.getMessage()).newline();
String help = e.getHelpText();
if (help != null) {
sb.fg(CYAN);
sb.a("Help : ").newline();
sb.a(help);
}
s = sb.reset().toString();
} else {
s = Strings.toMultilineString(result);
}
if (!s.isEmpty()) {
_console.println(s);
_console.flush();
}
}
}
}
use of dmg.cells.nucleus.NoRouteToCellException in project dcache by dCache.
the class ReservationCaches method buildSpaceLookupCache.
/**
* Build a loading cache for looking up space reservations by space token.
*/
public static LoadingCache<String, Optional<Space>> buildSpaceLookupCache(CellStub spaceManager, Executor executor) {
return CacheBuilder.newBuilder().maximumSize(1000).expireAfterWrite(10, MINUTES).refreshAfterWrite(30, SECONDS).recordStats().build(new CacheLoader<String, Optional<Space>>() {
@Override
public Optional<Space> load(String token) throws CacheException, NoRouteToCellException, InterruptedException {
Space space = spaceManager.sendAndWait(new GetSpaceMetaData(token)).getSpaces()[0];
return Optional.ofNullable(space);
}
@Override
public ListenableFuture<Optional<Space>> reload(String token, Optional<Space> oldValue) {
final SettableFuture<Optional<Space>> future = SettableFuture.create();
CellStub.addCallback(spaceManager.send(new GetSpaceMetaData(token)), new AbstractMessageCallback<GetSpaceMetaData>() {
@Override
public void success(GetSpaceMetaData message) {
future.set(Optional.ofNullable(message.getSpaces()[0]));
}
@Override
public void failure(int rc, Object error) {
CacheException exception = CacheExceptionFactory.exceptionOf(rc, Objects.toString(error, null));
future.setException(exception);
}
}, executor);
return future;
}
});
}
use of dmg.cells.nucleus.NoRouteToCellException in project dcache by dCache.
the class AbstractCellsTopology method buildTopologyMap.
protected Map<String, CellDomainNode> buildTopologyMap(String domain) throws InterruptedException {
Queue<CellDomainNode> queue = new ArrayDeque<>();
Map<String, CellDomainNode> map = new HashMap<>();
CellDomainNode node = new CellDomainNode(domain, "System@" + domain);
queue.add(node);
map.put(node.getName(), node);
while ((node = queue.poll()) != null) {
try {
node.setLinks(getCellTunnelInfos(node.getAddress()));
for (CellDomainNode connectedNode : getConnectedNodes(node)) {
String name = connectedNode.getName();
if (!map.containsKey(name)) {
queue.add(connectedNode);
map.put(name, connectedNode);
}
}
} catch (NoRouteToCellException | CacheException e) {
LOGGER.warn("Failed to fetch topology info from {}: {}", node.getAddress(), e.getMessage());
}
}
return map;
}
Aggregations