Fix followerDistributedDataStore tear down
[controller.git] / opendaylight / md-sal / sal-cluster-admin-impl / src / main / java / org / opendaylight / controller / cluster / datastore / admin / OSGiClusterAdmin.java
1 /*
2  * Copyright (c) 2020 PANTHEON.tech, s.r.o. 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.datastore.admin;
9
10 import org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface;
11 import org.opendaylight.controller.eos.akka.DataCenterControl;
12 import org.opendaylight.mdsal.binding.api.RpcProviderService;
13 import org.opendaylight.yangtools.concepts.Registration;
14 import org.osgi.service.component.annotations.Activate;
15 import org.osgi.service.component.annotations.Component;
16 import org.osgi.service.component.annotations.Deactivate;
17 import org.osgi.service.component.annotations.Reference;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
20
21 @Component(service = { })
22 public final class OSGiClusterAdmin {
23     private static final Logger LOG = LoggerFactory.getLogger(OSGiClusterAdmin.class);
24
25     private final Registration reg;
26
27     @Activate
28     public OSGiClusterAdmin(
29             @Reference(target = "(type=distributed-config)") final DistributedDataStoreInterface configDatastore,
30             @Reference(target = "(type=distributed-operational)") final DistributedDataStoreInterface operDatastore,
31             @Reference final RpcProviderService rpcProviderService,
32             @Reference final DataCenterControl dataCenterControls,
33             @Reference final DataCenterControl dataCenterControl) {
34         reg = new ClusterAdminRpcService(configDatastore, operDatastore, dataCenterControl)
35             .registerWith(rpcProviderService);
36         LOG.info("Cluster Admin services started");
37     }
38
39     @Deactivate
40     void deactivate() {
41         reg.close();
42         LOG.info("Cluster Admin services stopped");
43     }
44 }