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

## org.apache.catalina.tribes.tipis
Class AbstractReplicatedMap

    java.lang.Object
      java.util.AbstractMap<K,V>
          java.util.concurrent.ConcurrentHashMap
              org.apache.catalina.tribes.tipis.AbstractReplicatedMap

All Implemented Interfaces:
  java.io.Serializable, java.util.concurrent.ConcurrentMap, java.util.Map, ChannelListener, RpcCallback, Heartbeat, MembershipListener

Direct Known Subclasses:
  LazyReplicatedMap, ReplicatedMap

    public abstract class AbstractReplicatedMap

extends java.util.concurrent.ConcurrentHashMap
implements RpcCallback, ChannelListener, MembershipListener, Heartbeat

Version:
  1.0
Author:
  Filip Hanik
See Also:
  Serialized Form

Nested Class Summary
`static class` | `AbstractReplicatedMap.MapEntry`
`static class` | `AbstractReplicatedMap.MapMessage`
`static interface` | `AbstractReplicatedMap.MapOwner`

Nested classes/interfaces inherited from interface java.util.Map
`java.util.Map.Entry<K,V>`

Field Summary
`protected long` | `accessTimeout` Since the map keeps internal membership this is the timeout for a ping message to be responded to If a remote map doesn't respond within this timeframe, its considered dead.
`protected Channel` | `channel` Reference to the channel for sending messages
`protected int` | `channelSendOptions` Our default send options
`protected int` | `currentNode` The node we are currently backing up data to, this index will rotate on a round robin basis
`static int` | `DEFAULT_INITIAL_CAPACITY` The default initial capacity - MUST be a power of two.
`static float` | `DEFAULT_LOAD_FACTOR` The load factor used when none specified in constructor.
`protected java.lang.ClassLoader[]` | `externalLoaders` External class loaders if serialization and deserialization is to be performed successfully.
`protected static Log` | `log`
`protected byte[]` | `mapContextName` The Map context name makes this map unique, this allows us to have more than one map shared through one channel
`protected java.util.HashMap` | `mapMembers` A list of members in our map
`protected java.lang.String` | `mapname` Readable string of the mapContextName value
`protected AbstractReplicatedMap.MapOwner` | `mapOwner` The owner of this map, ala a SessionManager for example
`protected RpcChannel` | `rpcChannel` The RpcChannel to send RPC messages through
`protected long` | `rpcTimeout` Timeout for RPC messages, how long we will wait for a reply
`protected java.lang.Object` | `stateMutex` Simple lock object for transfers
`protected boolean` | `stateTransferred` Has the state been transferred

Constructor Summary
`AbstractReplicatedMap(AbstractReplicatedMap.MapOwner owner, Channel channel, long timeout, java.lang.String mapContextName, int initialCapacity, float loadFactor, int channelSendOptions, java.lang.ClassLoader[] cls)` Creates a new map

