org.tranche.project
Class ProjectReplicationTool

java.lang.Object
  extended by org.tranche.project.ProjectReplicationTool
All Implemented Interfaces:
ProjectReplicationToolListener

public class ProjectReplicationTool
extends java.lang.Object
implements ProjectReplicationToolListener

Replicates chunks for one or more projects to select servers.

Author:
Bryan E. Smith - bryanesmith@gmail.com

Constructor Summary
ProjectReplicationTool(java.security.cert.X509Certificate cert, java.security.PrivateKey key)
           
ProjectReplicationTool(java.security.cert.X509Certificate cert, java.security.PrivateKey key, java.util.Collection<java.lang.String> serversToRead, java.util.Collection<java.lang.String> serversToWrite)
           
 
Method Summary
 boolean addProjectReplicationToolListener(ProjectReplicationToolListener l)
          Add a listener to the tool.
 void clearProjectReplicationToolListeners()
          Clear out listeners used by the tool.
 void execute()
          Start replication.
 void fireDataChunkFailed(BigHash h)
          Event fired when data chunk failed.
 void fireDataChunkReplicated(BigHash h)
          Event fired when data chunk replicated.
 void fireDataChunkSkipped(BigHash h)
          Event fired when data chunk skipped.
 void fireFileFailed(BigHash h)
          Event fired when file failed.
 void fireFileFinished(BigHash h)
          Event fired when file finished.
 void fireMetaDataChunkFailed(BigHash h)
          Event fired when meta data chunk failed.
 void fireMetaDataChunkReplicated(BigHash h)
          Event fired when meta data chunk replicated.
 void fireMetaDataChunkSkipped(BigHash h)
          Event fired when meta data chunk skipped.
 void fireReplicationFailed()
          Event fired when replication failed.
 void fireReplicationFinished()
          Event fired when replication finished.
 void fireReplicationStarted(ProjectReplicationTool tool)
          Event fired when replication started.
 java.security.cert.X509Certificate getCert()
          Get the certificate used by the tool.
 long getFailedDataChunkCount()
          Get the failed data chunk count.
 long getFailedMetaDataChunkCount()
          Get the failed meta data chunk count.
 BigHash getHash()
          Get the project hash used by the tool.
 java.security.PrivateKey getKey()
          Get the private key used by the tool.
 int getNumberRequiredReplications()
          Get the required replication count.
 java.lang.String getPassphrase()
          Get passphrase used by the tool.
 java.util.Collection<java.lang.String> getServersToRead()
          Get the servers from which to read.
 java.util.Collection<java.lang.String> getServersToWrite()
          Get the servers to which to write.
 long getSizeAlreadyHandled()
          Get the size of data already replicated.
 long getSizeOfProject()
          Get the size of the project being replicated.
 long getSkippedDataChunkCount()
          Get the skipped data chunk count.
 long getSkippedMetaDataChunkCount()
          Get the skipped meta data chunk count.
 long getSuccessDataChunkCount()
          Get the count of successful data chunk replications.
 long getSuccessMetaDataChunkCount()
          Get the count of successful meta data chunk replications.
protected  void replicateProject(MetaData projectMetaData)
          Helper method to replicate the project.
protected  void replicateSingleFile(BigHash fileHash, MetaData fileMetaData)
          Used to replicate a single-file upload OR a file within a project.
 void setCert(java.security.cert.X509Certificate cert)
          Set the certificate used by the tool.
 void setHash(BigHash hash)
          Set the project hash used by the tool.
 void setKey(java.security.PrivateKey key)
          Set the private key used by the tool.
 void setNumberRequiredReplications(int numberRequiredReplications)
          Set the required replication count.
 void setPassphrase(java.lang.String passphrase)
          Set passphrase used by the tool.
 void setServersToRead(java.util.List<java.lang.String> serversToRead)
          Set the servers from which to read.
 void setServersToWrite(java.util.List<java.lang.String> serversToWrite)
          Set the servers to which to write.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProjectReplicationTool

public ProjectReplicationTool(java.security.cert.X509Certificate cert,
                              java.security.PrivateKey key)
Parameters:
cert -
key -

ProjectReplicationTool

public ProjectReplicationTool(java.security.cert.X509Certificate cert,
                              java.security.PrivateKey key,
                              java.util.Collection<java.lang.String> serversToRead,
                              java.util.Collection<java.lang.String> serversToWrite)
Parameters:
cert -
key -
serversToRead -
serversToWrite -
Method Detail

execute

public void execute()
             throws java.lang.Exception

Start replication.

Throws:
java.lang.Exception

replicateSingleFile

protected void replicateSingleFile(BigHash fileHash,
                                   MetaData fileMetaData)
                            throws java.lang.Exception

Used to replicate a single-file upload OR a file within a project. When replicating project, this will be called many times.

Parameters:
fileHash -
fileMetaData -
Throws:
java.lang.Exception

replicateProject

protected void replicateProject(MetaData projectMetaData)
                         throws java.lang.Exception

Helper method to replicate the project.

Parameters:
projectMetaData -
Throws:
java.lang.Exception

getCert

public java.security.cert.X509Certificate getCert()

Get the certificate used by the tool.

