2 * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.controller.config.yang.config.distributed_datastore_provider;
11 import org.opendaylight.controller.cluster.datastore.DatastoreContext;
12 import org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface;
13 import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
14 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
15 import org.osgi.framework.BundleContext;
17 public class DistributedConfigDataStoreProviderModule extends
18 org.opendaylight.controller.config.yang.config.distributed_datastore_provider.AbstractDistributedConfigDataStoreProviderModule {
19 private BundleContext bundleContext;
21 public DistributedConfigDataStoreProviderModule(
22 org.opendaylight.controller.config.api.ModuleIdentifier identifier,
23 org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
24 super(identifier, dependencyResolver);
27 public DistributedConfigDataStoreProviderModule(
28 org.opendaylight.controller.config.api.ModuleIdentifier identifier,
29 org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
30 org.opendaylight.controller.config.yang.config.distributed_datastore_provider.DistributedConfigDataStoreProviderModule oldModule,
31 java.lang.AutoCloseable oldInstance) {
32 super(identifier, dependencyResolver, oldModule, oldInstance);
36 public void customValidation() {
37 // add custom validation form module attributes here.
41 public boolean canReuseInstance(AbstractDistributedConfigDataStoreProviderModule oldModule) {
46 public AutoCloseable createInstance() {
47 // The DistributedConfigDataStore is provided via blueprint so wait for and return it here for
48 // backwards compatibility.
49 WaitingServiceTracker<DistributedDataStoreInterface> tracker = WaitingServiceTracker.create(
50 DistributedDataStoreInterface.class, bundleContext, "(type=distributed-config)");
51 DistributedDataStoreInterface delegate = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
52 return new ForwardingDistributedDataStore(delegate, tracker);
55 public static DatastoreContext newDatastoreContext() {
56 return newDatastoreContext(null);
59 private static DatastoreContext newDatastoreContext(ConfigProperties inProps) {
60 ConfigProperties props = inProps;
62 props = new ConfigProperties();
65 return DatastoreContext.newBuilder()
66 .logicalStoreType(LogicalDatastoreType.CONFIGURATION)
67 .maxShardDataChangeExecutorPoolSize(props.getMaxShardDataChangeExecutorPoolSize().getValue().intValue())
68 .maxShardDataChangeExecutorQueueSize(props.getMaxShardDataChangeExecutorQueueSize().getValue().intValue())
69 .maxShardDataChangeListenerQueueSize(props.getMaxShardDataChangeListenerQueueSize().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().getValue().intValue())
77 .shardHeartbeatIntervalInMillis(props.getShardHeartbeatIntervalInMillis().getValue())
78 .shardInitializationTimeoutInSeconds(props.getShardInitializationTimeoutInSeconds().getValue())
79 .shardLeaderElectionTimeoutInSeconds(props.getShardLeaderElectionTimeoutInSeconds().getValue())
80 .shardTransactionCommitTimeoutInSeconds(
81 props.getShardTransactionCommitTimeoutInSeconds().getValue().intValue())
82 .shardTransactionCommitQueueCapacity(
83 props.getShardTransactionCommitQueueCapacity().getValue().intValue())
84 .persistent(props.getPersistent().booleanValue())
85 .shardIsolatedLeaderCheckIntervalInMillis(
86 props.getShardIsolatedLeaderCheckIntervalInMillis().getValue())
87 .shardElectionTimeoutFactor(props.getShardElectionTimeoutFactor().getValue())
88 .transactionCreationInitialRateLimit(props.getTransactionCreationInitialRateLimit().getValue())
89 .shardBatchedModificationCount(props.getShardBatchedModificationCount().getValue().intValue())
90 .shardCommitQueueExpiryTimeoutInSeconds(
91 props.getShardCommitQueueExpiryTimeoutInSeconds().getValue().intValue())
92 .transactionDebugContextEnabled(props.getTransactionDebugContextEnabled())
93 .customRaftPolicyImplementation(props.getCustomRaftPolicyImplementation())
94 .shardSnapshotChunkSize(props.getShardSnapshotChunkSize().getValue().intValue())
98 public void setBundleContext(BundleContext bundleContext) {
99 this.bundleContext = bundleContext;