|
JXTA | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.jxta.impl.endpoint.router.EndpointRouter
public class EndpointRouter
Nested Class Summary | |
---|---|
(package private) class |
EndpointRouter.ClearPendingQuery
|
Field Summary | |
---|---|
static long |
ASYNC_MESSENGER_WAIT
how long we are willing to wait for a response from an async getMessenger. |
static Integer |
GET_ROUTE_CONTROL
MessageTransport Control operation |
static int |
RouteControlOp
|
Fields inherited from interface net.jxta.platform.Module |
---|
START_AGAIN_PROGRESS, START_AGAIN_STALLED, START_DISABLED, START_OK |
Constructor Summary | |
---|---|
EndpointRouter()
Default constructor |
Method Summary | |
---|---|
(package private) static PeerID |
addr2pid(EndpointAddress addr)
Convert a Router EndpointAddress into a PeerID |
(package private) EndpointAddress |
addressMessage(Message message,
EndpointAddress dstAddress)
Updates the router element of a message and returns the peerAddress address of the next hop (where to send the message). |
boolean |
allowsRouting()
Returns true if the Message Transport can be used by the EndpointRouter. |
(package private) Messenger |
ensureLocalRoute(EndpointAddress peerAddress,
RouteAdvertisement hint)
Get a Messenger for the specified destination if a direct route is known. |
(package private) Messenger |
findBestReachableEndpoint(EndpointAddress dest,
List<EndpointAddress> mightWork,
boolean exist)
Given a list of addresses, find the best reachable endpoint. |
(package private) Messenger |
findReachableEndpoint(EndpointAddress destPeerAddress,
boolean exist,
RouteAdvertisement hint)
Read the route advertisement for a peer and find a suitable transport endpoint for sending to that peer either directly or via one of the advertised peer router |
(package private) Iterator<EndpointAddress> |
getAllCachedMessengerDestinations()
Get all direct route destinations |
(package private) Iterator<ID> |
getAllRoutedRouteAddresses()
Get all long route destination addresses |
(package private) BadRoute |
getBadRoute(EndpointAddress addr)
get bad route entry |
(package private) Messenger |
getCachedMessenger(EndpointAddress addr)
Snoop if we have a messenger |
EndpointService |
getEndpointService()
Returns the endpoint service with which this MessageTransport is registered. |
(package private) EndpointAddress |
getGatewayAddress(EndpointAddress peerAddress,
boolean seekRoute,
RouteAdvertisement hint)
Given a peer id, return an address to reach that peer. |
Messenger |
getMessenger(EndpointAddress addr,
Object hint)
Return a Messenger for sending messages to the specified
destination EndpointAddress . |
(package private) RouteAdvertisement |
getMyLocalRoute()
|
(package private) Collection<Map.Entry<PeerID,EndpointRouter.ClearPendingQuery>> |
getPendingQueriesAllDestinations()
Get all pendingRouteQuery destinations |
(package private) EndpointRouter.ClearPendingQuery |
getPendingRouteQuery(PeerID peerID)
get a pending route query info |
String |
getProtocolName()
Returns a String containing the name of the protocol used by this MessageTransport. |
EndpointAddress |
getPublicAddress()
Returns the EndpointAddress which will be used as the source
address for all messages sent by this message sender. |
Iterator<EndpointAddress> |
getPublicAddresses()
Returns an Iterator of all of the EndpointAddresses by which this
MessageReceiver is reachable. |
(package private) RouteAdvertisement |
getRoute(EndpointAddress peerAddress,
boolean seekRoute)
Get the routed route, if any, for a given peer id. |
(package private) RouteCM |
getRouteCM()
Get the route CM cache Manager |
(package private) Iterator<Map.Entry<ID,RouteAdvertisement>> |
getRoutedRouteAllDestinations()
Get all long route destinations |
(package private) RouteResolver |
getRouteResolver()
Get the route resolver manager |
void |
init(PeerGroup group,
ID assignedID,
Advertisement impl)
Initialize the module, passing it its peer group and advertisement. |
boolean |
isConnectionOriented()
Returns true if the Message Transport is connection oriented
(like TCP/IP). |
(package private) boolean |
isLocalRoute(EndpointAddress peerAddress)
isLocalRoute is a shallow test. |
(package private) boolean |
isPendingRouteQuery(PeerID peerID)
is there a pending route query for that destination |
(package private) boolean |
isRoutedRoute(PeerID peerID)
Do we have a long route for that destination |
boolean |
messengerReady(MessengerEvent event)
Receives notifications of new messengers being generated by the underlying network transports. |
(package private) boolean |
newMessenger(MessengerEvent event)
Call when an asynchronous new messenger is ready. |
(package private) void |
noMessenger(EndpointAddress logDest)
Call when an asynchronous new messenger could not be obtained. |
(package private) static EndpointAddress |
pid2addr(ID pid)
Convert an ID into a Router Endpoint Address |
boolean |
ping(EndpointAddress addr)
Deprecated. |
void |
processIncomingMessage(Message msg,
EndpointAddress srcAddr,
EndpointAddress dstAddr)
This method is invoked by the EndpointService for each incoming message which is addressed to this listener. |
(package private) void |
removeRoute(PeerID peerID)
This method is used to remove a route |
(package private) void |
sendOnLocalRoute(EndpointAddress destination,
Message message)
Send a message to a given logical destination if it maps to some messenger in our messenger pool or if such a mapping can be found and added. |
(package private) void |
setBadRoute(EndpointAddress addr,
BadRoute badRoute)
set bad route entry |
(package private) boolean |
setRoute(RouteAdvertisement route,
boolean force)
set new route info |
int |
startApp(String[] arg)
Complete any remaining initialization of the module. |
void |
stopApp()
Stop a module. |
Object |
transportControl(Object operation,
Object value)
Pass a transport control object to a message transport. |
(package private) void |
updateRouteAdv(RouteAdvertisement route)
check if it is a new route adv |
(package private) void |
updateRouteAdv(RouteAdvertisement route,
boolean force)
check if it is a new route adv |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final long ASYNC_MESSENGER_WAIT
public static final Integer GET_ROUTE_CONTROL
public static final int RouteControlOp
Constructor Detail |
---|
public EndpointRouter()
Method Detail |
---|
RouteAdvertisement getMyLocalRoute()
boolean isLocalRoute(EndpointAddress peerAddress)
peerAddress
- Address of the destination who's route is desired.
true
if we know a direct route to the specified address
otherwise false
.Messenger ensureLocalRoute(EndpointAddress peerAddress, RouteAdvertisement hint)
peerAddress
- The peer who's messenger is desired.hint
- A route hint to use if a new Messenger must be created.
null
if none could be
found or created.void sendOnLocalRoute(EndpointAddress destination, Message message) throws IOException
destination
- peer-based address to send the message to.message
- the message to be sent.
IOException
- if an io error occurspublic void init(PeerGroup group, ID assignedID, Advertisement impl) throws PeerGroupException
init
in interface Module
group
- The PeerGroup from which this Module can obtain services.
If this module is a Service, this is also the PeerGroup of which this
module is a service.assignedID
- Identity of Module within group.
modules can use it as a the root of their namespace to create
names that are unique within the group but predictable by the
same module on another peer. This is normally the ModuleClassID
which is also the name under which the module is known by other
modules. For a group it is the PeerGroupID itself.
The parameters of a service, in the Peer configuration, are indexed
by the assignedID of that service, and a Service must publish its
run-time parameters in the Peer Advertisement under its assigned ID.impl
- The implementation advertisement for this
Module. It is permissible to pass null if no implementation
advertisement is available. This may happen if the
implementation was selected by explicit class name rather than
by following an implementation advertisement. Modules are not
required to support that style of loading, but if they do, then
their documentation should mention it.
PeerGroupException
- This module failed to initialize.public int startApp(String[] arg)
startApp()
is completed. That is
also the opportunity to supply arbitrary arguments (mostly to
applications).
If this module is a PeerGroup
service, it may be invoked
several times depending on its return value.
startApp
in interface Module
arg
- An array of Strings forming the parameters for this
Module.
Module.START_OK
, Module.START_AGAIN_PROGRESS
,
Module.START_AGAIN_STALLED
, which indicates partial or complete
success, or any other value (negative values are
recommended for future compatibility), which indicates failure.public void stopApp()
init()
completes and should not assume that startApp()
has been
called or completed.
The Module cannot be forced to comply, but in the future
we might be able to deny it access to anything after some timeout.
Careful that stopApp() could in theory be called before startApp().
stopApp
in interface Module
public boolean isConnectionOriented()
true
if the Message Transport is connection oriented
(like TCP/IP). Indicates that the Message Transport can provide
efficient transport of a series of messages to the same destination.
isConnectionOriented
in interface MessageSender
true
if the Message Transport is connection oriented.public boolean allowsRouting()
getReachableEndpointAddresses
.
allowsRouting
in interface MessageSender
public EndpointService getEndpointService()
getEndpointService
in interface MessageTransport
public EndpointAddress getPublicAddress()
EndpointAddress
which will be used as the source
address for all messages sent by this message sender. This is the
"preferred" address to which replies should be sent. This address is not
necessarily the best or only address by which the peer may be reached.
The public address may also be for a different message transport.
getPublicAddress
in interface MessageSender
public Iterator<EndpointAddress> getPublicAddresses()
EndpointAddresses
by which this
MessageReceiver is reachable. The list is in order of
"preference" with the most "preferred" EndpointAddress being at the
beginning of the list.
getPublicAddresses
in interface MessageReceiver
public String getProtocolName()
EndpointAddress
.
getProtocolName
in interface MessageTransport
EndpointAddress getGatewayAddress(EndpointAddress peerAddress, boolean seekRoute, RouteAdvertisement hint)
peerAddress
- the peer we are trying to reach.seekRoute
- whether to go as far as issuing a route query, or just fish in our cache.
when forwarding a message we allow ourselves to mend a broken source-issued route but we
won't go as far as seeking one from other peers. When originating a message, on the other end
we will aggressively try to find route.hint
- whether we are passed a route hint to be used, in that case that route
hint should be used
@Deprecated public boolean ping(EndpointAddress addr)
true
if the specified destination address is reachable
via this Message Transport otherwise returns false
.
ping
in interface MessageSender
addr
- Address to ping
true
if the specified destination address is reachable
via this Message Transport otherwise returns false
.public boolean messengerReady(MessengerEvent event)
messengerReady
in interface MessengerEventListener
event
- the new messenger event.
true
if the listener wants to claim the Messenger.
(Normally means that it will not be offered to any other listener).void noMessenger(EndpointAddress logDest)
logDest
- the failed logical destinationboolean newMessenger(MessengerEvent event)
event
- the new messenger event.
RouteAdvertisement getRoute(EndpointAddress peerAddress, boolean seekRoute)
peerAddress
- the peer who's route is desired.seekRoute
- boolean to indicate if we should search for a route
if we don't have one
boolean setRoute(RouteAdvertisement route, boolean force)
route
- new route to learnforce
- true if the route was obtained by receiving
a message
void removeRoute(PeerID peerID)
peerID
- route to peerid to be removedpublic void processIncomingMessage(Message msg, EndpointAddress srcAddr, EndpointAddress dstAddr)
processIncomingMessage
in interface EndpointListener
msg
- Incoming messagesrcAddr
- Endpoint Address of the source of the message.dstAddr
- Endpoint Address of the destination of the message.Messenger findBestReachableEndpoint(EndpointAddress dest, List<EndpointAddress> mightWork, boolean exist)
dest
- destination address.mightWork
- A list of addresses to evaluate reachability.exist
- true if there already are existing messengers for
the given destinations but we want one more. It may lead us to reject
certain addresses that we would otherwise accept.
Messenger findReachableEndpoint(EndpointAddress destPeerAddress, boolean exist, RouteAdvertisement hint)
destPeerAddress
- dest addressexist
- use existing messengers, avoid creating a new onehint
- route hint
public Messenger getMessenger(EndpointAddress addr, Object hint)
Messenger
for sending messages to the specified
destination EndpointAddress
.
getMessenger
in interface MessageSender
addr
- The destination address for which a messenger is requested.hint
- An optional hint for the transport to use when creating the
messenger. The format of the hint is specific to each Message Transport
and may be null
if no hint is provided.
null
if the destination is not reachable.EndpointAddress addressMessage(Message message, EndpointAddress dstAddress)
message
- the message for which to compute/update a route.dstAddress
- the final destination of the route which the message be set to follow.
public Object transportControl(Object operation, Object value)
transportControl
in interface MessageTransport
operation
- Object that specifies the type of control operation
to be performedvalue
- Object that specifies a value object associated
with the control operation
static PeerID addr2pid(EndpointAddress addr)
addr
- the address to extract peerAddress from
static EndpointAddress pid2addr(ID pid)
pid
- The ID who's equivalent Endpoint Address is desired.
void updateRouteAdv(RouteAdvertisement route)
route
- route advertisementvoid updateRouteAdv(RouteAdvertisement route, boolean force)
route
- route advertisementforce
- enforce the routeboolean isPendingRouteQuery(PeerID peerID)
peerID
- destination address
EndpointRouter.ClearPendingQuery getPendingRouteQuery(PeerID peerID)
peerID
- destination address
boolean isRoutedRoute(PeerID peerID)
peerID
- destination address
Messenger getCachedMessenger(EndpointAddress addr)
addr
- destination address
Iterator<EndpointAddress> getAllCachedMessengerDestinations()
Iterator<Map.Entry<ID,RouteAdvertisement>> getRoutedRouteAllDestinations()
Iterator<ID> getAllRoutedRouteAddresses()
Collection<Map.Entry<PeerID,EndpointRouter.ClearPendingQuery>> getPendingQueriesAllDestinations()
RouteCM getRouteCM()
RouteResolver getRouteResolver()
void setBadRoute(EndpointAddress addr, BadRoute badRoute)
addr
- of the bad routebadRoute
- bad route infoBadRoute getBadRoute(EndpointAddress addr)
addr
- of the bad route
|
JXSE | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |