blob: 1af57275d82e4fdeffe1924c3c4d0aa340675b51 [file] [log] [blame]
Yuta HIGUCHI80912e62014-10-12 00:15:47 -07001package org.onlab.onos.store.mastership.impl;
tomb41d1ac2014-09-24 01:51:24 -07002
Yuta HIGUCHI80912e62014-10-12 00:15:47 -07003import static org.onlab.onos.mastership.MastershipEvent.Type.MASTER_CHANGED;
alshabib339a3d92014-09-26 17:54:32 -07004
5import java.util.Map;
alshabib339a3d92014-09-26 17:54:32 -07006import java.util.Set;
Yuta HIGUCHIc8e19d42014-09-24 17:20:52 -07007
tomb41d1ac2014-09-24 01:51:24 -07008import org.apache.felix.scr.annotations.Activate;
9import org.apache.felix.scr.annotations.Component;
10import org.apache.felix.scr.annotations.Deactivate;
11import org.apache.felix.scr.annotations.Reference;
12import org.apache.felix.scr.annotations.ReferenceCardinality;
13import org.apache.felix.scr.annotations.Service;
14import org.onlab.onos.cluster.ClusterService;
tomb41d1ac2014-09-24 01:51:24 -070015import org.onlab.onos.cluster.NodeId;
Ayaka Koshibeabedb092014-10-20 17:01:31 -070016import org.onlab.onos.cluster.RoleInfo;
Yuta HIGUCHI80912e62014-10-12 00:15:47 -070017import org.onlab.onos.mastership.MastershipEvent;
18import org.onlab.onos.mastership.MastershipStore;
19import org.onlab.onos.mastership.MastershipStoreDelegate;
20import org.onlab.onos.mastership.MastershipTerm;
tomb41d1ac2014-09-24 01:51:24 -070021import org.onlab.onos.net.DeviceId;
22import org.onlab.onos.net.MastershipRole;
Yuta HIGUCHIb5df76d2014-09-27 20:54:00 -070023import org.onlab.onos.store.common.AbstractHazelcastStore;
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -070024import org.onlab.onos.store.common.SMap;
Yuta HIGUCHI8d143d22014-10-19 23:15:09 -070025import org.onlab.onos.store.serializers.KryoNamespaces;
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -070026import org.onlab.onos.store.serializers.KryoSerializer;
Yuta HIGUCHI8d143d22014-10-19 23:15:09 -070027import org.onlab.util.KryoNamespace;
tomb41d1ac2014-09-24 01:51:24 -070028
alshabib339a3d92014-09-26 17:54:32 -070029import com.google.common.collect.ImmutableSet;
Ayaka Koshibeb5c63a02014-10-18 18:42:27 -070030import com.hazelcast.core.EntryEvent;
31import com.hazelcast.core.EntryListener;
Ayaka Koshibee8e45352014-10-16 00:37:19 -070032import com.hazelcast.core.IAtomicLong;
Ayaka Koshibeb5c63a02014-10-18 18:42:27 -070033import com.hazelcast.core.MapEvent;
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -070034import static org.onlab.onos.net.MastershipRole.*;
35
tomb41d1ac2014-09-24 01:51:24 -070036/**
Ayaka Koshibec4047702014-10-07 14:43:52 -070037 * Distributed implementation of the mastership store. The store is
38 * responsible for the master selection process.
tomb41d1ac2014-09-24 01:51:24 -070039 */
40@Component(immediate = true)
41@Service
tom0755a362014-09-24 11:54:43 -070042public class DistributedMastershipStore
Yuta HIGUCHI2e963892014-09-27 13:00:39 -070043extends AbstractHazelcastStore<MastershipEvent, MastershipStoreDelegate>
alshabib339a3d92014-09-26 17:54:32 -070044implements MastershipStore {
tomb41d1ac2014-09-24 01:51:24 -070045
Ayaka Koshibec4047702014-10-07 14:43:52 -070046 //initial term/TTL value
Ayaka Koshibe8583ff32014-10-02 16:25:30 -070047 private static final Integer INIT = 0;
Ayaka Koshibe8583ff32014-10-02 16:25:30 -070048
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -070049 //device to node roles
50 protected SMap<DeviceId, RoleValue> roleMap;
Ayaka Koshibe8583ff32014-10-02 16:25:30 -070051 //devices to terms
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -070052 protected SMap<DeviceId, Integer> terms;
Ayaka Koshibee8e45352014-10-16 00:37:19 -070053 //last-known cluster size, used for tie-breaking when partitioning occurs
54 protected IAtomicLong clusterSize;
55
Ayaka Koshibe8583ff32014-10-02 16:25:30 -070056
tomb41d1ac2014-09-24 01:51:24 -070057 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
58 protected ClusterService clusterService;
59
Ayaka Koshibe406d0102014-09-24 16:08:12 -070060 @Override
tomb41d1ac2014-09-24 01:51:24 -070061 @Activate
62 public void activate() {
63 super.activate();
64
Ayaka Koshibee8e45352014-10-16 00:37:19 -070065 this.serializer = new KryoSerializer() {
66 @Override
67 protected void setupKryoPool() {
Yuta HIGUCHI8d143d22014-10-19 23:15:09 -070068 serializerPool = KryoNamespace.newBuilder()
69 .register(KryoNamespaces.API)
Ayaka Koshibee8e45352014-10-16 00:37:19 -070070
71 .register(RoleValue.class, new RoleValueSerializer())
72 .build()
73 .populate(1);
74 }
75 };
76
Yuta HIGUCHI9def0472014-10-23 15:51:10 -070077 roleMap = new SMap<>(theInstance.<byte[], byte[]>getMap("nodeRoles"), this.serializer);
Ayaka Koshibe67af1f42014-10-20 15:26:37 -070078 roleMap.addEntryListener((new RemoteMasterShipEventHandler()), true);
Yuta HIGUCHI9def0472014-10-23 15:51:10 -070079 terms = new SMap<>(theInstance.<byte[], byte[]>getMap("terms"), this.serializer);
Ayaka Koshibee8e45352014-10-16 00:37:19 -070080 clusterSize = theInstance.getAtomicLong("clustersize");
Yuta HIGUCHIc8e19d42014-09-24 17:20:52 -070081
tomb41d1ac2014-09-24 01:51:24 -070082 log.info("Started");
83 }
84
85 @Deactivate
86 public void deactivate() {
87 log.info("Stopped");
88 }
89
90 @Override
Ayaka Koshibec4047702014-10-07 14:43:52 -070091 public MastershipRole getRole(NodeId nodeId, DeviceId deviceId) {
Ayaka Koshibea7384a82014-10-22 18:59:06 -070092 final RoleValue roleInfo = getRoleValue(deviceId);
93 if (roleInfo.contains(MASTER, nodeId)) {
94 return MASTER;
Ayaka Koshibec4047702014-10-07 14:43:52 -070095 }
Ayaka Koshibea7384a82014-10-22 18:59:06 -070096 if (roleInfo.contains(STANDBY, nodeId)) {
97 return STANDBY;
98 }
99 return NONE;
Ayaka Koshibec4047702014-10-07 14:43:52 -0700100 }
101
102 @Override
Ayaka Koshibe406d0102014-09-24 16:08:12 -0700103 public MastershipEvent setMaster(NodeId nodeId, DeviceId deviceId) {
tomb41d1ac2014-09-24 01:51:24 -0700104
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -0700105 MastershipRole role = getRole(nodeId, deviceId);
106 roleMap.lock(deviceId);
Ayaka Koshibe8583ff32014-10-02 16:25:30 -0700107 try {
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -0700108 RoleValue rv = getRoleValue(deviceId);
Ayaka Koshibe8583ff32014-10-02 16:25:30 -0700109 switch (role) {
110 case MASTER:
Ayaka Koshibec4047702014-10-07 14:43:52 -0700111 //reinforce mastership
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -0700112 rv.reassign(nodeId, STANDBY, NONE);
Ayaka Koshibee8e45352014-10-16 00:37:19 -0700113 roleMap.put(deviceId, rv);
Ayaka Koshibe8583ff32014-10-02 16:25:30 -0700114 return null;
115 case STANDBY:
Ayaka Koshibea7384a82014-10-22 18:59:06 -0700116 case NONE:
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -0700117 NodeId current = rv.get(MASTER);
Ayaka Koshibec4047702014-10-07 14:43:52 -0700118 if (current != null) {
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -0700119 //backup and replace current master
Ayaka Koshibea7384a82014-10-22 18:59:06 -0700120 rv.reassign(current, NONE, STANDBY);
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -0700121 rv.replace(current, nodeId, MASTER);
122 } else {
123 //no master before so just add.
124 rv.add(MASTER, nodeId);
Ayaka Koshibe8583ff32014-10-02 16:25:30 -0700125 }
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -0700126 rv.reassign(nodeId, STANDBY, NONE);
Ayaka Koshibee8e45352014-10-16 00:37:19 -0700127 roleMap.put(deviceId, rv);
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -0700128 updateTerm(deviceId);
Ayaka Koshibefc981cf2014-10-21 12:44:17 -0700129 return new MastershipEvent(MASTER_CHANGED, deviceId, rv.roleInfo());
Ayaka Koshibe8583ff32014-10-02 16:25:30 -0700130 default:
131 log.warn("unknown Mastership Role {}", role);
132 return null;
133 }
Ayaka Koshibe8583ff32014-10-02 16:25:30 -0700134 } finally {
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -0700135 roleMap.unlock(deviceId);
tomb41d1ac2014-09-24 01:51:24 -0700136 }
137 }
138
139 @Override
140 public NodeId getMaster(DeviceId deviceId) {
Ayaka Koshibee8e45352014-10-16 00:37:19 -0700141 return getNode(MASTER, deviceId);
tomb41d1ac2014-09-24 01:51:24 -0700142 }
143
Ayaka Koshibe45503ce2014-10-14 11:26:45 -0700144
145 @Override
Ayaka Koshibeabedb092014-10-20 17:01:31 -0700146 public RoleInfo getNodes(DeviceId deviceId) {
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -0700147 roleMap.lock(deviceId);
Ayaka Koshibe45503ce2014-10-14 11:26:45 -0700148 try {
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -0700149 RoleValue rv = getRoleValue(deviceId);
Ayaka Koshibeabedb092014-10-20 17:01:31 -0700150 return rv.roleInfo();
Ayaka Koshibe45503ce2014-10-14 11:26:45 -0700151 } finally {
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -0700152 roleMap.unlock(deviceId);
Ayaka Koshibe45503ce2014-10-14 11:26:45 -0700153 }
154 }
155
tomb41d1ac2014-09-24 01:51:24 -0700156 @Override
157 public Set<DeviceId> getDevices(NodeId nodeId) {
158 ImmutableSet.Builder<DeviceId> builder = ImmutableSet.builder();
Ayaka Koshibe8583ff32014-10-02 16:25:30 -0700159
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -0700160 for (Map.Entry<DeviceId, RoleValue> el : roleMap.entrySet()) {
161 if (nodeId.equals(el.getValue().get(MASTER))) {
162 builder.add(el.getKey());
tomb41d1ac2014-09-24 01:51:24 -0700163 }
164 }
Ayaka Koshibe8583ff32014-10-02 16:25:30 -0700165
tomb41d1ac2014-09-24 01:51:24 -0700166 return builder.build();
167 }
168
169 @Override
170 public MastershipRole requestRole(DeviceId deviceId) {
Ayaka Koshibe8583ff32014-10-02 16:25:30 -0700171 NodeId local = clusterService.getLocalNode().id();
Ayaka Koshibe8583ff32014-10-02 16:25:30 -0700172
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -0700173 roleMap.lock(deviceId);
Ayaka Koshibe8583ff32014-10-02 16:25:30 -0700174 try {
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -0700175 RoleValue rv = getRoleValue(deviceId);
Ayaka Koshibe8583ff32014-10-02 16:25:30 -0700176 MastershipRole role = getRole(local, deviceId);
177 switch (role) {
178 case MASTER:
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -0700179 rv.reassign(local, STANDBY, NONE);
Ayaka Koshibea7384a82014-10-22 18:59:06 -0700180 terms.putIfAbsent(deviceId, INIT);
Ayaka Koshibee8e45352014-10-16 00:37:19 -0700181 roleMap.put(deviceId, rv);
Ayaka Koshibe8583ff32014-10-02 16:25:30 -0700182 break;
183 case STANDBY:
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -0700184 rv.reassign(local, NONE, STANDBY);
Ayaka Koshibee8e45352014-10-16 00:37:19 -0700185 roleMap.put(deviceId, rv);
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -0700186 terms.putIfAbsent(deviceId, INIT);
Ayaka Koshibe8583ff32014-10-02 16:25:30 -0700187 break;
188 case NONE:
Ayaka Koshibea7384a82014-10-22 18:59:06 -0700189 //either we're the first standby, or first to device.
190 //for latter, claim mastership.
191 if (rv.get(MASTER) == null) {
192 rv.add(MASTER, local);
193 rv.reassign(local, STANDBY, NONE);
194 updateTerm(deviceId);
195 role = MastershipRole.MASTER;
196 } else {
197 rv.add(STANDBY, local);
198 rv.reassign(local, NONE, STANDBY);
199 role = MastershipRole.STANDBY;
200 }
Ayaka Koshibee8e45352014-10-16 00:37:19 -0700201 roleMap.put(deviceId, rv);
Ayaka Koshibe8583ff32014-10-02 16:25:30 -0700202 break;
203 default:
204 log.warn("unknown Mastership Role {}", role);
205 }
206 return role;
207 } finally {
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -0700208 roleMap.unlock(deviceId);
Ayaka Koshibe8583ff32014-10-02 16:25:30 -0700209 }
tomb41d1ac2014-09-24 01:51:24 -0700210 }
211
212 @Override
Ayaka Koshibeb70d34b2014-09-25 15:43:01 -0700213 public MastershipTerm getTermFor(DeviceId deviceId) {
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -0700214 RoleValue rv = getRoleValue(deviceId);
215 if ((rv.get(MASTER) == null) || (terms.get(deviceId) == null)) {
Ayaka Koshibe8583ff32014-10-02 16:25:30 -0700216 return null;
217 }
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -0700218 return MastershipTerm.of(rv.get(MASTER), terms.get(deviceId));
Ayaka Koshibeb70d34b2014-09-25 15:43:01 -0700219 }
220
Ayaka Koshibed9f693e2014-09-29 18:04:54 -0700221 @Override
Ayaka Koshibec4047702014-10-07 14:43:52 -0700222 public MastershipEvent setStandby(NodeId nodeId, DeviceId deviceId) {
Ayaka Koshibec4047702014-10-07 14:43:52 -0700223 MastershipEvent event = null;
Ayaka Koshibe8583ff32014-10-02 16:25:30 -0700224
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -0700225 roleMap.lock(deviceId);
Ayaka Koshibe8583ff32014-10-02 16:25:30 -0700226 try {
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -0700227 RoleValue rv = getRoleValue(deviceId);
Ayaka Koshibe8583ff32014-10-02 16:25:30 -0700228 MastershipRole role = getRole(nodeId, deviceId);
229 switch (role) {
230 case MASTER:
Ayaka Koshibee8e45352014-10-16 00:37:19 -0700231 event = reelect(nodeId, deviceId, rv);
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -0700232 //fall through to reinforce role
Ayaka Koshibe8583ff32014-10-02 16:25:30 -0700233 case STANDBY:
Ayaka Koshibec4047702014-10-07 14:43:52 -0700234 //fall through to reinforce role
Ayaka Koshibe8583ff32014-10-02 16:25:30 -0700235 case NONE:
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -0700236 rv.reassign(nodeId, NONE, STANDBY);
Ayaka Koshibee8e45352014-10-16 00:37:19 -0700237 roleMap.put(deviceId, rv);
Ayaka Koshibe8583ff32014-10-02 16:25:30 -0700238 break;
239 default:
240 log.warn("unknown Mastership Role {}", role);
241 }
Ayaka Koshibec4047702014-10-07 14:43:52 -0700242 return event;
Ayaka Koshibe8583ff32014-10-02 16:25:30 -0700243 } finally {
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -0700244 roleMap.unlock(deviceId);
Ayaka Koshibe8583ff32014-10-02 16:25:30 -0700245 }
246 }
247
Ayaka Koshibec4047702014-10-07 14:43:52 -0700248 @Override
249 public MastershipEvent relinquishRole(NodeId nodeId, DeviceId deviceId) {
Ayaka Koshibec4047702014-10-07 14:43:52 -0700250 MastershipEvent event = null;
Ayaka Koshibe25fd23a2014-10-03 15:50:43 -0700251
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -0700252 roleMap.lock(deviceId);
Ayaka Koshibec4047702014-10-07 14:43:52 -0700253 try {
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -0700254 RoleValue rv = getRoleValue(deviceId);
Ayaka Koshibec4047702014-10-07 14:43:52 -0700255 MastershipRole role = getRole(nodeId, deviceId);
256 switch (role) {
257 case MASTER:
Ayaka Koshibee8e45352014-10-16 00:37:19 -0700258 event = reelect(nodeId, deviceId, rv);
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -0700259 //fall through to reinforce relinquishment
Ayaka Koshibec4047702014-10-07 14:43:52 -0700260 case STANDBY:
261 //fall through to reinforce relinquishment
262 case NONE:
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -0700263 rv.reassign(nodeId, STANDBY, NONE);
Ayaka Koshibee8e45352014-10-16 00:37:19 -0700264 roleMap.put(deviceId, rv);
Ayaka Koshibec4047702014-10-07 14:43:52 -0700265 break;
266 default:
267 log.warn("unknown Mastership Role {}", role);
Ayaka Koshibe8583ff32014-10-02 16:25:30 -0700268 }
Ayaka Koshibec4047702014-10-07 14:43:52 -0700269 return event;
270 } finally {
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -0700271 roleMap.unlock(deviceId);
Ayaka Koshibe8583ff32014-10-02 16:25:30 -0700272 }
Ayaka Koshibed9f693e2014-09-29 18:04:54 -0700273 }
274
Ayaka Koshibec4047702014-10-07 14:43:52 -0700275 //helper to fetch a new master candidate for a given device.
Ayaka Koshibeb5c63a02014-10-18 18:42:27 -0700276 private MastershipEvent reelect(
277 NodeId current, DeviceId deviceId, RoleValue rv) {
Ayaka Koshibec4047702014-10-07 14:43:52 -0700278
279 //if this is an queue it'd be neater.
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -0700280 NodeId backup = null;
281 for (NodeId n : rv.nodesOfRole(STANDBY)) {
282 if (!current.equals(n)) {
Ayaka Koshibec4047702014-10-07 14:43:52 -0700283 backup = n;
284 break;
285 }
286 }
287
288 if (backup == null) {
Ayaka Koshibeb5c63a02014-10-18 18:42:27 -0700289 log.info("{} giving up and going to NONE for {}", current, deviceId);
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -0700290 rv.remove(MASTER, current);
Ayaka Koshibee8e45352014-10-16 00:37:19 -0700291 roleMap.put(deviceId, rv);
Ayaka Koshibec4047702014-10-07 14:43:52 -0700292 return null;
293 } else {
Ayaka Koshibeb5c63a02014-10-18 18:42:27 -0700294 log.info("{} trying to pass mastership for {} to {}", current, deviceId, backup);
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -0700295 rv.replace(current, backup, MASTER);
296 rv.reassign(backup, STANDBY, NONE);
Ayaka Koshibee8e45352014-10-16 00:37:19 -0700297 roleMap.put(deviceId, rv);
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -0700298 Integer term = terms.get(deviceId);
299 terms.put(deviceId, ++term);
Ayaka Koshibefc981cf2014-10-21 12:44:17 -0700300 return new MastershipEvent(MASTER_CHANGED, deviceId, rv.roleInfo());
Ayaka Koshibec4047702014-10-07 14:43:52 -0700301 }
302 }
303
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -0700304 //return the RoleValue structure for a device, or create one
305 private RoleValue getRoleValue(DeviceId deviceId) {
306 RoleValue value = roleMap.get(deviceId);
307 if (value == null) {
308 value = new RoleValue();
Ayaka Koshibea7384a82014-10-22 18:59:06 -0700309 RoleValue concurrentlyAdded = roleMap.putIfAbsent(deviceId, value);
310 if (concurrentlyAdded != null) {
311 return concurrentlyAdded;
312 }
Ayaka Koshibec4047702014-10-07 14:43:52 -0700313 }
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -0700314 return value;
Ayaka Koshibec4047702014-10-07 14:43:52 -0700315 }
316
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -0700317 //get first applicable node out of store-unique structure.
318 private NodeId getNode(MastershipRole role, DeviceId deviceId) {
319 RoleValue value = roleMap.get(deviceId);
320 if (value != null) {
321 return value.get(role);
Ayaka Koshibec4047702014-10-07 14:43:52 -0700322 }
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -0700323 return null;
324 }
325
Ayaka Koshibec4047702014-10-07 14:43:52 -0700326 //adds or updates term information.
Ayaka Koshibef9b02fc2014-10-15 17:07:05 -0700327 private void updateTerm(DeviceId deviceId) {
Ayaka Koshibeb5c63a02014-10-18 18:42:27 -0700328 terms.lock(deviceId);
329 try {
330 Integer term = terms.get(deviceId);
331 if (term == null) {
332 terms.put(deviceId, INIT);
333 } else {
334 terms.put(deviceId, ++term);
335 }
336 } finally {
337 terms.unlock(deviceId);
Ayaka Koshibec4047702014-10-07 14:43:52 -0700338 }
Ayaka Koshibe8583ff32014-10-02 16:25:30 -0700339 }
340
Ayaka Koshibeb5c63a02014-10-18 18:42:27 -0700341 private class RemoteMasterShipEventHandler implements EntryListener<DeviceId, RoleValue> {
alshabib339a3d92014-09-26 17:54:32 -0700342
343 @Override
Ayaka Koshibeb5c63a02014-10-18 18:42:27 -0700344 public void entryAdded(EntryEvent<DeviceId, RoleValue> event) {
alshabib339a3d92014-09-26 17:54:32 -0700345 }
346
347 @Override
Ayaka Koshibeb5c63a02014-10-18 18:42:27 -0700348 public void entryRemoved(EntryEvent<DeviceId, RoleValue> event) {
alshabib339a3d92014-09-26 17:54:32 -0700349 }
350
351 @Override
Ayaka Koshibeb5c63a02014-10-18 18:42:27 -0700352 public void entryUpdated(EntryEvent<DeviceId, RoleValue> event) {
Yuta HIGUCHI3195f552014-10-24 22:07:05 -0700353
Ayaka Koshibeb5c63a02014-10-18 18:42:27 -0700354 notifyDelegate(new MastershipEvent(
Ayaka Koshibefc981cf2014-10-21 12:44:17 -0700355 MASTER_CHANGED, event.getKey(), event.getValue().roleInfo()));
Ayaka Koshibeb5c63a02014-10-18 18:42:27 -0700356 }
357
358 @Override
359 public void entryEvicted(EntryEvent<DeviceId, RoleValue> event) {
360 }
361
362 @Override
363 public void mapEvicted(MapEvent event) {
364 }
365
366 @Override
367 public void mapCleared(MapEvent event) {
alshabib339a3d92014-09-26 17:54:32 -0700368 }
369 }
370
tomb41d1ac2014-09-24 01:51:24 -0700371}