|
Openfire 3.6.1 Javadoc | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface RoutingTable
Maintains server-wide knowledge of routes to any node.
Routes are only concerned with node addresses. Destinations are packet handlers (typically of the three following types):
In almost all cases, the caller should not be concerned with what handler is associated with a given node. Simply obtain the packet handler and deliver the packet to the node, leaving the details up to the handler.
Routes are matched using the stringprep rules given in the XMPP specification. Wildcard routes for a particular name or resource is indicated by a null. E.g. routing to any address at server.com should set the name to null, the host to 'server.com' and the resource to null. A route to the best resource for user@server.com should indicate that route with a null resource component of the XMPPAddress. Session managers should add a route for both the generic user@server.com as well as user@server.com/resource routes (knowing that one is an alias for the other is the responsibility of the session or session manager).
In order to accomodate broadcasts, you can also do partial matches by querying all 'child' nodes of a particular node. The routing table contains a forest of node trees. The node tree is arranged in the following heirarchy:
Note: it is important that any component or action affecting routes update the routing table immediately.
Method Summary | |
---|---|
boolean |
addClientRoute(JID route,
LocalClientSession destination)
Adds a route to the routing table for the specified client session. |
void |
addComponentRoute(JID route,
RoutableChannelHandler destination)
Adds a route to the routing table for the specified internal or external component. |
void |
addServerRoute(JID route,
LocalOutgoingServerSession destination)
Adds a route to the routing table for the specified outoing server session. |
void |
broadcastPacket(Message packet,
boolean onlyLocal)
Broadcasts the specified message to connected client sessions to the local node or across the cluster. |
ClientSession |
getClientRoute(JID jid)
Returns the client session associated to the specified XMPP address or null if none was found. |
Collection<ClientSession> |
getClientsRoutes(boolean onlyLocal)
Returns collection of client sessions authenticated with the server. |
Collection<String> |
getComponentsDomains()
Returns domains of components hosted by the server. |
RemotePacketRouter |
getRemotePacketRouter()
Returns the RemotePacketRouter to use for deliverying packets to entities hosted
in remote nodes of the cluster or null if none was set. |
List<JID> |
getRoutes(JID route,
JID requester)
Returns the list of routes associated to the specified route address. |
Collection<String> |
getServerHostnames()
Returns a collection with the hostnames of the remote servers that currently may receive packets sent from this server. |
OutgoingServerSession |
getServerRoute(JID jid)
Returns the outgoing server session associated to the specified XMPP address or null if none was found. |
int |
getServerSessionsCount()
Returns the number of outgoing server sessions hosted in this JVM. |
boolean |
hasClientRoute(JID jid)
Returns true if a registered user or anonymous user with the specified full JID is currently logged. |
boolean |
hasComponentRoute(JID jid)
Returns true if an internal or external component is hosting the specified address. |
boolean |
hasServerRoute(JID jid)
Returns true if an outgoing server session exists to the specified remote server. |
boolean |
isAnonymousRoute(JID jid)
Returns true if an anonymous user with the specified full JID is currently logged. |
boolean |
isLocalRoute(JID jid)
Returns true if the specified address belongs to a route that is hosted by this JVM. |
boolean |
removeClientRoute(JID route)
Returns true if a route of a client session has been successfully removed. |
boolean |
removeComponentRoute(JID route)
Returns true if a route of a component has been successfully removed. |
boolean |
removeServerRoute(JID route)
Returns true if a route to an outoing server has been successfully removed. |
void |
routePacket(JID jid,
Packet packet,
boolean fromServer)
Routes a packet to the specified address. |
void |
setRemotePacketRouter(RemotePacketRouter remotePacketRouter)
Sets the RemotePacketRouter to use for deliverying packets to entities hosted
in remote nodes of the cluster. |
Method Detail |
---|
void addServerRoute(JID route, LocalOutgoingServerSession destination)
route
- the address associated to the route.destination
- the outgoing server session.void addComponentRoute(JID route, RoutableChannelHandler destination)
When running inside of a cluster this message must be sent from the cluster node that is actually hosting the component. The component may be available in all or some of cluster nodes. The routing table will keep track of all nodes hosting the component.
route
- the address associated to the route.destination
- the component.boolean addClientRoute(JID route, LocalClientSession destination)
route
- the address associated to the route.destination
- the client session.
void routePacket(JID jid, Packet packet, boolean fromServer) throws PacketException
When routing a packet to a remote server then a new outgoing connection will be created to the remote server if none was found and the packet will be delivered. If an existing outgoing connection already exists then it will be used for delivering the packet. Moreover, when runing inside of a cluster the node that has the actual outgoing connection will be requested to deliver the requested packet.
Packets routed to components will only be sent if the internal or external component is connected to the server. Moreover, when runing inside of a cluster the node that is hosting the component will be requested to deliver the requested packet. It will be first checked if the component is available in this JVM and if not then the first cluster node found hosting the component will be used.
Packets routed to users will be delivered if the user is connected to the server. Depending
on the packet type and the sender of the packet only available or all user sessions could
be considered. For instance, Messages
and
Presences
are only sent to available client sessions whilst
IQs
originated to the server can be sent to available or unavailable
sessions. When runing inside of a cluster the node that is hosting the user session will be
requested to deliver the requested packet.
jid
- the receipient of the packet to route.packet
- the packet to route.fromServer
- true if the packet was created by the server. This packets should
always be delivered
PacketException
- thrown if the packet is malformed (results in the sender's
session being shutdown).boolean hasClientRoute(JID jid)
jid
- the full JID of the user.
boolean isAnonymousRoute(JID jid)
jid
- the full JID of the anonymous user.
boolean isLocalRoute(JID jid)
XMPPServer.isLocal(org.xmpp.packet.JID)
to figure out if the address
belongs to tge domain hosted by this server.
jid
- the address of the route.
boolean hasServerRoute(JID jid)
When running inside of a cluster the look up will be done in all the cluster. So as long as a node has a connection to the remote server a true value will be returned.
jid
- JID that specifies the remote server address.
boolean hasComponentRoute(JID jid)
When running inside of a cluster the look up will be done in all the cluster. So as long as a node is hosting the component a true value will be returned.
jid
- JID that specifies the component address.
ClientSession getClientRoute(JID jid)
jid
- the address of the session.
Collection<ClientSession> getClientsRoutes(boolean onlyLocal)
onlyLocal
- true if only client sessions connected to this JVM must be considered.
OutgoingServerSession getServerRoute(JID jid)
jid
- the address of the session.
Collection<String> getServerHostnames()
int getServerSessionsCount()
Collection<String> getComponentsDomains()
List<JID> getRoutes(JID route, JID requester)
When asking for routes to client sessions the specified route address could either be a full JID of a bare JID. In the case of a full JID, a single element will be included in the answer in case the specified full JID exists or an empty collection if the full JID does not exist. Moreover, when passing a bare JID a list of full JIDs will be returned for each available resource associated to the bare JID. In any case, only JIDs of available client sessions are returned. However, there is an exception with directed presences. Unavailable routes may be returned if and only if the owner of the route sent a directed presence to the requester thus becoming available to the requester. If requester is null then only available resources are considered.
When asking for routes to components a single element will be returned in the answer only if an internal or external component is found for the specified route address. If no component was found then an empty collection will be returned.
route
- The address we want a route to.requester
- The address of the entity requesting the routes or null if we don't
care about directed presences.
boolean removeClientRoute(JID route)
route
- the route to remove.
boolean removeServerRoute(JID route)
route
- the route to remove.
boolean removeComponentRoute(JID route)
route
- the route to remove.
void setRemotePacketRouter(RemotePacketRouter remotePacketRouter)
RemotePacketRouter
to use for deliverying packets to entities hosted
in remote nodes of the cluster.
remotePacketRouter
- the RemotePacketRouter to use for deliverying packets to entities hosted
in remote nodes of the cluster.RemotePacketRouter getRemotePacketRouter()
RemotePacketRouter
to use for deliverying packets to entities hosted
in remote nodes of the cluster or null if none was set.
void broadcastPacket(Message packet, boolean onlyLocal)
packet
- the message to broadcast.onlyLocal
- true if only client sessions connecte to the local JVM will get the message.
|
Openfire 3.6.1 Javadoc | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |