org.shoal.ha.cache.impl.store
Class ReplicatedDataStore<K,V>

java.lang.Object
  extended by org.shoal.ha.cache.impl.store.ReplicatedDataStore<K,V>
All Implemented Interfaces:
DataStore<K,V>

public class ReplicatedDataStore<K,V>
extends java.lang.Object
implements DataStore<K,V>

Author:
Mahesh Kannan

Constructor Summary
ReplicatedDataStore(DataStoreConfigurator<K,V> conf, GroupService gs)
           
 
Method Summary
 void close()
          Close this datastore.
 java.util.Collection find(DataStoreEntryEvaluator<K,V> kvDataStoreEntryEvaluator)
          Finds / Retrieves values that satisfy a criteria as dictated by the evaluator.
 V get(K k)
          Returns the value to which the specified key is mapped in this cache.
 DataStoreContext<K,V> getDataStoreContext()
           
 java.lang.String put(K k, V v)
          Creates or Replaces the object associated with key k.
 void remove(K k)
          Removes the mapping between the key and the object.
 int removeIdleEntries(long idleFor)
          Removes all entries that were not accessed for more than 'idlefor' millis
 java.lang.String touch(K k, long version, long ts, long ttl)
          Updates the timestamp associated with this entry.
 void update(DataStoreEntryEvaluator<K,V> kvDataStoreEntryEvaluator)
          Updates all existing values associated with a key using the evaluator.
 java.lang.String updateDelta(K k, V obj)
          Performs an incremental update of the value associated with this key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReplicatedDataStore

public ReplicatedDataStore(DataStoreConfigurator<K,V> conf,
                           GroupService gs)
Method Detail

getDataStoreContext

public DataStoreContext<K,V> getDataStoreContext()

put

public java.lang.String put(K k,
                            V v)
                     throws DataStoreException
Description copied from interface: DataStore
Creates or Replaces the object associated with key k.

Specified by:
put in interface DataStore<K,V>
Parameters:
k - The Key
v - The value. The value must be either serializable of the DataStoreEntryHelper that is associated with this cache must be able to transform this into a serializable.
Throws:
DataStoreException

updateDelta

public java.lang.String updateDelta(K k,
                                    V obj)
                             throws DataStoreException
Description copied from interface: DataStore
Performs an incremental update of the value associated with this key. The DataStore's DataStoreEntryHelper.updateState() method will be called with the key, the DataStoreEnrty and the delta. If no value is associated with K, then a hollow DataStoreEntry will be passed to DataStoreEntryHelper.updateState().

Specified by:
updateDelta in interface DataStore<K,V>
Parameters:
k - The key
obj - The object whose eval() method will be called.
Throws:
DataStoreException
See Also:
#{DataStoreEntryEvaluator.eval}

get

public V get(K k)
      throws DataStoreException
Description copied from interface: DataStore
Returns the value to which the specified key is mapped in this cache.

Specified by:
get in interface DataStore<K,V>
Parameters:
k - The key
Returns:
The value if the association exists or null.
Throws:
DataStoreException

remove

public void remove(K k)
            throws DataStoreException
Description copied from interface: DataStore
Removes the mapping between the key and the object.

Specified by:
remove in interface DataStore<K,V>
Parameters:
k - The key
Throws:
DataStoreException

touch

public java.lang.String touch(K k,
                              long version,
                              long ts,
                              long ttl)
                       throws DataStoreException
Description copied from interface: DataStore
Updates the timestamp associated with this entry. see #{removeIdleEntries}

Specified by:
touch in interface DataStore<K,V>
Parameters:
k - The key
Throws:
DataStoreException

removeIdleEntries

public int removeIdleEntries(long idleFor)
Description copied from interface: DataStore
Removes all entries that were not accessed for more than 'idlefor' millis

Specified by:
removeIdleEntries in interface DataStore<K,V>
Parameters:
idleFor - Time in milli seconds

find

public java.util.Collection find(DataStoreEntryEvaluator<K,V> kvDataStoreEntryEvaluator)
Description copied from interface: DataStore
Finds / Retrieves values that satisfy a criteria as dictated by the evaluator. The evaluator's eval() method will be called with both the key and the existing value.

Specified by:
find in interface DataStore<K,V>
Parameters:
kvDataStoreEntryEvaluator - The StoreEntryEvaluator whose eval() method will be called.
See Also:
#{DataStoreEntryEvaluator.eval}

update

public void update(DataStoreEntryEvaluator<K,V> kvDataStoreEntryEvaluator)
Description copied from interface: DataStore
Updates all existing values associated with a key using the evaluator. The evaluator's eval() method will be called with both the key and the existing value.

Specified by:
update in interface DataStore<K,V>
Parameters:
kvDataStoreEntryEvaluator - The StoreEntryEvaluator whose eval() method will be called.
See Also:
#{DataStoreEntryEvaluator.eval}

close

public void close()
Description copied from interface: DataStore
Close this datastore. This causes all data to be removed(?)

Specified by:
close in interface DataStore<K,V>


Copyright © 2010. All Rights Reserved.