com.amazon.carbonado.spi
Class BelatedRepositoryCreator

java.lang.Object
  extended by com.amazon.carbonado.util.BelatedCreator<Repository,SupportException>
      extended by com.amazon.carbonado.spi.BelatedRepositoryCreator

public class BelatedRepositoryCreator
extends BelatedCreator<Repository,SupportException>

Generic one-shot Repository builder which supports late object creation. If the Repository building results in an exception or is taking too long, the Repository produced instead is a bogus one. Many operations result in an IllegalStateException. After retrying, if the real Repository is created, then the bogus Repository turns into a wrapper to the real Repository.

Author:
Brian S O'Neill
See Also:
BelatedStorageCreator

Constructor Summary
BelatedRepositoryCreator(org.apache.commons.logging.Log log, RepositoryBuilder builder, AtomicReference<Repository> rootRef, int minRetryDelayMillis)
           
BelatedRepositoryCreator(org.apache.commons.logging.Log log, RepositoryBuilder builder, int minRetryDelayMillis)
           
 
Method Summary
protected  Repository createBogus()
          Create instance of bogus object.
protected  Repository createReal()
          Create instance of real object.
protected  void timedOutNotification(long timedOutMillis)
          Notification that createReal is taking too long.
 
Methods inherited from class com.amazon.carbonado.util.BelatedCreator
createdNotification, get
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BelatedRepositoryCreator

public BelatedRepositoryCreator(org.apache.commons.logging.Log log,
                                RepositoryBuilder builder,
                                int minRetryDelayMillis)
Parameters:
log - error reporting log
builder - builds real Repository
minRetryDelayMillis - minimum milliseconds to wait before retrying to create object after failure; if negative, never retry

BelatedRepositoryCreator

public BelatedRepositoryCreator(org.apache.commons.logging.Log log,
                                RepositoryBuilder builder,
                                AtomicReference<Repository> rootRef,
                                int minRetryDelayMillis)
Parameters:
log - error reporting log
builder - builds real Repository
rootRef - reference to root repository
minRetryDelayMillis - minimum milliseconds to wait before retrying to create object after failure; if negative, never retry
Method Detail

createReal

protected Repository createReal()
                         throws SupportException
Description copied from class: BelatedCreator
Create instance of real object. If there is a recoverable error creating the object, return null. Any error logging must be performed by the implementation of this method. If null is returned, expect this method to be called again in the future.

Specified by:
createReal in class BelatedCreator<Repository,SupportException>
Returns:
real object, or null if there was a recoverable error
Throws:
SupportException

createBogus

protected Repository createBogus()
Description copied from class: BelatedCreator
Create instance of bogus object.

Specified by:
createBogus in class BelatedCreator<Repository,SupportException>

timedOutNotification

protected void timedOutNotification(long timedOutMillis)
Description copied from class: BelatedCreator
Notification that createReal is taking too long. This can be used to log a message.

Specified by:
timedOutNotification in class BelatedCreator<Repository,SupportException>
Parameters:
timedOutMillis - milliseconds waited before giving up


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