Package org.jgroups.blocks
Class ReplCache<K,V>
java.lang.Object
org.jgroups.blocks.ReplCache<K,V>
- All Implemented Interfaces:
Cache.ChangeListener,MembershipListener
Cache which allows for replication factors per data items; the factor determines how many replicas
of a key/value we create across the cluster.
See doc/design/ReplCache.txt for details.
See doc/design/ReplCache.txt for details.
- Author:
- Bela Ban
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic classstatic interfacestatic interfacestatic classUses arrays to store hash values of addresses, plus addresses. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid_removeMany(Set<K> keys) voidvoidvoidblock()Called (usually by the FLUSH protocol), as an indication that the member should stop sending messages.voidchanged()voidclear()Removes all keys and values in the L2 and L1 cachesdump()Returns the value associated with keylonglongintshortgetProps()getView()booleanbooleanvoidvoidvoidPlaces a key/value pair into one or several nodes in the cluster.voidPlaces a key/value pair into one or several nodes in the cluster.voidRemoves key in all nodes in the cluster, both from their local hashmaps and L1 cachesvoidRemoves key in all nodes in the cluster, both from their local hashmaps and L1 cachesvoidvoidvoidsetCachingTime(long caching_time) voidsetCallTimeout(long call_timeout) voidsetClusterName(String cluster_name) voidsetDefaultReplicationCount(short default_replication_count) voidsetHashFunction(ReplCache.HashFunction<K> hash_function) voidsetHashFunctionFactory(ReplCache.HashFunctionFactory<K> hash_function_factory) voidsetL1Cache(Cache<K, V> cache) voidsetL2Cache(Cache<K, ReplCache.Value<V>> cache) voidsetMigrateData(boolean migrate_data) voidvoidstart()voidstop()voidCalled whenever a member is suspected of having crashed, but has not yet been excluded.toString()voidviewAccepted(View new_view) Called when a change in membership has occurred.
-
Field Details
-
methods
-
-
Constructor Details
-
ReplCache
-
-
Method Details
-
getProps
-
setProps
-
getLocalAddress
-
getLocalAddressAsString
-
getView
-
getClusterSize
public int getClusterSize() -
isL1CacheEnabled
public boolean isL1CacheEnabled() -
getClusterName
-
setClusterName
-
getCallTimeout
public long getCallTimeout() -
setCallTimeout
public void setCallTimeout(long call_timeout) -
getCachingTime
public long getCachingTime() -
setCachingTime
public void setCachingTime(long caching_time) -
isMigrateData
public boolean isMigrateData() -
setMigrateData
public void setMigrateData(boolean migrate_data) -
getDefaultReplicationCount
public short getDefaultReplicationCount() -
setDefaultReplicationCount
public void setDefaultReplicationCount(short default_replication_count) -
getHashFunction
-
setHashFunction
-
getHashFunctionFactory
-
setHashFunctionFactory
-
addMembershipListener
-
removeMembershipListener
-
addChangeListener
-
removeChangeListener
-
getL1Cache
-
setL1Cache
-
getL2Cache
-
setL2Cache
-
start
- Throws:
Exception
-
stop
public void stop() -
put
Places a key/value pair into one or several nodes in the cluster.- Parameters:
key- The key, needs to be serializableval- The value, needs to be serializablerepl_count- Number of replicas. The total number of times a data item should be present in a cluster. Needs to be > 0- -1: create key/val in all the nodes in the cluster
- 1: create key/val only in one node in the cluster, picked by computing the consistent hash of KEY
- K > 1: create key/val in those nodes in the cluster which match the consistent hashes created for KEY
timeout- Expiration time for key/value.- -1: don't cache at all in the L1 cache
- 0: cache forever, until removed or evicted because we need space for newer elements
- > 0: number of milliseconds to keep an idle element in the cache. An element is idle when not accessed.
synchronous- Whether or not to block until all cluster nodes have applied the change
-
put
Places a key/value pair into one or several nodes in the cluster.- Parameters:
key- The key, needs to be serializableval- The value, needs to be serializablerepl_count- Number of replicas. The total number of times a data item should be present in a cluster. Needs to be > 0- -1: create key/val in all the nodes in the cluster
- 1: create key/val only in one node in the cluster, picked by computing the consistent hash of KEY
- K > 1: create key/val in those nodes in the cluster which match the consistent hashes created for KEY
timeout- Expiration time for key/value.- -1: don't cache at all in the L1 cache
- 0: cache forever, until removed or evicted because we need space for newer elements
- > 0: number of milliseconds to keep an idle element in the cache. An element is idle when not accessed.
-
put
-
get
Returns the value associated with key- Parameters:
key- The key, has to be serializable- Returns:
- The value associated with key, or null
-
remove
Removes key in all nodes in the cluster, both from their local hashmaps and L1 caches- Parameters:
key- The key, needs to be serializable
-
remove
Removes key in all nodes in the cluster, both from their local hashmaps and L1 caches- Parameters:
key- The key, needs to be serializable
-
clear
public void clear()Removes all keys and values in the L2 and L1 caches -
_put
-
_put
- Parameters:
key-val-repl_count-timeout-force- Skips acceptance checking and simply adds the key/value- Returns:
-
_get
-
_remove
-
_removeMany
-
viewAccepted
Description copied from interface:MembershipListenerCalled when a change in membership has occurred. No long running actions or sending of messages should be done in this callback. If some long running action needs to be performed, it should be done in a separate thread. Note that on reception of the first view (a new member just joined), the channel will not yet be in the connected state. This only happens whenChannel.connect(String)returns.- Specified by:
viewAcceptedin interfaceMembershipListener
-
suspect
Description copied from interface:MembershipListenerCalled whenever a member is suspected of having crashed, but has not yet been excluded.- Specified by:
suspectin interfaceMembershipListener
-
block
public void block()Description copied from interface:MembershipListenerCalled (usually by the FLUSH protocol), as an indication that the member should stop sending messages. Any messages sent after returning from this callback might get blocked by the FLUSH protocol. When the FLUSH protocol is done, and messages can be sent again, the FLUSH protocol will simply unblock all pending messages. If a callback for unblocking is desired, implementExtendedMembershipListener.unblock(). Note that block() is the equivalent of reception of a BlockEvent in the pull mode.- Specified by:
blockin interfaceMembershipListener
-
changed
public void changed()- Specified by:
changedin interfaceCache.ChangeListener
-
toString
-
dump
-
mcastEntries
public void mcastEntries()
-