|
||||||||||
| 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.StatusTableRow
public class StatusTableRow
A row in the status table. Each row represents a server of the network.
| Field Summary | |
|---|---|
static int |
CAN_READ_BIT
The location of the "Can Read" bit in the set of flags. |
static int |
CAN_WRITE_BIT
The location of the "Can Write" bit in the set of flags. |
static int |
DATA_STORE_BIT
The location of the "Data Store" bit in the set of flags. |
static long |
DEFAULT_FLAGS
The default value for the flags. |
static java.util.Collection<HashSpan> |
DEFAULT_HASH_SPANS
The default set of hash spans. |
static java.util.Collection<HashSpan> |
DEFAULT_TARGET_HASH_SPANS
The default set of target hash spans. |
static int |
LENGTH_MAX_GROUP
The maximum length of the group name. |
static int |
LENGTH_MAX_NAME
The maximum length of the name. |
static int |
ONLINE_BIT
The location of the Online bit in the set of flags. |
static int |
SSL_BIT
The location of the SSL bit in the set of flags. |
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. |
static int |
VERSION_TWO
|
| Constructor Summary | |
|---|---|
StatusTableRow(java.io.InputStream in)
Deserializes the row based on the given stream. |
|
StatusTableRow(Server server)
Constructs a row based on a local server. |
|
StatusTableRow(java.lang.String host)
Starts the row with a host name. |
|
StatusTableRow(java.lang.String host,
int port,
boolean isSSL)
Starts the row with a host name. |
|
StatusTableRow(java.lang.String host,
int port,
boolean isSSL,
boolean isOnline)
Starts the row with a host name. |
|
| Method Summary | |
|---|---|
static boolean |
areEqual(java.util.Collection<StatusTableRow> c1,
java.util.Collection<StatusTableRow> c2)
Returns whether the two collections of rows are equivalent. |
protected static java.util.Collection<StatusTableRow> |
calculateFullHashSpan(java.util.Collection<StatusTableRow> allRows)
Given a collection of StatusTableRows, randomizes the rows and returns the first found full hash span. |
protected static java.util.Collection<StatusTableRow> |
calculateFullHashSpan(java.util.Collection<StatusTableRow> seedRows,
java.util.Collection<StatusTableRow> allRows)
Given two collections of StatusTableRows, randomizes the rows and returns the first found full hash span with read and write priveleges and core servers containing as many of the seedRows as possible. |
StatusTableRow |
clone()
Creates a duplication of this row. |
protected void |
deserialize(java.io.InputStream in)
Sets the values of the row based on the given serialized row. |
protected void |
deserializeVersionOne(java.io.InputStream in)
Sets the values of the row based the given version one serialized row. |
protected void |
deserializeVersionTwo(java.io.InputStream in)
|
boolean |
equals(java.lang.Object o)
Evaluates all the attributes except the update timestamp of the given object against this one. |
long |
getFlags()
Returns the flags object. |
java.lang.String |
getGroup()
Gets the group name. |
java.util.Collection<HashSpan> |
getHashSpans()
Gets the hash spans. |
java.lang.String |
getHost()
Gets the host name. |
java.lang.String |
getName()
Gets the name. |
int |
getPort()
Gets the port number. |
long |
getResponseTimestamp()
|
java.util.Collection<HashSpan> |
getTargetHashSpans()
Gets the target hash spans. |
long |
getUpdateTimestamp()
Gets the timestamp when the row's information was last updated. |
java.lang.String |
getURL()
Gets the URL of the row. |
int |
getVersion()
Gets the version. |
int |
hashCode()
Hashes the host name only. |
boolean |
isCore()
Returns whether this row is a core server. |
boolean |
isDataStore()
Returns whether the server stores data. |
boolean |
isLocalServer()
Returns whether this row is for the local server. |
boolean |
isOnline()
Returns whether the server is online. |
boolean |
isReadable()
Returns whether the server allows its data to be read. |
boolean |
isSSL()
Returns whether the server communicates over SSL. |
boolean |
isWritable()
Gets whether the server can be written to. |
void |
responseReceived()
|
void |
serialize(int version,
java.io.OutputStream out)
Outputs the values of this row in the structure defined by the given version to the given output stream. |
protected boolean |
setGroup(java.lang.String group)
Sets the group name. |
protected boolean |
setHashSpans(java.util.Collection<HashSpan> hashSpans)
Sets the hash spans. |
protected boolean |
setHost(java.lang.String host)
Sets the host name. |
protected boolean |
setIsDataStore(boolean dataStore)
Sets whether the server stores data. |
protected boolean |
setIsOnline(boolean online)
Sets whether the server is online. |
protected boolean |
setIsReadable(boolean readable)
Sets whether the server allows its data to be read. |
protected boolean |
setIsSSL(boolean ssl)
Sets whether the server communicates over SSL. |
protected boolean |
setIsWritable(boolean writable)
Sets whether the server can be written to. |
protected boolean |
setName(java.lang.String name)
Sets the name. |
protected boolean |
setPort(int port)
Sets the port number. |
protected boolean |
setResponseTimestamp(long responseTimestamp)
|
protected boolean |
setTargetHashSpans(java.util.Collection<HashSpan> hashSpans)
Sets the target hash spans. |
protected boolean |
setUpdateTimestamp(long updateTimestamp)
Sets the timestamp when the row's information was last updated. |
protected boolean |
setVersion(int version)
Sets the version. |
byte[] |
toByteArray(int version)
|
java.lang.String |
toString()
Prints out the values of the attributes in the row. |
void |
update(Configuration config)
Updates the information in the row based on the given configuration. |
protected void |
update(Server server)
Updates the information in the row based on the given local server. |
protected boolean |
update(StatusTableRow 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_TWO
public static final int VERSION_LATEST
The value for the latest version of the object.
public static final int SSL_BIT
The location of the SSL bit in the set of flags.
public static final int ONLINE_BIT
The location of the Online bit in the set of flags.
public static final int CAN_READ_BIT
The location of the "Can Read" bit in the set of flags.
public static final int CAN_WRITE_BIT
The location of the "Can Write" bit in the set of flags.
public static final int DATA_STORE_BIT
The location of the "Data Store" bit in the set of flags.
public static final long DEFAULT_FLAGS
The default value for the flags.
public static final java.util.Collection<HashSpan> DEFAULT_HASH_SPANS
The default set of hash spans.
public static final java.util.Collection<HashSpan> DEFAULT_TARGET_HASH_SPANS
The default set of target hash spans.
public static final int LENGTH_MAX_NAME
The maximum length of the name.
public static final int LENGTH_MAX_GROUP
The maximum length of the group name.
| Constructor Detail |
|---|
public StatusTableRow(java.lang.String host)
Starts the row with a host name. All other values are the defaults.
host - Host name.
public StatusTableRow(java.io.InputStream in)
throws java.io.IOException
Deserializes the row based on the given stream.
in - The stream containing a serialized row
java.io.IOExceptionpublic StatusTableRow(Server server)
Constructs a row based on a local server.
server - A server
public StatusTableRow(java.lang.String host,
int port,
boolean isSSL)
Starts the row with a host name.
host - port - isSSL -
public StatusTableRow(java.lang.String host,
int port,
boolean isSSL,
boolean isOnline)
Starts the row with a host name.
host - port - isSSL - isOnline - | Method Detail |
|---|
public void update(Configuration config)
Updates the information in the row based on the given configuration.
This is updated by the network status table and related utilities, as well as by tests.
config - A configurationprotected void update(Server server)
Updates the information in the row based on the given local server.
server - A serverprotected boolean update(StatusTableRow row)
row -
public boolean isCore()
Returns whether this row is a core server. A core server is defined a server that exists in the startup list of servers.
public boolean isLocalServer()
Returns whether this row is for the local server.
public java.lang.String getURL()
Gets the URL of the row. Uses IOUtil.createURL(String, int, boolean).
public int getVersion()
Gets the version.
protected boolean setVersion(int version)
Sets the version.
version - The new version
public long getUpdateTimestamp()
Gets the timestamp when the row's information was last updated.
protected boolean setUpdateTimestamp(long updateTimestamp)
Sets the timestamp when the row's information was last updated.
updateTimestamp - The timestamp when the row's information was last updated.
public long getResponseTimestamp()
public void responseReceived()
protected boolean setResponseTimestamp(long responseTimestamp)
responseTimestamp -
public long getFlags()
Returns the flags object.
public java.lang.String getHost()
Gets the host name.
protected boolean setHost(java.lang.String host)
Sets the host name.
host - The new host name
public int getPort()
Gets the port number.
protected boolean setPort(int port)
Sets the port number.
port - The new port number
public java.lang.String getName()
Gets the name.
protected boolean setName(java.lang.String name)
Sets the name.
name - The new name
public java.lang.String getGroup()
Gets the group name.
protected boolean setGroup(java.lang.String group)
Sets the group name.
group - The new group name
public boolean isSSL()
Returns whether the server communicates over SSL.
protected boolean setIsSSL(boolean ssl)
Sets whether the server communicates over SSL.
ssl - Whether the server communicates over SSLpublic boolean isOnline()
Returns whether the server is online.
protected boolean setIsOnline(boolean online)
Sets whether the server is online.
online - Whether the server is online.
public boolean isReadable()
Returns whether the server allows its data to be read.
protected boolean setIsReadable(boolean readable)
Sets whether the server allows its data to be read.
readable - Whether the server allows its data to be read.
public boolean isWritable()
Gets whether the server can be written to.
protected boolean setIsWritable(boolean writable)
Sets whether the server can be written to.
writable - Whether the server can be written to.public boolean isDataStore()
Returns whether the server stores data.
protected boolean setIsDataStore(boolean dataStore)
Sets whether the server stores data.
dataStore - Whether the server stores data.
public java.util.Collection<HashSpan> getHashSpans()
Gets the hash spans.
protected boolean setHashSpans(java.util.Collection<HashSpan> hashSpans)
Sets the hash spans.
hashSpans - The hash spans
public java.util.Collection<HashSpan> getTargetHashSpans()
Gets the target hash spans.
protected boolean setTargetHashSpans(java.util.Collection<HashSpan> hashSpans)
Sets the target hash spans.
hashSpans - The hash spans
public byte[] toByteArray(int version)
throws java.io.IOException
java.io.IOException
public void serialize(int version,
java.io.OutputStream out)
throws java.io.IOException
Outputs the values of this row in the structure defined by the given version 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 values of the row based on the given serialized row.
in - An input stream containing a serialized row
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 row.
in - An input stream containing a version one serialized row
java.io.IOException
protected void deserializeVersionTwo(java.io.InputStream in)
throws java.io.IOException
in -
java.io.IOExceptionpublic boolean equals(java.lang.Object o)
Evaluates all the attributes except the update timestamp of the given object against this one.
equals in class java.lang.Objecto - A StatusTableRow object
public StatusTableRow clone()
Creates a duplication of this row.
clone in class java.lang.Objectpublic int hashCode()
Hashes the host name only.
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.Object
public static boolean areEqual(java.util.Collection<StatusTableRow> c1,
java.util.Collection<StatusTableRow> c2)
Returns whether the two collections of rows are equivalent.
c1 - A collection of rowsc2 - A collection of rows
protected static java.util.Collection<StatusTableRow> calculateFullHashSpan(java.util.Collection<StatusTableRow> allRows)
throws java.lang.Exception
Given a collection of StatusTableRows, randomizes the rows and returns the first found full hash span.
It is important that the rows are randomized before finding the full hash span because the status table sorts all the rows alphabetically, and we don't want all clients connecting to the same servers.
allRows - The rows to use in trying to put together a full hash span.
java.lang.Exception
protected static java.util.Collection<StatusTableRow> calculateFullHashSpan(java.util.Collection<StatusTableRow> seedRows,
java.util.Collection<StatusTableRow> allRows)
throws java.lang.Exception
Given two collections of StatusTableRows, randomizes the rows and returns the first found full hash span with read and write priveleges and core servers containing as many of the seedRows as possible.
It is important that the rows are randomized before finding the full hash span because the status table sorts all the rows alphabetically, and we don't want all clients connecting to the same servers.
seedRows - The function should try to keep as many of these in the full hash span as possible.allRows - All the rows to use in trying to put together a full hash span, possibly including the seed rows.
java.lang.Exception - TODO: allow for partial priveleges -- read on one server with a hash span plus write on another server with the same hash span
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||