Convert FileModuleShardConfigProvider to OSGi DS 56/91756/3
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 29 Jul 2020 10:09:34 +0000 (12:09 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 30 Jul 2020 10:19:29 +0000 (12:19 +0200)
This is a simple injected holder, convert it to a full-blown
component.

JIRA: CONTROLLER-1882
Change-Id: I6676055801c178c4ffb4137ec6721128014dedde
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/config/FileModuleShardConfigProvider.java
opendaylight/md-sal/sal-distributed-datastore/src/main/resources/OSGI-INF/blueprint/clustered-datastore.xml

index adafa54..7ee67be 100644 (file)
@@ -9,16 +9,28 @@ package org.opendaylight.controller.cluster.datastore.config;
 
 import com.typesafe.config.Config;
 import java.util.Map;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Implementation of ModuleShardConfigProvider that reads the module and shard configuration from files.
  *
  * @author Thomas Pantelis
  */
+@Component(immediate = true, service = ModuleShardConfigProvider.class)
 public class FileModuleShardConfigProvider extends AbstractModuleShardConfigProvider {
+    private static final Logger LOG = LoggerFactory.getLogger(FileModuleShardConfigProvider.class);
+
     private final String moduleShardsConfigPath;
     private final String modulesConfigPath;
 
+    public FileModuleShardConfigProvider() {
+        this("./configuration/initial/module-shards.conf", "./configuration/initial/modules.conf");
+    }
+
     public FileModuleShardConfigProvider(final String moduleShardsConfigPath, final String modulesConfigPath) {
         this.moduleShardsConfigPath = moduleShardsConfigPath;
         this.modulesConfigPath = modulesConfigPath;
@@ -33,4 +45,14 @@ public class FileModuleShardConfigProvider extends AbstractModuleShardConfigProv
         readModulesConfig(modulesConfig, moduleConfigMap, configuration);
         return moduleConfigMap;
     }
+
+    @Activate
+    void activate() {
+        LOG.info("Shard configuration provider started");
+    }
+
+    @Deactivate
+    void deactivate() {
+        LOG.info("Shard configuration provider stopped");
+    }
 }
index c97bfc4..1446320 100644 (file)
@@ -16,6 +16,7 @@
   <reference id="actorSystemProvider" interface="org.opendaylight.controller.cluster.ActorSystemProvider"/>
   <reference id="introspectorFactory" interface="org.opendaylight.controller.cluster.datastore.DatastoreContextIntrospectorFactory"/>
   <reference id="datastoreSnapshotRestore" interface="org.opendaylight.controller.cluster.datastore.DatastoreSnapshotRestore"/>
+  <reference id="fileModuleShardConfigProvider" interface="org.opendaylight.controller.cluster.datastore.config.ModuleShardConfigProvider"/>
 
   <cm:cm-properties id="datastoreProps" persistent-id="org.opendaylight.controller.cluster.datastore"/>
 
   </service>
 
   <!-- Distributed Operational Datastore -->
-  <bean id="fileModuleShardConfigProvider" class="org.opendaylight.controller.cluster.datastore.config.FileModuleShardConfigProvider">
-    <argument value="./configuration/initial/module-shards.conf"/>
-    <argument value="./configuration/initial/modules.conf"/>
-  </bean>
 
   <bean id="configurationImpl" class="org.opendaylight.controller.cluster.datastore.config.ConfigurationImpl">
     <argument ref="fileModuleShardConfigProvider"/>

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.