JXTA

net.jxta.instantp2p
Class Discover

java.lang.Object
  |
  +--net.jxta.instantp2p.Discover

public class Discover
extends java.lang.Object

Discovers peers and peergroups.

Since:
JXTA 1.0

Constructor Summary
Discover(net.jxta.peergroup.PeerGroup group)
          Creates a new Discover service.
 
Method Summary
 void flush()
          Clears the local cache of all stored peers and pee groups.
 java.util.Enumeration getAdvertisements()
          Searches for service advertisments.
 java.util.Enumeration getAdvertisements(java.lang.String peerID)
          Returns an Enumeration to discovered service advertisment objects.
 java.util.Enumeration getAdvertisements(java.lang.String peerID, java.lang.String attribute, java.lang.String value)
          Returns an Enumeration to discovered service advertisment objects.
 net.jxta.discovery.Discovery getDiscovery()
          Returns the instance of the Discovery service we are currently using
 java.util.Enumeration getGroups()
          Returns an Enumeration to all groups discovered.
 java.util.Enumeration getGroups(java.lang.String peerID)
          Returns an Enumeration to all groups discovered.
 java.util.Enumeration getGroups(java.lang.String peerID, java.lang.String attribute, java.lang.String value)
          Returns an Enumeration to all groups discovered.
 net.jxta.peergroup.PeerGroup getPeerGroup()
          Returns the peer group currently in use
 java.util.Enumeration getPeers()
          Discovers the peers in the current group which are currently in the local cache
 java.util.Enumeration getPeers(java.lang.String peerID)
          Discovers the peers in the current group.
 java.util.Enumeration getPeers(java.lang.String peerID, java.lang.String attribute, java.lang.String value)
          Discovers the peers in the current group by searching the local cache.
 void getRemoteAdvertisements(java.lang.String peerID, java.lang.String attribute, java.lang.String value)
          Sends a request to remotely find service Advertisments.
 void getRemoteGroups(int threshold)
          Sends a request to remotely find available peer groups The response from any one peer is limited to threshold.
 void getRemoteGroups(java.lang.String peerID, java.lang.String attribute, java.lang.String value, int threshold)
          Sends a request to remotely find available peer groups.
 void getRemotePeers(int threshold)
          Sends a request to remotely find the peer members of the current peer group.
 void setPeerGroup(net.jxta.peergroup.PeerGroup group)
          Changes the peer group.
 int setThreashold(int value)
          Sets the threshold for the number of responses expected from any one peer we query.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Discover

public Discover(net.jxta.peergroup.PeerGroup group)
Creates a new Discover service. The peer group is set to group, the threshold value is set to THRESHOLD and we initatiate a search for remote peers in the given peer group.
Parameters:
group - the peer group in which context to do all discovery
Method Detail

getDiscovery

public net.jxta.discovery.Discovery getDiscovery()
Returns the instance of the Discovery service we are currently using
Returns:
the instance of the Discovery service currently in use

setPeerGroup

public void setPeerGroup(net.jxta.peergroup.PeerGroup group)
Changes the peer group. The discovery services instance is changed to the one used by group and a search for remote peers is initiated.
Parameters:
group - the new peer group

getPeerGroup

public net.jxta.peergroup.PeerGroup getPeerGroup()
Returns the peer group currently in use
Returns:
the current peer group

setThreashold

public int setThreashold(int value)
Sets the threshold for the number of responses expected from any one peer we query.
Parameters:
value - the new threshold value
Returns:
the old value for the threshold

getGroups

public java.util.Enumeration getGroups()
Returns an Enumeration to all groups discovered. A remote search for all groups is initiated and then the local store is queried to return the peer groups found.
Returns:
an Enumeration to the groups found

getGroups

public java.util.Enumeration getGroups(java.lang.String peerID)
Returns an Enumeration to all groups discovered. The request for groups will be send to the peer given in peerId, which is probably running a rendez service. If peerId is null, discovery is done by mulitcast and/or via known rendezvous points. A remote search for all groups is initiated and then the local store is queried to return the peer groups found.
Parameters:
peerId - the peerId of the peer to query
Returns:
an Enumeration to the groups found

getGroups

public java.util.Enumeration getGroups(java.lang.String peerID,
                                       java.lang.String attribute,
                                       java.lang.String value)
Returns an Enumeration to all groups discovered. The request for groups will be send to the peer given in peerId, which is probably running a rendez service. If peerId is null, discovery is done by mulitcast and/or via known rendezvous points. In addition the search is limited to advertisments that contain the indicated attribute value pair.
Parameters:
peerId - the peerId of the peer to query
attribute - attribute name to narrow discovery to
value - value of attribute to narrow disocvery to
Returns:
an Enumeration to the groups found

