org.tranche
Class TrancheServer

java.lang.Object
  extended by org.tranche.commons.Debuggable
      extended by org.tranche.TrancheServer
Direct Known Subclasses:
FlatFileTrancheServer, RemoteTrancheServer, RoutingTrancheServer

public abstract class TrancheServer
extends org.tranche.commons.Debuggable

This is the abstract interface for a node in the distributed file system. The get() methods are intended for public use however, the add() and delete() methods may only be invoked by a recognized authority.

Author:
Jayson Falkner - jfalkner@umich.edu, James "Augie" Hill - augman85@gmail.com, Bryan Smith - bryanesmith@gmail.com

Field Summary
static java.lang.String BAD_NONCE
           
static java.lang.String BAD_SIG
           
 
Constructor Summary
TrancheServer()
           
 
Method Summary
abstract  void close()
          Closes the server and shuts down any associated resources.
abstract  PropagationReturnWrapper deleteData(BigHash hash, Signature[] sigs, byte[][] nonces, java.lang.String[] hosts)
          Delete data chunk from selected servers.
abstract  PropagationReturnWrapper deleteMetaData(BigHash hash, java.lang.String uploaderName, java.lang.Long uploadTimestamp, java.lang.String relativePathInDataSet, Signature[] sigs, byte[][] nonces, java.lang.String[] hosts)
           
abstract  Activity[] getActivityLogEntries(long startTimestamp, long finishTimestamp, int limit, byte mask)
          Get all activity log entries from within a time period.
abstract  int getActivityLogEntriesCount(long startTimestamp, long stopTimestamp, byte mask)
          Returns a count of all activity log entries from within a time period.
abstract  Configuration getConfiguration()
           
abstract  Configuration getConfiguration(Signature sig, byte[] nonce)
           
abstract  PropagationReturnWrapper getData(BigHash[] hashes, boolean propagateRequest)
           
abstract  BigHash[] getDataHashes(java.math.BigInteger offset, java.math.BigInteger length)
           
abstract  java.lang.String getHost()
          Returns the host name of the server.
abstract  PropagationReturnWrapper getMetaData(BigHash[] hashes, boolean propagateRequest)
           
abstract  BigHash[] getMetaDataHashes(java.math.BigInteger offset, java.math.BigInteger length)
           
abstract  StatusTable getNetworkStatusPortion(java.lang.String startHost, java.lang.String endHost)
           
abstract  PropagationReturnWrapper getNonces(java.lang.String[] hosts, int count)
          Get batch of nonces from selected server hosts.
abstract  BigHash[] getProjectHashes(java.math.BigInteger offset, java.math.BigInteger length)
          Returns a list of all projects that this server has.
abstract  boolean[] hasData(BigHash[] hashes)
           
abstract  boolean[] hasMetaData(BigHash[] hashes)
           
abstract  void ping()
          Ping the server.
abstract  void registerServer(java.lang.String url)
          Registers the given URL as a known server.
abstract  void requestShutdown(Signature sig, byte[] nonce)
          Request that a server shut down.
abstract  void setConfiguration(byte[] data, Signature sig, byte[] nonce)
          Sets a new configuration for the server.
abstract  PropagationReturnWrapper setData(BigHash hash, byte[] data, Signature sig, java.lang.String[] hosts)
          Set data and replicate to specified hosts.
abstract  PropagationReturnWrapper setMetaData(boolean merge, BigHash hash, byte[] data, Signature sig, java.lang.String[] hosts)
          Set meta data and replicate to specified hosts.
 
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

BAD_NONCE

public static final java.lang.String BAD_NONCE
See Also:
Constant Field Values

BAD_SIG

public static final java.lang.String BAD_SIG
See Also:
Constant Field Values
Constructor Detail

TrancheServer

public TrancheServer()
Method Detail

ping

public abstract void ping()
                   throws java.lang.Exception

Ping the server. Handled by Server object which wraps this object.

Throws:
java.lang.Exception

getNetworkStatusPortion

public abstract StatusTable getNetworkStatusPortion(java.lang.String startHost,
                                                    java.lang.String endHost)
                                             throws java.lang.Exception
Parameters:
startHost -
endHost -
Returns:
Throws:
java.lang.Exception

getNonces

public abstract PropagationReturnWrapper getNonces(java.lang.String[] hosts,
                                                   int count)
                                            throws java.lang.Exception

Get batch of nonces from selected server hosts.

Parameters:
hosts -
count -
Returns:
Throws:
java.lang.Exception

hasData

public abstract boolean[] hasData(BigHash[] hashes)
                           throws java.lang.Exception
Parameters:
hashes - the BigHash array of data chunks
Returns:
boolean array
Throws:
java.lang.Exception - if any exception occurs

getData

public abstract PropagationReturnWrapper getData(BigHash[] hashes,
                                                 boolean propagateRequest)
                                          throws java.lang.Exception
