|
Project JXTA | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface DiscoveryService
The JXTA DiscoveryService provides an asynchronous mechanism for discovering Peer Advertisements, Group Advertisements, and other general JXTA Advertisements (pipe, service, etc.). The scope of discovery can be controlled by specifying name and attribute pair, and a threshold. The threshold is an upper limit the requesting peer specifies for responding peers not to exceed. Each JXTA Peer Group has an instance of a DiscoveryService. The scope of discovery is limited to the group. For example :
A peer in the soccer group invokes the soccer group's DiscoveryService to discover pipe advertisements in the group, and is interested in a maximum of 10 Advertisements from each peer:discovery.getRemoteAdvertisements(null, discovery.ADV, null, null, 10, null);In the above example, peers that are part of the soccer group would respond. After a getRemoteAdvertisements call is made and the peers respond, a call to getLocalAdvertisements can be made to retrieve results that have been found and added to the local group cache. Alternately, a call to addDiscoveryListener() will provide asynchronous notification of discovered advertisements. Advertisement indexes are shared with a rendezvous peer upon connect, and subsequent publications are shared at 30 second intervals DiscoveryService also provides a mechanism for publishing advertisements, so that they may be discovered. The rules to follow when publishing are:
discovery.publish(adv,discovery.ADV);
parent=soccerGroup.getParent(); discovery= parent.getDiscoveryService() discovery.publish(adv,discovery.ADV);
0
Advertisements are often stored in a persistent local cache. When a peer
restarts up the same cache is referenced. this is an area where several
optimizations can take place, and intelligence about discovery patterns, etc.
Another feature of discovery is automatic discovery, a peer initiates a
discovery message by including it's own Advertisement in the discovery
message, which also can be viewed as a announcement.
Another feature of discovery is a learning about other rendezvous, i.e.
when discovery comes across a peer advertisement of a rendezvous peer it
passes the information down to the endpoint router.
Service
,
ResolverService
,
DiscoveryQueryMsg
,
DiscoveryResponseMsg
,
ResolverQueryMsg
,
ResolverResponseMsg
Field Summary | |
---|---|
static int |
ADV
DiscoveryService type Advertisement |
static long |
DEFAULT_EXPIRATION
Default expiration time for advertisements. |
static long |
DEFAULT_LIFETIME
Default lifetime time for advertisements. |
static int |
GROUP
DiscoveryService type Group |
static long |
INFINITE_LIFETIME
infinite lifetime for advertisements. |
static long |
NO_EXPIRATION
Specifies that the advertisement will have no expiration and will be kept indefinitely. |
static int |
PEER
DiscoveryService type Peer |
Fields inherited from interface net.jxta.platform.Module |
---|
START_AGAIN_PROGRESS, START_AGAIN_STALLED, START_OK |
Method Summary | |
---|---|
void |
addDiscoveryListener(DiscoveryListener listener)
register a discovery listener, to notified on discovery events |
void |
flushAdvertisement(Advertisement adv)
flush a stored Advertisement |
void |
flushAdvertisements(String id,
int type)
flushs stored Advertisement(s), |
long |
getAdvExpirationTime(Advertisement adv)
Returns the maximum duration in milliseconds for which this document should be cached by those other than the publisher. |
long |
getAdvExpirationTime(ID id,
int type)
Returns the maximum duration in milliseconds for which this document should be cached by those other than the publisher. |
long |
getAdvLifeTime(Advertisement adv)
Returns the maximum duration in milliseconds for which this document should be kept in local cache |
long |
getAdvLifeTime(ID id,
int type)
Returns the maximum duration in milliseconds for which this document should be kept in local cache |
Enumeration |
getLocalAdvertisements(int type,
String attribute,
String value)
Retrieve Stored Peer, Group, and General Advertisements |
int |
getRemoteAdvertisements(String peerid,
int type,
String attribute,
String value,
int threshold)
This method discovers PeerAdvertisements, GroupAdvertisements and other jxta Advertisements. jxta Advertisements are documents that describe pipes, services, etc. |
int |
getRemoteAdvertisements(String peerid,
int type,
String attribute,
String value,
int threshold,
DiscoveryListener listener)
This method discovers PeerAdvertisements, GroupAdvertisements and jxta Advertisements. jxta Advertisements are documents that describe pipes, services, etc. |
void |
publish(Advertisement advertisement)
Publish an advertisement with a default lifetime of
DEFAULT_LIFETIME and default expiration time for "others" of DEFAULT_EXPIRATION
Advertisement indexes are shared with a rendezvous peer upon connect,
and subsequent publications are shared at a an implementation specified interval |
void |
publish(Advertisement advertisement,
int type)
Deprecated. Advertisement type is no longer required to publish an advertisement |
void |
publish(Advertisement adv,
int type,
long lifetime,
long lifetimeForOthers)
Deprecated. Advertisement type is no longer required to publish an advertisement |
void |
publish(Advertisement adv,
long lifetime,
long lifetimeForOthers)
Publish an advertisement that will expire after a certain time. |
void |
remotePublish(Advertisement adv)
Remote Publish an advertisement will attempt to remote publish adv on all configured transports, the Advertisement will carry a lifetime of Expiration time, or lifetime whichever is smaller |
void |
remotePublish(Advertisement adv,
int type)
Deprecated. Advertisement type is no longer required to remote publish an advertisement |
void |
remotePublish(Advertisement adv,
int type,
long lifetime)
Deprecated. Advertisement type is no longer required to remote publish an advertisement |
void |
remotePublish(Advertisement adv,
long lifetime)
Remote Publish an advertisement will attempt to remote publish adv on all configured transports, the Advertisement will carry a a expiration of lifetime |
void |
remotePublish(String peerid,
Advertisement adv)
Remote Publish an advertisement will attempt to remote publish adv on all configured transports, the Advertisement will carry a lifetime of Expiration time, or lifetime whichever is smaller |
void |
remotePublish(String peerid,
Advertisement adv,
int type)
Deprecated. Advertisement type is no longer required to remote publish an advertisement |
void |
remotePublish(String peerid,
Advertisement adv,
int type,
long lifetime)
Deprecated. Advertisement type is no longer required to remote publish an advertisement |
void |
remotePublish(String peerid,
Advertisement adv,
long lifetime)
Remote Publish an advertisement will attempt to remote publish adv on all configured transports, the Advertisement will carry a a expiration of lifetime |
boolean |
removeDiscoveryListener(DiscoveryListener listener)
remove a discovery listener |
Methods inherited from interface net.jxta.service.Service |
---|
getImplAdvertisement, getInterface |
Methods inherited from interface net.jxta.platform.Module |
---|
init, startApp, stopApp |
Field Detail |
---|
static final int PEER
static final int GROUP
static final int ADV
static final long DEFAULT_LIFETIME
static final long DEFAULT_EXPIRATION
static final long INFINITE_LIFETIME
static final long NO_EXPIRATION
Method Detail |
---|
int getRemoteAdvertisements(String peerid, int type, String attribute, String value, int threshold)
peerid
- id of a peer, specifying null results in a propagate
within the grouptype
- Discovery type PEER, GROUP, ADVattribute
- attribute name to narrow discovery to Valid values for
this parameter are null (don't care), or exact element name in the
advertisement of interest (e.g. "Name")value
- value of attribute to narrow discovery to valid values for
this parameter are null (don't care), Exact value, or use of wild
card(s) (e.g. if a Advertisement defines threshold
- the upper limit of responses from one peer
threshold of 0, and type of PEER has a special behaviour
peers respond with own adv only.
int getRemoteAdvertisements(String peerid, int type, String attribute, String value, int threshold, DiscoveryListener listener)
attribute
- attribute name to narrow discovery to Valid values for
this parameter are null (don't care), or exact element name in the
advertisement of interest (e.g. "Name")value
- value of attribute to narrow discovery to valid values for
this parameter are null (don't care), Exact value, or use of wild
card(s) (e.g. if a Advertisement defines threshold
- the upper limit of responses from one peer
threshold of 0, and type of PEER has a special behaviourpeerid
- id of a peer, specifying null results in a propagate
within the grouptype
- Discovery type PEER, GROUP, ADVlistener
- the listener which will be called back with found
advertisements.
Enumeration getLocalAdvertisements(int type, String attribute, String value) throws IOException
type
- Discovery type PEER, GROUP, ADVattribute
- attribute name to narrow discovery to Valid values
for this parameter are null (don't care), or exact element name in the
advertisement of interest (e.g. "Name")value
- value of attribute to narrow discovery to valid
values for this parameter are null (don't care), Exact value, or use of
wild card(s) (e.g. if a Advertisement defines IOException
- - If an I/O error occursvoid publish(Advertisement advertisement) throws IOException
DEFAULT_LIFETIME
and default expiration time for "others" of DEFAULT_EXPIRATION
Advertisement indexes are shared with a rendezvous peer upon connect,
and subsequent publications are shared at a an implementation specified interval
advertisement
- publish an advertisement within this group
IOException
- - If an I/O error occursvoid publish(Advertisement advertisement, int type) throws IOException
DEFAULT_LIFETIME
and default expiration time for "others" of DEFAULT_EXPIRATION
Advertisement indexes are shared with a rendezvous peer upon connect,
and subsequent publications are shared at a an implementation specified interval
advertisement
- publish an advertisement within this grouptype
- Discovery type PEER, GROUP, ADV
IOException
- - If an I/O error occursvoid publish(Advertisement adv, long lifetime, long lifetimeForOthers) throws IOException
lifetime
- the amount of time this advertisement will live in
my cache in millisecondslifetimeForOthers
- the amount of time this advertisement will live in
other people's caches in milliseconds.adv
- advertisement to publish
IOException
- - If an I/O error occursvoid publish(Advertisement adv, int type, long lifetime, long lifetimeForOthers) throws IOException
type
- Discovery type PEER, GROUP, ADVlifetime
- the amount of time this advertisement will live in
my cache in millisecondslifetimeForOthers
- the amount of time this advertisement will live in
other people's caches in milliseconds.adv
- advertisement to publish
IOException
- - If an I/O error occursvoid remotePublish(Advertisement adv, int type)
type
- Discovery type PEER, GROUP, ADVadv
- advertisement to publishvoid remotePublish(Advertisement adv)
adv
- advertisement to publishvoid remotePublish(Advertisement adv, int type, long lifetime)
type
- Discovery type PEER, GROUP, ADVlifetime
- the amount of time to advise other nodes to hold this
advertisement in their caches.adv
- advertisement to publishvoid remotePublish(Advertisement adv, long lifetime)
lifetime
- the amount of time to advise other nodes to hold this
advertisement in their caches.adv
- advertisement to publishvoid remotePublish(String peerid, Advertisement adv, int type)
peerid
- id of a peer, specifying null results in a propagate
within the grouptype
- Discovery type PEER, GROUP, ADVadv
- advertisement to publishvoid remotePublish(String peerid, Advertisement adv)
peerid
- id of a peer, specifying null results in a propagate
within the groupadv
- advertisement to publishvoid remotePublish(String peerid, Advertisement adv, int type, long lifetime)
peerid
- id of a peer, specifying null results in a propagate
within the grouptype
- Discovery type PEER, GROUP, ADVlifetime
- the amount of time to advise other nodes to hold this
advertisement in their caches.adv
- advertisement to publishvoid remotePublish(String peerid, Advertisement adv, long lifetime)
peerid
- id of a peer, specifying null results in a propagate
within the grouplifetime
- the amount of time to advise other nodes to hold this
advertisement in their caches.adv
- advertisement to publishvoid flushAdvertisement(Advertisement adv) throws IOException
adv
- Advertisement to remove
IOException
- - If an I/O error occursvoid flushAdvertisements(String id, int type) throws IOException
id
- Document ID, Peer ID, or PeerGroup ID
flushs all content of type "type"type
- Discovery type PEER, GROUP, ADV
IOException
- - If an I/O error occurslong getAdvExpirationTime(ID id, int type)
id
- Document ID, Peer ID, or PeerGroup IDtype
- Discovery type PEER, GROUP, ADV
long getAdvLifeTime(ID id, int type)
id
- Document ID, Peer ID, or PeerGroup IDtype
- Discovery type PEER, GROUP, ADV
long getAdvExpirationTime(Advertisement adv)
adv
- Advertisement
long getAdvLifeTime(Advertisement adv)
adv
- Advertisement
void addDiscoveryListener(DiscoveryListener listener)
listener
- The feature to be added to the DiscoveryListener attributeboolean removeDiscoveryListener(DiscoveryListener listener)
listener
- listener to be called back for discovery events
|
JXTA J2SE | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |