Yuta HIGUCHI

minor Device - Mastership fixes

Change-Id: Id6d46e22fb67f01cd5c0802cf4fad135a043ec77
...@@ -269,10 +269,6 @@ implements MastershipService, MastershipAdminService { ...@@ -269,10 +269,6 @@ implements MastershipService, MastershipAdminService {
269 269
270 @Override 270 @Override
271 public void notify(MastershipEvent event) { 271 public void notify(MastershipEvent event) {
272 - if (clusterService.getLocalNode().id().equals(event.roleInfo().master())) {
273 - log.info("ignoring locally-generated event {}", event);
274 - // return;
275 - }
276 log.info("dispatching mastership event {}", event); 272 log.info("dispatching mastership event {}", event);
277 eventDispatcher.post(event); 273 eventDispatcher.post(event);
278 } 274 }
......
...@@ -432,7 +432,6 @@ public class DeviceManager ...@@ -432,7 +432,6 @@ public class DeviceManager
432 if (!isReachable(device)) { 432 if (!isReachable(device)) {
433 log.warn("Device {} has disconnected after this event", did); 433 log.warn("Device {} has disconnected after this event", did);
434 mastershipService.relinquishMastership(did); 434 mastershipService.relinquishMastership(did);
435 - applyRole(did, MastershipRole.STANDBY);
436 return; 435 return;
437 } 436 }
438 //flag the device as online. Is there a better way to do this? 437 //flag the device as online. Is there a better way to do this?
...@@ -448,6 +447,7 @@ public class DeviceManager ...@@ -448,6 +447,7 @@ public class DeviceManager
448 if (!isReachable(getDevice(did))) { 447 if (!isReachable(getDevice(did))) {
449 log.warn("Device {} has disconnected after this event", did); 448 log.warn("Device {} has disconnected after this event", did);
450 mastershipService.relinquishMastership(did); 449 mastershipService.relinquishMastership(did);
450 + return;
451 } 451 }
452 applyRole(did, MastershipRole.STANDBY); 452 applyRole(did, MastershipRole.STANDBY);
453 } 453 }
...@@ -455,19 +455,21 @@ public class DeviceManager ...@@ -455,19 +455,21 @@ public class DeviceManager
455 455
456 // checks for duplicate event, returning true if one is found. 456 // checks for duplicate event, returning true if one is found.
457 private boolean checkDuplicate(RoleInfo roleInfo, int term) { 457 private boolean checkDuplicate(RoleInfo roleInfo, int term) {
458 - synchronized (eventCache) { 458 + // turning off duplicate check
459 - if (eventCache.get(term).contains(roleInfo)) { 459 + return false;
460 - log.info("duplicate event detected; ignoring"); 460 +// synchronized (eventCache) {
461 - return true; 461 +// if (eventCache.get(term).contains(roleInfo)) {
462 - } else { 462 +// log.info("duplicate event detected; ignoring");
463 - eventCache.put(term, roleInfo); 463 +// return true;
464 - // purge by-term oldest entries to keep the cache size under limit 464 +// } else {
465 - if (eventCache.size() > cacheSize) { 465 +// eventCache.put(term, roleInfo);
466 - eventCache.removeAll(term - cacheSize); 466 +// // purge by-term oldest entries to keep the cache size under limit
467 - } 467 +// if (eventCache.size() > cacheSize) {
468 - return false; 468 +// eventCache.removeAll(term - cacheSize);
469 - } 469 +// }
470 - } 470 +// return false;
471 +// }
472 +// }
471 } 473 }
472 474
473 } 475 }
......
...@@ -358,6 +358,7 @@ implements MastershipStore { ...@@ -358,6 +358,7 @@ implements MastershipStore {
358 358
359 @Override 359 @Override
360 public void entryAdded(EntryEvent<DeviceId, RoleValue> event) { 360 public void entryAdded(EntryEvent<DeviceId, RoleValue> event) {
361 + entryUpdated(event);
361 } 362 }
362 363
363 @Override 364 @Override
...@@ -366,7 +367,6 @@ implements MastershipStore { ...@@ -366,7 +367,6 @@ implements MastershipStore {
366 367
367 @Override 368 @Override
368 public void entryUpdated(EntryEvent<DeviceId, RoleValue> event) { 369 public void entryUpdated(EntryEvent<DeviceId, RoleValue> event) {
369 - // this subsumes entryAdded event
370 notifyDelegate(new MastershipEvent( 370 notifyDelegate(new MastershipEvent(
371 MASTER_CHANGED, event.getKey(), event.getValue().roleInfo())); 371 MASTER_CHANGED, event.getKey(), event.getValue().roleInfo()));
372 } 372 }
......