| org.apache.catalina.tribes.tipis.AbstractReplicatedMap org.apache.catalina.tribes.tipis.LazyReplicatedMap
LazyReplicatedMap | public class LazyReplicatedMap extends AbstractReplicatedMap implements RpcCallback,ChannelListener,MembershipListener(Code) | | A smart implementation of a stateful replicated map. uses primary/secondary backup strategy.
One node is always the primary and one node is always the backup.
This map is synchronized across a cluster, and only has one backup member.
A perfect usage for this map would be a session map for a session manager in a clustered environment.
The only way to modify this list is to use the put, putAll, remove methods.
entrySet, entrySetFull, keySet, keySetFull, returns all non modifiable sets.
If objects (values) in the map change without invoking put() or remove()
the data can be distributed using two different methods:
replicate(boolean) and replicate(Object, boolean)
These two methods are very important two understand. The map can work with two set of value objects:
1. Serializable - the entire object gets serialized each time it is replicated
2. ReplicatedMapEntry - this interface allows for a isDirty() flag and to replicate diffs if desired.
Implementing the ReplicatedMapEntry interface allows you to decide what objects
get replicated and how much data gets replicated each time.
If you implement a smart AOP mechanism to detect changes in underlying objects, you can replicate
only those changes by implementing the ReplicatedMapEntry interface, and return true when isDiffable()
is invoked.
This map implementation doesn't have a background thread running to replicate changes.
If you do have changes without invoking put/remove then you need to invoke one of the following methods:
replicate(Object,boolean) - replicates only the object that belongs to the key
replicate(boolean) - Scans the entire map for changes and replicates data
the boolean value in the replicate method used to decide
whether to only replicate objects that implement the ReplicatedMapEntry interface
or to replicate all objects. If an object doesn't implement the ReplicatedMapEntry interface
each time the object gets replicated the entire object gets serialized, hence a call to replicate(true)
will replicate all objects in this map that are using this node as primary.
REMBER TO CALL breakdown() or finalize() when you are done with the map to
avoid memory leaks.
author: Filip Hanik version: 1.0 |
Constructor Summary | |
public | LazyReplicatedMap(Object owner, Channel channel, long timeout, String mapContextName, int initialCapacity, float loadFactor, ClassLoader[] cls) | public | LazyReplicatedMap(Object owner, Channel channel, long timeout, String mapContextName, int initialCapacity, ClassLoader[] cls) | public | LazyReplicatedMap(Object owner, Channel channel, long timeout, String mapContextName, ClassLoader[] cls) |
LazyReplicatedMap | public LazyReplicatedMap(Object owner, Channel channel, long timeout, String mapContextName, int initialCapacity, float loadFactor, ClassLoader[] cls)(Code) | | Creates a new map
Parameters: channel - The channel to use for communication Parameters: timeout - long - timeout for RPC messags Parameters: mapContextName - String - unique name for this map, to allow multiple maps per channel Parameters: initialCapacity - int - the size of this map, see HashMap Parameters: loadFactor - float - load factor, see HashMap |
LazyReplicatedMap | public LazyReplicatedMap(Object owner, Channel channel, long timeout, String mapContextName, int initialCapacity, ClassLoader[] cls)(Code) | | Creates a new map
Parameters: channel - The channel to use for communication Parameters: timeout - long - timeout for RPC messags Parameters: mapContextName - String - unique name for this map, to allow multiple maps per channel Parameters: initialCapacity - int - the size of this map, see HashMap |
LazyReplicatedMap | public LazyReplicatedMap(Object owner, Channel channel, long timeout, String mapContextName, ClassLoader[] cls)(Code) | | Creates a new map
Parameters: channel - The channel to use for communication Parameters: timeout - long - timeout for RPC messags Parameters: mapContextName - String - unique name for this map, to allow multiple maps per channel |
getStateMessageType | protected int getStateMessageType()(Code) | | |
publishEntryInfo | protected Member[] publishEntryInfo(Object key, Object value) throws ChannelException(Code) | | publish info about a map pair (key/value) to other nodes in the cluster
Parameters: key - Object Parameters: value - Object Member - the backup node throws: ChannelException - |
Methods inherited from org.apache.catalina.tribes.tipis.AbstractReplicatedMap | public boolean accept(Serializable msg, Member sender)(Code)(Java Doc) public void breakdown()(Code)(Java Doc) protected void broadcast(int msgtype, boolean rpc) throws ChannelException(Code)(Java Doc) public void clear()(Code)(Java Doc) public void clear(boolean notify)(Code)(Java Doc) public Object clone()(Code)(Java Doc) public boolean containsKey(Object key)(Code)(Java Doc) public boolean containsValue(Object value)(Code)(Java Doc) public Set entrySet()(Code)(Java Doc) public Set entrySetFull()(Code)(Java Doc) public boolean equals(Object o)(Code)(Java Doc) public Member[] excludeFromSet(Member[] mbrs, Member[] set)(Code)(Java Doc) public void finalize()(Code)(Java Doc) public Object get(Object key)(Code)(Java Doc) public long getAccessTimeout()(Code)(Java Doc) public Channel getChannel()(Code)(Java Doc) public int getChannelSendOptions()(Code)(Java Doc) public ClassLoader[] getExternalLoaders()(Code)(Java Doc) public MapEntry getInternal(Object key)(Code)(Java Doc) public byte[] getMapContextName()(Code)(Java Doc) public Member[] getMapMembers(HashMap members)(Code)(Java Doc) public Member[] getMapMembers()(Code)(Java Doc) public Member[] getMapMembersExcl(Member[] exclude)(Code)(Java Doc) public Object getMapOwner()(Code)(Java Doc) public int getNextBackupIndex()(Code)(Java Doc) public Member getNextBackupNode()(Code)(Java Doc) public RpcChannel getRpcChannel()(Code)(Java Doc) public long getRpcTimeout()(Code)(Java Doc) abstract protected int getStateMessageType()(Code)(Java Doc) public Object getStateMutex()(Code)(Java Doc) public int hashCode()(Code)(Java Doc) public void heartbeat()(Code)(Java Doc) public boolean inSet(Member m, Member[] set)(Code)(Java Doc) protected void init(Object owner, Channel channel, String mapContextName, long timeout, int channelSendOptions, ClassLoader[] cls)(Code)(Java Doc) public boolean isEmpty()(Code)(Java Doc) public boolean isStateTransferred()(Code)(Java Doc) public Set keySet()(Code)(Java Doc) public Set keySetFull()(Code)(Java Doc) public void leftOver(Serializable msg, Member sender)(Code)(Java Doc) public void mapMemberAdded(Member member)(Code)(Java Doc) public void memberAdded(Member member)(Code)(Java Doc) protected void memberAlive(Member member)(Code)(Java Doc) public void memberDisappeared(Member member)(Code)(Java Doc) public void messageReceived(Serializable msg, Member sender)(Code)(Java Doc) protected void ping(long timeout) throws ChannelException(Code)(Java Doc) protected void printMap(String header)(Code)(Java Doc) abstract protected Member[] publishEntryInfo(Object key, Object value) throws ChannelException(Code)(Java Doc) public Object put(Object key, Object value)(Code)(Java Doc) public Object put(Object key, Object value, boolean notify)(Code)(Java Doc) public void putAll(Map m)(Code)(Java Doc) public Object remove(Object key)(Code)(Java Doc) public Object remove(Object key, boolean notify)(Code)(Java Doc) protected boolean removeEldestEntry(Map.Entry eldest)(Code)(Java Doc) public void replicate(Object key, boolean complete)(Code)(Java Doc) public void replicate(boolean complete)(Code)(Java Doc) public Serializable replyRequest(Serializable msg, Member sender)(Code)(Java Doc) public void setAccessTimeout(long accessTimeout)(Code)(Java Doc) public void setChannelSendOptions(int channelSendOptions)(Code)(Java Doc) public void setExternalLoaders(ClassLoader[] externalLoaders)(Code)(Java Doc) public void setMapOwner(Object mapOwner)(Code)(Java Doc) public int size()(Code)(Java Doc) public int sizeFull()(Code)(Java Doc) public void transferState()(Code)(Java Doc) public Collection values()(Code)(Java Doc) protected Member[] wrap(Member m)(Code)(Java Doc)
|
|
|