+ private void onUnregisterCandidateLocal(UnregisterCandidateLocal unregisterCandidate) {
+ LOG.debug("{}: onUnregisterCandidateLocal: {}", persistenceId(), unregisterCandidate);
+
+ DOMEntity entity = unregisterCandidate.getEntity();
+ listenerSupport.unsetHasCandidateForEntity(entity);
+
+ YangInstanceIdentifier candidatePath = candidatePath(entity.getType(), entity.getIdentifier(), localMemberName.getName());
+ commitCoordinator.commitModification(new DeleteModification(candidatePath), this);
+
+ getSender().tell(SuccessReply.INSTANCE, getSelf());
+ }
+
+ private void onRegisterListenerLocal(final RegisterListenerLocal registerListener) {
+ LOG.debug("{}: onRegisterListenerLocal: {}", persistenceId(), registerListener);
+
+ listenerSupport.addEntityOwnershipListener(registerListener.getEntityType(), registerListener.getListener());
+
+ getSender().tell(SuccessReply.INSTANCE, getSelf());
+
+ searchForEntities((entityTypeNode, entityNode) -> {
+ Optional<DataContainerChild<?, ?>> possibleType = entityTypeNode.getChild(ENTITY_TYPE_NODE_ID);
+ String entityType = possibleType.isPresent() ? possibleType.get().getValue().toString() : null;
+ if (registerListener.getEntityType().equals(entityType)) {
+ 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(entityType,
+ (YangInstanceIdentifier) entityNode.getChild(ENTITY_ID_NODE_ID).get().getValue());
+
+ listenerSupport.notifyEntityOwnershipListener(entity, false, isOwner, hasOwner,
+ registerListener.getListener());
+ }
+ });
+ }
+
+ private void onUnregisterListenerLocal(UnregisterListenerLocal unregisterListener) {
+ LOG.debug("{}: onUnregisterListenerLocal: {}", persistenceId(), unregisterListener);
+
+ listenerSupport.removeEntityOwnershipListener(unregisterListener.getEntityType(), unregisterListener.getListener());
+
+ getSender().tell(SuccessReply.INSTANCE, getSelf());
+ }
+