org.apache.catalina.tribes.tipis
public abstract class AbstractReplicatedMap extends ConcurrentHashMap implements RpcCallback, ChannelListener, MembershipListener, Heartbeat
Version: 1.0
| Nested Class Summary | |
|---|---|
| static class | AbstractReplicatedMap.MapEntry |
| static class | AbstractReplicatedMap.MapMessage |
| static interface | AbstractReplicatedMap.MapOwner |
| 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 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 HashMap | mapMembers
A list of members in our map |
| protected 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 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, String mapContextName, int initialCapacity, float loadFactor, int channelSendOptions, ClassLoader[] cls)
Creates a new map | |
| Method Summary | |
|---|---|
| boolean | accept(Serializable msg, Member sender) |
| 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) |
| Object | clone() |
| boolean | containsKey(Object key)
Returns true if the key has an entry in the map.
|
| boolean | containsValue(Object value) |
| Set | entrySet() |
| 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(Object o) |
| Member[] | excludeFromSet(Member[] mbrs, Member[] set) |
| void | finalize() |
| Object | get(Object key) |
| long | getAccessTimeout() |
| Channel | getChannel() |
| int | getChannelSendOptions() |
| ClassLoader[] | getExternalLoaders() |
| AbstractReplicatedMap.MapEntry | getInternal(Object key) |
| byte[] | getMapContextName() |
| Member[] | getMapMembers(HashMap members) |
| Member[] | getMapMembers() |
| Member[] | getMapMembersExcl(Member[] exclude) |
| AbstractReplicatedMap.MapOwner | getMapOwner() |
| int | getNextBackupIndex() |
| Member | getNextBackupNode() |
| RpcChannel | getRpcChannel() |
| long | getRpcTimeout() |
| protected abstract int | getStateMessageType() |
| Object | getStateMutex() |
| int | hashCode() |
| void | heartbeat() |
| protected void | init(AbstractReplicatedMap.MapOwner owner, Channel channel, String mapContextName, long timeout, int channelSendOptions, 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() |
| Set | keySet() |
| Set | keySetFull() |
| void | leftOver(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) |
| protected void | memberAlive(Member member)
We have received a member alive notification |
| void | memberDisappeared(Member member) |
| void | messageReceived(Serializable msg, Member sender) |
| 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(String header) |
| protected abstract Member[] | publishEntryInfo(Object key, Object value) |
| Object | put(Object key, Object value) |
| Object | put(Object key, Object value, boolean notify) |
| void | putAll(Map m)
Copies all values from one map to this instance |
| Object | remove(Object key)
Removes an object from this map, it will also remove it from
|
| Object | remove(Object key, boolean notify) |
| protected boolean | removeEldestEntry(Entry eldest) |
| void | replicate(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 |
| void | replicate(boolean complete)
This can be invoked by a periodic thread to replicate out any changes.
|
| Serializable | replyRequest(Serializable msg, Member sender) |
| void | setAccessTimeout(long accessTimeout) |
| void | setChannelSendOptions(int channelSendOptions) |
| void | setExternalLoaders(ClassLoader[] externalLoaders) |
| void | setMapOwner(AbstractReplicatedMap.MapOwner mapOwner) |
| int | size() |
| int | sizeFull() |
| void | transferState() |
| Collection | values() |
| protected Member[] | wrap(Member m)
Helper methods, wraps a single member in an array |
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.
Parameters: msgtype int rpc boolean
Throws: ChannelException
get(key)
will make this entry primary for the groupParameters: key Object
Returns: boolean
Returns: Set
Parameters: owner Object channel Channel mapContextName String timeout long channelSendOptions int cls ClassLoader[]
Parameters: msg Serializable sender Member
Parameters: member Member
Parameters: timeout long
Throws: ChannelException
Parameters: m Map
Parameters: key Object
Returns: Object
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
Parameters: complete boolean
Parameters: msg Serializable
Returns: Serializable - null if no reply should be sent
UNKNOWN: implement state transfer
Parameters: m Member
Returns: Member[]