|
JXTA | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.jxta.impl.rendezvous.RendezVousServiceImpl
public final class RendezVousServiceImpl
A JXTA RendezVousService
implementation which
implements the standard JXTA Rendezvous Protocol (RVP).
RendezVousService
,
JXTA Protocols Specification : Rendezvous ProtocolField Summary | |
---|---|
EndpointService |
endpoint
|
protected static int |
MAX_MSGIDS
|
Fields inherited from interface net.jxta.rendezvous.RendezVousService |
---|
DEFAULT_TTL |
Fields inherited from interface net.jxta.platform.Module |
---|
START_AGAIN_PROGRESS, START_AGAIN_STALLED, START_DISABLED, START_OK |
Constructor Summary | |
---|---|
RendezVousServiceImpl()
Constructor for the RendezVousServiceImpl object |
Method Summary | |
---|---|
void |
addListener(RendezvousListener listener)
Add a listener for RendezVousEvents. |
boolean |
addMsgId(UUID id)
Checks if a message id has been recorded. |
boolean |
addPropagateListener(String serviceName,
String serviceParam,
EndpointListener listener)
Registers the provided listener under the given serviceName and serviceParam to receive messages propagated by the Rendezvous service. |
void |
challengeRendezVous(ID peer,
long delay)
Set a new deadline for the rendezvous to be proven alive. |
void |
connectToRendezVous(EndpointAddress addr)
Attempt connection to the specified RendezVous peer. |
void |
connectToRendezVous(PeerAdvertisement adv)
Attempt connection to the specified RendezVous peer. |
UUID |
createMsgId()
|
void |
disconnectFromRendezVous(ID peerId)
Disconnect from the specified rendezvous. |
void |
generateEvent(int type,
ID regarding)
Creates a rendezvous event and sends it to all registered listeners. |
ID |
getAssignedID()
Return the assigned ID for this service. |
Vector<ID> |
getConnectedPeerIDs()
Returns a Vector of the PeerID of the peers that are currently connected to this peer. |
Enumeration<ID> |
getConnectedPeers()
Returns an Enumeration of the PeerID of the peers that are currently connected to this peer. |
Enumeration<ID> |
getConnectedRendezVous()
Returns an Enumeration of the PeerID all the RendezVous on which this Peer is currently connected. |
Enumeration<ID> |
getDisconnectedRendezVous()
Returns an Enumeration of the PeerID all the RendezVous on which this Peer failed to connect to. |
ModuleImplAdvertisement |
getImplAdvertisement()
Returns the advertisement for this service. |
RendezVousService |
getInterface()
Service objects are not manipulated directly to protect usage of the service. |
Vector<RdvAdvertisement> |
getLocalWalkView()
Returns a vector of RdvAdvertisement of the local view of rendezvous peers. |
PeerView |
getPeerView()
Returns the PeerView |
(package private) RendezVousServiceProvider |
getRendezvousProvider()
Deprecated. This is private for debugging and diagnostics only. |
RendezVousStatus |
getRendezVousStatus()
Returns the current role of this peer within the peergroup. |
void |
init(PeerGroup g,
ID assignedID,
Advertisement impl)
Initialize the module, passing it its peer group and advertisement. |
boolean |
isConnectedToRendezVous()
Gets the rendezvousConnected attribute of the RendezVousServiceImpl object |
boolean |
isMsgIdRecorded(UUID id)
|
boolean |
isRendezVous()
Returns true if this peer is acting as a rendezvous peer (per the
implementation definition) within the peer group. |
void |
propagate(Enumeration<? extends ID> destPeerIDs,
Message msg,
String serviceName,
String serviceParam,
int defaultTTL)
Propagates a message to the specified peers. |
void |
propagate(Message msg,
String serviceName,
String serviceParam,
int defaultTTL)
Propagates a message to the local network and to as many members of the peer group as possible. |
void |
propagateInGroup(Message msg,
String serviceName,
String serviceParam,
int ttl)
Propagates a message to as many members of the peer group as possible. |
void |
propagateToNeighbors(Message msg,
String serviceName,
String serviceParam,
int ttl)
Propagates a message to members of the peer group reachable via the local network. |
boolean |
removeListener(RendezvousListener listener)
Removes a Rendezvous event listener previously added with addListener. |
EndpointListener |
removePropagateListener(String serviceName,
String serviceParam,
EndpointListener listener)
Removes a Listener previously added with addPropagateListener. |
boolean |
setAutoStart(boolean auto)
Enable or disable the automatic switching between an Edge Peer and a Rendezvous Peer. |
boolean |
setAutoStart(boolean auto,
long period)
Enable or disable the automatic switching between an Edge Peer and a Rendezvous Peer. |
int |
startApp(String[] arg)
Complete any remaining initialization of the module. |
void |
startRendezVous()
Start the local peer as a RendezVous peer. |
void |
stopApp()
Stop a module. |
void |
stopRendezVous()
Stop the RendezVous function on the local Peer. |
void |
walk(Message msg,
String serviceName,
String serviceParam,
int defaultTTL)
Walk a message through the rendezvous peers of the network: only rendezvous peers will receive the message. |
void |
walk(Vector<? extends ID> destPeerIDs,
Message msg,
String serviceName,
String serviceParam,
int defaultTTL)
Walk a message through the rendezvous peers of the network: only rendezvous peers will receive the message. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final int MAX_MSGIDS
public EndpointService endpoint
Constructor Detail |
---|
public RendezVousServiceImpl()
Method Detail |
---|
public RendezVousService getInterface()
getInterface
in interface Service
public ModuleImplAdvertisement getImplAdvertisement()
getImplAdvertisement
in interface Service
ModuleImplAdvertisement
.public ID getAssignedID()
public void init(PeerGroup g, ID assignedID, Advertisement impl)
init
in interface Module
g
- 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.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.
stopApp
in interface Module
public boolean isRendezVous()
true
if this peer is acting as a rendezvous peer (per the
implementation definition) within the peer group. false
is
returned for all other peer roles.
isRendezVous
in interface RendezVousService
true
if this peer is acting as a rendezvous peer (per the
implementation definition) within the peer group. false
is
returned for all other peer roles.public RendezVousStatus getRendezVousStatus()
net.jxta.rendezvous.RendezVousService
getRendezVousStatus
in interface RendezVousService
public boolean setAutoStart(boolean auto)
setAutoStart
in interface RendezVousService
auto
- true
will activate automatic role switching.
public boolean setAutoStart(boolean auto, long period)
setAutoStart
in interface RendezVousService
auto
- true
will activate automatic role switching.period
- The interval in milliseconds at which the peer should
reconsider it's role.
public void connectToRendezVous(PeerAdvertisement adv) throws IOException
connectToRendezVous
in interface RendezVousService
adv
- the advertisement of the RendezVousService peer
IOException
- When the specified peer is unreachablepublic void connectToRendezVous(EndpointAddress addr) throws IOException
connectToRendezVous
in interface RendezVousService
addr
- EndpointAddress of the rendezvous peer
IOException
- When the specified peer is unreachablepublic void challengeRendezVous(ID peer, long delay)
challengeRendezVous
in interface RendezVousService
peer
- The peer to be challengeddelay
- The delaypublic void disconnectFromRendezVous(ID peerId)
disconnectFromRendezVous
in interface RendezVousService
peerId
- the PeerId of the RendezVous to disconnect from.public Enumeration<ID> getConnectedRendezVous()
RendezVousService.getConnectedPeers()
.
getConnectedRendezVous
in interface RendezVousService
public Enumeration<ID> getDisconnectedRendezVous()
getDisconnectedRendezVous
in interface RendezVousService
public Enumeration<ID> getConnectedPeers()
getConnectedPeers
in interface RendezVousService
PeerID
connected to this peer.public Vector<ID> getConnectedPeerIDs()
getConnectedPeerIDs
in interface RendezVousService
PeerID
connected to this peer.public boolean isConnectedToRendezVous()
isConnectedToRendezVous
in interface RendezVousService
public void startRendezVous()
startRendezVous
in interface RendezVousService
public void stopRendezVous()
stopRendezVous
in interface RendezVousService
public boolean addPropagateListener(String serviceName, String serviceParam, EndpointListener listener)
addPropagateListener
in interface RendezVousService
serviceName
- The serviceName of the listener.serviceParam
- The serviceParam of the listener.listener
- An EndpointListener to process the message.
public EndpointListener removePropagateListener(String serviceName, String serviceParam, EndpointListener listener)
removePropagateListener
in interface RendezVousService
serviceName
- The serviceName of the listener.serviceParam
- The serviceParam of the listener.listener
- An EndpointListener to process the message.
public void propagate(Message msg, String serviceName, String serviceParam, int defaultTTL) throws IOException
propagate
in interface RendezVousService
msg
- is the message to propagate.serviceName
- is the name of the service.serviceParam
- is the parameter of the service.defaultTTL
- The requested TTL for the message.
IOException
- if an io error occurspublic void propagate(Enumeration<? extends ID> destPeerIDs, Message msg, String serviceName, String serviceParam, int defaultTTL) throws IOException
propagate
in interface RendezVousService
destPeerIDs
- An enumeration of PeerIDs of the peers that are the
intended recipients of the propagated message.msg
- The message to propagate.serviceName
- The name of the service.serviceParam
- The parameter of the service.defaultTTL
- The requested TTL for the message.
IOException
- if an io error occurspublic void walk(Message msg, String serviceName, String serviceParam, int defaultTTL) throws IOException
walk
in interface RendezVousService
msg
- is the message to walk.serviceName
- is the name of the serviceserviceParam
- is the parameter of the servicedefaultTTL
- is the maximum TTL of the message.
IOException
- when walking the message is impossible (network failure)public void walk(Vector<? extends ID> destPeerIDs, Message msg, String serviceName, String serviceParam, int defaultTTL) throws IOException
walk
in interface RendezVousService
destPeerIDs
- is a Vector of PeerIDs of the peers which are receiving
first the walker. Note that each entry in the Vector will create its own
walker.msg
- is the message to walk.serviceName
- is the name of the serviceserviceParam
- is the parameter of the servicedefaultTTL
- is the maximum TTL of the message.
IOException
- when walking the message is impossible (network failure)public Vector<RdvAdvertisement> getLocalWalkView()
getLocalWalkView
in interface RendezVousService
public PeerView getPeerView()
public void propagateToNeighbors(Message msg, String serviceName, String serviceParam, int ttl) throws IOException
propagateToNeighbors
in interface RendezVousService
msg
- is the message to propagate.serviceName
- is the name of the service.serviceParam
- is the parameter of the service.ttl
- The requested TTL for the message.
IOException
- if an io error occurspublic void propagateInGroup(Message msg, String serviceName, String serviceParam, int ttl) throws IOException
propagateInGroup
in interface RendezVousService
msg
- is the message to propagate.serviceName
- is the name of the serviceserviceParam
- is the parameter of the servicettl
- The requested TTL for the message.
IOException
- if an io error occurspublic final void addListener(RendezvousListener listener)
addListener
in interface RendezVousService
listener
- An RendezvousListener to process the event.public final boolean removeListener(RendezvousListener listener)
removeListener
in interface RendezVousService
listener
- the RendezvousListener listener remove
public final void generateEvent(int type, ID regarding)
type
- event typeregarding
- event peer IDpublic boolean isMsgIdRecorded(UUID id)
public boolean addMsgId(UUID id)
id
- message to record.
true
If message was added otherwise (duplicate)
false
.public UUID createMsgId()
@Deprecated RendezVousServiceProvider getRendezvousProvider()
|
JXSE | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |