org.sdnplatform.sync.internal
Class StoreRegistry

java.lang.Object
  extended by org.sdnplatform.sync.internal.StoreRegistry

public class StoreRegistry
extends java.lang.Object

Manage registered stores and associated metadata

Author:
readams

Nested Class Summary
static class StoreRegistry.Hint
          A hint representing a hint key and a value
static class StoreRegistry.HintKey
          A key in the hint store
 
Field Summary
protected static org.slf4j.Logger logger
           
 
Constructor Summary
StoreRegistry(SyncManager syncManager, java.lang.String dbPath)
          Construct a new StoreRegistry
 
Method Summary
 SynchronizingStorageEngine get(java.lang.String storeName)
          Get the store associated with the given name, or null if there is no such store
 void queueHint(java.lang.String storeName, ByteArray key, Versioned<byte[]> value)
          Add a key/value to the hint store for the given store
 SynchronizingStorageEngine register(java.lang.String storeName, ISyncService.Scope scope, boolean persistent)
          Register a new store with the given name, scope and persistence
 void shutdown()
           
 void takeHints(java.util.Collection<StoreRegistry.Hint> c, int maxElements)
          Drain up to the given number of hints to the provided collection.
 java.util.Collection<SynchronizingStorageEngine> values()
          Get a collection containing all the currently-registered stores
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static final org.slf4j.Logger logger
Constructor Detail

StoreRegistry

public StoreRegistry(SyncManager syncManager,
                     java.lang.String dbPath)
Construct a new StoreRegistry

Parameters:
syncManager - The associated syncManager
Method Detail

get

public SynchronizingStorageEngine get(java.lang.String storeName)
Get the store associated with the given name, or null if there is no such store

Parameters:
storeName -
Returns:
a SynchronizingStorageEngine

register

public SynchronizingStorageEngine register(java.lang.String storeName,
                                           ISyncService.Scope scope,
                                           boolean persistent)
                                    throws PersistException
Register a new store with the given name, scope and persistence

Parameters:
storeName - the name of the store
scope - the scope for the store
persistent - whether the store should be persistent
Returns:
the newly-allocated store
Throws:
PersistException

values

public java.util.Collection<SynchronizingStorageEngine> values()
Get a collection containing all the currently-registered stores

Returns:
the Collection

queueHint

public void queueHint(java.lang.String storeName,
                      ByteArray key,
                      Versioned<byte[]> value)
Add a key/value to the hint store for the given store

Parameters:
storeName - the name of the store for the keyed value
key - the key
value - the value

takeHints

public void takeHints(java.util.Collection<StoreRegistry.Hint> c,
                      int maxElements)
               throws java.lang.InterruptedException
Drain up to the given number of hints to the provided collection. This method will block until at least one hint is available

Parameters:
c - the collection to which the hints should be copied
maxElements - the maximum number of hints to drain
Throws:
java.lang.InterruptedException

shutdown

public void shutdown()