|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.tranche.commons.Debuggable
org.tranche.TrancheServer
org.tranche.remote.RemoteTrancheServer
public class RemoteTrancheServer
Handles client socket connection to the server.
| Field Summary | |
|---|---|
static int |
BATCH_GET_LIMIT
Limit for batch-get requests. |
static int |
BATCH_HAS_LIMIT
Absolute limit for all batch sizes. |
static int |
BATCH_NONCE_LIMIT
Limit for batch-nonce requests. |
static int |
BATCH_SET_LIMIT
Limit for batch-set requests. |
protected java.net.Socket |
dataSocket
|
static int |
DEFAULT_MAX_TRIES
|
static long |
DEFAULT_RESPONSE_TIMEOUT
|
protected RemoteTrancheServerDownloadThread |
downloadThread
|
static byte |
OK_BYTE
Abstract OK byte to keep sync in order |
protected java.util.LinkedList<OutGoingBytes> |
outgoingQueue
|
protected java.util.Map<java.lang.Long,RemoteCallback> |
outgoingSent
Buffer of outgoing tasks |
static long |
responseTimeout
The number of milliseconds before a response is decidedly not going to be returned. |
protected RemoteTrancheServerUploadThread |
uploadThread
|
| Fields inherited from class org.tranche.TrancheServer |
|---|
BAD_NONCE, BAD_SIG |
| Constructor Summary | |
|---|---|
RemoteTrancheServer(java.lang.String host,
int port,
boolean secure)
|
|
| Method Summary | |
|---|---|
void |
addListener(RemoteTrancheServerListener l)
Adds the given server listener from the list of server listeners. |
void |
clearListeners()
Removes all server listeners. |
void |
close()
Tears down the TCP connection to the remote server and releases the associated resources. |
int |
countOutstandingRequests()
|
PropagationReturnWrapper |
deleteData(BigHash hash,
Signature[] sigs,
byte[][] nonces,
java.lang.String[] hosts)
Delete data chunk from selected servers. |
PropagationReturnWrapper |
deleteMetaData(BigHash hash,
java.lang.String uploaderName,
java.lang.Long uploadTimestamp,
java.lang.String relativePathInDataSet,
Signature[] sigs,
byte[][] nonces,
java.lang.String[] hosts)
|
boolean |
equals(java.lang.Object obj)
Returns whether the URL for this server is the same as the URL for the given server. |
protected void |
fireCreatedBytesToUpload(long callbackId,
long bytesToUpload)
Notify the listeners that bytes have been created to go to the server. |
protected void |
fireCreatedCallback(RemoteCallback rc)
Notify server listeners that a new callback has been created. |
protected void |
fireFailedCallback(RemoteCallback rc)
Notify server listeners that a server request failed. |
protected void |
fireFailedDownloadingBytes(long callbackId)
Notify the listeners that bytes have failed to be downloaded from the server. |
protected void |
fireFailedUploadingBytes(long callbackId)
Notify the listeners that bytes could not be uploaded to the server. |
protected void |
fireFinishedDownloadingBytes(long callbackId,
long bytesToDownload,
long bytesDownloaded)
Notify the listeners that bytes have been downloaded from the server. |
protected void |
fireFinishedUploadingBytes(long callbackId,
long bytesToUpload,
long bytesUploaded)
Notify the listeners that bytes have been uploaded to the server. |
protected void |
fireFulfilledCallback(RemoteCallback rc)
Notify server listeners that a server request has been fulfilled. |
protected void |
fireNewConnection()
Notify the listeners that a new connection has been made to the server. |
protected void |
fireStartedDownloadingBytes(long callbackId,
long bytesToDownload)
Notify the listeners that bytes have been downloaded from the server. |
protected void |
fireStartedUploadingBytes(long callbackId,
long bytesToUpload)
Notify the listeners that bytes are starting to be uploaded to the server. |
protected void |
fireUpdateDownloadingBytes(long callbackId,
long bytesToDownload,
long bytesDownloaded)
Notify the listeners that bytes have been downloaded from the server. |
protected void |
flushOutputStreams()
Send the output. |
Activity[] |
getActivityLogEntries(long startTimestamp,
long finishTimestamp,
int limit,
byte mask)
Get all activity log entries from within a time period. |
int |
getActivityLogEntriesCount(long startTimestamp,
long stopTimestamp,
byte mask)
Returns a count of all activity log entries from within a time period. |
Configuration |
getConfiguration()
Gets the configuration from the remote tranche server. |
Configuration |
getConfiguration(Signature sig,
byte[] nonce)
Gets the configuration from the remote tranche server. |
PropagationReturnWrapper |
getData(BigHash[] hashes,
boolean propagateRequest)
Gets a list of data chunks corresponding to the given list of hashes from the remote tranche server. |
BigHash[] |
getDataHashes(java.math.BigInteger offset,
java.math.BigInteger length)
Returns a list of data hashes from the remote tranche server. |
protected java.io.DataInputStream |
getDataInputStream()
|
protected java.io.DataOutputStream |
getDataOutputStream()
|
java.lang.String |
getHost()
Gets the host name of the remote tranche server. |
long |
getLastTimeNotify(int index)
Used to track timestamps of last time client sent request to server. |
long |
getLastTimeWakeUp(int index)
Used to track timestamps of last time client download thread resumed after a wait. |
java.util.Collection<RemoteTrancheServerListener> |
getListeners()
Returns the list of server listeners. |
static int |
getMaxTries()
Returns the maximum number of attempts before failing. |
PropagationReturnWrapper |
getMetaData(BigHash[] hashes,
boolean propagateRequest)
Gets a list of meta data chunks corresponding to the given list of hashes from the remote tranche server. |
BigHash[] |
getMetaDataHashes(java.math.BigInteger offset,
java.math.BigInteger length)
Returns a list of meta data hashes from the remote tranche server. |
long |
getMillisSinceLastServerResponse()
Time in milliseconds since last server response. |
StatusTable |
getNetworkStatus()
|
StatusTable |
getNetworkStatusPortion(java.lang.String startHost,
java.lang.String endHost)
|
PropagationReturnWrapper |
getNonces(java.lang.String[] hosts,
int count)
Get batch of nonces from selected server hosts. |
int |
getPort()
Gest the port number of the remote tranche server. |
BigHash[] |
getProjectHashes(java.math.BigInteger offset,
java.math.BigInteger length)
Remote protocol for sending project hashes. |
static long |
getResponseTimeout()
|
long |
getTimeLastServerResponse()
Returns the UNIX timetsamp of the last server response. |
long |
getTimeLastUsed()
Gets the time this server was last communicated with. |
boolean[] |
hasData(BigHash[] hashes)
Asks whether the remote tranche server has the given list of data chunks. |
BooleanArrayCallback |
hasDataInternal(BigHash[] hashes)
|
int |
hashCode()
Returns the hash code of the URL for this server. |
boolean[] |
hasMetaData(BigHash[] hashes)
Asks whether the remote tranche server has the given list of meta data chunks. |
BooleanArrayCallback |
hasMetaDataInternal(BigHash[] hashes)
|
boolean |
isClosed()
|
boolean |
isSecure()
Does this server use SSL? |
protected void |
notifyPreviousCallbacks(long id,
java.lang.String reasonMsg)
Ends all pending callbacks with ids before a certain id. |
void |
ping()
Pings the remote tranche server. |
boolean |
purge(long id,
RemoteCallback callback,
java.lang.String reason)
Ask RTS to purge callback. |
protected void |
reconnect()
Intelligently reconnect or connect to the remote Tranche server. |
void |
registerServer(java.lang.String url)
Register a tranche server with the remote tranche server. |
void |
removeListener(RemoteTrancheServerListener l)
Removes the given server listener from the list of server listeners. |
void |
removeListeners(java.util.List<RemoteTrancheServerListener> listeners)
Removes the given server listeners from the list of server listeners. |
void |
requestShutdown(Signature sig,
byte[] nonce)
Sends a request for a shutdown to the remote tranche server. |
void |
setConfiguration(byte[] data,
Signature sig,
byte[] nonce)
Sets the configuration to the remote tranche server. |
PropagationReturnWrapper |
setData(BigHash hash,
byte[] data,
Signature sig,
java.lang.String[] hosts)
Set data and replicate to specified hosts. |
void |
setLastTimeNotify(long timestamp)
Used to track timestamps of last time client sent request to server. |
void |
setLastTimeWakeUp(long timestamp)
Used to track timestamps of last time client download thread resumed after a wait. |
void |
setListeners(java.util.List<RemoteTrancheServerListener> listeners)
Replace the list of server listeners with the given list. |
static void |
setMaxRetries(int maxRetries)
Sets the maximum number of connection attempts before failing. |
PropagationReturnWrapper |
setMetaData(boolean merge,
BigHash hash,
byte[] data,
Signature sig,
java.lang.String[] hosts)
Set meta data and replicate to specified hosts. |
static void |
setMultiSocketTest(boolean isMultiSocketTest)
Used for stress testing only. |
static void |
setResponseTimeout(long milliseconds)
|
void |
setTimeLastServerResponse(long timeLastServerResponse)
Set the timestamp of the server's last message received. |
void |
setTimeLastUsed(long timeLastUsed)
Sets the time this server was last communicated with. |
void |
submitLatencyChunk(int latency)
Submit the latency of the chunk to server. |
void |
submitLatencyNonce(int latency)
Submit the latency of the nonce to server. |
| Methods inherited from class org.tranche.commons.Debuggable |
|---|
debugErr, debugErr, debugOut, isDebug, setDebug |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int BATCH_HAS_LIMIT
Absolute limit for all batch sizes. Likely to change.
public static final int BATCH_GET_LIMIT
Limit for batch-get requests.
public static final int BATCH_SET_LIMIT
Limit for batch-set requests.
public static final int BATCH_NONCE_LIMIT
Limit for batch-nonce requests.
public static final byte OK_BYTE
Abstract OK byte to keep sync in order
public static final long DEFAULT_RESPONSE_TIMEOUT
public static final int DEFAULT_MAX_TRIES
public static long responseTimeout
The number of milliseconds before a response is decidedly not going to be returned.
protected java.net.Socket dataSocket
protected final java.util.Map<java.lang.Long,RemoteCallback> outgoingSent
Buffer of outgoing tasks
protected final java.util.LinkedList<OutGoingBytes> outgoingQueue
protected final RemoteTrancheServerDownloadThread downloadThread
protected final RemoteTrancheServerUploadThread uploadThread
| Constructor Detail |
|---|
public RemoteTrancheServer(java.lang.String host,
int port,
boolean secure)
throws java.lang.Exception
host - port - secure -
java.lang.Exception| Method Detail |
|---|
protected void reconnect()
throws java.io.IOException
Intelligently reconnect or connect to the remote Tranche server.
java.io.IOExceptionprotected java.io.DataOutputStream getDataOutputStream()
protected java.io.DataInputStream getDataInputStream()
public int countOutstandingRequests()
public boolean purge(long id,
RemoteCallback callback,
java.lang.String reason)
throws java.lang.Exception
Ask RTS to purge callback. Must have matchign copy of callback or will not purge.
id - callback - reason -
java.lang.Exception
protected void notifyPreviousCallbacks(long id,
java.lang.String reasonMsg)
Ends all pending callbacks with ids before a certain id.
id - reasonMsg - protected void flushOutputStreams()
Send the output.
public int getPort()
Gest the port number of the remote tranche server.
public java.lang.String getHost()
Gets the host name of the remote tranche server.
getHost in class TrancheServer
public boolean[] hasMetaData(BigHash[] hashes)
throws java.lang.Exception
Asks whether the remote tranche server has the given list of meta data chunks.
hasMetaData in class TrancheServerhashes -
java.lang.Exception
public BooleanArrayCallback hasMetaDataInternal(BigHash[] hashes)
throws java.lang.Exception
java.lang.Exception
public boolean[] hasData(BigHash[] hashes)
throws java.lang.Exception
Asks whether the remote tranche server has the given list of data chunks.
hasData in class TrancheServerhashes -
java.lang.Exception
public BooleanArrayCallback hasDataInternal(BigHash[] hashes)
throws java.lang.Exception
hashes -
java.lang.Exception
public StatusTable getNetworkStatus()
throws java.lang.Exception
java.lang.Exception
public StatusTable getNetworkStatusPortion(java.lang.String startHost,
java.lang.String endHost)
throws java.lang.Exception
getNetworkStatusPortion in class TrancheServerstartHost - endHost -
java.lang.Exception
public void ping()
throws java.lang.Exception
Pings the remote tranche server.
ping in class TrancheServerjava.lang.Exception
public void requestShutdown(Signature sig,
byte[] nonce)
throws java.lang.Exception
Sends a request for a shutdown to the remote tranche server.
requestShutdown in class TrancheServersig - nonce -
java.lang.Exception
public BigHash[] getDataHashes(java.math.BigInteger offset,
java.math.BigInteger length)
throws java.lang.Exception
Returns a list of data hashes from the remote tranche server.
getDataHashes in class TrancheServeroffset - length -
java.lang.Exception
public BigHash[] getMetaDataHashes(java.math.BigInteger offset,
java.math.BigInteger length)
throws java.lang.Exception
Returns a list of meta data hashes from the remote tranche server.
getMetaDataHashes in class TrancheServeroffset - length -
java.lang.Exception
public void registerServer(java.lang.String url)
throws java.lang.Exception
Register a tranche server with the remote tranche server.
registerServer in class TrancheServerurl -
java.lang.Exception
public Configuration getConfiguration()
throws java.lang.Exception
Gets the configuration from the remote tranche server.
getConfiguration in class TrancheServerjava.lang.Exception
public Configuration getConfiguration(Signature sig,
byte[] nonce)
throws java.lang.Exception
Gets the configuration from the remote tranche server.
getConfiguration in class TrancheServersig - nonce -
java.lang.Exception
public void setConfiguration(byte[] data,
Signature sig,
byte[] nonce)
throws java.lang.Exception
Sets the configuration to the remote tranche server.
setConfiguration in class TrancheServerdata - sig - nonce -
java.lang.Exception
public BigHash[] getProjectHashes(java.math.BigInteger offset,
java.math.BigInteger length)
throws java.lang.Exception
Remote protocol for sending project hashes.
getProjectHashes in class TrancheServeroffset - length -
java.lang.Exception
public PropagationReturnWrapper getData(BigHash[] hashes,
boolean propagateRequest)
throws java.lang.Exception
Gets a list of data chunks corresponding to the given list of hashes from the remote tranche server.
getData in class TrancheServerhashes - propagateRequest -
java.lang.Exception
public PropagationReturnWrapper getMetaData(BigHash[] hashes,
boolean propagateRequest)
throws java.lang.Exception
Gets a list of meta data chunks corresponding to the given list of hashes from the remote tranche server.
getMetaData in class TrancheServerhashes - propagateRequest -
java.lang.Exception
public Activity[] getActivityLogEntries(long startTimestamp,
long finishTimestamp,
int limit,
byte mask)
throws java.lang.Exception
Get all activity log entries from within a time period.
getActivityLogEntries in class TrancheServerstartTimestamp - Timestamp from which to include activities (inclusive)finishTimestamp - Timestamp to which to include activities (inclusive)limit - Limit number of activity entries to returnmask - Used to match activity bytes. If all the bits in the mask are included in the activity byte, then the activity will be included. For example, if the mask is Activity.ACTION_TYPE_SET, then all logs that have this bit set (set data and set meta data) will be included. However, if Activity.SET_DATA is the mask, then only set data actions will match (since there are two bits set in the mask, making it more restrictive). 0 is least restrictive (restricts nothing) and 0xFF is most restrictive (restricts everything but itself).
java.lang.Exception
public int getActivityLogEntriesCount(long startTimestamp,
long stopTimestamp,
byte mask)
throws java.lang.Exception
Returns a count of all activity log entries from within a time period.
getActivityLogEntriesCount in class TrancheServerstartTimestamp - Timestamp from which to include activities (inclusive)stopTimestamp - Timestamp to which to include activities (inclusive)mask - Used to match activity bytes. If all the bits in the mask are included in the activity byte, then the activity will be included. For example, if the mask is Activity.ACTION_TYPE_SET, then all logs that have this bit set (set data and set meta data) will be included. However, if Activity.SET_DATA is the mask, then only set data actions will match (since there are two bits set in the mask, making it more restrictive). 0 is least restrictive (restricts nothing) and 0xFF is most restrictive (restricts everything but itself).
java.lang.Exceptionpublic static void setMultiSocketTest(boolean isMultiSocketTest)
Used for stress testing only.
isMultiSocketTest - public void close()
Tears down the TCP connection to the remote server and releases the associated resources. If another method is invoked by this RemoteDistributedFileSystem, the TCP connection will automatically be re-established. i.e. this method is a way to terminate lingering TCP connections that likly won't be needed.
close in class TrancheServerpublic boolean isSecure()
Does this server use SSL?
public boolean isClosed()
public boolean equals(java.lang.Object obj)
Returns whether the URL for this server is the same as the URL for the given server.
equals in class java.lang.Objectobj -
public int hashCode()
Returns the hash code of the URL for this server.
hashCode in class java.lang.Objectpublic long getMillisSinceLastServerResponse()
Time in milliseconds since last server response.
public void submitLatencyChunk(int latency)
Submit the latency of the chunk to server. Tries once then quits.
latency - public void submitLatencyNonce(int latency)
Submit the latency of the nonce to server. Tries once then quits.
latency - public long getTimeLastUsed()
Gets the time this server was last communicated with.
public void setTimeLastUsed(long timeLastUsed)
Sets the time this server was last communicated with.
timeLastUsed - public void setLastTimeWakeUp(long timestamp)
Used to track timestamps of last time client download thread resumed after a wait. Used for detecting timeouts and thread synchronization issues.
timestamp - public long getLastTimeWakeUp(int index)
Used to track timestamps of last time client download thread resumed after a wait. Used for detecting timeouts and thread synchronization issues.
index -
public void setLastTimeNotify(long timestamp)
Used to track timestamps of last time client sent request to server. Used for detecting timeouts.
timestamp - public long getLastTimeNotify(int index)
Used to track timestamps of last time client sent request to server. Used for detecting timeouts.
index -
public long getTimeLastServerResponse()
Returns the UNIX timetsamp of the last server response.
public void setTimeLastServerResponse(long timeLastServerResponse)
Set the timestamp of the server's last message received.
timeLastServerResponse - public void setListeners(java.util.List<RemoteTrancheServerListener> listeners)
Replace the list of server listeners with the given list.
listeners - public void addListener(RemoteTrancheServerListener l)
Adds the given server listener from the list of server listeners.
l - public void removeListener(RemoteTrancheServerListener l)
Removes the given server listener from the list of server listeners.
l - public void removeListeners(java.util.List<RemoteTrancheServerListener> listeners)
Removes the given server listeners from the list of server listeners.
listeners - public void clearListeners()
Removes all server listeners.
public java.util.Collection<RemoteTrancheServerListener> getListeners()
Returns the list of server listeners.
protected void fireNewConnection()
Notify the listeners that a new connection has been made to the server.
protected void fireStartedDownloadingBytes(long callbackId,
long bytesToDownload)
Notify the listeners that bytes have been downloaded from the server.
callbackId - bytesToDownload -
protected void fireUpdateDownloadingBytes(long callbackId,
long bytesToDownload,
long bytesDownloaded)
Notify the listeners that bytes have been downloaded from the server.
callbackId - bytesToDownload - bytesDownloaded -
protected void fireFinishedDownloadingBytes(long callbackId,
long bytesToDownload,
long bytesDownloaded)
Notify the listeners that bytes have been downloaded from the server.
callbackId - bytesToDownload - bytesDownloaded - protected void fireFailedDownloadingBytes(long callbackId)
Notify the listeners that bytes have failed to be downloaded from the server.
callbackId -
protected void fireCreatedBytesToUpload(long callbackId,
long bytesToUpload)
Notify the listeners that bytes have been created to go to the server.
callbackId - bytesToUpload -
protected void fireStartedUploadingBytes(long callbackId,
long bytesToUpload)
Notify the listeners that bytes are starting to be uploaded to the server.
callbackId - bytesToUpload -
protected void fireFinishedUploadingBytes(long callbackId,
long bytesToUpload,
long bytesUploaded)
Notify the listeners that bytes have been uploaded to the server.
callbackId - bytesToUpload - bytesUploaded - protected void fireFailedUploadingBytes(long callbackId)
Notify the listeners that bytes could not be uploaded to the server.
callbackId - protected void fireCreatedCallback(RemoteCallback rc)
Notify server listeners that a new callback has been created.
rc - protected void fireFulfilledCallback(RemoteCallback rc)
Notify server listeners that a server request has been fulfilled.
rc - protected void fireFailedCallback(RemoteCallback rc)
Notify server listeners that a server request failed.
rc - public static int getMaxTries()
Returns the maximum number of attempts before failing.
public static void setMaxRetries(int maxRetries)
Sets the maximum number of connection attempts before failing.
maxRetries - public static void setResponseTimeout(long milliseconds)
milliseconds - public static long getResponseTimeout()
public PropagationReturnWrapper setData(BigHash hash,
byte[] data,
Signature sig,
java.lang.String[] hosts)
throws java.lang.Exception
Set data and replicate to specified hosts.
setData in class TrancheServerhash - data - sig - hosts -
java.lang.Exception
public PropagationReturnWrapper setMetaData(boolean merge,
BigHash hash,
byte[] data,
Signature sig,
java.lang.String[] hosts)
throws java.lang.Exception
Set meta data and replicate to specified hosts.
setMetaData in class TrancheServermerge - hash - data - sig - hosts -
java.lang.Exception
public PropagationReturnWrapper getNonces(java.lang.String[] hosts,
int count)
throws java.lang.Exception
Get batch of nonces from selected server hosts.
getNonces in class TrancheServerhosts - count -
java.lang.Exception
public PropagationReturnWrapper deleteData(BigHash hash,
Signature[] sigs,
byte[][] nonces,
java.lang.String[] hosts)
throws java.lang.Exception
Delete data chunk from selected servers.
deleteData in class TrancheServerhash - sigs - nonces - hosts -
java.lang.Exception
public PropagationReturnWrapper deleteMetaData(BigHash hash,
java.lang.String uploaderName,
java.lang.Long uploadTimestamp,
java.lang.String relativePathInDataSet,
Signature[] sigs,
byte[][] nonces,
java.lang.String[] hosts)
throws java.lang.Exception
deleteMetaData in class TrancheServerhash - uploaderName - uploadTimestamp - relativePathInDataSet - sigs - nonces - hosts -
java.lang.Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||