|
||||||||||
| 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.flatfile.FlatFileTrancheServer
public class FlatFileTrancheServer
An implementation of the TrancheServer interface that relies on the underlying operating system's filesystem.
This is the workhorse for the Tranche server, and it is very efficient in terms of speed and memory usage.
| Field Summary | |
|---|---|
static int |
DEFAULT_GET_CONFIGURATION_CACHE_TIME
Servers will re-use cached configuration when getConfiguration called. |
protected boolean |
doneLoadingDataBlocks
Flag if finished loading data blocks (a start-up activity). |
| Fields inherited from class org.tranche.TrancheServer |
|---|
BAD_NONCE, BAD_SIG |
| Constructor Summary | |
|---|---|
FlatFileTrancheServer(java.io.File dir)
|
|
FlatFileTrancheServer(java.io.File dir,
ActivityLog log)
|
|
FlatFileTrancheServer(java.lang.String homeDirectoryName)
|
|
FlatFileTrancheServer(java.lang.String homeDirectoryName,
ActivityLog log)
|
|
FlatFileTrancheServer(java.lang.String homeDirectoryName,
ActivityLog log,
java.security.cert.X509Certificate cert,
java.security.PrivateKey key)
|
|
FlatFileTrancheServer(java.lang.String homeDirectoryName,
java.security.cert.X509Certificate cert,
java.security.PrivateKey key)
|
|
| Method Summary | |
|---|---|
protected void |
addKnownProject(BigHash hash)
|
boolean |
addListener(FlatFileTrancheServerListener l)
Add a FlatFileTrancheServerListener. |
boolean |
canRead()
Returns whether server mode flag is set to allow clients to read server's data. |
boolean |
canWrite()
Returns whether server mode flag is set to allow clients to write data to server. |
protected void |
clearKnownProjects()
|
void |
clearListeners()
Clear all FlatFileTrancheServerListener objects. |
void |
close()
Close off resources associated with this server. |
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)
|
void |
fireConfigurationSet(Configuration config)
Fired when configuration is set. |
void |
fireDataChunkAdded(BigHash hash)
Fired when data chunk is added. |
void |
fireDataChunkDeleted(BigHash hash)
Fired when data chunk is deleted. |
void |
fireMetaDataChunkAdded(BigHash hash)
Fired when meta data chunk is added. |
void |
fireMetaDataChunkDeleted(BigHash hash)
Fired when meta data chunk is deleted. |
ActivityLog |
getActivityLog()
Returns the activity log. |
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. |
java.security.cert.X509Certificate |
getAuthCert()
By setting a certificate and private key to the flat file server that has write privileges on other servers, can inject data to network when needed. |
java.security.PrivateKey |
getAuthPrivateKey()
By setting a certificate and private key to the flat file server that has write privileges on other servers, can inject data to network when needed. |
Configuration |
getConfiguration()
Get the Configuration object for this FlatFileTrancheServer. |
protected Configuration |
getConfiguration(boolean useCache)
Get the Configuration object for this FlatFileTrancheServer. |
Configuration |
getConfiguration(Signature sig,
byte[] nonce)
Get the Configuration object. |
int |
getConfigurationCacheTime()
Gets the time to internally cache the configuration. |
PropagationReturnWrapper |
getData(BigHash[] hashes,
boolean propagateRequest)
Get a batch of data chunks. |
DataBlockUtil |
getDataBlockUtil()
Get the DataBlockUtil associated with this FlatFileTrancheServer. |
BigHash[] |
getDataHashes(java.math.BigInteger offset,
java.math.BigInteger length)
Get a batch of hashes. |
static java.lang.String |
getDefaultHomeDir()
A simple method for determining the home directory where Tranche should both store files and keep temporary files. |
HashSpanFixingThread |
getHashSpanFixingThread()
Return the healing thread associated with this FlatFileTrancheServer. |
java.io.File |
getHomeDirectory()
|
java.lang.String |
getHost()
Returns the host name for this server. |
long |
getLastTimeConfigurationWasSet()
Timestamp of last change to Configuration. |
PropagationReturnWrapper |
getMetaData(BigHash[] hashes,
boolean propagateRequest)
Get a batch of meta data chunks. |
BigHash[] |
getMetaDataHashes(java.math.BigInteger offset,
java.math.BigInteger length)
Get a batch of hashes. |
StatusTable |
getNetworkStatusPortion(java.lang.String startHost,
java.lang.String endHost)
Returns the rows in the local network status that have host names that are between the startHost (inclusive) and the endHost (exclusive.) |
PropagationReturnWrapper |
getNonces(java.lang.String[] hosts,
int count)
Get batch of nonces from selected server hosts. |
BigHash[] |
getProjectHashes(java.math.BigInteger offset,
java.math.BigInteger length)
Gets all of the hashes for projects that are in memory. |
TargetHashSpanThread |
getTargetHashSpanThread()
The thread that looks for target hash spans and injects/deletes chunks until can swap out current hash span(s) with target hash span. |
java.lang.String |
getTrancheUrl()
Returns the Tranche url (e.g., tranche://123.123.123.123:443), if set. |
boolean[] |
hasData(BigHash[] hashes)
Check to see whether server has the data chunks represented by the hashes. |
boolean[] |
hasMetaData(BigHash[] hashes)
Check to see whether server has the meta data chunks represented by the hashes. |
boolean |
isClosed()
Returns true if the server is closed down. |
boolean |
isReadOnly()
Deprecated. There are different modes for server. Right now, there's none, read-only, write-only, and read/write. |
protected boolean |
isStickyMetaDataForThisServer(MetaData md)
Determine whether meta data specifies that this is sticky server. |
void |
ping()
Functionality to ping this server. |
void |
registerServer(java.lang.String url)
Register a Tranche server. |
protected void |
removeKnownProject(BigHash hash)
|
boolean |
removeListener(FlatFileTrancheServerListener l)
Remove a FlatFileTrancheServerListener. |
void |
requestShutdown(Signature sig,
byte[] nonce)
Ask whether allowed to shutdown. |
void |
saveConfiguration()
Serialize the Configurtation data and save to disk. |
void |
setAuthCert(java.security.cert.X509Certificate authCert)
By setting a certificate and private key to the flat file server that has write privileges on other servers, can inject data to network when needed. |
void |
setAuthPrivateKey(java.security.PrivateKey authPrivateKey)
By setting a certificate and private key to the flat file server that has write privileges on other servers, can inject data to network when needed. |
void |
setConfiguration(byte[] data,
Signature sig,
byte[] nonce)
Set the Configuration for this FlatFileTrancheServer. |
void |
setConfiguration(Configuration c)
Set the Configuration for this FlatFileTrancheServer. |
void |
setConfigurationCacheTime(int value)
Gets the time to internally cache the configuration. |
PropagationReturnWrapper |
setData(BigHash hash,
byte[] data,
Signature sig,
java.lang.String[] hosts)
Set data and replicate to specified hosts. |
void |
setHostsToUseWithOverlappingHashSpans(java.util.Map<java.util.Collection<HashSpan>,java.lang.String> hostsToUseWithOverlappingHashSpans)
Tells the server to use the given server hosts for necessary communications with servers with overlapping hash spans. |
PropagationReturnWrapper |
setMetaData(boolean merge,
BigHash hash,
byte[] metaData,
Signature sig,
java.lang.String[] hosts)
Set meta data and replicate to specified hosts. |
static boolean |
tryDirectory(java.lang.String subdirName)
Test a directory to see whether can read and write. |
void |
waitToLoadExistingDataBlocks()
Blocking method to wait for project-finding thread to finish loading. |
| Methods inherited from class org.tranche.commons.Debuggable |
|---|
debugErr, debugErr, debugOut, isDebug, setDebug |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected boolean doneLoadingDataBlocks
Flag if finished loading data blocks (a start-up activity).
public static final int DEFAULT_GET_CONFIGURATION_CACHE_TIME
Servers will re-use cached configuration when getConfiguration called. This is the default time to cache.
The value used can be set in Configuration attributes.
| Constructor Detail |
|---|
public FlatFileTrancheServer(java.io.File dir)
dir - the directory received
public FlatFileTrancheServer(java.io.File dir,
ActivityLog log)
dir - log - public FlatFileTrancheServer(java.lang.String homeDirectoryName)
homeDirectoryName -
public FlatFileTrancheServer(java.lang.String homeDirectoryName,
java.security.cert.X509Certificate cert,
java.security.PrivateKey key)
public FlatFileTrancheServer(java.lang.String homeDirectoryName,
ActivityLog log)
homeDirectoryName - the home directory name received
public FlatFileTrancheServer(java.lang.String homeDirectoryName,
ActivityLog log,
java.security.cert.X509Certificate cert,
java.security.PrivateKey key)
homeDirectoryName - log - cert - key - | Method Detail |
|---|
public static java.lang.String getDefaultHomeDir()
A simple method for determining the home directory where Tranche should both store files and keep temporary files.
public static boolean tryDirectory(java.lang.String subdirName)
Test a directory to see whether can read and write. Also, don't want multiple processes writing to same temporary subdirectory, so identify if available.
subdirName -
public java.io.File getHomeDirectory()
public Configuration getConfiguration()
Get the Configuration object for this FlatFileTrancheServer.
getConfiguration in class TrancheServerprotected Configuration getConfiguration(boolean useCache)
Get the Configuration object for this FlatFileTrancheServer.
useCache - If true, uses cache if time not elapsed to update; if false, updates unconditionally
public void waitToLoadExistingDataBlocks()
Blocking method to wait for project-finding thread to finish loading.
public void ping()
throws java.lang.Exception
Functionality to ping this server. Note this does nothing for the FlatFileTrancheServer.
ping in class TrancheServerjava.lang.Exception
public StatusTable getNetworkStatusPortion(java.lang.String startHost,
java.lang.String endHost)
throws java.lang.Exception
Returns the rows in the local network status that have host names that are between the startHost (inclusive) and the endHost (exclusive.)
getNetworkStatusPortion in class TrancheServerstartHost - endHost -
java.lang.Exception
public BigHash[] getDataHashes(java.math.BigInteger offset,
java.math.BigInteger length)
throws java.lang.Exception
Get a batch of hashes. Used to discover data chunks on server.
getDataHashes in class TrancheServeroffset - the offsetlength - the length
java.lang.Exception - if any exception occurs
public BigHash[] getMetaDataHashes(java.math.BigInteger offset,
java.math.BigInteger length)
throws java.lang.Exception
Get a batch of hashes. Used to discover meta data chunks on server.
getMetaDataHashes in class TrancheServeroffset - the offsetlength - the length
java.lang.Exception - if any exception occurs
public boolean[] hasData(BigHash[] hashes)
throws java.lang.Exception
Check to see whether server has the data chunks represented by the hashes.
hasData in class TrancheServerhashes - the BigHash array of data chunks
java.lang.Exception - if any exception occurs
public boolean[] hasMetaData(BigHash[] hashes)
throws java.lang.Exception
Check to see whether server has the meta data chunks represented by the hashes.
hasMetaData in class TrancheServerhashes - the BigHash array of meta data
java.lang.Exception - if any exception occurs
public PropagationReturnWrapper getData(BigHash[] hashes,
boolean propagateRequest)
throws java.lang.Exception
Get a batch of data chunks.
getData in class TrancheServerhashes - propagateRequest -
java.lang.Exception
public PropagationReturnWrapper getMetaData(BigHash[] hashes,
boolean propagateRequest)
throws java.lang.Exception
Get a batch of meta data chunks.
getMetaData in class TrancheServerhashes - propagateRequest -
java.lang.Exception
public void registerServer(java.lang.String url)
throws java.lang.Exception
Register a Tranche server.
registerServer in class TrancheServerurl - the URL of the Tranche server (e.g. tranche://proteomecommons.org:443)
java.io.IOException - if an exception occurs
java.lang.Exception - if any exception occurs
protected boolean isStickyMetaDataForThisServer(MetaData md)
throws java.lang.Exception
Determine whether meta data specifies that this is sticky server.
md -
java.lang.Exceptionpublic void close()
Close off resources associated with this server.
close in class TrancheServerpublic void saveConfiguration()
Serialize the Configurtation data and save to disk.
public DataBlockUtil getDataBlockUtil()
Get the DataBlockUtil associated with this FlatFileTrancheServer.
public Configuration getConfiguration(Signature sig,
byte[] nonce)
throws java.lang.Exception
Get the Configuration object.
getConfiguration in class TrancheServersig - the signaturenonce - the nonce bytes
java.lang.Exception - if any exception occurs
public void requestShutdown(Signature sig,
byte[] nonce)
throws java.lang.Exception
Ask whether allowed to shutdown. Does NOT shutdown the server. Used by Server to find out whether it should shut down resources or not.
requestShutdown in class TrancheServersig - nonce -
java.lang.Exception - Any security issues.
public void setConfiguration(Configuration c)
throws java.lang.Exception
Set the Configuration for this FlatFileTrancheServer.
c -
java.lang.Exception
public void setConfiguration(byte[] data,
Signature sig,
byte[] nonce)
throws java.lang.Exception
Set the Configuration for this FlatFileTrancheServer.
setConfiguration in class TrancheServerdata - the data bytessig - the signaturenonce - the nonce bytes
java.lang.Exception - if any exception occurs
public BigHash[] getProjectHashes(java.math.BigInteger offset,
java.math.BigInteger length)
throws java.lang.Exception
Gets all of the hashes for projects that are in memory.
getProjectHashes in class TrancheServeroffset - the offsetlength - the length
java.lang.Exception - if any exception occurspublic HashSpanFixingThread getHashSpanFixingThread()
Return the healing thread associated with this FlatFileTrancheServer.
public boolean isClosed()
Returns true if the server is closed down.
public boolean canRead()
Returns whether server mode flag is set to allow clients to read server's data.
public boolean canWrite()
Returns whether server mode flag is set to allow clients to write data to server.
public boolean isReadOnly()
throws java.lang.Exception
Checks configuration to see whether this server is read-only.
java.lang.ExceptioncanRead(),
canWrite()public long getLastTimeConfigurationWasSet()
Timestamp of last change to Configuration.
public int getConfigurationCacheTime()
Gets the time to internally cache the configuration. This is the time that must ellapse before the FlatFileTrancheServer will update the configuration that is returned by getConfiguration.
A lower time means up-to-date configurations, but substantially more work.
public void setConfigurationCacheTime(int value)
Gets the time to internally cache the configuration. This is the time that must ellapse before the FlatFileTrancheServer will update the configuration that is returned by getConfiguration.
A lower time means up-to-date configurations, but substantially more work.
value - public java.lang.String getTrancheUrl()
Returns the Tranche url (e.g., tranche://123.123.123.123:443), if set.
public java.lang.String getHost()
Returns the host name for this server. Prefers one set by Server, but if not found, finds by iterating the interfaces.
getHost in class TrancheServer
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 ActivityLog getActivityLog()
Returns the activity log.
public boolean addListener(FlatFileTrancheServerListener l)
Add a FlatFileTrancheServerListener.
l -
public boolean removeListener(FlatFileTrancheServerListener l)
Remove a FlatFileTrancheServerListener.
l -
public void clearListeners()
Clear all FlatFileTrancheServerListener objects.
public void fireDataChunkAdded(BigHash hash)
Fired when data chunk is added.
hash - public void fireMetaDataChunkAdded(BigHash hash)
Fired when meta data chunk is added.
hash - public void fireDataChunkDeleted(BigHash hash)
Fired when data chunk is deleted.
hash - public void fireMetaDataChunkDeleted(BigHash hash)
Fired when meta data chunk is deleted.
hash - public void fireConfigurationSet(Configuration config)
Fired when configuration is set.
config - public void setHostsToUseWithOverlappingHashSpans(java.util.Map<java.util.Collection<HashSpan>,java.lang.String> hostsToUseWithOverlappingHashSpans)
Tells the server to use the given server hosts for necessary communications with servers with overlapping hash spans.
The data structure is given the way it is to allow for ease-of-lookup.
The hosts to be used will be modified every time connections are adjusted.
hostsToUseWithOverlappingHashSpans - protected void clearKnownProjects()
protected void addKnownProject(BigHash hash)
hash - protected void removeKnownProject(BigHash hash)
hash -
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[] metaData,
Signature sig,
java.lang.String[] hosts)
throws java.lang.Exception
Set meta data and replicate to specified hosts.
setMetaData in class TrancheServermerge - hash - metaData - 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.Exceptionpublic TargetHashSpanThread getTargetHashSpanThread()
The thread that looks for target hash spans and injects/deletes chunks until can swap out current hash span(s) with target hash span.
public java.security.cert.X509Certificate getAuthCert()
By setting a certificate and private key to the flat file server that has write privileges on other servers, can inject data to network when needed.
It is the responsibility of the administrator starting the server to secure a signed key/certificate that can set chunks. Please contact the Tranche network administrators for more information.
public void setAuthCert(java.security.cert.X509Certificate authCert)
By setting a certificate and private key to the flat file server that has write privileges on other servers, can inject data to network when needed.
It is the responsibility of the administrator starting the server to secure a signed key/certificate that can set chunks. Please contact the Tranche network administrators for more information.
authCert - public java.security.PrivateKey getAuthPrivateKey()
By setting a certificate and private key to the flat file server that has write privileges on other servers, can inject data to network when needed.
It is the responsibility of the administrator starting the server to secure a signed key/certificate that can set chunks. Please contact the Tranche network administrators for more information.
public void setAuthPrivateKey(java.security.PrivateKey authPrivateKey)
By setting a certificate and private key to the flat file server that has write privileges on other servers, can inject data to network when needed.
It is the responsibility of the administrator starting the server to secure a signed key/certificate that can set chunks. Please contact the Tranche network administrators for more information.
authPrivateKey -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||