com.amazon.carbonado.spi
Class BelatedStorageCreator<S extends Storable>

java.lang.Object
  extended by com.amazon.carbonado.util.BelatedCreator<Storage<S>,SupportException>
      extended by com.amazon.carbonado.spi.BelatedStorageCreator<S>

public class BelatedStorageCreator<S extends Storable>
extends BelatedCreator<Storage<S>,SupportException>

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

Author:
Brian S O'Neill
See Also:
BelatedRepositoryCreator

Constructor Summary
BelatedStorageCreator(org.apache.commons.logging.Log log, Repository repo, Class<S> storableType, int minRetryDelayMillis)
           
 
Method Summary
protected  Storage<S> createBogus()
          Create instance of bogus object.
protected  Storage<S> 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

BelatedStorageCreator

public BelatedStorageCreator(org.apache.commons.logging.Log log,
                             Repository repo,
                             Class<S> storableType,
                             int minRetryDelayMillis)
Parameters:
log - error reporting log
repo - Repository to get Storage from
storableType - type of Storable to get Storage for
minRetryDelayMillis - minimum milliseconds to wait before retrying to create object after failure; if negative, never retry
Method Detail

createReal

protected Storage<S> 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<Storage<S extends Storable>,SupportException>
Returns:
real object, or null if there was a recoverable error
Throws:
SupportException

createBogus

protected Storage<S> createBogus()
Description copied from class: BelatedCreator
Create instance of bogus object.

Specified by:
createBogus in class BelatedCreator<Storage<S extends Storable>,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<Storage<S extends Storable>,SupportException>
Parameters:
timedOutMillis - milliseconds waited before giving up


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