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.sharding;
10 import com.google.common.collect.ClassToInstanceMap;
11 import java.util.Collection;
12 import java.util.concurrent.CompletionStage;
13 import org.opendaylight.controller.cluster.ActorSystemProvider;
14 import org.opendaylight.controller.cluster.access.concepts.MemberName;
15 import org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface;
16 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
17 import org.opendaylight.mdsal.dom.api.DOMDataTreeListener;
18 import org.opendaylight.mdsal.dom.api.DOMDataTreeLoopException;
19 import org.opendaylight.mdsal.dom.api.DOMDataTreeProducer;
20 import org.opendaylight.mdsal.dom.api.DOMDataTreeService;
21 import org.opendaylight.mdsal.dom.api.DOMDataTreeServiceExtension;
22 import org.opendaylight.mdsal.dom.api.DOMDataTreeShard;
23 import org.opendaylight.mdsal.dom.api.DOMDataTreeShardingConflictException;
24 import org.opendaylight.mdsal.dom.api.DOMDataTreeShardingService;
25 import org.opendaylight.yangtools.concepts.ListenerRegistration;
26 import org.osgi.service.component.annotations.Activate;
27 import org.osgi.service.component.annotations.Component;
28 import org.osgi.service.component.annotations.Deactivate;
29 import org.osgi.service.component.annotations.Reference;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
33 @Component(immediate = true, property = "type=default")
34 @Deprecated(forRemoval = true)
35 public final class OSGiDistributedShardedDOMDataTree
36 implements DOMDataTreeService, DOMDataTreeShardingService, DistributedShardFactory {
37 private static final Logger LOG = LoggerFactory.getLogger(OSGiDistributedShardedDOMDataTree.class);
40 ActorSystemProvider actorSystemProvider = null;
41 @Reference(target = "(type=distributed-config)")
42 DistributedDataStoreInterface configDatastore = null;
43 @Reference(target = "(type=distributed-operational)")
44 DistributedDataStoreInterface operDatastore = null;
46 private DistributedShardedDOMDataTree delegate;
49 public DOMDataTreeProducer createProducer(final Collection<DOMDataTreeIdentifier> subtrees) {
50 return delegate.createProducer(subtrees);
54 public ClassToInstanceMap<DOMDataTreeServiceExtension> getExtensions() {
55 return delegate.getExtensions();
59 public CompletionStage<DistributedShardRegistration> createDistributedShard(final DOMDataTreeIdentifier prefix,
60 final Collection<MemberName> replicaMembers) throws DOMDataTreeShardingConflictException {
61 return delegate.createDistributedShard(prefix, replicaMembers);
65 public <T extends DOMDataTreeShard> ListenerRegistration<T> registerDataTreeShard(
66 final DOMDataTreeIdentifier prefix, final T shard, final DOMDataTreeProducer producer)
67 throws DOMDataTreeShardingConflictException {
68 return delegate.registerDataTreeShard(prefix, shard, producer);
72 public <T extends DOMDataTreeListener> ListenerRegistration<T> registerListener(final T listener,
73 final Collection<DOMDataTreeIdentifier> subtrees, final boolean allowRxMerges,
74 final Collection<DOMDataTreeProducer> producers) throws DOMDataTreeLoopException {
75 return delegate.registerListener(listener, subtrees, allowRxMerges, producers);
80 LOG.info("Distributed DOM Data Tree Service starting");
81 delegate = new DistributedShardedDOMDataTree(actorSystemProvider, operDatastore, configDatastore);
83 LOG.info("Distributed DOM Data Tree Service started");
88 LOG.info("Distributed DOM Data Tree Service stopping");
89 // TODO: this needs a shutdown hook, I think
91 LOG.info("Distributed DOM Data Tree Service stopped");