Parameters:
hashes -
propagateRequest - Whether the server should propagate the request across the network.
Returns:
Throws:
java.lang.Exception

setData

public abstract PropagationReturnWrapper setData(BigHash hash,
                                                 byte[] data,
                                                 Signature sig,
                                                 java.lang.String[] hosts)
                                          throws java.lang.Exception

Set data and replicate to specified hosts.

Parameters:
hash -
data -
sig -
hosts -
Returns:
Throws:
java.lang.Exception

deleteData

public abstract PropagationReturnWrapper deleteData(BigHash hash,
                                                    Signature[] sigs,
                                                    byte[][] nonces,
                                                    java.lang.String[] hosts)
                                             throws java.lang.Exception

Delete data chunk from selected servers.

Parameters:
hash -
sigs -
nonces -
hosts -
Throws:
java.lang.Exception

hasMetaData

public abstract boolean[] hasMetaData(BigHash[] hashes)
                               throws java.lang.Exception
Parameters:
hashes - the BigHash array of meta data chunks
Returns:
boolean array
Throws:
java.lang.Exception - if any exception occurs

getMetaData

public abstract PropagationReturnWrapper getMetaData(BigHash[] hashes,
                                                     boolean propagateRequest)
                                              throws java.lang.Exception
Parameters:
hashes -
propagateRequest -
Returns:
Throws:
java.lang.Exception

setMetaData

public abstract 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.

Parameters:
merge -
hash -
data -
sig -
hosts -
Returns:
Throws:
java.lang.Exception

deleteMetaData

public abstract 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
Parameters:
hash -
sigs -
nonces -
hosts -
Throws:
java.lang.Exception

getDataHashes

public abstract BigHash[] getDataHashes(java.math.BigInteger offset,
                                        java.math.BigInteger length)
                                 throws java.lang.Exception
Parameters:
offset - the offset
length - the length
Returns:
an array of data hashes
Throws:
java.lang.Exception - if any exception occurs

getMetaDataHashes

public abstract BigHash[] getMetaDataHashes(java.math.BigInteger offset,
                                            java.math.BigInteger length)
                                     throws java.lang.Exception
Parameters:
offset - the offset
length - the length
Returns:
an array of meta data hashes
Throws:
java.lang.Exception - if any exception occurs

getProjectHashes

public abstract BigHash[] getProjectHashes(java.math.BigInteger offset,
                                           java.math.BigInteger length)
                                    throws java.lang.Exception
Returns a list of all projects that this server has.

Parameters:
offset - the offset
length - the length
Returns:
an array of project hashes
Throws:
java.lang.Exception - if any exception occurs

getConfiguration

public abstract Configuration getConfiguration()
                                        throws java.lang.Exception
Returns:
Throws:
java.lang.Exception

getConfiguration

public abstract Configuration getConfiguration(Signature sig,
                                               byte[] nonce)
                                        throws java.lang.Exception
Parameters:
sig - the signature
nonce - the nonce bytes
Returns:
the configuration
Throws:
java.lang.Exception - if any exception occurs

setConfiguration

public abstract void setConfiguration(byte[] data,
                                      Signature sig,
                                      byte[] nonce)
                               throws java.lang.Exception
Sets a new configuration for the server. Must have appropriate permission to do so.

Parameters:
data - The configuration saved as an array of bytes. Use ConfigurationUtil to generate the appropriate bytes.
sig - A signature for the data.
nonce - The nonce used from the server.
Throws:
java.lang.Exception - If invalid configuration format exceptions or security exceptions occur.

registerServer

public abstract void registerServer(java.lang.String url)
                             throws java.lang.Exception
Registers the given URL as a known server. The server chooses if or if not it will remember this URL.

Parameters:
url - the URL to register (e.g. tranche://proteomecommons.org:443 )
Throws:
java.lang.Exception - if any exception occurs

requestShutdown

public abstract void requestShutdown(Signature sig,
                                     byte[] nonce)
                              throws java.lang.Exception

Request that a server shut down. Intended for remote administration of servers.

Parameters:
sig -
nonce -
Throws:
java.lang.Exception

getActivityLogEntries

public abstract Activity[] getActivityLogEntries(long startTimestamp,
                                                 long finishTimestamp,
                                                 int limit,
                                                 byte mask)
                                          throws java.lang.Exception

Get all activity log entries from within a time period.

Parameters:
startTimestamp - Timestamp from which to include activities (inclusive)
finishTimestamp - Timestamp to which to include activities (inclusive)
limit - Limit number of activity entries to return
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).
Returns:
Throws:
java.lang.Exception

getActivityLogEntriesCount

public abstract 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.

Parameters:
startTimestamp - 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).
Returns:
Throws:
java.lang.Exception

close

public abstract void close()

Closes the server and shuts down any associated resources.


getHost

public abstract java.lang.String getHost()

Returns the host name of the server.

Returns:


This code is free for use both commercially and non-commercially as stated in the project's license