Method Summary
`boolean` | `accept(java.io.Serializable msg, Member sender)` Invoked by the channel to determine if the listener will process this message or not.
`void` | `breakdown()`
`protected void` | `broadcast(int msgtype, boolean rpc)` Helper method to broadcast a message to all members in a channel
`void` | `clear()`
`void` | `clear(boolean notify)`
`java.lang.Object` | `clone()`
`boolean` | `containsKey(java.lang.Object key)` Returns true if the key has an entry in the map.
`boolean` | `containsValue(java.lang.Object value)`
`java.util.Set` | `entrySet()`
`java.util.Set` | `entrySetFull()` Returns the entire contents of the map Map.Entry.getValue() will return a LazyReplicatedMap.MapEntry object containing all the information about the object.
`boolean` | `equals(java.lang.Object o)`
`Member[]` | `excludeFromSet(Member[] mbrs, Member[] set)`
`void` | `finalize()`
`java.lang.Object` | `get(java.lang.Object key)`
`long` | `getAccessTimeout()`
`Channel` | `getChannel()`
`int` | `getChannelSendOptions()`
`java.lang.ClassLoader[]` | `getExternalLoaders()`
`AbstractReplicatedMap.MapEntry` | `getInternal(java.lang.Object key)`
`byte[]` | `getMapContextName()`
`Member[]` | `getMapMembers()`
`Member[]` | `getMapMembers(java.util.HashMap members)`
`Member[]` | `getMapMembersExcl(Member[] exclude)`
`AbstractReplicatedMap.MapOwner` | `getMapOwner()`
`int` | `getNextBackupIndex()`
`Member` | `getNextBackupNode()`
`RpcChannel` | `getRpcChannel()`
`long` | `getRpcTimeout()`
`protected abstract int` | `getStateMessageType()`
`java.lang.Object` | `getStateMutex()`
`int` | `hashCode()`
`void` | `heartbeat()` Heartbeat invokation for resources cleanup etc
`protected void` | `init(AbstractReplicatedMap.MapOwner owner, Channel channel, java.lang.String mapContextName, long timeout, int channelSendOptions, java.lang.ClassLoader[] cls)` Initializes the map by creating the RPC channel, registering itself as a channel listener This method is also responsible for initiating the state transfer
`boolean` | `inSet(Member m, Member[] set)`
`boolean` | `isEmpty()`
`boolean` | `isStateTransferred()`
`java.util.Set` | `keySet()`
`java.util.Set` | `keySetFull()`
`void` | `leftOver(java.io.Serializable msg, Member sender)` If the reply has already been sent to the requesting thread, the rpc callback can handle any data that comes in after the fact.
`void` | `mapMemberAdded(Member member)`
`void` | `memberAdded(Member member)` A member was added to the group
`protected void` | `memberAlive(Member member)` We have received a member alive notification
`void` | `memberDisappeared(Member member)` A member was removed from the group If the member left voluntarily, the Member.getCommand will contain the Member.SHUTDOWN_PAYLOAD data
`void` | `messageReceived(java.io.Serializable msg, Member sender)` Receive a message from the channel
`protected void` | `ping(long timeout)` Sends a ping out to all the members in the cluster, not just map members that this map is alive.
`protected void` | `printMap(java.lang.String header)`
`protected abstract Member[]` | `publishEntryInfo(java.lang.Object key, java.lang.Object value)`
`java.lang.Object` | `put(java.lang.Object key, java.lang.Object value)`
`java.lang.Object` | `put(java.lang.Object key, java.lang.Object value, boolean notify)`
`void` | `putAll(java.util.Map m)` Copies all values from one map to this instance
`java.lang.Object` | `remove(java.lang.Object key)` Removes an object from this map, it will also remove it from
`java.lang.Object` | `remove(java.lang.Object key, boolean notify)`
`protected boolean` | `removeEldestEntry(java.util.Map.Entry eldest)`
`void` | `replicate(boolean complete)` This can be invoked by a periodic thread to replicate out any changes.
`void` | `replicate(java.lang.Object key, boolean complete)` Replicates any changes to the object since the last time The object has to be primary, ie, if the object is a proxy or a backup, it will not be replicated
`java.io.Serializable` | `replyRequest(java.io.Serializable msg, Member sender)`
`void` | `setAccessTimeout(long accessTimeout)`
`void` | `setChannelSendOptions(int channelSendOptions)`
`void` | `setExternalLoaders(java.lang.ClassLoader[] externalLoaders)`
`void` | `setMapOwner(AbstractReplicatedMap.MapOwner mapOwner)`
`int` | `size()`
`int` | `sizeFull()`
`void` | `transferState()`
`java.util.Collection` | `values()`
`protected Member[]` | `wrap(Member m)` Helper methods, wraps a single member in an array

Methods inherited from class java.util.concurrent.ConcurrentHashMap
`contains, elements, keys, putIfAbsent, remove, replace, replace`

Methods inherited from class java.util.AbstractMap
`toString`

Methods inherited from class java.lang.Object
`getClass, notify, notifyAll, wait, wait, wait`

Field Detail

### log

    protected static Log log

### DEFAULT_INITIAL_CAPACITY

    public static final int DEFAULT_INITIAL_CAPACITY

  The default initial capacity - MUST be a power of two.

  See Also:
    Constant Field Values

### DEFAULT_LOAD_FACTOR

    public static final float DEFAULT_LOAD_FACTOR

  The load factor used when none specified in constructor.

  See Also:
    Constant Field Values

### rpcTimeout

    protected transient long rpcTimeout

  Timeout for RPC messages, how long we will wait for a reply

### channel

    protected transient Channel channel

  Reference to the channel for sending messages

### rpcChannel

    protected transient RpcChannel rpcChannel

  The RpcChannel to send RPC messages through

### mapContextName

    protected transient byte[] mapContextName

  The Map context name makes this map unique, this allows us to have more than one map shared through one channel

### stateTransferred

    protected transient boolean stateTransferred

  Has the state been transferred

### stateMutex

    protected transient java.lang.Object stateMutex

  Simple lock object for transfers

### mapMembers

    protected transient java.util.HashMap mapMembers

  A list of members in our map

### channelSendOptions

    protected transient int channelSendOptions

  Our default send options

### mapOwner

    protected transient AbstractReplicatedMap.MapOwner mapOwner

  The owner of this map, ala a SessionManager for example

### externalLoaders

    protected transient java.lang.ClassLoader[] externalLoaders

  External class loaders if serialization and deserialization is to be performed successfully.

### currentNode

    protected transient int currentNode

  The node we are currently backing up data to, this index will rotate on a round robin basis

### accessTimeout

    protected transient long accessTimeout

  Since the map keeps internal membership this is the timeout for a ping message to be responded to If a remote map doesn't respond within this timeframe, its considered dead.

### mapname

    protected transient java.lang.String mapname

  Readable string of the mapContextName value

Constructor Detail

### AbstractReplicatedMap

    public AbstractReplicatedMap(AbstractReplicatedMap.MapOwner owner,
                                 Channel channel,
                                 long timeout,
                                 java.lang.String mapContextName,
                                 int initialCapacity,
                                 float loadFactor,
                                 int channelSendOptions,
                                 java.lang.ClassLoader[] cls)

  Creates a new map

  Parameters:
    `channel` - The channel to use for communication
    `timeout` - long - timeout for RPC messags
    `mapContextName` - String - unique name for this map, to allow multiple maps per channel
    `initialCapacity` - int - the size of this map, see HashMap
    `loadFactor` - float - load factor, see HashMap
    `cls` - - a list of classloaders to be used for deserialization of objects.

Method Detail

### getStateMessageType

    protected abstract int getStateMessageType()

### wrap

    protected Member[] wrap(Member m)

  Helper methods, wraps a single member in an array

  Parameters:
    `m` - Member
  Returns:
    Member[]

### init

    protected void init(AbstractReplicatedMap.MapOwner owner,
                        Channel channel,
                        java.lang.String mapContextName,
                        long timeout,
                        int channelSendOptions,
                        java.lang.ClassLoader[] cls)

  Initializes the map by creating the RPC channel, registering itself as a channel listener This method is also responsible for initiating the state transfer

  Parameters:
    `owner` - Object
    `channel` - Channel
    `mapContextName` - String
    `timeout` - long
    `channelSendOptions` - int
    `cls` - ClassLoader[]

### ping

    protected void ping(long timeout)
                 throws ChannelException

  Sends a ping out to all the members in the cluster, not just map members that this map is alive.

  Parameters:
    `timeout` - long
  Throws:
    `ChannelException`

### memberAlive

    protected void memberAlive(Member member)

  We have received a member alive notification

  Parameters:
    `member` - Member

### broadcast

    protected void broadcast(int msgtype,
                             boolean rpc)
                      throws ChannelException

  Helper method to broadcast a message to all members in a channel

  Parameters:
    `msgtype` - int
    `rpc` - boolean
  Throws:
    `ChannelException`

### breakdown

    public void breakdown()

### finalize

    public void finalize()

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

### hashCode

    public int hashCode()

  Specified by:
    `hashCode` in interface `java.util.Map`
  Specified by:
    `hashCode` in interface `ChannelListener`
  Overrides:
    `hashCode` in class `java.util.AbstractMap`
  Returns:
    int
  See Also:
    `Object#hashCode(int)`

### equals

    public boolean equals(java.lang.Object o)

  Specified by:
    `equals` in interface `java.util.Map`
  Specified by:
    `equals` in interface `ChannelListener`
  Overrides:
    `equals` in class `java.util.AbstractMap`
  Parameters:
    `o` - Object
  Returns:
    boolean
  See Also:
    `Object.equals(Object)`

