Merge "Bug 1850 - The earlier patch missed out on removing the unnecessary call to...
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / config / yang / config / distributed_datastore_provider / DistributedOperationalDataStoreProviderModule.java
1 package org.opendaylight.controller.config.yang.config.distributed_datastore_provider;
2
3 import java.util.concurrent.TimeUnit;
4
5 import org.opendaylight.controller.cluster.datastore.DatastoreContext;
6 import org.opendaylight.controller.cluster.datastore.DistributedDataStoreFactory;
7 import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreConfigProperties;
8 import org.osgi.framework.BundleContext;
9
10 import scala.concurrent.duration.Duration;
11
12 public class DistributedOperationalDataStoreProviderModule extends
13     org.opendaylight.controller.config.yang.config.distributed_datastore_provider.AbstractDistributedOperationalDataStoreProviderModule {
14     private BundleContext bundleContext;
15
16     public DistributedOperationalDataStoreProviderModule(
17         org.opendaylight.controller.config.api.ModuleIdentifier identifier,
18         org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
19         super(identifier, dependencyResolver);
20     }
21
22     public DistributedOperationalDataStoreProviderModule(
23         org.opendaylight.controller.config.api.ModuleIdentifier identifier,
24         org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
25         org.opendaylight.controller.config.yang.config.distributed_datastore_provider.DistributedOperationalDataStoreProviderModule oldModule,
26         java.lang.AutoCloseable oldInstance) {
27         super(identifier, dependencyResolver, oldModule, oldInstance);
28     }
29
30     @Override
31     public void customValidation() {
32         // add custom validation form module attributes here.
33     }
34
35     @Override
36     public java.lang.AutoCloseable createInstance() {
37
38         OperationalProperties props = getOperationalProperties();
39         if(props == null) {
40             props = new OperationalProperties();
41         }
42
43         DatastoreContext datastoreContext = new DatastoreContext("DistributedOperationalDatastore",
44                 InMemoryDOMDataStoreConfigProperties.create(
45                         props.getMaxShardDataChangeExecutorPoolSize().getValue().intValue(),
46                         props.getMaxShardDataChangeExecutorQueueSize().getValue().intValue(),
47                         props.getMaxShardDataChangeListenerQueueSize().getValue().intValue(),
48                         props.getMaxShardDataStoreExecutorQueueSize().getValue().intValue()),
49                 Duration.create(props.getShardTransactionIdleTimeoutInMinutes().getValue(),
50                         TimeUnit.MINUTES),
51                 props.getOperationTimeoutInSeconds().getValue(),
52                 props.getShardJournalRecoveryLogBatchSize().getValue().intValue(),
53                 props.getShardSnapshotBatchCount().getValue().intValue(),
54                 props.getShardHearbeatIntervalInMillis().getValue());
55
56         return DistributedDataStoreFactory.createInstance("operational",
57                 getOperationalSchemaServiceDependency(), datastoreContext, bundleContext);
58     }
59
60     public void setBundleContext(BundleContext bundleContext) {
61         this.bundleContext = bundleContext;
62     }
63
64 }