private void restoreCacheContent() { // Add outgoing server sessions hosted locally to the cache (using new nodeID) for (LocalOutgoingServerSession session : localRoutingTable.getServerRoutes()) { for (DomainPair pair : session.getOutgoingDomainPairs()) { addServerRoute(pair, session); } } // Add component sessions hosted locally to the cache (using new nodeID) and remove traces to old nodeID for (RoutableChannelHandler route : localRoutingTable.getComponentRoute()) { addComponentRoute(route.getAddress(), route); } // Add client sessions hosted locally to the cache (using new nodeID) for (LocalClientSession session : localRoutingTable.getClientRoutes()) { addClientRoute(session.getAddress(), session); } }
List<ClientSession> sessions = new ArrayList<>(); for (JID address : getRoutes(recipientJID, packet.getFrom())) { ClientSession session = getClientRoute(address); if (session != null && session.isInitialized()) { sessions.add(session); List<ClientSession> nonNegativePrioritySessions = getNonNegativeSessions(sessions, 0); } else if (shouldCarbonCopyToResource(session, packet, isPrivate)) { session.process(packet); List<ClientSession> highestPrioritySessions = getHighestPrioritySessions(nonNegativePrioritySessions); if (!shouldCarbonCopyToResource(highestPrioritySessions.get(0), packet, isPrivate)) { highestPrioritySessions.get(0).process(packet); if (!shouldCarbonCopyToResource(session, packet, isPrivate)) { for (ClientSession session : highestPrioritySessions) { if (!shouldCarbonCopyToResource(session, packet, isPrivate)) { session.process(packet);
if (serverName.equals(jid.getDomain())) { routed = routeToLocalDomain(jid, packet, fromServer); else if (jid.getDomain().endsWith(serverName) && hasComponentRoute(jid)) { routed = routeToComponent(jid, packet, routed); routed = routeToRemoteDomain(jid, packet, routed);
removeClientRoute(new JID(route)); removeServerRoute(pair); removeComponentRoute(new JID(entry.getKey()), entry.getValue());
routed = routeToBareJID(jid, (Message) packet, isPrivate); if (!clientRoute.isAvailable() && routeOnlyAvailable(packet, fromServer) && !presenceUpdateHandler.hasDirectPresence(packet.getTo(), packet.getFrom())) { Log.debug("Unable to route packet. Packet should only be sent to available sessions and the route is not available. {} ", packet.toXML()); Message message = (Message) packet; if (message.getType() == Message.Type.chat && !isPrivate) { List<JID> routes = getRoutes(jid.asBareJID(), null); for (JID route : routes) { ClientSession clientSession = getClientRoute(route); if (clientSession.isMessageCarbonsEnabled()) { Message carbon = new Message(); .routePacket(clientRoute.getNodeID().toByteArray(), jid, packet); if (!routed) { removeClientRoute(jid); // drop invalid client route
@Override public boolean hasClientRoute(JID jid) { return usersCache.containsKey(jid.toString()) || isAnonymousRoute(jid); }
/** * Returns the sessions that had the highest presence priority that is non-negative. * * @param sessions the list of user sessions that filter and get the ones with highest priority. * @return the sessions that had the highest presence non-negative priority or empty collection * if all were negative. */ private List<ClientSession> getHighestPrioritySessions(List<ClientSession> sessions) { int highest = Integer.MIN_VALUE; // Get the highest priority amongst the sessions for (ClientSession session : sessions) { int priority = session.getPresence().getPriority(); if (priority >= 0 && priority > highest) { highest = priority; } } // Get sessions that have the highest priority return getNonNegativeSessions(sessions, highest); }
if (!hasComponentRoute(jid) && !ExternalComponentManager.hasConfiguration(jid.getDomain())) { return false;
routed = routeToBareJID(jid, (Message) packet, isPrivate); if (!clientRoute.isAvailable() && routeOnlyAvailable(packet, fromServer) && !presenceUpdateHandler.hasDirectPresence(packet.getTo(), packet.getFrom())) { Log.debug("Unable to route packet. Packet should only be sent to available sessions and the route is not available. {} ", packet.toXML()); Message message = (Message) packet; if (message.getType() == Message.Type.chat && !isPrivate) { List<JID> routes = getRoutes(jid.asBareJID(), null); for (JID route : routes) { ClientSession clientSession = getClientRoute(route); if (clientSession.isMessageCarbonsEnabled()) { Message carbon = new Message(); .routePacket(clientRoute.getNodeID().toByteArray(), jid, packet); if (!routed) { removeClientRoute(jid); // drop invalid client route
removeClientRoute(new JID(route)); removeServerRoute(pair); removeComponentRoute(new JID(jid));
if ( isAnonymousRoute( packet.getFrom() ) )
/** * Returns the sessions that had the highest presence priority that is non-negative. * * @param sessions the list of user sessions that filter and get the ones with highest priority. * @return the sessions that had the highest presence non-negative priority or empty collection * if all were negative. */ private List<ClientSession> getHighestPrioritySessions(List<ClientSession> sessions) { int highest = Integer.MIN_VALUE; // Get the highest priority amongst the sessions for (ClientSession session : sessions) { int priority = session.getPresence().getPriority(); if (priority >= 0 && priority > highest) { highest = priority; } } // Get sessions that have the highest priority return getNonNegativeSessions(sessions, highest); }
if (!hasComponentRoute(jid) && !ExternalComponentManager.hasConfiguration(jid.getDomain())) { return false;
List<ClientSession> sessions = new ArrayList<>(); for (JID address : getRoutes(recipientJID, packet.getFrom())) { ClientSession session = getClientRoute(address); if (session != null && session.isInitialized()) { sessions.add(session); List<ClientSession> nonNegativePrioritySessions = getNonNegativeSessions(sessions, 0); } else if (shouldCarbonCopyToResource(session, packet, isPrivate)) { session.process(packet); List<ClientSession> highestPrioritySessions = getHighestPrioritySessions(nonNegativePrioritySessions); if (!shouldCarbonCopyToResource(highestPrioritySessions.get(0), packet, isPrivate)) { highestPrioritySessions.get(0).process(packet); if (!shouldCarbonCopyToResource(session, packet, isPrivate)) { for (ClientSession session : highestPrioritySessions) { if (!shouldCarbonCopyToResource(session, packet, isPrivate)) { session.process(packet);
if (serverName.equals(jid.getDomain())) { routed = routeToLocalDomain(jid, packet, fromServer); else if (jid.getDomain().endsWith(serverName) && hasComponentRoute(jid)) { routed = routeToComponent(jid, packet, routed); routed = routeToRemoteDomain(jid, packet, routed);
private void restoreCacheContent() { // Add outgoing server sessions hosted locally to the cache (using new nodeID) for (LocalOutgoingServerSession session : localRoutingTable.getServerRoutes()) { for (DomainPair pair : session.getOutgoingDomainPairs()) { addServerRoute(pair, session); } } // Add component sessions hosted locally to the cache (using new nodeID) and remove traces to old nodeID for (RoutableChannelHandler route : localRoutingTable.getComponentRoute()) { addComponentRoute(route.getAddress(), route); } // Add client sessions hosted locally to the cache (using new nodeID) for (LocalClientSession session : localRoutingTable.getClientRoutes()) { addClientRoute(session.getAddress(), session); } }
@Override public boolean hasClientRoute(JID jid) { return usersCache.containsKey(jid.toString()) || isAnonymousRoute(jid); }
if ( isAnonymousRoute( packet.getFrom() ) )