com.amazon.carbonado.repo.replicated
Class ReplicatedRepositoryBuilder

java.lang.Object
  extended by com.amazon.carbonado.spi.AbstractRepositoryBuilder
      extended by com.amazon.carbonado.repo.replicated.ReplicatedRepositoryBuilder
All Implemented Interfaces:
RepositoryBuilder

public class ReplicatedRepositoryBuilder
extends AbstractRepositoryBuilder

Repository builder for the replicated repository.

The following extra capabilities are supported:

Author:
Don Schneider, Brian S O'Neill

Constructor Summary
ReplicatedRepositoryBuilder()
           
 
Method Summary
 Repository build(AtomicReference<Repository> rootRef)
          Builds a repository instance.
 void errorCheck(Collection<String> messages)
          This method is called by assertReady, and subclasses must override to perform custom checks.
 RepositoryBuilder getMasterRepositoryBuilder()
           
 String getName()
          Returns the name of the repository.
 RepositoryBuilder getReplicaRepositoryBuilder()
           
 boolean isMaster()
          Returns true if repository should assume the role of master, which is true by default.
 void setMaster(boolean b)
          Set to false if repository should not assume the role of master.
 void setMasterRepositoryBuilder(RepositoryBuilder masterRepositoryBuilder)
          Set "master" respository to replicate from, which is required.
 void setName(String name)
          Set name for the repository, which is required.
 void setReplicaRepositoryBuilder(RepositoryBuilder replicaRepositoryBuilder)
          Set "replica" respository to replicate to, which is required.
 
Methods inherited from class com.amazon.carbonado.spi.AbstractRepositoryBuilder
addTriggerFactory, assertReady, build, getTriggerFactories, removeTriggerFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReplicatedRepositoryBuilder

public ReplicatedRepositoryBuilder()
Method Detail

build

public Repository build(AtomicReference<Repository> rootRef)
                 throws RepositoryException
Description copied from interface: RepositoryBuilder
Builds a repository instance.

If the repository is being wrapped by a parent repository, the child repository will need to know this fact for some operations to work correctly. Since the parent repository is not built yet, a reference is used instead.

Parameters:
rootRef - reference to root parent repository, to be set by parent repository upon being built
Throws:
ConfigurationException - if there is a problem in the builder's configuration
RepositoryException - if there is a general problem opening the repository

getName

public String getName()
Description copied from interface: RepositoryBuilder
Returns the name of the repository.


setName

public void setName(String name)
Description copied from interface: RepositoryBuilder
Set name for the repository, which is required.


isMaster

public boolean isMaster()
Description copied from interface: RepositoryBuilder
Returns true if repository should assume the role of master, which is true by default. Repositories that link different repositories together will designate only one as the master.

A master repository is responsible for version and sequence properties. For insert operations, a master repository must set these properties if they are uninitialized. For updates, the version property is checked to see if an OptimisticLockException should be thrown.

See Also:
ReplicatedRepositoryBuilder

setMaster

public void setMaster(boolean b)
Description copied from interface: RepositoryBuilder
Set to false if repository should not assume the role of master. By default, this option is true. Repositories that link different repositories together will designate only one as the master.

A master repository is responsible for version and sequence properties. For insert operations, a master repository must set these properties if they are uninitialized. For updates, the version property is checked to see if an OptimisticLockException should be thrown.

See Also:
ReplicatedRepositoryBuilder

getReplicaRepositoryBuilder

public RepositoryBuilder getReplicaRepositoryBuilder()
Returns:
"replica" respository to replicate to.

setReplicaRepositoryBuilder

public void setReplicaRepositoryBuilder(RepositoryBuilder replicaRepositoryBuilder)
Set "replica" respository to replicate to, which is required. This builder automatically sets the master option of the given repository builder to false.


getMasterRepositoryBuilder

public RepositoryBuilder getMasterRepositoryBuilder()
Returns:
"master" respository to replicate from.

setMasterRepositoryBuilder

public void setMasterRepositoryBuilder(RepositoryBuilder masterRepositoryBuilder)
Set "master" respository to replicate from, which is required. This builder automatically sets the master option of the given repository to true.


errorCheck

public void errorCheck(Collection<String> messages)
                throws ConfigurationException
Description copied from class: AbstractRepositoryBuilder
This method is called by assertReady, and subclasses must override to perform custom checks. Be sure to call super.errorCheck as well.

Overrides:
errorCheck in class AbstractRepositoryBuilder
Parameters:
messages - add any error messages to this list
Throws:
ConfigurationException - if error checking indirectly caused another exception


Copyright © 2006-2009 Amazon Technologies, Inc.. All Rights Reserved.