|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.tranche.commons.Debuggable
org.tranche.network.StatusTable
public class StatusTable
Represents a set of servers. Each server is represented by a row in the table.
The table keeps the servers sorted alphabetically by host name.
| Field Summary | |
|---|---|
static int |
VERSION_LATEST
The value for the latest version of the object. |
static int |
VERSION_ONE
The value for the first version of the object. |
| Constructor Summary | |
|---|---|
StatusTable()
Default constructor. |
|
StatusTable(java.util.Collection<StatusTableRow> rows)
|
|
StatusTable(java.io.InputStream in)
Deserializes the table based on the given stream. |
|
| Method Summary | |
|---|---|
void |
addListener(StatusTableListener l)
Adds the given listener to the list of listeners. |
void |
clear()
Removes all the rows from the table. |
StatusTable |
clone()
Creates a duplicate table. |
boolean |
contains(java.lang.String host)
Returns whether a row with the given host name is contained within the table. |
protected void |
deserialize(java.io.InputStream in)
Sets the table based on the given serialized table. |
protected void |
deserializeVersionOne(java.io.InputStream in)
Sets the values of the row based the given version one serialized table. |
boolean |
equals(java.lang.Object o)
Evaluates the given object against this one. |
void |
fireRowsUpdated(java.util.Map<java.lang.String,java.lang.Boolean> hosts,
java.util.Map<java.lang.String,java.lang.Boolean> affectsHashSpans)
Fires an event for having updated a map of hosts. |
void |
fireRowUpdated(java.lang.String host,
boolean affectsConnectivity,
boolean affectsHashSpans)
Fires an event for having updated a row. |
java.lang.String |
getHost(int i)
|
java.util.List<java.lang.String> |
getHosts()
Returns the list of hosts. |
java.util.Collection<StatusTableListener> |
getListeners()
|
StatusTableRow |
getRow(java.lang.String host)
Gets the row with the given host name. |
java.util.List<StatusTableRow> |
getRows()
Returns the rows in the table. |
java.util.List<StatusTableRow> |
getRows(java.lang.String startHost,
java.lang.String endHost)
Gets all of the rows that have host names between startHost (inclusive) and endHost (exclusive.) |
StatusTable |
getStatus(java.lang.String startHost,
java.lang.String endHost)
Returns a status table containing the rows between the two given host names. |
java.util.List<java.lang.String> |
getURLs()
Returns the list of URLs. |
int |
getVersion()
Gets the version. |
int |
hashCode()
|
boolean |
isEmpty()
Returns whether there are no rows in the table. |
void |
removeDefunctRows()
Removes rows that are offline, not connected, and haven't been updated in x number of milliseconds. |
void |
removeListener(StatusTableListener l)
Removes the given listener from the list of listeners. |
void |
removeRow(java.lang.String host)
Removes the rows with the given host name. |
void |
removeRows(java.util.Collection<java.lang.String> hosts)
Removes the rows with host names within the given collection |
void |
serialize(int tableVersion,
int rowVersion,
java.io.OutputStream out)
Write to the output stream in the given table and row versions. |
protected void |
serializeVersionOne(int rowVersion,
java.io.OutputStream out)
Outputs the values in the structure defined by version one to the given output stream. |
protected void |
setRow(StatusTableRow row)
Sets the row in the table. |
protected void |
setRows(java.util.Collection<StatusTableRow> rows)
Sets the rows of the table. |
int |
size()
Gets the number of rows in the table. |
byte[] |
toByteArray(int tableVersion,
int rowVersion)
|
java.lang.String |
toString()
Prints out the values of the attributes in the row. |
| Methods inherited from class org.tranche.commons.Debuggable |
|---|
debugErr, debugErr, debugOut, isDebug, setDebug |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int VERSION_ONE
The value for the first version of the object.
public static final int VERSION_LATEST
The value for the latest version of the object.
| Constructor Detail |
|---|
public StatusTable()
Default constructor.
public StatusTable(java.util.Collection<StatusTableRow> rows)
rows - A collection of rows
public StatusTable(java.io.InputStream in)
throws java.io.IOException
Deserializes the table based on the given stream.
in - The stream containing a serialized row
java.io.IOException| Method Detail |
|---|
public int getVersion()
Gets the version.
public void clear()
Removes all the rows from the table.
protected void setRows(java.util.Collection<StatusTableRow> rows)
Sets the rows of the table. The rows are sorted alphabetically by host name.
Will overwrite rows of the same host names.
Does not clear the previous rows.
rows - A collection of rowsprotected void setRow(StatusTableRow row)
Sets the row in the table. The rows are sorted alphabetically by host name.
Will overwrite rows of the same host names.
If setting many rows, use setRows(Collection
row - A rowpublic void removeDefunctRows()
Removes rows that are offline, not connected, and haven't been updated in x number of milliseconds.
Also removes banned servers.
public void removeRows(java.util.Collection<java.lang.String> hosts)
Removes the rows with host names within the given collection
hosts - A collection of host namespublic void removeRow(java.lang.String host)
Removes the rows with the given host name.
Removing many rows, use removeRows(Collection
host - public int size()
Gets the number of rows in the table.
public boolean isEmpty()
Returns whether there are no rows in the table.
public java.util.List<StatusTableRow> getRows()
Returns the rows in the table. They will be sorted in alphabetical order by host name.
public java.util.List<StatusTableRow> getRows(java.lang.String startHost,
java.lang.String endHost)
Gets all of the rows that have host names between startHost (inclusive) and endHost (exclusive.)
startHost - Return rows that have host names alphabetically after or equal to this host name.endHost - Return rows that have host names alphabetically before this host name.
public StatusTable getStatus(java.lang.String startHost,
java.lang.String endHost)
Returns a status table containing the rows between the two given host names.
startHost - A host nameendHost - A host name
public StatusTableRow getRow(java.lang.String host)
Gets the row with the given host name.
host - A host name.
public boolean contains(java.lang.String host)
Returns whether a row with the given host name is contained within the table.
host - A host name
public java.lang.String getHost(int i)
i -
public java.util.List<java.lang.String> getHosts()
Returns the list of hosts.
public java.util.List<java.lang.String> getURLs()
Returns the list of URLs.
public byte[] toByteArray(int tableVersion,
int rowVersion)
throws java.io.IOException
java.io.IOException
public void serialize(int tableVersion,
int rowVersion,
java.io.OutputStream out)
throws java.io.IOException
Write to the output stream in the given table and row versions.
out - The output stream
java.io.IOException
protected void serializeVersionOne(int rowVersion,
java.io.OutputStream out)
throws java.io.IOException
Outputs the values in the structure defined by version one to the given output stream.
out - The output stream
java.io.IOException
protected void deserialize(java.io.InputStream in)
throws java.io.IOException
Sets the table based on the given serialized table.
in - An input stream containing a serialized table
java.io.IOException
protected void deserializeVersionOne(java.io.InputStream in)
throws java.io.IOException
Sets the values of the row based the given version one serialized table.
in - An input stream containing a version one serialized table
java.io.IOExceptionpublic StatusTable clone()
Creates a duplicate table.
clone in class java.lang.Objectpublic boolean equals(java.lang.Object o)
Evaluates the given object against this one.
equals in class java.lang.Objecto - A StatusTable object
public int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
Prints out the values of the attributes in the row.
toString in class java.lang.Objectpublic void addListener(StatusTableListener l)
Adds the given listener to the list of listeners.
l - A listenerpublic void removeListener(StatusTableListener l)
Removes the given listener from the list of listeners.
l - A listenerpublic java.util.Collection<StatusTableListener> getListeners()
public void fireRowsUpdated(java.util.Map<java.lang.String,java.lang.Boolean> hosts,
java.util.Map<java.lang.String,java.lang.Boolean> affectsHashSpans)
Fires an event for having updated a map of hosts.
hosts - A map of hosts to whether connectivity was affectedaffectsHashSpans - A map of hosts to whether hash spans were affected
public void fireRowUpdated(java.lang.String host,
boolean affectsConnectivity,
boolean affectsHashSpans)
Fires an event for having updated a row.
host - The host nameaffectsConnectivity - Whether the update changes the connectivity
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||