|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.p2psockets.P2PNameService
This class provides a "Name Service" facade to the JXTA network. It provides a standard way to resolve a hostname, port, or IP address into a JXTA socket that can be used to communicate with the given endpoint (the 'resolve' set of methods). It also provides a set of methods to 'bind' a given hostname, port, or IP address together, and returns a JXTA server socket that can be used to service clients that communicate with this endpoint. Implementation Notes: The IP address we generate is created from a random number generator, using no seed. We use all four bytes. If the localhost or "any" interfaces are requested, we generate a random IP address and then cache the value so that the same local IP address is always returned for this session (though it will clear out if the JVM is restarted). This class has been extensively refactored to port to JXTA 2.3.1. We used to have an application peer group nested inside the net peer group; inside of this group we would create another peer group for each host name. When I tried to port P2P Sockets to JXTA 2.3.1 I ran into all sorts of strange problems that I could not solve, so to get around them I decided to drastically simplify how P2P Sockets works. Now we only have one peer group, the net peer group, that we publish all of our JXTA Server Socket ads into. We set the Name tag for all of these ads as follows: appName/IPAddress/hostName:port For example: Paper Airplane/33.66.23.88/www.nike.laborpolicy:80 Threading: this class is threadsafe because it is both static and has no private variables.
Field Summary | |
static java.lang.String |
NAME_FIELD
The field that holds the domain name. |
static java.lang.String |
PEER_SERVICE_PREFIX
This is an optional prefix, such as "www.", that will be added to automatically generated peer domain names, such as "www.bradgnuberg.peer". |
static java.lang.String |
PEER_SERVICE_SUFFIX
To make it easy to differentiate peer services from peer group services, all peer domain names must end with this ending. |
Constructor Summary | |
P2PNameService()
|
Method Summary | |
protected static void |
becomeRendezvous(net.jxta.peergroup.PeerGroup inGroup)
If we create a new P2P server peer group or publish a port ad into the group then we automatically become a rendezvous server. |
static net.jxta.socket.JxtaServerSocket |
bind(P2PSocketAddress endpoint,
net.jxta.peergroup.PeerGroup hostParentPeerGroup)
Creates and binds the given P2PSocketAddress to run in the PeerGroup 'hostParentPeerGroup'. |
protected static net.jxta.protocol.PipeAdvertisement |
createAndPublishPipe(java.lang.String advName,
net.jxta.peergroup.PeerGroup startServerInGroup)
|
protected static net.jxta.protocol.PipeAdvertisement |
createPipeAdvertisement(java.lang.String advName,
net.jxta.peergroup.PeerGroup parentPeerGroup)
|
static java.lang.String |
findHostName(java.lang.String ipAddress)
This method will search on the network to find an advertisement for the given IP address and discover the host name for that IP address. |
static java.lang.String |
findHostName(java.lang.String ipAddress,
net.jxta.peergroup.PeerGroup searchInPeerGroup)
This method will search on the network to find an advertisement for the given IP address and discover the host name for that IP address. |
static byte[] |
findIPAddress(java.lang.String host)
This method will search on the network to find an advertisement for the given host and discover the IP address for that host. |
static byte[] |
findIPAddress(java.lang.String host,
net.jxta.peergroup.PeerGroup searchInPeerGroup)
This method will search on the network to find an advertisement for the given host and discover the IP address for that host. |
protected static byte[] |
generateHash(java.lang.String clearTextID,
java.lang.String function)
|
protected static net.jxta.pipe.PipeID |
getPipeID(java.lang.String advName,
net.jxta.peergroup.PeerGroup parentPeerGroup)
|
static boolean |
isHostNameTaken(java.lang.String hostName)
Determines if the given host name is already being used on the peer network. |
static boolean |
isIPAddressTaken(java.lang.String ipAddress)
Determines if the given IP address is already taken. |
static boolean |
isPortTaken(java.lang.String hostName,
int port)
Determines if the given port for the given host name is already being used in the peer network. |
static net.jxta.socket.JxtaSocket |
resolve(byte[] ipAddress,
int port,
net.jxta.peergroup.PeerGroup hostParentPeerGroup)
Resolves the given IP address and port name in the given peer group to a socket that can be used to communicate with this service. |
static net.jxta.socket.JxtaSocket |
resolve(P2PSocketAddress endpoint,
net.jxta.peergroup.PeerGroup hostParentPeerGroup)
Resolves the given remote socket address in the given peer group to a socket that can be used to communicate with this service. |
static net.jxta.socket.JxtaSocket |
resolve(java.lang.String host,
int port,
net.jxta.peergroup.PeerGroup hostParentPeerGroup)
Resolves the given host and port name in the given peer group to a socket that can be used to communicate with this service. |
protected static net.jxta.protocol.PipeAdvertisement |
searchForPipeAdvertisement(java.lang.String advName,
net.jxta.peergroup.PeerGroup parentPeerGroup)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String PEER_SERVICE_SUFFIX
public static final java.lang.String PEER_SERVICE_PREFIX
public static final java.lang.String NAME_FIELD
Constructor Detail |
public P2PNameService()
Method Detail |
public static net.jxta.socket.JxtaServerSocket bind(P2PSocketAddress endpoint, net.jxta.peergroup.PeerGroup hostParentPeerGroup) throws java.io.IOException
java.io.IOException
public static net.jxta.socket.JxtaSocket resolve(P2PSocketAddress endpoint, net.jxta.peergroup.PeerGroup hostParentPeerGroup) throws java.io.IOException
java.io.IOException
public static net.jxta.socket.JxtaSocket resolve(java.lang.String host, int port, net.jxta.peergroup.PeerGroup hostParentPeerGroup) throws java.io.IOException
java.io.IOException
public static net.jxta.socket.JxtaSocket resolve(byte[] ipAddress, int port, net.jxta.peergroup.PeerGroup hostParentPeerGroup) throws java.io.IOException
java.io.IOException
public static byte[] findIPAddress(java.lang.String host) throws java.io.IOException, java.net.UnknownHostException
java.io.IOException
java.net.UnknownHostException
public static byte[] findIPAddress(java.lang.String host, net.jxta.peergroup.PeerGroup searchInPeerGroup) throws java.io.IOException, java.net.UnknownHostException
java.io.IOException
java.net.UnknownHostException
public static java.lang.String findHostName(java.lang.String ipAddress) throws java.io.IOException, java.net.UnknownHostException
java.io.IOException
java.net.UnknownHostException
public static java.lang.String findHostName(java.lang.String ipAddress, net.jxta.peergroup.PeerGroup searchInPeerGroup) throws java.io.IOException, java.net.UnknownHostException
java.io.IOException
java.net.UnknownHostException
public static boolean isHostNameTaken(java.lang.String hostName) throws java.io.IOException
java.io.IOException
public static boolean isPortTaken(java.lang.String hostName, int port) throws java.io.IOException
java.io.IOException
public static boolean isIPAddressTaken(java.lang.String ipAddress) throws java.io.IOException
java.io.IOException
protected static net.jxta.protocol.PipeAdvertisement createAndPublishPipe(java.lang.String advName, net.jxta.peergroup.PeerGroup startServerInGroup) throws java.lang.Exception
java.lang.Exception
protected static net.jxta.protocol.PipeAdvertisement createPipeAdvertisement(java.lang.String advName, net.jxta.peergroup.PeerGroup parentPeerGroup) throws java.lang.Exception
java.lang.Exception
protected static net.jxta.protocol.PipeAdvertisement searchForPipeAdvertisement(java.lang.String advName, net.jxta.peergroup.PeerGroup parentPeerGroup)
protected static net.jxta.pipe.PipeID getPipeID(java.lang.String advName, net.jxta.peergroup.PeerGroup parentPeerGroup) throws java.lang.Exception
java.lang.Exception
protected static void becomeRendezvous(net.jxta.peergroup.PeerGroup inGroup) throws java.lang.Exception
java.lang.Exception
protected static byte[] generateHash(java.lang.String clearTextID, java.lang.String function)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |