Fix warnings/javadocs in sal-distributed-datastore
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / config / yang / config / distributed_datastore_provider / DistributedConfigDataStoreProviderModule.java
1 /*
2  * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.config.yang.config.distributed_datastore_provider;
10
11 import org.opendaylight.controller.cluster.datastore.DatastoreContext;
12 import org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface;
13 import org.opendaylight.controller.config.api.DependencyResolver;
14 import org.opendaylight.controller.config.api.ModuleIdentifier;
15 import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
16 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
17 import org.osgi.framework.BundleContext;
18
19 public class DistributedConfigDataStoreProviderModule extends AbstractDistributedConfigDataStoreProviderModule {
20     private BundleContext bundleContext;
21
22     public DistributedConfigDataStoreProviderModule(
23         org.opendaylight.controller.config.api.ModuleIdentifier identifier,
24         org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
25         super(identifier, dependencyResolver);
26     }
27
28     public DistributedConfigDataStoreProviderModule(ModuleIdentifier identifier, DependencyResolver dependencyResolver,
29             DistributedConfigDataStoreProviderModule oldModule, AutoCloseable oldInstance) {
30         super(identifier, dependencyResolver, oldModule, oldInstance);
31     }
32
33     @Override
34     public void customValidation() {
35         // add custom validation form module attributes here.
36     }
37
38     @Override
39     public boolean canReuseInstance(AbstractDistributedConfigDataStoreProviderModule oldModule) {
40         return true;
41     }
42
43     @Override
44     public AutoCloseable createInstance() {
45         // The DistributedConfigDataStore is provided via blueprint so wait for and return it here for
46         // backwards compatibility.
47         WaitingServiceTracker<DistributedDataStoreInterface> tracker = WaitingServiceTracker.create(
48                 DistributedDataStoreInterface.class, bundleContext, "(type=distributed-config)");
49         DistributedDataStoreInterface delegate = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
50         return new ForwardingDistributedDataStore(delegate, tracker);
51     }
52
53     public static DatastoreContext newDatastoreContext() {
54         return newDatastoreContext(null);
55     }
56
57     private static DatastoreContext newDatastoreContext(ConfigProperties inProps) {
58         ConfigProperties props = inProps;
59         if (props == null) {
60             props = new ConfigProperties();
61         }
62
63         return DatastoreContext.newBuilder()
64                 .logicalStoreType(LogicalDatastoreType.CONFIGURATION)
65                 .maxShardDataChangeExecutorPoolSize(props.getMaxShardDataChangeExecutorPoolSize().getValue().intValue())
66                 .maxShardDataChangeExecutorQueueSize(props.getMaxShardDataChangeExecutorQueueSize()
67                         .getValue().intValue())
68                 .maxShardDataChangeListenerQueueSize(props.getMaxShardDataChangeListenerQueueSize()
69                         .getValue().intValue())
70                 .maxShardDataStoreExecutorQueueSize(props.getMaxShardDataStoreExecutorQueueSize().getValue().intValue())
71                 .shardTransactionIdleTimeoutInMinutes(props.getShardTransactionIdleTimeoutInMinutes().getValue())
72                 .operationTimeoutInSeconds(props.getOperationTimeoutInSeconds().getValue())
73                 .shardJournalRecoveryLogBatchSize(props.getShardJournalRecoveryLogBatchSize()
74                         .getValue().intValue())
75                 .shardSnapshotBatchCount(props.getShardSnapshotBatchCount().getValue().intValue())
76                 .shardSnapshotDataThresholdPercentage(props.getShardSnapshotDataThresholdPercentage()
77                         .getValue().intValue())
78                 .shardHeartbeatIntervalInMillis(props.getShardHeartbeatIntervalInMillis().getValue())
79                 .shardInitializationTimeoutInSeconds(props.getShardInitializationTimeoutInSeconds().getValue())
80                 .shardLeaderElectionTimeoutInSeconds(props.getShardLeaderElectionTimeoutInSeconds().getValue())
81                 .shardTransactionCommitTimeoutInSeconds(
82                         props.getShardTransactionCommitTimeoutInSeconds().getValue().intValue())
83                 .shardTransactionCommitQueueCapacity(
84                         props.getShardTransactionCommitQueueCapacity().getValue().intValue())
85                 .persistent(props.getPersistent().booleanValue())
86                 .shardIsolatedLeaderCheckIntervalInMillis(
87                     props.getShardIsolatedLeaderCheckIntervalInMillis().getValue())
88                 .shardElectionTimeoutFactor(props.getShardElectionTimeoutFactor().getValue())
89                 .transactionCreationInitialRateLimit(props.getTransactionCreationInitialRateLimit().getValue())
90                 .shardBatchedModificationCount(props.getShardBatchedModificationCount().getValue().intValue())
91                 .shardCommitQueueExpiryTimeoutInSeconds(
92                         props.getShardCommitQueueExpiryTimeoutInSeconds().getValue().intValue())
93                 .transactionDebugContextEnabled(props.getTransactionDebugContextEnabled())
94                 .customRaftPolicyImplementation(props.getCustomRaftPolicyImplementation())
95                 .shardSnapshotChunkSize(props.getShardSnapshotChunkSize().getValue().intValue())
96                 .build();
97     }
98
99     public void setBundleContext(BundleContext bundleContext) {
100         this.bundleContext = bundleContext;
101     }
102 }