org.tranche.network
Class NetworkUtil

java.lang.Object
  extended by org.tranche.network.NetworkUtil

public class NetworkUtil
extends java.lang.Object

Manages the representation of the Tranche network.

Author:
James "Augie" Hill - augman85@gmail.com, Bryan Smith - bryanesmith@gmail.com

Method Summary
static void addBannedServerHost(java.lang.String host)
           
static void clearLocalServer()
          Called by the Server upon shutdown.
static java.util.Collection<java.lang.String> getBannedServerHosts()
           
static Server getLocalServer()
          Returns the Tranche server running on this JVM, if there is one.
static StatusTableRow getLocalServerRow()
          Returns the status row for the Tranche server on this JVM, if there is one.
static java.util.Collection<java.lang.String> getStartupServerURLs()
          Returns the collection of startup server URL's.
static StatusTable getStatus()
          Returns the master status table for this JVM.
static boolean isBannedServer(java.lang.String host)
           
static boolean isStartupServer(java.lang.String host)
          Returns whether the given host name is within the list of startup Tranche server URL's.
static void lazyLoad()
          Loads the network status from one of the startup servers and calls the ConnectionUtil.adjustConnections() method.
static void reload()
           
static void restartUpdateProcess()
          Stops and starts the running update process.
static void setBannedServerHosts(java.util.Collection<java.lang.String> serverHosts)
           
static void setLocalServer(Server localServer)
          Sets the Tranche server for this JVM.
static void setStartupServerURLs(java.util.Collection<java.lang.String> serverURLs)
          Clears all the startup server URL's and adds the ones from the given collection of server URL's.
static void updateRow(StatusTableRow row)
          Updates the master status table with the given rows except when trying to update the local server row.
static void updateRows(java.util.Collection<StatusTableRow> rows)
          Updates the master status table with the given rows except when trying to update the local server row.
static void waitForStartup()
          Waits until the network is loaded.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setBannedServerHosts

public static void setBannedServerHosts(java.util.Collection<java.lang.String> serverHosts)
Parameters:
serverHosts -

addBannedServerHost

public static void addBannedServerHost(java.lang.String host)
Parameters:
host -

getBannedServerHosts

public static java.util.Collection<java.lang.String> getBannedServerHosts()
Returns:

isBannedServer

public static boolean isBannedServer(java.lang.String host)
Parameters:
host -
Returns:

setStartupServerURLs

public static void setStartupServerURLs(java.util.Collection<java.lang.String> serverURLs)

Clears all the startup server URL's and adds the ones from the given collection of server URL's.

Parameters:
serverURLs - A collection of Tranche server URL's

getStartupServerURLs

public static java.util.Collection<java.lang.String> getStartupServerURLs()

Returns the collection of startup server URL's.

Returns:
A collection of startup server URL's

isStartupServer

public static boolean isStartupServer(java.lang.String host)

Returns whether the given host name is within the list of startup Tranche server URL's.

Parameters:
host - A host name
Returns:
Whether the given host name is within the list of startup Tranche server URL's

reload

public static void reload()

waitForStartup

public static void waitForStartup()

Waits until the network is loaded.


lazyLoad

public static void lazyLoad()

Loads the network status from one of the startup servers and calls the ConnectionUtil.adjustConnections() method.

Throws:
java.lang.Exception

updateRow

public static void updateRow(StatusTableRow row)

Updates the master status table with the given rows except when trying to update the local server row.

If the local server row needs to be updated use NetworkUtil.getLocalServerRow().update(NetworkUtil.getLocalServer()) method.

Parameters:
row - A status row

updateRows

public static void updateRows(java.util.Collection<StatusTableRow> rows)

Updates the master status table with the given rows except when trying to update the local server row.

If the local server row needs to be updated use NetworkUtil.getLocalServerRow().update(NetworkUtil.getLocalServer()) method.

Parameters:
rows - A collection of status rows

restartUpdateProcess

public static void restartUpdateProcess()

Stops and starts the running update process.


getStatus

public static StatusTable getStatus()

Returns the master status table for this JVM.

Returns:
The status table for this JVM

getLocalServer

public static Server getLocalServer()

Returns the Tranche server running on this JVM, if there is one.

Returns:
The Tranche server running on this JVM, if there is one

getLocalServerRow

public static StatusTableRow getLocalServerRow()

Returns the status row for the Tranche server on this JVM, if there is one. Return NULL if there is no Trache server running on the local JVM.

Returns:
The status row for the Tranche server on this JVM

clearLocalServer

public static void clearLocalServer()

Called by the Server upon shutdown.


setLocalServer

public static void setLocalServer(Server localServer)

Sets the Tranche server for this JVM.

Will set the row in the network status table and load the network, if necessary.

Parameters:
localServer - A local Tranche server


This code is free for use both commercially and non-commercially as stated in the project's license