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 adafa54aa2c774c10ee9ad11414c23125fbad036..7ee67be47c0159b83218820951cf369903f4c598 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 c97bfc471fa5373e37b5edf02bf06e04ed6cf780..14463207e20a0406ba4b47c79cd9dbde6eae6357 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"/>