### getMapMembers

    public Member[] getMapMembers(java.util.HashMap members)

### getMapMembers

    public Member[] getMapMembers()

### getMapMembersExcl

    public Member[] getMapMembersExcl(Member[] exclude)

### replicate

    public void replicate(java.lang.Object key,
                          boolean complete)

  Replicates any changes to the object since the last time The object has to be primary, ie, if the object is a proxy or a backup, it will not be replicated

  Parameters:
    `complete` - - if set to true, the object is replicated to its backup if set to false, only objects that implement ReplicatedMapEntry and the isDirty() returns true will be replicated

### replicate

    public void replicate(boolean complete)

  This can be invoked by a periodic thread to replicate out any changes. For maps that don't store objects that implement ReplicatedMapEntry, this method should be used infrequently to avoid large amounts of data transfer

  Parameters:
    `complete` - boolean

### transferState

    public void transferState()

### replyRequest

    public java.io.Serializable replyRequest(java.io.Serializable msg,
                                             Member sender)

  Specified by:
    `replyRequest` in interface `RpcCallback`
  Parameters:
    `msg` - Serializable
  Returns:
    Serializable - null if no reply should be sent

### leftOver

    public void leftOver(java.io.Serializable msg,
                         Member sender)

  If the reply has already been sent to the requesting thread, the rpc callback can handle any data that comes in after the fact.

  Specified by:
    `leftOver` in interface `RpcCallback`
  Parameters:
    `msg` - Serializable
    `sender` - Member

### messageReceived

    public void messageReceived(java.io.Serializable msg,
                                Member sender)

  Description copied from interface: `ChannelListener`
  Receive a message from the channel

  Specified by:
    `messageReceived` in interface `ChannelListener`
  Parameters:
    `msg` - Serializable
    `sender` - - the source of the message

### accept

    public boolean accept(java.io.Serializable msg,
                          Member sender)

  Description copied from interface: `ChannelListener`
  Invoked by the channel to determine if the listener will process this message or not.

  Specified by:
    `accept` in interface `ChannelListener`
  Parameters:
    `msg` - Serializable
    `sender` - Member
  Returns:
    boolean

### mapMemberAdded

    public void mapMemberAdded(Member member)

### inSet

    public boolean inSet(Member m,
                         Member[] set)

### excludeFromSet

    public Member[] excludeFromSet(Member[] mbrs,
                                   Member[] set)

### memberAdded

    public void memberAdded(Member member)

  Description copied from interface: `MembershipListener`
  A member was added to the group

  Specified by:
    `memberAdded` in interface `MembershipListener`
  Parameters:
    `member` - Member - the member that was added

### memberDisappeared

    public void memberDisappeared(Member member)

  Description copied from interface: `MembershipListener`
  A member was removed from the group
  If the member left voluntarily, the Member.getCommand will contain the Member.SHUTDOWN_PAYLOAD data

  Specified by:
    `memberDisappeared` in interface `MembershipListener`
  Parameters:
    `member` - Member
  See Also:
    `Member.SHUTDOWN_PAYLOAD`

### getNextBackupIndex

    public int getNextBackupIndex()

### getNextBackupNode

    public Member getNextBackupNode()

### publishEntryInfo

    protected abstract Member[] publishEntryInfo(java.lang.Object key,
                                                 java.lang.Object value)
                                          throws ChannelException

  Throws:
    `ChannelException`

### heartbeat

    public void heartbeat()

  Description copied from interface: `Heartbeat`
  Heartbeat invokation for resources cleanup etc

  Specified by:
    `heartbeat` in interface `Heartbeat`

### remove

    public java.lang.Object remove(java.lang.Object key)

  Removes an object from this map, it will also remove it from

  Specified by:
    `remove` in interface `java.util.Map`
  Overrides:
    `remove` in class `java.util.concurrent.ConcurrentHashMap`
  Parameters:
    `key` - Object
  Returns:
    Object

### remove

    public java.lang.Object remove(java.lang.Object key,
                                   boolean notify)

### getInternal

    public AbstractReplicatedMap.MapEntry getInternal(java.lang.Object key)

