Committed by
Gerrit Code Review
Fix for Mastership exception fetching timestamp - from Madan
Change-Id: Ifec4fe8a559a7d5832afc8eb62c936b28fffc186
Showing
1 changed file
with
7 additions
and
5 deletions
| ... | @@ -312,13 +312,15 @@ public class DeviceManager | ... | @@ -312,13 +312,15 @@ public class DeviceManager |
| 312 | log.debug("Checking mastership"); | 312 | log.debug("Checking mastership"); |
| 313 | for (Device device : getDevices()) { | 313 | for (Device device : getDevices()) { |
| 314 | final DeviceId deviceId = device.id(); | 314 | final DeviceId deviceId = device.id(); |
| 315 | - log.trace("Checking device {}", deviceId); | 315 | + MastershipRole myRole = mastershipService.getLocalRole(deviceId); |
| 316 | - | 316 | + log.trace("Checking device {}. Current role is {}", deviceId, myRole); |
| 317 | if (!isReachable(deviceId)) { | 317 | if (!isReachable(deviceId)) { |
| 318 | - if (mastershipService.getLocalRole(deviceId) != NONE) { | 318 | + if (myRole != NONE) { |
| 319 | // can't be master if device is not reachable | 319 | // can't be master if device is not reachable |
| 320 | try { | 320 | try { |
| 321 | - post(store.markOffline(deviceId)); | 321 | + if (myRole == MASTER) { |
| 322 | + post(store.markOffline(deviceId)); | ||
| 323 | + } | ||
| 322 | //relinquish master role and ability to be backup. | 324 | //relinquish master role and ability to be backup. |
| 323 | mastershipService.relinquishMastership(deviceId).get(); | 325 | mastershipService.relinquishMastership(deviceId).get(); |
| 324 | } catch (InterruptedException e) { | 326 | } catch (InterruptedException e) { |
| ... | @@ -331,7 +333,7 @@ public class DeviceManager | ... | @@ -331,7 +333,7 @@ public class DeviceManager |
| 331 | continue; | 333 | continue; |
| 332 | } | 334 | } |
| 333 | 335 | ||
| 334 | - if (mastershipService.getLocalRole(deviceId) != NONE) { | 336 | + if (myRole != NONE) { |
| 335 | continue; | 337 | continue; |
| 336 | } | 338 | } |
| 337 | 339 | ... | ... |
-
Please register or login to post a comment