use of dmg.cells.nucleus.NoRouteToCellException in project dcache by dCache.
the class LoginManager method messageArrived.
@Override
public void messageArrived(CellMessage envelope) {
Serializable message = envelope.getMessageObject();
if (_loginBrokerPublisher != null) {
if (message instanceof NoRouteToCellException) {
_loginBrokerPublisher.messageArrived((NoRouteToCellException) message);
} else if (message instanceof LoginBrokerInfoRequest) {
_loginBrokerPublisher.messageArrived((LoginBrokerInfoRequest) message);
}
}
// Try delivering message to all children.
if (message instanceof OfInterestToChildren) {
for (String child : _children.keySet()) {
CellMessage msg = envelope.clone();
msg.getDestinationPath().add(child);
sendMessage(msg);
}
}
}
use of dmg.cells.nucleus.NoRouteToCellException in project dcache by dCache.
the class LoginManager method validateUser.
@Override
public boolean validateUser(String userName, String password) {
String[] request = { "request", userName, "check-password", userName, password };
try {
CellMessage msg = new CellMessage(_authenticator, request);
msg = getNucleus().sendAndWait(msg, (long) 10000);
if (msg == null) {
LOGGER.warn("Pam request timed out {}", Thread.currentThread().getStackTrace());
return false;
}
Object[] r = (Object[]) msg.getMessageObject();
return (Boolean) r[5];
} catch (NoRouteToCellException e) {
LOGGER.warn(e.getMessage());
return false;
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
return false;
} catch (ExecutionException e) {
LOGGER.warn(e.getCause().getMessage());
return false;
}
}
use of dmg.cells.nucleus.NoRouteToCellException in project dcache by dCache.
the class CoreRoutingManager method messageArrived.
@Override
public void messageArrived(CellMessage msg) {
Serializable obj = msg.getMessageObject();
if (obj instanceof CoreRouteUpdate) {
String domain = msg.getSourceAddress().getCellDomainName();
if (updates.put(domain, (CoreRouteUpdate) obj) == null) {
executor.execute(() -> {
CoreRouteUpdate update = updates.remove(domain);
updateTopicRoutes(domain, update.getTopics(), update.getZone());
updateQueueRoutes(domain, update.getExports(), update.getZone());
});
}
} else if (obj instanceof GetAllDomainsRequest) {
CellTunnelInfo tunnel;
synchronized (this) {
tunnel = Iterables.getFirst(coreTunnels.values(), null);
}
if (role == CellDomainRole.SATELLITE && tunnel != null) {
msg.getDestinationPath().insert(new CellPath(nucleus.getCellName(), tunnel.getRemoteCellDomainInfo().getCellDomainName()));
nucleus.sendMessage(msg, false, true, false);
} else {
Map<String, Collection<String>> domains = new HashMap<>();
synchronized (this) {
domains.put(getCellDomainName(), new ArrayList<>(localConsumers.values()));
Stream.of(coreTunnels, satelliteTunnels).flatMap(map -> map.values().stream()).map(CellTunnelInfo::getRemoteCellDomainInfo).map(CellDomainInfo::getCellDomainName).forEach(domain -> domains.put(domain, new ArrayList<>()));
queueRoutes.asMap().forEach((domain, cells) -> domains.put(domain, Lists.newArrayList(cells)));
}
msg.revertDirection();
msg.setMessageObject(new GetAllDomainsReply(domains));
sendMessage(msg);
}
} else if (obj instanceof NoRouteToCellException) {
LOG.info(((NoRouteToCellException) obj).getMessage());
} else if (obj instanceof PeerShutdownNotification) {
PeerShutdownNotification notification = (PeerShutdownNotification) obj;
String remoteDomain = notification.getDomainName();
synchronized (this) {
coreTunnels.values().stream().filter(i -> i.getRemoteCellDomainInfo().getCellDomainName().equals(remoteDomain)).forEach(i -> {
CellRoute route = new CellRoute(null, i.getTunnel(), i.getRemoteCellDomainInfo().getZone(), CellRoute.DEFAULT);
delayedDefaultRoutes.remove(route);
if (!hasAlternativeDefaultRoute(route)) {
installDefaultRoute();
}
try {
nucleus.routeDelete(route);
} catch (IllegalArgumentException ignored) {
}
});
}
msg.revertDirection();
sendMessage(msg);
} else {
LOG.warn("Unidentified message ignored: {}", obj);
}
}
use of dmg.cells.nucleus.NoRouteToCellException in project dcache by dCache.
the class LocationMgrTunnel method messageArrived.
@Override
public void messageArrived(MessageEvent me) {
if (me instanceof RoutedMessageEvent) {
CellMessage msg = me.getMessage();
try {
_messagesToTunnel.increment();
_output.writeObject(msg);
} catch (IOException e) {
NDC.push(_remoteDomainInfo.toString());
try {
kill();
_log.warn("Error while sending message: {}", e.getMessage());
NoRouteToCellException noRoute = new NoRouteToCellException(msg, "Communication failure. Message could not be delivered.");
CellMessage envelope = new CellMessage(msg.getSourcePath().revert(), noRoute);
envelope.setLastUOID(msg.getUOID());
_nucleus.sendMessage(envelope, true, true, true);
} finally {
NDC.pop();
}
}
} else {
super.messageArrived(me);
}
}
use of dmg.cells.nucleus.NoRouteToCellException in project dcache by dCache.
the class Inotify method select.
private synchronized SelectionResult select(String channelId, BiConsumer<String, JsonNode> receiver, InotifySelector selector) {
try {
PnfsId pnfsid = lookup(selector);
WatchIdentity watchId = new WatchIdentity(channelId, pnfsid);
InotifySelection selection = selectionByWatch.get(watchId);
if (selection == null) {
selection = new InotifySelection(receiver, selector, watchId);
selectionByWatch.put(watchId, selection);
selectionByPnfsId.put(pnfsid, selection);
updateZK();
return SelectionResult.created(selection);
} else {
selection.accept(selector);
updateZK();
return SelectionResult.merged(selection);
}
} catch (PermissionDeniedCacheException e) {
return SelectionResult.permissionDenied("Not allowed.");
} catch (FileNotFoundCacheException e) {
return SelectionResult.resourceNotFound("Problem with path: " + e.getMessage());
} catch (NotDirCacheException e) {
return SelectionResult.conditionFailed(e.getMessage());
} catch (CacheException | NoRouteToCellException e) {
return SelectionResult.internalError(e.getMessage());
} catch (InterruptedException e) {
return SelectionResult.internalError("Service going down");
}
}
Aggregations