Class ReplicatedMap<K,​V>

  • Type Parameters:
    K - The type of Key
    V - The type of Value
    All Implemented Interfaces:
    java.io.Serializable, java.util.Map<K,​V>, ChannelListener, RpcCallback, Heartbeat, MembershipListener

    public class ReplicatedMap<K,​V>
    extends AbstractReplicatedMap<K,​V>
    All-to-all replication for a hash map implementation. Each node in the cluster will carry an identical copy of the map.

    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.

    REMEMBER TO CALL breakdown() when you are done with the map to avoid memory leaks.

    TODO implement periodic sync/transfer thread
    TODO memberDisappeared, should do nothing except change map membership by default it relocates the primary objects
    See Also:
    Serialized Form
    • Constructor Detail

      • ReplicatedMap

        public ReplicatedMap​(AbstractReplicatedMap.MapOwner owner,
                             Channel channel,
                             long timeout,
                             java.lang.String mapContextName,
                             int initialCapacity,
                             float loadFactor,
                             java.lang.ClassLoader[] cls)
        Creates a new map
        Parameters:
        owner - The map owner
        channel - The channel to use for communication
        timeout - long - timeout for RPC messages
        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 - Class loaders
      • ReplicatedMap

        public ReplicatedMap​(AbstractReplicatedMap.MapOwner owner,
                             Channel channel,
                             long timeout,
                             java.lang.String mapContextName,
                             int initialCapacity,
                             java.lang.ClassLoader[] cls)
        Creates a new map
        Parameters:
        owner - The map owner
        channel - The channel to use for communication
        timeout - long - timeout for RPC messages
        mapContextName - String - unique name for this map, to allow multiple maps per channel
        initialCapacity - int - the size of this map, see HashMap
        cls - Class loaders
      • ReplicatedMap

        public ReplicatedMap​(AbstractReplicatedMap.MapOwner owner,
                             Channel channel,
                             long timeout,
                             java.lang.String mapContextName,
                             java.lang.ClassLoader[] cls)
        Creates a new map
        Parameters:
        owner - The map owner
        channel - The channel to use for communication
        timeout - long - timeout for RPC messages
        mapContextName - String - unique name for this map, to allow multiple maps per channel
        cls - Class loaders
      • ReplicatedMap

        public ReplicatedMap​(AbstractReplicatedMap.MapOwner owner,
                             Channel channel,
                             long timeout,
                             java.lang.String mapContextName,
                             java.lang.ClassLoader[] cls,
                             boolean terminate)
        Creates a new map
        Parameters:
        owner - The map owner
        channel - The channel to use for communication
        timeout - long - timeout for RPC messages
        mapContextName - String - unique name for this map, to allow multiple maps per channel
        cls - Class loaders
        terminate - boolean - Flag for whether to terminate this map that failed to start.