Merge "Bug 1029: Remove dead code: p2site"
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / config / yang / config / distributed_datastore_provider / DistributedConfigDataStoreProviderModule.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 DistributedConfigDataStoreProviderModule extends
13     org.opendaylight.controller.config.yang.config.distributed_datastore_provider.AbstractDistributedConfigDataStoreProviderModule {
14     private BundleContext bundleContext;
15
16     public DistributedConfigDataStoreProviderModule(
17         org.opendaylight.controller.config.api.ModuleIdentifier identifier,
18         org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
19         super(identifier, dependencyResolver);
20     }
21
22     public DistributedConfigDataStoreProviderModule(
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.DistributedConfigDataStoreProviderModule 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         ConfigProperties props = getConfigProperties();
39         if(props == null) {
40             props = new ConfigProperties();
41         }
42
43         DatastoreContext datastoreContext = DatastoreContext.newBuilder()
44                 .dataStoreMXBeanType("DistributedConfigDatastore")
45                 .dataStoreProperties(InMemoryDOMDataStoreConfigProperties.create(
46                         props.getMaxShardDataChangeExecutorPoolSize().getValue().intValue(),
47                         props.getMaxShardDataChangeExecutorQueueSize().getValue().intValue(),
48                         props.getMaxShardDataChangeListenerQueueSize().getValue().intValue(),
49                         props.getMaxShardDataStoreExecutorQueueSize().getValue().intValue()))
50                 .shardTransactionIdleTimeout(Duration.create(
51                         props.getShardTransactionIdleTimeoutInMinutes().getValue(), TimeUnit.MINUTES))
52                 .operationTimeoutInSeconds(props.getOperationTimeoutInSeconds().getValue())
53                 .shardJournalRecoveryLogBatchSize(props.getShardJournalRecoveryLogBatchSize().
54                         getValue().intValue())
55                 .shardSnapshotBatchCount(props.getShardSnapshotBatchCount().getValue().intValue())
56                 .shardHeartbeatIntervalInMillis(props.getShardHearbeatIntervalInMillis().getValue())
57                 .shardInitializationTimeout(props.getShardInitializationTimeoutInSeconds().getValue(),
58                         TimeUnit.SECONDS)
59                 .shardLeaderElectionTimeout(props.getShardLeaderElectionTimeoutInSeconds().getValue(),
60                         TimeUnit.SECONDS)
61                 .shardTransactionCommitTimeoutInSeconds(
62                         props.getShardTransactionCommitTimeoutInSeconds().getValue().intValue())
63                 .shardTransactionCommitQueueCapacity(
64                         props.getShardTransactionCommitQueueCapacity().getValue().intValue())
65                 .persistent(props.getPersistent().booleanValue())
66                 .build();
67
68         return DistributedDataStoreFactory.createInstance("config", getConfigSchemaServiceDependency(),
69                 datastoreContext, bundleContext);
70     }
71
72     public void setBundleContext(BundleContext bundleContext) {
73         this.bundleContext = bundleContext;
74     }
75 }