com.caucho.server.repository
Class ClusterRepository

java.lang.Object
  extended by com.caucho.env.repository.AbstractRepository
      extended by com.caucho.server.repository.ClusterRepository
All Implemented Interfaces:
NotifyListener, Repository, RepositorySpi

public class ClusterRepository
extends AbstractRepository
implements NotifyListener


Constructor Summary
ClusterRepository(RepositorySpi localRepository)
           
 
Method Summary
 java.lang.String addBlob(java.io.InputStream is)
          Adds a path to the repository.
 java.lang.String addBlob(java.io.InputStream is, long length)
          Adds a path to the repository.
 java.lang.String addCommit(GitCommit commit)
          Adds a git commit to the repository
 java.lang.String addPath(Path path)
          Adds a path to the repository.
 java.lang.String addTree(GitTree tree)
          Adds a git tree to the repository
 void checkForUpdate(boolean isExact)
          Updates based on the system store.
 boolean exists(java.lang.String sha1)
          Returns the file's git type: blob, tree, or commit
 void expandToPath(java.lang.String contentHash, Path path)
          Writes the contents to a stream.
 java.lang.String getRepositoryRootHash()
          Returns the hash stored in the git tag
 GitType getType(java.lang.String hash)
          Returns the file's git type: blob, tree, or commit
 void init()
          initialize the repository
 boolean isActive()
           
 boolean load(java.lang.String sha1)
          Loads from remote
 void onNotify(java.io.Serializable payload)
          Called when a triad has updated the store.
 java.io.InputStream openBlob(java.lang.String sha1)
          Opens a stream to a blob
 java.io.InputStream openRawGitFile(java.lang.String contentHash)
          Opens a stream to the raw git file.
 boolean putTag(java.lang.String tag, java.lang.String contentHash, java.util.Map<java.lang.String,java.lang.String> commitMetaData)
          Adds a tag
 GitCommit readCommit(java.lang.String sha1)
          Reads a git commit from the repository
 GitTree readTree(java.lang.String sha1)
          Reads a git tree from the repository
 boolean removeTag(java.lang.String tagName, java.util.Map<java.lang.String,java.lang.String> commitMetaData)
          Removes a tag
 void setRepositoryRootHash(java.lang.String repositoryCommitHash)
          Sets the hash stored in the git tag
 void start()
          Start the repository
 void stop()
           
protected  void updateLoad(java.lang.String sha1, boolean isNew)
          Updates the tag map from a load.
protected  void updateRepositoryRoot(java.lang.String sha1, long sequence)
           
 void validateRawGitFile(java.lang.String hash)
          Removes a raw git file
 void writeBlobToStream(java.lang.String blobHash, java.io.OutputStream os)
          Writes the contents to a stream.
 void writeRawGitFile(java.lang.String sha1, java.io.InputStream is)
          Writes a raw git file
 
Methods inherited from class com.caucho.env.repository.AbstractRepository
addArchive, addArchive, addArchive, addListener, addTagData, checkForUpdate, commitArchive, commitArchive, commitPath, getCommitHash, getRepositoryTag, getTagContentHash, getTagHash, getTagMap, getTagSequence, isBlob, isCommit, isTree, loadLocalRoot, removeListener, removeTag, removeTagData, setTagMap, toString, update, updateTagMap, validateHash, validateRawHash
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClusterRepository

public ClusterRepository(RepositorySpi localRepository)
Method Detail

init

public void init()
initialize the repository

Overrides:
init in class AbstractRepository

start

public void start()
Description copied from class: AbstractRepository
Start the repository

Overrides:
start in class AbstractRepository

stop

public void stop()
Overrides:
stop in class AbstractRepository

isActive

public boolean isActive()

onNotify

public void onNotify(java.io.Serializable payload)
Called when a triad has updated the store.

Specified by:
onNotify in interface NotifyListener

checkForUpdate

public void checkForUpdate(boolean isExact)
Updates based on the system store.

Specified by:
checkForUpdate in interface RepositorySpi
Overrides:
checkForUpdate in class AbstractRepository

updateLoad

protected void updateLoad(java.lang.String sha1,
                          boolean isNew)
Updates the tag map from a load.

Overrides:
updateLoad in class AbstractRepository

updateRepositoryRoot

protected void updateRepositoryRoot(java.lang.String sha1,
                                    long sequence)
Overrides:
updateRepositoryRoot in class AbstractRepository

load

public boolean load(java.lang.String sha1)
Loads from remote


putTag

public boolean putTag(java.lang.String tag,
                      java.lang.String contentHash,
                      java.util.Map<java.lang.String,java.lang.String> commitMetaData)
Adds a tag

Specified by:
putTag in interface RepositorySpi
Specified by:
putTag in class AbstractRepository
Parameters:
tagName - the symbolic tag for the repository
contentHash - the hash of the tag's content
commitMessage - user's message for the commit
commitMetaData - additional commit meta-data

removeTag

public boolean removeTag(java.lang.String tagName,
                         java.util.Map<java.lang.String,java.lang.String> commitMetaData)