### get

    public java.lang.Object get(java.lang.Object key)

  Specified by:
    `get` in interface `java.util.Map`
  Overrides:
    `get` in class `java.util.concurrent.ConcurrentHashMap`

### printMap

    protected void printMap(java.lang.String header)

### containsKey

    public boolean containsKey(java.lang.Object key)

  Returns true if the key has an entry in the map. The entry can be a proxy or a backup entry, invoking `get(key)` will make this entry primary for the group

  Specified by:
    `containsKey` in interface `java.util.Map`
  Overrides:
    `containsKey` in class `java.util.concurrent.ConcurrentHashMap`
  Parameters:
    `key` - Object
  Returns:
    boolean

### put

    public java.lang.Object put(java.lang.Object key,
                                java.lang.Object value)

  Specified by:
    `put` in interface `java.util.Map`
  Overrides:
    `put` in class `java.util.concurrent.ConcurrentHashMap`

### put

    public java.lang.Object put(java.lang.Object key,
                                java.lang.Object value,
                                boolean notify)

### putAll

    public void putAll(java.util.Map m)

  Copies all values from one map to this instance

  Specified by:
    `putAll` in interface `java.util.Map`
  Overrides:
    `putAll` in class `java.util.concurrent.ConcurrentHashMap`
  Parameters:
    `m` - Map

### clear

    public void clear()

  Specified by:
    `clear` in interface `java.util.Map`
  Overrides:
    `clear` in class `java.util.concurrent.ConcurrentHashMap`

### clear

    public void clear(boolean notify)

### containsValue

    public boolean containsValue(java.lang.Object value)

  Specified by:
    `containsValue` in interface `java.util.Map`
  Overrides:
    `containsValue` in class `java.util.concurrent.ConcurrentHashMap`

### clone

    public java.lang.Object clone()

  Overrides:
    `clone` in class `java.util.AbstractMap`

### entrySetFull

    public java.util.Set entrySetFull()

  Returns the entire contents of the map Map.Entry.getValue() will return a LazyReplicatedMap.MapEntry object containing all the information about the object.

  Returns:
    Set

### keySetFull

    public java.util.Set keySetFull()

### sizeFull

    public int sizeFull()

### entrySet

    public java.util.Set entrySet()

  Specified by:
    `entrySet` in interface `java.util.Map`
  Overrides:
    `entrySet` in class `java.util.concurrent.ConcurrentHashMap`

### keySet

    public java.util.Set keySet()

  Specified by:
    `keySet` in interface `java.util.Map`
  Overrides:
    `keySet` in class `java.util.concurrent.ConcurrentHashMap`

### size

    public int size()

  Specified by:
    `size` in interface `java.util.Map`
  Overrides:
    `size` in class `java.util.concurrent.ConcurrentHashMap`

### removeEldestEntry

    protected boolean removeEldestEntry(java.util.Map.Entry eldest)

### isEmpty

    public boolean isEmpty()

  Specified by:
    `isEmpty` in interface `java.util.Map`
  Overrides:
    `isEmpty` in class `java.util.concurrent.ConcurrentHashMap`

### values

    public java.util.Collection values()

  Specified by:
    `values` in interface `java.util.Map`
  Overrides:
    `values` in class `java.util.concurrent.ConcurrentHashMap`

### getChannel

    public Channel getChannel()

### getMapContextName

    public byte[] getMapContextName()

### getRpcChannel

    public RpcChannel getRpcChannel()

### getRpcTimeout

    public long getRpcTimeout()

### getStateMutex

    public java.lang.Object getStateMutex()

### isStateTransferred

    public boolean isStateTransferred()

### getMapOwner

    public AbstractReplicatedMap.MapOwner getMapOwner()

### getExternalLoaders

    public java.lang.ClassLoader[] getExternalLoaders()

### getChannelSendOptions

    public int getChannelSendOptions()

### getAccessTimeout

    public long getAccessTimeout()

### setMapOwner

    public void setMapOwner(AbstractReplicatedMap.MapOwner mapOwner)

### setExternalLoaders

    public void setExternalLoaders(java.lang.ClassLoader[] externalLoaders)

### setChannelSendOptions

    public void setChannelSendOptions(int channelSendOptions)

### setAccessTimeout

    public void setAccessTimeout(long accessTimeout)

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

Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.