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.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;
19 public class DistributedConfigDataStoreProviderModule extends AbstractDistributedConfigDataStoreProviderModule {
20 private BundleContext bundleContext;
22 public DistributedConfigDataStoreProviderModule(
23 org.opendaylight.controller.config.api.ModuleIdentifier identifier,
24 org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
25 super(identifier, dependencyResolver);
28 public DistributedConfigDataStoreProviderModule(ModuleIdentifier identifier, DependencyResolver dependencyResolver,
29 DistributedConfigDataStoreProviderModule oldModule, AutoCloseable oldInstance) {
30 super(identifier, dependencyResolver, oldModule, oldInstance);
34 public void customValidation() {
35 // add custom validation form module attributes here.
39 public boolean canReuseInstance(AbstractDistributedConfigDataStoreProviderModule oldModule) {
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);
53 public static DatastoreContext newDatastoreContext() {
54 return newDatastoreContext(null);
57 private static DatastoreContext newDatastoreContext(ConfigProperties inProps) {
58 ConfigProperties props = inProps;
60 props = new ConfigProperties();
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 .useTellBasedProtocol(props.getUseTellBasedProtocol())
100 public void setBundleContext(BundleContext bundleContext) {
101 this.bundleContext = bundleContext;