Add blueprint wiring to sal-distributed-datastore 49/35849/22
authorTom Pantelis <tpanteli@brocade.com>
Sat, 5 Mar 2016 12:25:59 +0000 (07:25 -0500)
committerAnil Vishnoi <vishnoianil@gmail.com>
Mon, 11 Apr 2016 17:15:43 +0000 (17:15 +0000)
ALso changed the default in the config yang for shard-election-timeout-factor
as it was changed in the config XML which will no longer be used.

Change-Id: I2439587210c347dc1ac7e3e8ac5e9671fa86cf02
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
opendaylight/md-sal/sal-common-util/src/main/java/org/opendaylight/controller/md/sal/common/util/jmx/AbstractMXBean.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ConcurrentDOMDataBroker.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreFactory.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedConfigDataStoreProviderModule.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_datastore_provider/DistributedOperationalDataStoreProviderModule.java
opendaylight/md-sal/sal-distributed-datastore/src/main/resources/org/opendaylight/blueprint/clustered-datastore.xml [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/main/yang/distributed-datastore-provider.yang

index c24c8dc..40e1bd3 100644 (file)
@@ -69,6 +69,14 @@ public abstract class AbstractMXBean {
         return new ObjectName(builder.toString());
     }
 
+    /**
+     * This method is a wrapper for registerMBean with void return type so it can be invoked by dependency
+     * injection frameworks such as Spring and Blueprint.
+     */
+    public void register() {
+        registerMBean();
+    }
+
     /**
      * Registers this bean with the platform MBean server with the domain defined by
      * {@link #BASE_JMX_PREFIX}.
@@ -107,6 +115,14 @@ public abstract class AbstractMXBean {
         return registered;
     }
 
+    /**
+     * This method is a wrapper for unregisterMBean with void return type so it can be invoked by dependency
+     * injection frameworks such as Spring and Blueprint.
+     */
+    public void unregister() {
+        unregisterMBean();
+    }
+
     /**
      * Unregisters this bean with the platform MBean server.
      *
index 582f258..84cdccc 100644 (file)
@@ -47,7 +47,7 @@ public class ConcurrentDOMDataBroker extends AbstractDOMBroker {
     private static final String PRE_COMMIT = "PRE_COMMIT";
     private static final String COMMIT = "COMMIT";
 
-    private final DurationStatisticsTracker commitStatsTracker = DurationStatisticsTracker.createConcurrent();
+    private final DurationStatisticsTracker commitStatsTracker;
 
     /**
      * This executor is used to execute Future listener callback Runnables async.
@@ -55,8 +55,14 @@ public class ConcurrentDOMDataBroker extends AbstractDOMBroker {
     private final Executor clientFutureCallbackExecutor;
 
     public ConcurrentDOMDataBroker(final Map<LogicalDatastoreType, DOMStore> datastores, Executor listenableFutureExecutor) {
+        this(datastores, listenableFutureExecutor, DurationStatisticsTracker.createConcurrent());
+    }
+
+    public ConcurrentDOMDataBroker(final Map<LogicalDatastoreType, DOMStore> datastores, Executor listenableFutureExecutor,
+            DurationStatisticsTracker commitStatsTracker) {
         super(datastores);
         this.clientFutureCallbackExecutor = Preconditions.checkNotNull(listenableFutureExecutor);
+        this.commitStatsTracker = Preconditions.checkNotNull(commitStatsTracker);
     }
 
     public DurationStatisticsTracker getCommitStatsTracker() {
index 211465a..484a400 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.controller.cluster.datastore;
 
 import akka.actor.ActorSystem;
+import org.opendaylight.controller.cluster.ActorSystemProvider;
 import org.opendaylight.controller.cluster.datastore.config.Configuration;
 import org.opendaylight.controller.cluster.datastore.config.ConfigurationImpl;
 import org.opendaylight.controller.cluster.datastore.messages.DatastoreSnapshot;
@@ -20,11 +21,14 @@ public class DistributedDataStoreFactory {
     private static final Logger LOG = LoggerFactory.getLogger(DistributedDataStoreFactory.class);
 
     public static DistributedDataStore createInstance(SchemaService schemaService,
-            DatastoreContext datastoreContext, DatastoreSnapshot restoreFromSnapshot, ActorSystem actorSystem,
-            BundleContext bundleContext) {
+            DatastoreContext datastoreContext, DatastoreSnapshotRestore datastoreSnapshotRestore,
+            ActorSystemProvider actorSystemProvider, BundleContext bundleContext) {
 
         LOG.info("Create data store instance of type : {}", datastoreContext.getDataStoreName());
 
+        ActorSystem actorSystem = actorSystemProvider.getActorSystem();
+        DatastoreSnapshot restoreFromSnapshot = datastoreSnapshotRestore.getAndRemove(
+                datastoreContext.getDataStoreName());
         DatastoreContextIntrospector introspector = new DatastoreContextIntrospector(datastoreContext);
         DatastoreContextConfigAdminOverlay overlay = new DatastoreContextConfigAdminOverlay(
                 introspector, bundleContext);
index 4d20b6f..daa4c14 100644 (file)
@@ -44,12 +44,24 @@ public class DistributedConfigDataStoreProviderModule extends
 
     @Override
     public java.lang.AutoCloseable createInstance() {
-        ConfigProperties props = getConfigProperties();
+        DatastoreContext datastoreContext = newDatastoreContext(getConfigProperties());
+
+        return DistributedDataStoreFactory.createInstance(getConfigSchemaServiceDependency(),
+                datastoreContext, DatastoreSnapshotRestore.instance(),
+                getConfigActorSystemProviderDependency(), bundleContext);
+    }
+
+    public static DatastoreContext newDatastoreContext() {
+        return newDatastoreContext(null);
+    }
+
+    private static DatastoreContext newDatastoreContext(ConfigProperties inProps) {
+        ConfigProperties props = inProps;
         if(props == null) {
             props = new ConfigProperties();
         }
 
-        DatastoreContext datastoreContext = DatastoreContext.newBuilder()
+        return DatastoreContext.newBuilder()
                 .logicalStoreType(LogicalDatastoreType.CONFIGURATION)
                 .maxShardDataChangeExecutorPoolSize(props.getMaxShardDataChangeExecutorPoolSize().getValue().intValue())
                 .maxShardDataChangeExecutorQueueSize(props.getMaxShardDataChangeExecutorQueueSize().getValue().intValue())
@@ -80,10 +92,6 @@ public class DistributedConfigDataStoreProviderModule extends
                 .customRaftPolicyImplementation(props.getCustomRaftPolicyImplementation())
                 .shardSnapshotChunkSize(props.getShardSnapshotChunkSize().getValue().intValue())
                 .build();
-
-        return DistributedDataStoreFactory.createInstance(getConfigSchemaServiceDependency(),
-                datastoreContext, DatastoreSnapshotRestore.instance().getAndRemove(datastoreContext.getDataStoreName()),
-                getConfigActorSystemProviderDependency().getActorSystem(), bundleContext);
     }
 
     public void setBundleContext(BundleContext bundleContext) {
index bae52c5..9bb6b82 100644 (file)
@@ -44,13 +44,24 @@ public class DistributedOperationalDataStoreProviderModule extends
 
     @Override
     public java.lang.AutoCloseable createInstance() {
+        DatastoreContext datastoreContext = newDatastoreContext(getOperationalProperties());
 
-        OperationalProperties props = getOperationalProperties();
+        return DistributedDataStoreFactory.createInstance(getOperationalSchemaServiceDependency(),
+                datastoreContext, DatastoreSnapshotRestore.instance(),
+                getOperationalActorSystemProviderDependency(), bundleContext);
+    }
+
+    public static DatastoreContext newDatastoreContext() {
+        return newDatastoreContext(null);
+    }
+
+    private static DatastoreContext newDatastoreContext(OperationalProperties inProps) {
+        OperationalProperties props = inProps;
         if(props == null) {
             props = new OperationalProperties();
         }
 
-        DatastoreContext datastoreContext = DatastoreContext.newBuilder()
+        return DatastoreContext.newBuilder()
                 .logicalStoreType(LogicalDatastoreType.OPERATIONAL)
                 .maxShardDataChangeExecutorPoolSize(props.getMaxShardDataChangeExecutorPoolSize().getValue().intValue())
                 .maxShardDataChangeExecutorQueueSize(props.getMaxShardDataChangeExecutorQueueSize().getValue().intValue())
@@ -81,10 +92,6 @@ public class DistributedOperationalDataStoreProviderModule extends
                 .customRaftPolicyImplementation(props.getCustomRaftPolicyImplementation())
                 .shardSnapshotChunkSize(props.getShardSnapshotChunkSize().getValue().intValue())
                 .build();
-
-        return DistributedDataStoreFactory.createInstance(getOperationalSchemaServiceDependency(),
-                datastoreContext, DatastoreSnapshotRestore.instance().getAndRemove(datastoreContext.getDataStoreName()),
-                getOperationalActorSystemProviderDependency().getActorSystem(), bundleContext);
     }
 
     public void setBundleContext(BundleContext bundleContext) {
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/resources/org/opendaylight/blueprint/clustered-datastore.xml b/opendaylight/md-sal/sal-distributed-datastore/src/main/resources/org/opendaylight/blueprint/clustered-datastore.xml
new file mode 100644 (file)
index 0000000..ac0f02f
--- /dev/null
@@ -0,0 +1,116 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+           xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0">
+
+  <cm:property-placeholder persistent-id="org.opendaylight.controller.cluster.datastore.broker" update-strategy="none">
+    <cm:default-properties>
+      <cm:property name="max-data-broker-future-callback-queue-size" value="1000"/>
+      <cm:property name="max-data-broker-future-callback-pool-size" value="20"/>
+    </cm:default-properties>
+  </cm:property-placeholder>
+
+  <reference id="schemaService" interface="org.opendaylight.controller.sal.core.api.model.SchemaService" />
+
+  <!-- ActorSystemProvider -->
+
+  <bean id="actorSystemProvider" class="org.opendaylight.controller.config.yang.config.actor_system_provider.impl.ActorSystemProviderImpl"
+          destroy-method="close">
+    <argument ref="blueprintBundleContext"/>
+  </bean>
+
+  <service ref="actorSystemProvider" interface="org.opendaylight.controller.cluster.ActorSystemProvider"/>
+
+  <!-- Distributed Config Datastore -->
+
+  <bean id="datastoreSnapshotRestore" class="org.opendaylight.controller.cluster.datastore.DatastoreSnapshotRestore"
+          factory-method="instance" />
+
+  <bean id="configDatastoreContext" class="org.opendaylight.controller.config.yang.config.distributed_datastore_provider.DistributedConfigDataStoreProviderModule"
+          factory-method="newDatastoreContext" />
+
+  <bean id="configDatastore" class="org.opendaylight.controller.cluster.datastore.DistributedDataStoreFactory"
+          factory-method="createInstance" destroy-method="close">
+    <argument ref="schemaService"/>
+    <argument ref="configDatastoreContext"/>
+    <argument ref="datastoreSnapshotRestore"/>
+    <argument ref="actorSystemProvider"/>
+    <argument ref="blueprintBundleContext"/>
+  </bean>
+
+  <!-- Distributed Operational Datastore -->
+
+  <bean id="operDatastoreContext" class="org.opendaylight.controller.config.yang.config.distributed_datastore_provider.DistributedOperationalDataStoreProviderModule"
+          factory-method="newDatastoreContext" />
+
+  <bean id="operDatastore" class="org.opendaylight.controller.cluster.datastore.DistributedDataStoreFactory"
+          factory-method="createInstance" destroy-method="close">
+    <argument ref="schemaService"/>
+    <argument ref="operDatastoreContext"/>
+    <argument ref="datastoreSnapshotRestore"/>
+    <argument ref="actorSystemProvider"/>
+    <argument ref="blueprintBundleContext"/>
+  </bean>
+
+  <!-- Concurrent DOMDataBroker -->
+
+  <bean id="listenableFutureExecutor" class="org.opendaylight.yangtools.util.concurrent.SpecialExecutors"
+          factory-method="newBlockingBoundedCachedThreadPool">
+    <argument value="${max-data-broker-future-callback-pool-size}"/>
+    <argument value="${max-data-broker-future-callback-queue-size}"/>
+    <argument value="CommitFutures"/>
+  </bean>
+
+  <bean id="commitStatsTracker" class="org.opendaylight.yangtools.util.DurationStatisticsTracker"
+          factory-method="createConcurrent"/>
+
+  <bean id="clusteredDOMDataBroker" class="org.opendaylight.controller.cluster.datastore.ConcurrentDOMDataBroker"
+          destroy-method="close">
+    <argument>
+      <map>
+        <entry key="CONFIGURATION" value-ref="configDatastore"/>
+        <entry key="OPERATIONAL" value-ref="operDatastore"/>
+      </map>
+    </argument>
+    <argument ref="listenableFutureExecutor"/>
+    <argument ref="commitStatsTracker"/>
+  </bean>
+
+  <service ref="clusteredDOMDataBroker" interface="org.opendaylight.controller.md.sal.dom.api.DOMDataBroker"
+          odl:type="default"/>
+
+  <!-- JMX beans for the data broker -->
+
+  <bean id="commitStatsMXBean" class="org.opendaylight.controller.md.sal.dom.broker.impl.jmx.CommitStatsMXBeanImpl"
+          init-method="register" destroy-method="unregister">
+    <argument ref="commitStatsTracker"/>
+    <argument value="DOMDataBroker"/>
+  </bean>
+
+  <bean id="threadStatsMXBean" class="org.opendaylight.controller.md.sal.common.util.jmx.ThreadExecutorStatsMXBeanImpl"
+          factory-method="create" destroy-method="unregister">
+    <argument ref="listenableFutureExecutor"/>
+    <argument value="CommitFutureExecutorStats"/>
+    <argument value="DOMDataBroker"/>
+    <argument><null/></argument>
+  </bean>
+
+  <!-- Distributed EntityOwnershipService -->
+
+  <bean id="selectionStrategyConfig" class="org.opendaylight.controller.cluster.datastore.entityownership.selectionstrategy.EntityOwnerSelectionStrategyConfigReader"
+          factory-method="loadStrategyWithConfig">
+    <argument ref="blueprintBundleContext"/>
+  </bean>
+
+  <bean id="distributedEntityOwnershipService" class="org.opendaylight.controller.cluster.datastore.entityownership.DistributedEntityOwnershipService"
+          factory-method="start" destroy-method="close">
+    <argument>
+      <bean factory-ref="operDatastore" factory-method="getActorContext"/>
+    </argument>
+    <argument ref="selectionStrategyConfig"/>
+  </bean>
+
+  <service ref="distributedEntityOwnershipService" interface="org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService"
+        odl:type="default"/>
+
+</blueprint>
\ No newline at end of file
index 8ae1ec9..d40a3aa 100644 (file)
@@ -112,7 +112,7 @@ module distributed-datastore-provider {
          }
 
          leaf shard-election-timeout-factor {
-            default 2;
+            default 20;
             type non-zero-uint32-type;
             description "The multiplication factor to be used to determine shard election timeout. The shard election timeout
                          is determined by multiplying shard-heartbeat-interval-in-millis with the shard-election-timeout-factor";