Reference Guide

Table Of Contents
}
Distributed Map
A Distributed Map is a class of a decentralized distributed system that provides a lookup service
similar to a hash table; (key, value) pairs are stored in a Distributed Map, and any participating
node can efficiently retrieve the value associated with a given key. Responsibility for maintaining
the mapping from keys to values is distributed among the nodes, in such a way that a change in
the set of participants causes a minimal amount of disruption. This allows a Distributed Map to
scale to extremely large numbers of nodes and to handle continual node arrivals, departures, and
failures.
The distributed map is an extension to the Java Map interface and due to this, the applications
can perform any operation that can be performed on a regular Java map. The data structure
internally distributes data across nodes in the cluster. The data is almost evenly distributed among
the members and backups can be configured so the data is also replicated. Backups can be
configured as synchronous or asynchronous; for synchronous backups when a map.put(key, value)
returns, it is guaranteed that the entry is replicated to one other node. Each distribute map is
distinguished by the namespace and it is set upon creation of the distributed map.
The Distributed Coordination Service provides a mechanism where applications running on
multiple controllers to register for notifications for specific distributed maps. Notifications of a
distributed map are received when entries in the distributed map are added, updated or removed.
Notifications are received per entry.
Distributed Map Example:
SampleDistributedMap.java
package com.hp.dcord_test.impl;
import java.util.Map.Entry;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.ReferencePolicy;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.hp.sdn.teaming.TeamingService;
import com.hp.util.dcord.CoordinationService;
import com.hp.util.dcord.DistributedMap;
import com.hp.util.dcord.Namespace;
@Component
public class SampleDistributedMap {
private CoordinationService coordinationService;
private SimpleEntryListener listener;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY,
policy = ReferencePolicy.DYNAMIC)
71