2 * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others. All rights reserved.
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
8 package org.opendaylight.controller.cluster.datastore;
10 import static com.google.common.base.Verify.verifyNotNull;
12 import com.google.common.annotations.Beta;
14 import org.opendaylight.controller.cluster.datastore.utils.ActorUtils;
15 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
16 import org.opendaylight.mdsal.dom.api.DOMDataBroker.CommitCohortExtension;
17 import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
18 import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohort;
19 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
20 import org.opendaylight.mdsal.dom.spi.store.DOMStore;
21 import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction;
22 import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction;
23 import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain;
24 import org.opendaylight.mdsal.dom.spi.store.DOMStoreTreeChangePublisher;
25 import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
26 import org.opendaylight.yangtools.concepts.Registration;
27 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
28 import org.osgi.service.component.annotations.Activate;
29 import org.osgi.service.component.annotations.Component;
30 import org.osgi.service.component.annotations.Deactivate;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
35 * OSGi manifestation of a the distributed datastore, as represented by {@link AbstractDataStore}. This component's
36 * configuration is managed by {@link OSGiDistributedDataStore}.
39 @Component(factory = OSGiDOMStore.FACTORY_NAME, service = { DOMStore.class, DistributedDataStoreInterface.class })
40 public final class OSGiDOMStore
41 implements DistributedDataStoreInterface, DOMStoreTreeChangePublisher, CommitCohortExtension {
42 // OSGi DS Component Factory name
43 static final String FACTORY_NAME = "org.opendaylight.controller.cluster.datastore.OSGiDOMStore";
44 static final String DATASTORE_INST_PROP = ".datastore.instance";
45 static final String DATASTORE_TYPE_PROP = ".datastore.type";
47 private static final Logger LOG = LoggerFactory.getLogger(OSGiDOMStore.class);
49 private final LogicalDatastoreType datastoreType;
50 private AbstractDataStore datastore;
53 public OSGiDOMStore(final Map<String, ?> properties) {
54 datastoreType = (LogicalDatastoreType) verifyNotNull(properties.get(DATASTORE_TYPE_PROP));
55 datastore = (AbstractDataStore) verifyNotNull(properties.get(DATASTORE_INST_PROP));
56 LOG.info("Datastore service type {} activated", datastoreType);
62 LOG.info("Datastore service type {} deactivated", datastoreType);
66 public ActorUtils getActorUtils() {
67 return datastore.getActorUtils();
71 public Registration registerProxyListener(final YangInstanceIdentifier shardLookup,
72 final YangInstanceIdentifier insideShard, final DOMDataTreeChangeListener delegate) {
73 return datastore.registerProxyListener(shardLookup, insideShard, delegate);
77 public Registration registerTreeChangeListener(final YangInstanceIdentifier treeId,
78 final DOMDataTreeChangeListener listener) {
79 return datastore.registerTreeChangeListener(treeId, listener);
83 public Registration registerCommitCohort(final DOMDataTreeIdentifier path, final DOMDataTreeCommitCohort cohort) {
84 return datastore.registerCommitCohort(path, cohort);
88 public DOMStoreTransactionChain createTransactionChain() {
89 return datastore.createTransactionChain();
93 public DOMStoreReadTransaction newReadOnlyTransaction() {
94 return datastore.newReadOnlyTransaction();
98 public DOMStoreWriteTransaction newWriteOnlyTransaction() {
99 return datastore.newWriteOnlyTransaction();
103 public DOMStoreReadWriteTransaction newReadWriteTransaction() {
104 return datastore.newReadWriteTransaction();
108 public Registration registerLegacyTreeChangeListener(final YangInstanceIdentifier treeId,
109 final DOMDataTreeChangeListener listener) {
110 return datastore.registerLegacyTreeChangeListener(treeId, listener);