Search in sources :

Example 46 with NoRouteToCellException

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);
        }
    }
}
Also used : CellMessage(dmg.cells.nucleus.CellMessage) Serializable(java.io.Serializable) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) InetAddresses.toUriString(com.google.common.net.InetAddresses.toUriString)

Example 47 with NoRouteToCellException

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;
    }
}
Also used : CellMessage(dmg.cells.nucleus.CellMessage) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) InetAddresses.toUriString(com.google.common.net.InetAddresses.toUriString) ExecutionException(java.util.concurrent.ExecutionException)

Example 48 with NoRouteToCellException

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);
    }
}
Also used : CellPath(dmg.cells.nucleus.CellPath) Iterables(com.google.common.collect.Iterables) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) CellAddressCore(dmg.cells.nucleus.CellAddressCore) CellMessage(dmg.cells.nucleus.CellMessage) LoggerFactory(org.slf4j.LoggerFactory) CellDomainInfo(dmg.cells.nucleus.CellDomainInfo) HashMap(java.util.HashMap) Multimap(com.google.common.collect.Multimap) CellNucleus(dmg.cells.nucleus.CellNucleus) CellRoute(dmg.cells.nucleus.CellRoute) ArrayList(java.util.ArrayList) ConcurrentMap(java.util.concurrent.ConcurrentMap) HashSet(java.util.HashSet) HashMultimap(com.google.common.collect.HashMultimap) Lists(com.google.common.collect.Lists) Collectors.toMap(java.util.stream.Collectors.toMap) Map(java.util.Map) ExecutorService(java.util.concurrent.ExecutorService) PrintWriter(java.io.PrintWriter) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) CellEventListener(dmg.cells.nucleus.CellEventListener) FutureCellMessageAnswerable(dmg.cells.nucleus.FutureCellMessageAnswerable) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) CellTunnelInfo(dmg.cells.nucleus.CellTunnelInfo) Set(java.util.Set) CellEvent(dmg.cells.nucleus.CellEvent) GuardedBy(javax.annotation.concurrent.GuardedBy) Sets(com.google.common.collect.Sets) Executors(java.util.concurrent.Executors) Serializable(java.io.Serializable) ExecutionException(java.util.concurrent.ExecutionException) Futures(com.google.common.util.concurrent.Futures) CellAdapter(dmg.cells.nucleus.CellAdapter) List(java.util.List) Stream(java.util.stream.Stream) Args(org.dcache.util.Args) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) Optional(java.util.Optional) CellPath(dmg.cells.nucleus.CellPath) CellDomainRole(dmg.cells.nucleus.CellDomainRole) Collections(java.util.Collections) Serializable(java.io.Serializable) CellRoute(dmg.cells.nucleus.CellRoute) CellDomainInfo(dmg.cells.nucleus.CellDomainInfo) ArrayList(java.util.ArrayList) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) Collectors.toMap(java.util.stream.Collectors.toMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) CellTunnelInfo(dmg.cells.nucleus.CellTunnelInfo)

Example 49 with NoRouteToCellException

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);
    }
}
Also used : CellMessage(dmg.cells.nucleus.CellMessage) RoutedMessageEvent(dmg.cells.nucleus.RoutedMessageEvent) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) IOException(java.io.IOException)

Example 50 with NoRouteToCellException

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");
    }
}
Also used : PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) CacheException(diskCacheV111.util.CacheException) NotDirCacheException(diskCacheV111.util.NotDirCacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) PnfsId(diskCacheV111.util.PnfsId) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) NotDirCacheException(diskCacheV111.util.NotDirCacheException)

Aggregations

NoRouteToCellException (dmg.cells.nucleus.NoRouteToCellException)67 CacheException (diskCacheV111.util.CacheException)55 TimeoutCacheException (diskCacheV111.util.TimeoutCacheException)25 PermissionDeniedCacheException (diskCacheV111.util.PermissionDeniedCacheException)22 FileNotFoundCacheException (diskCacheV111.util.FileNotFoundCacheException)19 ArrayList (java.util.ArrayList)15 ApiOperation (io.swagger.annotations.ApiOperation)14 ApiResponses (io.swagger.annotations.ApiResponses)14 Produces (javax.ws.rs.Produces)14 BadRequestException (javax.ws.rs.BadRequestException)13 InternalServerErrorException (javax.ws.rs.InternalServerErrorException)13 Path (javax.ws.rs.Path)13 CellPath (dmg.cells.nucleus.CellPath)11 ExecutionException (java.util.concurrent.ExecutionException)11 ForbiddenException (javax.ws.rs.ForbiddenException)11 GET (javax.ws.rs.GET)11 FsPath (diskCacheV111.util.FsPath)10 PnfsId (diskCacheV111.util.PnfsId)10 SRMException (org.dcache.srm.SRMException)10 SRMInternalErrorException (org.dcache.srm.SRMInternalErrorException)10