org.sdnplatform.sync.internal
Class AbstractStoreClient<K,V>

java.lang.Object
  extended by org.sdnplatform.sync.internal.AbstractStoreClient<K,V>
All Implemented Interfaces:
IStoreClient<K,V>
Direct Known Subclasses:
DefaultStoreClient

public abstract class AbstractStoreClient<K,V>
extends java.lang.Object
implements IStoreClient<K,V>


Constructor Summary
AbstractStoreClient()
           
 
Method Summary
 void delete(K key)
          Delete the key by writing a null tombstone to the store obliterating any existing value stored for the key.
 void delete(K key, IVersion version)
          Delete the key by writing a null tombstone to the store using the provided IVersion.
 Versioned<V> get(K key)
          Get the versioned value associated with the given key.
 V getValue(K key)
          Get the value associated with the given key or null if there is no value associated with this key.
 V getValue(K key, V defaultValue)
          Get the value associated with the given key or defaultValue if there is no value associated with the key.
protected abstract  java.util.List<IVersion> getVersions(K key)
          Get the versions for a key
 IVersion put(K key, V value)
          Associated the given value to the key, clobbering any existing values stored for the key.
 boolean putIfNotObsolete(K key, Versioned<V> versioned)
          Put the versioned value to the key, ignoring any ObsoleteVersionException that may be thrown
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.sdnplatform.sync.IStoreClient
addStoreListener, entries, get, put
 

Constructor Detail

AbstractStoreClient

public AbstractStoreClient()
Method Detail

getValue

public V getValue(K key)
           throws SyncException
Description copied from interface: IStoreClient
Get the value associated with the given key or null if there is no value associated with this key. This method strips off all version information and is only useful when no further storage operations will be done on this key. In general, you should prefer the get() method that returns version information unless.

Specified by:
getValue in interface IStoreClient<K,V>
Parameters:
key - The key
Throws:
SyncException

getValue

public V getValue(K key,
                  V defaultValue)
           throws SyncException
Description copied from interface: IStoreClient
Get the value associated with the given key or defaultValue if there is no value associated with the key. This method strips off all version information and is only useful when no further storage operations will be done on this key.In general, you should prefer the get() method that returns version information unless.

Specified by:
getValue in interface IStoreClient<K,V>
Parameters:
key - The key for which to fetch the associated value
defaultValue - A value to return if there is no value associated with this key
Returns:
Either the value stored for the key or the default value.
Throws:
SyncException

getVersions

protected abstract java.util.List<IVersion> getVersions(K key)
                                                 throws SyncException
Get the versions for a key

Parameters:
key - the key
Returns:
the versions
Throws:
SyncException

get

public Versioned<V> get(K key)
                 throws SyncException
Description copied from interface: IStoreClient
Get the versioned value associated with the given key. Note that while this function will never return null, the Versioned returned can have a null value (i.e. can be null if the key is not present.

Specified by:
get in interface IStoreClient<K,V>
Parameters:
key - The key for which to fetch the value.
Returns:
The versioned value
Throws:
SyncException

put

public IVersion put(K key,
                    V value)
             throws SyncException
Description copied from interface: IStoreClient
Associated the given value to the key, clobbering any existing values stored for the key. Only use this variant if the write cannot possibly depend on the current value in the store and if there cannot be a concurrent update from multiple threads. Otherwise IStoreClient.put(Object, Versioned) or IStoreClient.putIfNotObsolete(Object, Versioned)

Specified by:
put in interface IStoreClient<K,V>
Parameters:
key - The key
value - The value
Returns:
version The version of the object
Throws:
ObsoleteVersionException
SyncException

putIfNotObsolete

public boolean putIfNotObsolete(K key,
                                Versioned<V> versioned)
                         throws SyncException
Description copied from interface: IStoreClient
Put the versioned value to the key, ignoring any ObsoleteVersionException that may be thrown

Specified by:
putIfNotObsolete in interface IStoreClient<K,V>
Parameters:
key - The key
versioned - The versioned value
Returns:
true if the put succeeded
Throws:
SyncException

delete

public void delete(K key)
            throws SyncException
Description copied from interface: IStoreClient
Delete the key by writing a null tombstone to the store obliterating any existing value stored for the key. Only use this variant if the delete cannot possibly depend on the current value in the store and if there cannot be a concurrent update from multiple threads. Otherwise IStoreClient.delete(Object, IVersion) should be used.

Specified by:
delete in interface IStoreClient<K,V>
Parameters:
key - The key
Throws:
SyncException

delete

public void delete(K key,
                   IVersion version)
            throws SyncException
Description copied from interface: IStoreClient
Delete the key by writing a null tombstone to the store using the provided IVersion.

Specified by:
delete in interface IStoreClient<K,V>
Parameters:
key - The key to delete
version - The version of the key
Throws:
SyncException
ObsoleteVersionException - if the entry assoicated with the key was locally modified by another thread after the get.