|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.limegroup.gnutella.RouterService
A facade for the entire LimeWire backend. This is the GUI's primary way of communicating with the backend. RouterService constructs the backend components. Typical use is as follows:
RouterService rs = new RouterService(ActivityCallback); rs.start(); rs.query(...); rs.download(...); rs.shutdown();The methods of this class are numerous, but they tend to fall into one of the following categories:
Constructor Summary | |
RouterService(ActivityCallback callback)
Creates a new RouterService instance. |
|
RouterService(ActivityCallback callback,
MessageRouter router)
Creates a new RouterService instance with special message handling code. |
|
RouterService(ActivityCallback ac,
MessageRouter mr,
FileManager fm)
|
Method Summary | |
static boolean |
acceptedIncomingConnection()
Returns true if this has accepted an incoming connection, and hence probably isn't firewalled. |
static boolean |
addressChanged()
Notifies components that this' IP address has changed. |
static void |
adjustSpamFilters()
Notifies the backend that spam filters settings have changed, and that extra work must be done. |
static void |
clearHostCatcher()
Clears the hostcatcher. |
static void |
connect()
Connects to the network. |
static void |
connectToHostAsynchronously(java.lang.String hostname,
int portnum)
Creates a new outgoing messaging connection to the given host and port. |
static ManagedConnection |
connectToHostBlocking(java.lang.String hostname,
int portnum)
Creates a new outgoing messaging connection to the given host and port. |
static int |
countConnectionsWithNMessages(int messageThreshold)
Count how many connections have already received N messages |
static Chatter |
createChat(java.lang.String host,
int port)
Creates and returns a new chat to the given host and port. |
static void |
disconnect()
Disconnects from the network. |
static void |
doBrowseHost(java.lang.String host,
int port,
GUID guid,
GUID serventID,
java.util.Set proxies)
Browses the passed host |
static Downloader |
download(java.io.File incompleteFile)
Starts a resume download for the given incomplete file. |
static Downloader |
download(RemoteFileDesc[] files,
boolean overwrite)
Stub for calling download(RemoteFileDesc[], DataUtils.EMPTY_LIST, boolean) |
static Downloader |
download(RemoteFileDesc[] files,
java.util.List alts,
boolean overwrite)
Tries to "smart download" any [sic] of the given files. |
static Downloader |
download(java.lang.String query,
java.lang.String richQuery,
byte[] guid,
MediaType type)
Starts a "requery download", aka, a "wishlist download". |
static Downloader |
download(URN urn,
java.lang.String textQuery,
java.lang.String filename,
java.lang.String[] defaultURL)
|
static void |
dumpConnections()
Prints out the information about current initialied connections |
static void |
forceKeepAlive(int newKeep)
Forces the backend to try to establish newKeep connections by kicking off connection fetchers as needed. |
static Acceptor |
getAcceptor()
Accessor for the Acceptor instance. |
static int |
getActiveConnectionMessages()
Count up all the messages on active connections |
static byte[] |
getAddress()
Returns the raw IP address for this host. |
static ActivityCallback |
getCallback()
Returns the ActivityCallback passed to this' constructor. |
static ConnectionManager |
getConnectionManager()
Accessor for the ConnectionManager instance. |
static long |
getCurrentUptime()
Returns the current uptime. |
static DownloadManager |
getDownloadManager()
Accessor for the DownloadManager instance in use. |
static FileManager |
getFileManager()
Accessor for the FileManager instance in use. |
static HostCatcher |
getHostCatcher()
Accessor for the HostCatcher instance. |
static java.util.Iterator |
getHosts()
Returns an iterator of the hosts in the host catcher, each an Endpoint. |
static FileDesc[] |
getIncompleteFileDescriptors()
Returns a list of all incomplete shared file descriptors. |
static boolean |
getIsShuttingDown()
Returns whether or not LimeWire is currently in the shutting down state, meaning that a shutdown has been initiated but not completed. |
static long |
getLastQueryTime()
Accessor for the last time a query was originated from this host. |
static MessageRouter |
getMessageRouter()
Accessor for the MessageRouter instance. |
static byte[] |
getNonForcedAddress()
Returns the Non-Forced IP address for this host. |
static int |
getNonForcedPort()
Returns the Non-Forced port for this host. |
static int |
getNumActiveDownloads()
Returns the number of active downloads. |
static int |
getNumConnections()
Returns the number of messaging connections. |
static int |
getNumDownloads()
Returns the number of downloads in progress. |
static long |
getNumFiles()
Returns the number of files in my horizon. |
static int |
getNumFreeLeafSlots()
|
static int |
getNumFreeNonLeafSlots()
|
static long |
getNumHosts()
Returns the number of good hosts in my horizon. |
static int |
getNumIndividualDownloaders()
Returns the number of individual downloaders. |
static int |
getNumInitializedConnections()
Returns the number of initialized messaging connections. |
static int |
getNumLeafToUltrapeerConnections()
Returns the number of leaf -> ultrapeer connections. |
static int |
getNumOldConnections()
Returns the number of old unrouted connections. |
static int |
getNumPendingShared()
Returns the number of files which are awaiting sharing. |
static int |
getNumQueuedUploads()
Returns the number of queued uploads. |
static int |
getNumSharedFiles()
Returns the number of files being shared locally. |
static int |
getNumUltrapeerToLeafConnections()
Returns the number of active ultrapeer -> leaf connections. |
static int |
getNumUltrapeerToUltrapeerConnections()
Returns the number of ultrapeer -> ultrapeer connections. |
static int |
getNumUploads()
Returns the number of uploads in progress. |
static int |
getNumWaitingDownloads()
Returns the number of downloads waiting to be started. |
static int |
getPort()
Returns the port used for downloads and messaging connections. |
static PushManager |
getPushManager()
Accessor for the PushManager instance. |
static int |
getRealNumHosts()
Returns the number of pongs in the host catcher. |
static SearchResultHandler |
getSearchResultHandler()
Accessor for the SearchResultHandler instance. |
static FileDesc[] |
getSharedFileDescriptors(java.io.File directory)
Returns a list of all shared file descriptors in the given directory. |
static int |
getSharedFileSize()
Returns the size in bytes of shared files. |
static long |
getTotalFileSize()
Returns the size of all files in my horizon, in kilobytes. |
static GUID |
getUDPConnectBackGUID()
|
static UDPService |
getUdpService()
Accessor for the UDPService instance. |
static UploadManager |
getUploadManager()
Accessor for the UploadManager instance. |
static boolean |
isConnected()
Returns whether or not this client currently has any initialized connections. |
static boolean |
isGUESSCapable()
Returns whether or not this node is capable of sending its own GUESS queries. |
static boolean |
isMandragoreWorm(byte[] guid,
Response response)
Returns true if the given response for the query with the given guid is a result of the Madragore worm (8KB files of form "x.exe"). |
static boolean |
isShieldedLeaf()
Accessor for whether or not this node is a shielded leaf. |
static boolean |
isStarted()
Used to determine whether or not the backend threads have been started. |
static boolean |
isSupernode()
Tells whether the node is a supernode or not |
static boolean |
matchesType(byte[] guid,
Response response)
Returns true if the given response is of the same type as the the query with the given guid. |
static byte[] |
newQueryGUID()
Returns a new GUID for passing to query. |
static void |
query(byte[] guid,
java.lang.String query)
Searches the network for files with the given query string and minimum speed, i.e., same as query(guid, query, minSpeed, null). |
static void |
query(byte[] guid,
java.lang.String query,
MediaType type)
Searches the network for files of the given type with the given GUID, query string and minimum speed. |
static void |
query(byte[] guid,
java.lang.String query,
java.lang.String richQuery,
MediaType type)
Searches the network for files with the given metadata. |
static void |
removeConnection(ManagedConnection c)
Closes and removes the given connection. |
static void |
removeHost(java.lang.String host,
int port)
Ensures that the given host:port pair is not in the host catcher. |
static void |
schedule(java.lang.Runnable task,
long delay,
long period)
Schedules the given task for repeated fixed-delay execution on this' backend thread. |
static void |
setAlwaysNotifyKnownHost(boolean notify)
Sets the host catcher's flag for always notifing ActivityCallback on a known host added to the catcher. |
static void |
setIsShuttingDown(boolean flag)
Sets the flag for whether or not LimeWire is currently in the process of shutting down. |
static void |
setKeepAlive(int newKeep)
Validates the passed new keep alive, and sets the backend to try to establish newKeep connections by kicking off connection fetchers as needed. |
static void |
setListeningPort(int port)
Sets the port on which to listen for incoming connections. |
static void |
shutdown()
Shuts down the backend and writes the gnutella.net file. |
void |
start()
Starts various threads and tasks once all core classes have been constructed. |
static void |
stopQuery(GUID guid)
Will make all attempts to stop a query from executing. |
static void |
updateHorizon()
Updates the horizon statistics. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public RouterService(ActivityCallback callback)
callback
- the ActivityCallback instance to use for
making callbackspublic RouterService(ActivityCallback ac, MessageRouter mr, FileManager fm)
public RouterService(ActivityCallback callback, MessageRouter router)
callback
- the ActivityCallback instance to use for
making callbacksrouter
- the MessageRouter instance to use for handling
all messagesMethod Detail |
public void start()
public static boolean isStarted()
public static ActivityCallback getCallback()
public static MessageRouter getMessageRouter()
public static FileManager getFileManager()
public static DownloadManager getDownloadManager()
public static UDPService getUdpService()
public static ConnectionManager getConnectionManager()
public static UploadManager getUploadManager()
public static PushManager getPushManager()
public static Acceptor getAcceptor()
public static HostCatcher getHostCatcher()
public static SearchResultHandler getSearchResultHandler()
public static void schedule(java.lang.Runnable task, long delay, long period)
task
- the task to run repeatedlydelay
- the initial delay, in millisecondsperiod
- the delay between executions, in milliseconds
java.lang.IllegalStateException
- this is cancelled
java.lang.IllegalArgumentException
- delay or period negativeSimpleTimer.schedule(java.lang.Runnable,long,long)
public static ManagedConnection connectToHostBlocking(java.lang.String hostname, int portnum) throws java.io.IOException
java.io.IOException
- the connection failedpublic static void connectToHostAsynchronously(java.lang.String hostname, int portnum)
public static void connect()
public static void disconnect()
public static void removeConnection(ManagedConnection c)
public static void clearHostCatcher()
public static int getRealNumHosts()
public static int getNumDownloads()
public static int getNumActiveDownloads()
public static int getNumWaitingDownloads()
public static int getNumIndividualDownloaders()
public static int getNumUploads()
public static int getNumQueuedUploads()
public static long getCurrentUptime()
public static void shutdown()
public static void forceKeepAlive(int newKeep)
newKeep
- the desired total number of messaging connectionspublic static void setKeepAlive(int newKeep) throws BadConnectionSettingException
newKeep
- the desired total number of messaging connections
if
- the suggested keep alive value is not suitable
BadConnectionSettingException
public static void adjustSpamFilters()
public static void setListeningPort(int port) throws java.io.IOException
java.io.IOException
public static void setAlwaysNotifyKnownHost(boolean notify)
public static boolean acceptedIncomingConnection()
public static int getActiveConnectionMessages()
public static int countConnectionsWithNMessages(int messageThreshold)
public static long getNumHosts()
public static long getNumFiles()
public static long getTotalFileSize()
public static void dumpConnections()
public static void updateHorizon()
public static byte[] newQueryGUID()
public static void query(byte[] guid, java.lang.String query, MediaType type)
ActivityCallback is notified asynchronously of responses. These responses can be matched with requests by looking at their GUIDs. (You may want to wrap the bytes with a GUID object for simplicity.) An earlier version of this method returned the reply GUID instead of taking it as an argument. Unfortunately this caused a race condition where replies were returned before the GUI was prepared to handle them.
guid
- the guid to use for the query. MUST be a 16-byte
value as returned by newQueryGUID.query
- the query string to usetype
- the desired type of result (e.g., audio, video), or
null if you don't carepublic static void query(byte[] guid, java.lang.String query)
query(byte[], String, MediaType)
public static void query(byte[] guid, java.lang.String query, java.lang.String richQuery, MediaType type)
richQuery
- metadata query to insert between the nulls,
typically in XML formatquery(byte[], String, MediaType)
public static long getLastQueryTime()
public static void stopQuery(GUID guid)
guid
- The GUID of the query you want to get rid of....public static boolean matchesType(byte[] guid, Response response)
guid
- the value returned by query(..). MUST be 16 bytes long.ResponseVerifier.matchesType(byte[], Response)
public static boolean isMandragoreWorm(byte[] guid, Response response)
guid
- the value returned by query(..). MUST be 16 byts long.ResponseVerifier.isMandragoreWorm(byte[], Response)
public static java.util.Iterator getHosts()
public static int getNumConnections()
public static int getNumInitializedConnections()
public static int getNumUltrapeerToLeafConnections()
public static int getNumLeafToUltrapeerConnections()
public static int getNumUltrapeerToUltrapeerConnections()
public static int getNumOldConnections()
public static boolean isConnected()
public static void removeHost(java.lang.String host, int port)
public static int getNumSharedFiles()
public static int getNumPendingShared()
public static int getSharedFileSize()
public static FileDesc[] getIncompleteFileDescriptors()
public static FileDesc[] getSharedFileDescriptors(java.io.File directory)
If directory is not a shared directory, returns null.
public static Downloader download(RemoteFileDesc[] files, java.util.List alts, boolean overwrite) throws FileExistsException, AlreadyDownloadingException, java.io.FileNotFoundException
If any of the files already being downloaded (or queued for downloaded) has the same temporary name as any of the files in 'files', throws AlreadyDownloadingException. Note, however, that this doesn't guarantee that a successfully downloaded file can be moved to the library.
If overwrite==false, then if any of the files already exists in the download directory, FileExistsException is thrown and no files are modified. If overwrite==true, the files may be overwritten.
Otherwise returns a Downloader that allows you to stop and resume this download. The ActivityCallback will also be notified of this download, so the return value can usually be ignored. The download begins immediately, unless it is queued. It stops after any of the files succeeds.
files
- a group of "similar" files to smart downloadalts
- a List of secondary RFDs to use for other sourcesoverwrite
- true iff the download should proceded without
checking if it's on disk
AlreadyDownloadingException
- the file is already being
downloaded.
FileExistsException
- the file already exists in the library
java.io.FileNotFoundException
DownloadManager#getFiles(RemoteFileDesc[], boolean)
public static Downloader download(RemoteFileDesc[] files, boolean overwrite) throws FileExistsException, AlreadyDownloadingException, java.io.FileNotFoundException
FileExistsException
AlreadyDownloadingException
java.io.FileNotFoundException
public static Downloader download(URN urn, java.lang.String textQuery, java.lang.String filename, java.lang.String[] defaultURL) throws java.lang.IllegalArgumentException, AlreadyDownloadingException
java.lang.IllegalArgumentException
AlreadyDownloadingException
public static Downloader download(java.io.File incompleteFile) throws AlreadyDownloadingException, CantResumeException
AlreadyDownloadingException
- couldn't download because the
another downloader is getting the file
CantResumeException
- incompleteFile is not a valid
incomplete filepublic static Downloader download(java.lang.String query, java.lang.String richQuery, byte[] guid, MediaType type) throws AlreadyDownloadingException
query
- The original query string.richQuery
- The original richQuery string.guid
- The guid associated with this query request.type
- The mediatype associated with this search.
AlreadyDownloadingException
public static Chatter createChat(java.lang.String host, int port)
public static void doBrowseHost(java.lang.String host, int port, GUID guid, GUID serventID, java.util.Set proxies)
host
- The host to browseport
- The port at which to browseguid
- The guid to be used for the query replies received
while browsing hostserventID
- The guid of the client to browse from. I need this in
case I need to push....proxies
- the list of PushProxies we can use - may be null.public static boolean isSupernode()
public static boolean isShieldedLeaf()
public static int getNumFreeLeafSlots()
public static int getNumFreeNonLeafSlots()
public static void setIsShuttingDown(boolean flag)
flag
- the shutting down state to setpublic static boolean getIsShuttingDown()
public static boolean addressChanged()
public static byte[] getAddress()
public static byte[] getNonForcedAddress()
public static int getPort()
Acceptor.getPort(boolean)
public static int getNonForcedPort()
public static boolean isGUESSCapable()
public static GUID getUDPConnectBackGUID()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |