Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jgroups.blocks
Class PartitionedHashMap<K,V>

    java.lang.Object
      org.jgroups.blocks.PartitionedHashMap<K,V>

All Implemented Interfaces:
  MembershipListener

    public class PartitionedHashMap<K,V>

extends java.lang.Object
implements MembershipListener

Hashmap which distributes its keys and values across the cluster. A PUT/GET/REMOVE computes the cluster node to which or from which to get/set the key/value from a hash of the key and then forwards the request to the remote cluster node. We also maintain a local cache (L1 cache) which is a bounded cache that caches retrieved keys/values.
Todos:

1. Use MarshalledValue to keep track of byte[] buffers, and be able to compute the exact size of the cache. This is good for maintaining a bounded cache (rather than using the number of entries)
2. Provide a better consistent hashing algorithm than ConsistentHashFunction as default
3. GUI (showing at least the topology and L1 and L2 caches)
4. Notifications (puts, removes, gets etc)
5. Invalidation of L1 caches (if used) on removal/put of item
6. Benchmarks, comparison to memcached
7. Documentation, comparison to memcached

Author:
  Bela Ban

Nested Class Summary
`static class` | `PartitionedHashMap.ArrayBasedConsistentHashFunction<K>` Uses arrays to store hash values of addresses, plus addresses.
`static class` | `PartitionedHashMap.ConsistentHashFunction<K>`
`static interface` | `PartitionedHashMap.HashFunction<K>`

Field Summary
`protected static java.util.Map<java.lang.Short,java.lang.reflect.Method>` | `methods`

Constructor Summary
`PartitionedHashMap(java.lang.String props, java.lang.String cluster_name)`

Method Summary
`Cache.Value<V>` | `_get(K key)`
`V` | `_put(K key, V val, long caching_time)`
`V` | `_remove(K key)`
`void` | `addMembershipListener(MembershipListener l)`
`void` | `block()` Called (usually by the FLUSH protocol), as an indication that the member should stop sending messages.
`java.lang.String` | `dump()`
`V` | `get(K key)`
`long` | `getCachingTime()`
`long` | `getCallTimeout()`
`java.lang.String` | `getClusterName()`
`PartitionedHashMap.HashFunction` | `getHashFunction()`
`Cache<K,V>` | `getL1Cache()`
`Cache<K,V>` | `getL2Cache()`
`Address` | `getLocalAddress()`
`java.lang.String` | `getLocalAddressAsString()`
`java.lang.String` | `getProps()`
`java.lang.String` | `getView()`
`boolean` | `isL1CacheEnabled()`
`boolean` | `isMigrateData()`
`void` | `put(K key, V val)`
`void` | `put(K key, V val, long caching_time)` Adds a key/value to the cache, replacing a previous item if there was one
`void` | `remove(K key)`
`void` | `removeMembershipListener(MembershipListener l)`
`void` | `setCachingTime(long caching_time)`
`void` | `setCallTimeout(long call_timeout)`
`void` | `setClusterName(java.lang.String cluster_name)`
`void` | `setHashFunction(PartitionedHashMap.HashFunction<K> hash_function)`
`void` | `setL1Cache(Cache<K,V> cache)`
`void` | `setL2Cache(Cache<K,V> cache)`
`void` | `setMigrateData(boolean migrate_data)`
`void` | `setProps(java.lang.String props)`
`void` | `start()`
`void` | `stop()`
`void` | `suspect(Address suspected_mbr)` Called whenever a member is suspected of having crashed, but has not yet been excluded.
`java.lang.String` | `toString()`
`void` | `viewAccepted(View new_view)` Called when a change in membership has occurred.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### methods

    protected static java.util.Map<java.lang.Short,java.lang.reflect.Method> methods

Constructor Detail

### PartitionedHashMap

    public PartitionedHashMap(java.lang.String props,
                              java.lang.String cluster_name)

Method Detail

### getProps

    public java.lang.String getProps()

### setProps

    public void setProps(java.lang.String props)

### getLocalAddress

    public Address getLocalAddress()

### getLocalAddressAsString

    public java.lang.String getLocalAddressAsString()

### getView

    public java.lang.String getView()

### isL1CacheEnabled

    public boolean isL1CacheEnabled()

### getClusterName

    public java.lang.String getClusterName()

### setClusterName

    public void setClusterName(java.lang.String cluster_name)

### 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)

### getHashFunction

    public PartitionedHashMap.HashFunction getHashFunction()

### setHashFunction

    public void setHashFunction(PartitionedHashMap.HashFunction<K> hash_function)

### addMembershipListener

    public void addMembershipListener(MembershipListener l)

### removeMembershipListener

    public void removeMembershipListener(MembershipListener l)

### getL1Cache

    public Cache<K,V> getL1Cache()

### setL1Cache

    public void setL1Cache(Cache<K,V> cache)

### getL2Cache

    public Cache<K,V> getL2Cache()

### setL2Cache

    public void setL2Cache(Cache<K,V> cache)

### start

    public void start()
               throws java.lang.Exception

  Throws:
    `java.lang.Exception`

### stop

    public void stop()

### put

    public void put(K key,
                    V val)

### put

    public void put(K key,
                    V val,
                    long caching_time)

  Adds a key/value to the cache, replacing a previous item if there was one

  Parameters:
    `key` - The key
    `val` - The value
    `caching_time` - Time to live. -1 means never cache, 0 means cache forever. All other (positive) values are the number of milliseconds to cache the item

### get

    public V get(K key)

### remove

    public void remove(K key)

### _put

    public V _put(K key,
                  V val,
                  long caching_time)

### _get

    public Cache.Value<V> _get(K key)

### _remove

    public V _remove(K key)

### viewAccepted

    public void viewAccepted(View new_view)

  Description copied from interface: `MembershipListener`
  Called 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 when `Channel.connect(String)` returns.

  Specified by:
    `viewAccepted` in interface `MembershipListener`

### suspect

    public void suspect(Address suspected_mbr)

  Description copied from interface: `MembershipListener`
  Called whenever a member is suspected of having crashed, but has not yet been excluded.

  Specified by:
    `suspect` in interface `MembershipListener`

### block

    public void block()

  Description copied from interface: `MembershipListener`
  Called (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, implement `ExtendedMembershipListener.unblock()`. Note that block() is the equivalent of reception of a BlockEvent in the pull mode.

  Specified by:
    `block` in interface `MembershipListener`

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

### dump

    public java.lang.String dump()

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 1998-2009 Bela Ban / Red Hat. All Rights Reserved.