Merge "Startup arch - add odlparent to root pom."
[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 org.opendaylight.controller.cluster.datastore.DatastoreContext;
4 import org.opendaylight.controller.cluster.datastore.DistributedDataStoreFactory;
5 import org.osgi.framework.BundleContext;
6
7 public class DistributedOperationalDataStoreProviderModule extends
8     org.opendaylight.controller.config.yang.config.distributed_datastore_provider.AbstractDistributedOperationalDataStoreProviderModule {
9     private BundleContext bundleContext;
10
11     public DistributedOperationalDataStoreProviderModule(
12         org.opendaylight.controller.config.api.ModuleIdentifier identifier,
13         org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
14         super(identifier, dependencyResolver);
15     }
16
17     public DistributedOperationalDataStoreProviderModule(
18         org.opendaylight.controller.config.api.ModuleIdentifier identifier,
19         org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
20         org.opendaylight.controller.config.yang.config.distributed_datastore_provider.DistributedOperationalDataStoreProviderModule oldModule,
21         java.lang.AutoCloseable oldInstance) {
22         super(identifier, dependencyResolver, oldModule, oldInstance);
23     }
24
25     @Override
26     public void customValidation() {
27         // add custom validation form module attributes here.
28     }
29
30     @Override
31     public java.lang.AutoCloseable createInstance() {
32
33         OperationalProperties props = getOperationalProperties();
34         if(props == null) {
35             props = new OperationalProperties();
36         }
37
38         DatastoreContext datastoreContext = DatastoreContext.newBuilder()
39                 .dataStoreType("operational")
40                 .maxShardDataChangeExecutorPoolSize(props.getMaxShardDataChangeExecutorPoolSize().getValue().intValue())
41                 .maxShardDataChangeExecutorQueueSize(props.getMaxShardDataChangeExecutorQueueSize().getValue().intValue())
42                 .maxShardDataChangeListenerQueueSize(props.getMaxShardDataChangeListenerQueueSize().getValue().intValue())
43                 .maxShardDataStoreExecutorQueueSize(props.getMaxShardDataStoreExecutorQueueSize().getValue().intValue())
44                 .shardTransactionIdleTimeoutInMinutes(props.getShardTransactionIdleTimeoutInMinutes().getValue())
45                 .operationTimeoutInSeconds(props.getOperationTimeoutInSeconds().getValue())
46                 .shardJournalRecoveryLogBatchSize(props.getShardJournalRecoveryLogBatchSize().
47                         getValue().intValue())
48                 .shardSnapshotBatchCount(props.getShardSnapshotBatchCount().getValue().intValue())
49                 .shardSnapshotDataThresholdPercentage(props.getShardSnapshotDataThresholdPercentage().getValue().intValue())
50                 .shardHeartbeatIntervalInMillis(props.getShardHeartbeatIntervalInMillis().getValue())
51                 .shardInitializationTimeoutInSeconds(props.getShardInitializationTimeoutInSeconds().getValue())
52                 .shardLeaderElectionTimeoutInSeconds(props.getShardLeaderElectionTimeoutInSeconds().getValue())
53                 .shardTransactionCommitTimeoutInSeconds(
54                         props.getShardTransactionCommitTimeoutInSeconds().getValue().intValue())
55                 .shardTransactionCommitQueueCapacity(
56                         props.getShardTransactionCommitQueueCapacity().getValue().intValue())
57                 .persistent(props.getPersistent().booleanValue())
58                 .shardIsolatedLeaderCheckIntervalInMillis(
59                     props.getShardIsolatedLeaderCheckIntervalInMillis().getValue())
60                 .shardElectionTimeoutFactor(props.getShardElectionTimeoutFactor().getValue())
61                 .transactionCreationInitialRateLimit(props.getTransactionCreationInitialRateLimit().getValue())
62                 .shardBatchedModificationCount(props.getShardBatchedModificationCount().getValue().intValue())
63                 .build();
64
65         return DistributedDataStoreFactory.createInstance(getOperationalSchemaServiceDependency(),
66                 datastoreContext, bundleContext);
67     }
68
69     public void setBundleContext(BundleContext bundleContext) {
70         this.bundleContext = bundleContext;
71     }
72
73 }