Switch default stream output to Magnesium
[controller.git] / opendaylight / md-sal / sal-distributed-eos / src / main / java / org / opendaylight / controller / cluster / entityownership / AbstractEntityOwnerChangeListener.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.cluster.entityownership;
9
10 import static org.opendaylight.controller.cluster.entityownership.EntityOwnersModel.ENTITY_OWNERS_PATH;
11 import static org.opendaylight.controller.cluster.entityownership.EntityOwnersModel.ENTITY_OWNER_QNAME;
12 import static org.opendaylight.controller.cluster.entityownership.EntityOwnersModel.ENTITY_QNAME;
13
14 import java.util.Optional;
15 import org.opendaylight.controller.cluster.datastore.ShardDataTree;
16 import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.clustering.entity.owners.rev150804.entity.owners.EntityType;
18 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
19 import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
20
21 public abstract class AbstractEntityOwnerChangeListener implements DOMDataTreeChangeListener {
22     private static final YangInstanceIdentifier EOS_PATH = YangInstanceIdentifier.builder(ENTITY_OWNERS_PATH)
23             .node(EntityType.QNAME).node(EntityType.QNAME).node(ENTITY_QNAME).node(ENTITY_QNAME)
24             .node(ENTITY_OWNER_QNAME).build();
25
26     void init(final ShardDataTree shardDataTree) {
27         shardDataTree.registerTreeChangeListener(EOS_PATH, this, Optional.empty(), noop -> { /* NOOP */ });
28     }
29
30     protected static String extractOwner(final LeafNode<?> ownerLeaf) {
31         return ownerLeaf.getValue().toString();
32     }
33
34 }