Returns:

setCert

public void setCert(java.security.cert.X509Certificate cert)

Set the certificate used by the tool.

Parameters:
cert -

getKey

public java.security.PrivateKey getKey()

Get the private key used by the tool.

Returns:

setKey

public void setKey(java.security.PrivateKey key)

Set the private key used by the tool.

Parameters:
key -

getHash

public BigHash getHash()

Get the project hash used by the tool.

Returns:

setHash

public void setHash(BigHash hash)

Set the project hash used by the tool.

Parameters:
hash -

getPassphrase

public java.lang.String getPassphrase()

Get passphrase used by the tool.

Returns:

setPassphrase

public void setPassphrase(java.lang.String passphrase)

Set passphrase used by the tool.

Parameters:
passphrase -

addProjectReplicationToolListener

public boolean addProjectReplicationToolListener(ProjectReplicationToolListener l)

Add a listener to the tool.

Parameters:
l -
Returns:

clearProjectReplicationToolListeners

public void clearProjectReplicationToolListeners()

Clear out listeners used by the tool.


fireReplicationStarted

public void fireReplicationStarted(ProjectReplicationTool tool)

Event fired when replication started.

Specified by:
fireReplicationStarted in interface ProjectReplicationToolListener
Parameters:
tool -

fireReplicationFailed

public void fireReplicationFailed()

Event fired when replication failed.

Specified by:
fireReplicationFailed in interface ProjectReplicationToolListener

fireReplicationFinished

public void fireReplicationFinished()

Event fired when replication finished.

Specified by:
fireReplicationFinished in interface ProjectReplicationToolListener

fireDataChunkReplicated

public void fireDataChunkReplicated(BigHash h)

Event fired when data chunk replicated.

Specified by:
fireDataChunkReplicated in interface ProjectReplicationToolListener
Parameters:
h -

fireMetaDataChunkReplicated

public void fireMetaDataChunkReplicated(BigHash h)

Event fired when meta data chunk replicated.

Specified by:
fireMetaDataChunkReplicated in interface ProjectReplicationToolListener
Parameters:
h -

fireDataChunkSkipped

public void fireDataChunkSkipped(BigHash h)

Event fired when data chunk skipped.

Specified by:
fireDataChunkSkipped in interface ProjectReplicationToolListener
Parameters:
h -

fireMetaDataChunkSkipped

public void fireMetaDataChunkSkipped(BigHash h)

Event fired when meta data chunk skipped.

Specified by:
fireMetaDataChunkSkipped in interface ProjectReplicationToolListener
Parameters:
h -

fireDataChunkFailed

public void fireDataChunkFailed(BigHash h)

Event fired when data chunk failed.

Specified by:
fireDataChunkFailed in interface ProjectReplicationToolListener
Parameters:
h -

fireMetaDataChunkFailed

public void fireMetaDataChunkFailed(BigHash h)

Event fired when meta data chunk failed.

Specified by:
fireMetaDataChunkFailed in interface ProjectReplicationToolListener
Parameters:
h -

fireFileFailed

public void fireFileFailed(BigHash h)

Event fired when file failed.

Specified by:
fireFileFailed in interface ProjectReplicationToolListener
Parameters:
h -

fireFileFinished

public void fireFileFinished(BigHash h)

Event fired when file finished.

Specified by:
fireFileFinished in interface ProjectReplicationToolListener
Parameters:
h -

getSizeOfProject

public long getSizeOfProject()

Get the size of the project being replicated.

Returns:

getSizeAlreadyHandled

public long getSizeAlreadyHandled()

Get the size of data already replicated.

Returns:

getFailedDataChunkCount

public long getFailedDataChunkCount()

Get the failed data chunk count.

Returns:

getFailedMetaDataChunkCount

public long getFailedMetaDataChunkCount()

Get the failed meta data chunk count.

Returns:

getSkippedDataChunkCount

public long getSkippedDataChunkCount()

Get the skipped data chunk count.

Returns:

getSkippedMetaDataChunkCount

public long getSkippedMetaDataChunkCount()

Get the skipped meta data chunk count.

Returns:

getSuccessDataChunkCount

public long getSuccessDataChunkCount()

Get the count of successful data chunk replications.

Returns:

getSuccessMetaDataChunkCount

public long getSuccessMetaDataChunkCount()

Get the count of successful meta data chunk replications.

Returns:

getNumberRequiredReplications

public int getNumberRequiredReplications()

Get the required replication count.

Returns:

setNumberRequiredReplications

public void setNumberRequiredReplications(int numberRequiredReplications)

Set the required replication count.

Parameters:
numberRequiredReplications -

getServersToRead

public java.util.Collection<java.lang.String> getServersToRead()

Get the servers from which to read.

Returns:

setServersToRead

public void setServersToRead(java.util.List<java.lang.String> serversToRead)

Set the servers from which to read.

Parameters:
serversToRead -

getServersToWrite

public java.util.Collection<java.lang.String> getServersToWrite()

Get the servers to which to write.

Returns:

setServersToWrite

public void setServersToWrite(java.util.List<java.lang.String> serversToWrite)

Set the servers to which to write.

Parameters:
serversToWrite -


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