|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ISSearch.ISPeerTools
This class provides some useful functions for RMI calls of the distributed Peer-to-Peer ISSEarch search engine.
Constructor Summary | |
ISPeerTools()
|
Method Summary | |
static byte[] |
getLocalIP()
Returns the IP address of the current machine. |
static ISPeerServerInterface |
getServer(String host,
int port,
String serviceName)
Returns the reference to the RMI Server (Peer) of the distributed search engine. |
static byte[] |
ID2IP(long id)
Converts the numerical ID of the host into its IP address. |
static long |
IP2ID(byte[] ipAddr)
Converts the IP address represented by 4-byte array to the host ID of the ISSearch engine. |
static String |
IP2String(byte[] ip)
Converts the array representation of the IP address (array of 4 bytes) into text string. |
static ISPeerResultInterface[] |
search(ISPeerServerInterface server,
String query,
int numResults)
Invokes the remote search method of the RMI server. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ISPeerTools()
Method Detail |
public static ISPeerServerInterface getServer(String host, int port, String serviceName) throws Exception
host
- The hostname of the RMI server.port
- The port of the RMI service (default 1099).serviceName
- The service name of the ISSerach search engine on this RMI server.
RemoteException
- if the connection to the remote service cannot be established or fails.
Exception
public static ISPeerResultInterface[] search(ISPeerServerInterface server, String query, int numResults) throws Exception
query
- The query that is submitted by the client. The query syntax is prescribed by Assignment 4 (Query Processor).numResults
- The max number of matches that can be returned as search results for the query.
numResults
matches, sorted
in descending order of similarity.
RemoteException
- or NotBoundException if the remote invocation of the search fails or the connection was not established.
Exception
public static long IP2ID(byte[] ipAddr)
public static byte[] ID2IP(long id)
public static String IP2String(byte[] ip) throws UnknownHostException
ip
- The specified IP address as an 4-byte array.
UnknownHostException,
- if the conversion fails.
UnknownHostException
public static byte[] getLocalIP() throws UnknownHostException
UnknownHostException,
- if the machine has no default network connection.
UnknownHostException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |