+ /**
+ * Determine if we are in jeopardy based on observed RAFT state.
+ */
+ private static boolean inJeopardy(final RaftState state) {
+ switch (state) {
+ case Candidate:
+ case Follower:
+ case Leader:
+ return false;
+ case IsolatedLeader:
+ return true;
+ }
+ throw new IllegalStateException("Unsupported RAFT state " + state);
+ }
+
+ private void notifyAllListeners() {
+ searchForEntities((entityTypeNode, entityNode) -> {
+ Optional<DataContainerChild<?, ?>> possibleType = entityTypeNode.getChild(ENTITY_TYPE_NODE_ID);
+ if (possibleType.isPresent()) {
+ final boolean hasOwner;
+ final boolean isOwner;
+
+ Optional<DataContainerChild<?, ?>> possibleOwner = entityNode.getChild(ENTITY_OWNER_NODE_ID);
+ if (possibleOwner.isPresent()) {
+ isOwner = localMemberName.getName().equals(possibleOwner.get().getValue().toString());
+ hasOwner = true;
+ } else {
+ isOwner = false;
+ hasOwner = false;
+ }
+
+ DOMEntity entity = new DOMEntity(possibleType.get().getValue().toString(),
+ (YangInstanceIdentifier) entityNode.getChild(ENTITY_ID_NODE_ID).get().getValue());
+
+ listenerSupport.notifyEntityOwnershipListeners(entity, isOwner, isOwner, hasOwner);
+ }
+ });
+ }
+