|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.tranche.network.ConnectionUtil
public class ConnectionUtil
Manages the Tranche server connections for the local JVM.
| Method Summary | |
|---|---|
static void |
addListener(ConnectionListener l)
Adds a connection listener. |
protected static void |
adjustConnection(java.lang.String host,
int port,
boolean ssl)
Updates the connection to use the given set of connection parameters. |
static void |
adjustConnections()
Establishes the connections for the client and the server to work with. |
static void |
clearExceptionsHost(java.lang.String host)
|
static TrancheServer |
connect(StatusTableRow row,
boolean locked)
Forces a connection on the Tranche server represented by the given row. |
static TrancheServer |
connect(java.lang.String host,
int port,
boolean secure,
boolean locked)
|
static TrancheServer |
connectHost(java.lang.String host,
boolean locked)
Forces a connection on the Tranche server with the given host name. |
static TrancheServer |
connectURL(java.lang.String url,
boolean locked)
Forces a connection on the Tranche server represented by the given URL. |
static void |
flagOffline(java.lang.String host)
Must FIRST safely force the closure of the connection. |
static void |
flagOffline(java.lang.String host,
java.lang.String reason)
Must FIRST safely force the closure of the connection. |
static TrancheServer |
get(StatusTableRow row)
Gets the connection to a Tranche server. |
static java.util.Collection<java.lang.String> |
getConnectedHosts()
Returns the host names for the servers with which there is an open connection. |
static java.util.Collection<StatusTableRow> |
getConnectedRows()
Returns the rows for the servers with which there is an open connection. |
static java.util.Collection<java.lang.String> |
getConnectedURLs()
Returns the URLs for the servers with which there is an open connection. |
static Connection |
getConnection(java.lang.String host)
|
static TrancheServer |
getHost(java.lang.String host)
Gets the connection to the Tranche server with the given host name. |
static java.util.Collection<ConnectionListener> |
getListeners()
|
static boolean |
isConnected(java.lang.String host)
Returns whether there is a connection open to the server with the given host name. |
static boolean |
isLocked(java.lang.String host)
|
static void |
lockConnection(java.lang.String host)
|
static void |
removeListener(ConnectionListener l)
Removes the given connection listener. |
static void |
reportException(StatusTableRow row,
java.lang.Exception e)
Interprets an exception as it occurred during communication with a Tranche server. |
static void |
reportExceptionHost(java.lang.String host,
java.lang.Exception e)
Interprets an exception as it occurred during communication with a Tranche server. |
static void |
reportExceptionURL(java.lang.String URL,
java.lang.Exception e)
Interprets an exception as it occurred during communication with a Tranche server. |
static void |
safeClose(StatusTableRow row)
Reports that a process is done using a Tranche server connection. |
static void |
safeCloseHost(java.lang.String host)
Reports that a process is done using a Tranche server connection. |
static void |
safeCloseURL(java.lang.String url)
Reports that a process is done using a Tranche server connection. |
static void |
safeForceClose(java.lang.String host,
java.lang.String reason)
Closes the connection immediately. |
static void |
safeForceCloseAll(java.lang.String reason)
|
static int |
size()
Gets the number of open connections. |
static void |
unlockConnection(java.lang.String host)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static boolean isConnected(java.lang.String host)
Returns whether there is a connection open to the server with the given host name.
host - A host name
public static boolean isLocked(java.lang.String host)
host -
public static int size()
Gets the number of open connections.
public static java.util.Collection<java.lang.String> getConnectedHosts()
Returns the host names for the servers with which there is an open connection.
public static java.util.Collection<StatusTableRow> getConnectedRows()
Returns the rows for the servers with which there is an open connection.
public static java.util.Collection<java.lang.String> getConnectedURLs()
Returns the URLs for the servers with which there is an open connection.
public static TrancheServer get(StatusTableRow row)
Gets the connection to a Tranche server.
Returns NULL if there is no connection with the Tranche server.
row - A row representing a Tranche server.
public static TrancheServer getHost(java.lang.String host)
Gets the connection to the Tranche server with the given host name.
Returns NULL if there is no connection with the Tranche server.
host - A host name
public static TrancheServer connect(StatusTableRow row,
boolean locked)
throws java.lang.Exception
Forces a connection on the Tranche server represented by the given row.
row - A row representing a Tranche serverlocked -
java.lang.Exception
public static TrancheServer connectHost(java.lang.String host,
boolean locked)
throws java.lang.Exception
Forces a connection on the Tranche server with the given host name.
host - A host namelocked -
java.lang.Exception
public static TrancheServer connect(java.lang.String host,
int port,
boolean secure,
boolean locked)
throws java.lang.Exception
host - port - secure - locked -
java.lang.Exception
public static TrancheServer connectURL(java.lang.String url,
boolean locked)
throws java.lang.Exception
Forces a connection on the Tranche server represented by the given URL.
url - A Tranche server URLlocked -
java.lang.Exception
public static void reportException(StatusTableRow row,
java.lang.Exception e)
Interprets an exception as it occurred during communication with a Tranche server.
Take care to ensure that only exceptions having to do with the communication with the Tranche server are being reported.
row - A rowe - An exception
public static void reportExceptionURL(java.lang.String URL,
java.lang.Exception e)
Interprets an exception as it occurred during communication with a Tranche server.
Take care to ensure that only exceptions having to do with the communication with the Tranche server are being reported.
URL - A Tranche URLe - An exception
public static void reportExceptionHost(java.lang.String host,
java.lang.Exception e)
Interprets an exception as it occurred during communication with a Tranche server.
Take care to ensure that only exceptions having to do with the communication with the Tranche server are being reported.
host - A host namee - An exceptionpublic static void clearExceptionsHost(java.lang.String host)
host - public static void flagOffline(java.lang.String host)
Must FIRST safely force the closure of the connection.
Sets a server as offline in the network status.
host - A host name
public static void flagOffline(java.lang.String host,
java.lang.String reason)
Must FIRST safely force the closure of the connection.
Sets a server as offline in the network status.
host - A host namereason - Brief explanation why flagging offline. Can be null, but any information helps.public static void lockConnection(java.lang.String host)
host - public static void unlockConnection(java.lang.String host)
host - public static Connection getConnection(java.lang.String host)
host -
public static void safeClose(StatusTableRow row)
Reports that a process is done using a Tranche server connection.
row - A status rowpublic static void safeCloseURL(java.lang.String url)
Reports that a process is done using a Tranche server connection.
url - A Tranche URLpublic static void safeCloseHost(java.lang.String host)
Reports that a process is done using a Tranche server connection.
host - A host name
public static void safeForceClose(java.lang.String host,
java.lang.String reason)
Closes the connection immediately.
host - A host namereason - An arbitrary message explaining why called. Useful for troubleshooting.public static void safeForceCloseAll(java.lang.String reason)
reason -
protected static void adjustConnection(java.lang.String host,
int port,
boolean ssl)
Updates the connection to use the given set of connection parameters.
When some connection parameters change, need to kill the old connection and open a new one.
host - A host nameport - A port numberssl - Whether the server communicates over SSLpublic static void adjustConnections()
Establishes the connections for the client and the server to work with.
For the client, this means connecting to a full hash span with read/write priveleges for all hashes.
For a data server, this means connecting to the servers from which to perform updates to the network status table, the servers with overlapping hash spans, and also a full hash span of servers (for maintenance of sticky chunks.)
For a routing server, this means connecting to the servers from which to perform update to the network status table and the servers being routed to.
If connections have already been made, will try to make as few changes as possible to that pool of existing connections.
public static void addListener(ConnectionListener l)
Adds a connection listener.
l - A connection listenerpublic static void removeListener(ConnectionListener l)
Removes the given connection listener.
l - A connection listenerpublic static java.util.Collection<ConnectionListener> getListeners()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||