Removes a tag

Specified by:
removeTag in interface RepositorySpi
Specified by:
removeTag in class AbstractRepository
Parameters:
tagName - the symbolic tag for the repository
commitMessage - user's message for the commit
commitMetaData - additional commit attributes

getRepositoryRootHash

public java.lang.String getRepositoryRootHash()
Returns the hash stored in the git tag

Specified by:
getRepositoryRootHash in interface RepositorySpi
Specified by:
getRepositoryRootHash in class AbstractRepository
Returns:
the hash of the .git Commit for the current repository root.

setRepositoryRootHash

public void setRepositoryRootHash(java.lang.String repositoryCommitHash)
Sets the hash stored in the git tag

Specified by:
setRepositoryRootHash in interface RepositorySpi
Specified by:
setRepositoryRootHash in class AbstractRepository
Parameters:
repositoryCommitHash - the hash of the new .git Commit for the repository.

exists

public boolean exists(java.lang.String sha1)
Returns the file's git type: blob, tree, or commit

Specified by:
exists in interface RepositorySpi
Specified by:
exists in class AbstractRepository

getType

public GitType getType(java.lang.String hash)
Returns the file's git type: blob, tree, or commit

Specified by:
getType in interface RepositorySpi
Specified by:
getType in class AbstractRepository

addPath

public java.lang.String addPath(Path path)
Adds a path to the repository. If the path is a directory or a jar scheme, adds the contents recursively.

Specified by:
addPath in interface RepositorySpi
Overrides:
addPath in class AbstractRepository

addBlob

public java.lang.String addBlob(java.io.InputStream is)
                         throws java.io.IOException
Adds a path to the repository. If the path is a directory or a jar scheme, adds the contents recursively.

Specified by:
addBlob in interface RepositorySpi
Parameters:
is - the blob's input stream
Throws:
java.io.IOException

addBlob

public java.lang.String addBlob(java.io.InputStream is,
                                long length)
                         throws java.io.IOException
Adds a path to the repository. If the path is a directory or a jar scheme, adds the contents recursively.

Specified by:
addBlob in interface RepositorySpi
Overrides:
addBlob in class AbstractRepository
Parameters:
is - the blob's input stream
length - the blob's length
Throws:
java.io.IOException

openBlob

public java.io.InputStream openBlob(java.lang.String sha1)
                             throws java.io.IOException
Opens a stream to a blob

Specified by:
openBlob in interface RepositorySpi
Specified by:
openBlob in class AbstractRepository
Throws:
java.io.IOException

readTree

public GitTree readTree(java.lang.String sha1)
                 throws java.io.IOException
Reads a git tree from the repository

Specified by:
readTree in interface RepositorySpi
Specified by:
readTree in class AbstractRepository
Throws:
java.io.IOException

addTree

public java.lang.String addTree(GitTree tree)
                         throws java.io.IOException
Adds a git tree to the repository

Specified by:
addTree in interface RepositorySpi
Overrides:
addTree in class AbstractRepository
Throws:
java.io.IOException

readCommit

public GitCommit readCommit(java.lang.String sha1)
                     throws java.io.IOException
Reads a git commit from the repository

Specified by:
readCommit in interface RepositorySpi
Specified by:
readCommit in class AbstractRepository
Throws:
java.io.IOException

addCommit

public java.lang.String addCommit(GitCommit commit)
                           throws java.io.IOException
Adds a git commit to the repository

Specified by:
addCommit in interface RepositorySpi
Specified by:
addCommit in class AbstractRepository
Throws:
java.io.IOException

writeBlobToStream

public void writeBlobToStream(java.lang.String blobHash,
                              java.io.OutputStream os)
Writes the contents to a stream.

Specified by:
writeBlobToStream in interface RepositorySpi
Specified by:
writeBlobToStream in class AbstractRepository
Parameters:
blobHash - the hash of the source blob
os - the OutputStream to write to

expandToPath

public void expandToPath(java.lang.String contentHash,
                         Path path)
Writes the contents to a stream.

Specified by:
expandToPath in interface RepositorySpi
Specified by:
expandToPath in class AbstractRepository

openRawGitFile

public java.io.InputStream openRawGitFile(java.lang.String contentHash)
                                   throws java.io.IOException
Opens a stream to the raw git file.

Specified by:
openRawGitFile in interface RepositorySpi
Specified by:
openRawGitFile in class AbstractRepository
Throws:
java.io.IOException

writeRawGitFile

public void writeRawGitFile(java.lang.String sha1,
                            java.io.InputStream is)
                     throws java.io.IOException
Writes a raw git file

Specified by:
writeRawGitFile in interface RepositorySpi
Specified by:
writeRawGitFile in class AbstractRepository
Throws:
java.io.IOException

validateRawGitFile

public void validateRawGitFile(java.lang.String hash)
Description copied from class: AbstractRepository
Removes a raw git file

Specified by:
validateRawGitFile in interface RepositorySpi
Overrides:
validateRawGitFile in class AbstractRepository