getPeers

public java.util.Enumeration getPeers()
Discovers the peers in the current group which are currently in the local cache
Returns:
an Enumeration of the discovered peers

getPeers

public java.util.Enumeration getPeers(java.lang.String peerID)
Discovers the peers in the current group. The request for peer discovery will be send to the peer given in peerId, which is probably running a rendez service. If peerId is null, discovery is done by mulitcast and/or via known rendezvous points. A remote search for peers is initiated and then the local store is queried and the result is returned.
Parameters:
peerId - the peerId of the peer to query
Returns:
an Enumeration of the discovered peers

getPeers

public java.util.Enumeration getPeers(java.lang.String peerID,
                                      java.lang.String attribute,
                                      java.lang.String value)
Discovers the peers in the current group by searching the local cache. The request for peer discovery will be send to the peer given in peerId, which is probably running a rendez service. If peerId is null, discovery is done by mulitcast and/or via known rendezvous points. In addition the search is limited to advertisments that contain the indicated attribute value pair.
Parameters:
peerId - the peerId of the peer to query
attribute - attribute name to narrow discovery to
value - value of attribute to narrow disocvery to
Returns:
an Enumeration of the discovered peers

getAdvertisements

public java.util.Enumeration getAdvertisements()
Searches for service advertisments. A remote search is initiated and then the values stored in the local cache are returned
Returns:
an Enumeration to the advertisements found

getAdvertisements

public java.util.Enumeration getAdvertisements(java.lang.String peerID)
Returns an Enumeration to discovered service advertisment objects. The request for advertisments will be send to the peer given in peerId, which is probably running a rendez service. If peerId is null, discovery is done by mulitcast and/or via known rendezvous points.
Parameters:
peerId - the peerId of the peer to query
attribute - attribute name to narrow discovery to
value - value of attribute to narrow disocvery to
Returns:
an Enumeration to the advertisements found

getAdvertisements

public java.util.Enumeration getAdvertisements(java.lang.String peerID,
                                               java.lang.String attribute,
                                               java.lang.String value)
Returns an Enumeration to discovered service advertisment objects. The request for advertisments will be send to the peer given in peerId, which is probably running a rendez service. If peerId is null, discovery is done by mulitcast and/or via known rendezvous points. In addition the search is limited to advertisments that contain the indicated attribute value pair.
Parameters:
peerId - the peerId of the peer to query
attribute - attribute name to narrow discovery to
value - value of attribute to narrow disocvery to
Returns:
an Enumeration to the advertisements found

getRemotePeers

public void getRemotePeers(int threshold)
Sends a request to remotely find the peer members of the current peer group. The response from any one peer is limited to threshold. The result will be deposited into the local cache and can later be retrieved from that cache.
Parameters:
threshold - limit to the response of any one peer

getRemoteGroups

public void getRemoteGroups(int threshold)
Sends a request to remotely find available peer groups The response from any one peer is limited to threshold. The result will be deposited into the local cache and can later be retrieved from that cache.
Parameters:
threshold - limit to the response of any one peer

getRemoteGroups

public void getRemoteGroups(java.lang.String peerID,
                            java.lang.String attribute,
                            java.lang.String value,
                            int threshold)
Sends a request to remotely find available peer groups. The response from any one peer is limited to threshold. The result will be deposited into the local cache and can later be retrieved from that cache. The request for groups will be send to the peer given in peerId, which is probably running a rendez service. If peerId is null, discovery is done by mulitcast and/or via known rendezvous points. In addition the search is limited to advertisments that contain the indicated attribute value pair.
Parameters:
peerId - the peerId of the peer to query
attribute - attribute name to narrow discovery to
value - value of attribute to narrow disocvery to
threshold - limit to the response of any one peer

getRemoteAdvertisements

public void getRemoteAdvertisements(java.lang.String peerID,
                                    java.lang.String attribute,
                                    java.lang.String value)
Sends a request to remotely find service Advertisments. The response from any one peer is limited to threshold. The result will be deposited into the local cache and can later be retrieved from that cache. The request for advertisements will be send to the peer given in peerId, which is probably running a rendez service. If peerId is null, discovery is done by mulitcast and/or via known rendezvous points. In addition the search is limited to advertisments that contain the indicated attribute value pair.
Parameters:
peerId - the peerId of the peer to query
attribute - attribute name to narrow discovery to
value - value of attribute to narrow disocvery to
threshold - limit to the response of any one peer

flush

public void flush()
Clears the local cache of all stored peers and pee groups.

JXTA