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 final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
24 final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
25 super(identifier, dependencyResolver);
28 public DistributedConfigDataStoreProviderModule(final ModuleIdentifier identifier,
29 final DependencyResolver dependencyResolver, final DistributedConfigDataStoreProviderModule oldModule,
30 final AutoCloseable oldInstance) {
31 super(identifier, dependencyResolver, oldModule, oldInstance);
35 public void customValidation() {
36 // add custom validation form module attributes here.
40 public boolean canReuseInstance(final AbstractDistributedConfigDataStoreProviderModule oldModule) {
45 public AutoCloseable createInstance() {
46 // The DistributedConfigDataStore is provided via blueprint so wait for and return it here for
47 // backwards compatibility.
48 WaitingServiceTracker<DistributedDataStoreInterface> tracker = WaitingServiceTracker.create(
49 DistributedDataStoreInterface.class, bundleContext, "(type=distributed-config)");
50 DistributedDataStoreInterface delegate = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
51 return new ForwardingDistributedDataStore(delegate, tracker);
54 public static DatastoreContext newDatastoreContext() {
55 return newDatastoreContext(null);
58 private static DatastoreContext newDatastoreContext(final ConfigProperties inProps) {
59 ConfigProperties props = inProps;
61 props = new ConfigProperties();
64 return DatastoreContext.newBuilder()
65 .logicalStoreType(LogicalDatastoreType.CONFIGURATION)
66 .tempFileDirectory("./data")
67 .fileBackedStreamingThresholdInMegabytes(props.getFileBackedStreamingThresholdInMegabytes()
68 .getValue().intValue())
69 .maxShardDataChangeExecutorPoolSize(props.getMaxShardDataChangeExecutorPoolSize().getValue().intValue())
70 .maxShardDataChangeExecutorQueueSize(props.getMaxShardDataChangeExecutorQueueSize()
71 .getValue().intValue())
72 .maxShardDataChangeListenerQueueSize(props.getMaxShardDataChangeListenerQueueSize()
73 .getValue().intValue())
74 .maxShardDataStoreExecutorQueueSize(props.getMaxShardDataStoreExecutorQueueSize().getValue().intValue())
75 .shardTransactionIdleTimeoutInMinutes(props.getShardTransactionIdleTimeoutInMinutes().getValue())
76 .operationTimeoutInSeconds(props.getOperationTimeoutInSeconds().getValue())
77 .shardJournalRecoveryLogBatchSize(props.getShardJournalRecoveryLogBatchSize()
78 .getValue().intValue())
79 .shardSnapshotBatchCount(props.getShardSnapshotBatchCount().getValue().intValue())
80 .shardSnapshotDataThresholdPercentage(props.getShardSnapshotDataThresholdPercentage()
81 .getValue().intValue())
82 .shardHeartbeatIntervalInMillis(props.getShardHeartbeatIntervalInMillis().getValue())
83 .shardInitializationTimeoutInSeconds(props.getShardInitializationTimeoutInSeconds().getValue())
84 .shardLeaderElectionTimeoutInSeconds(props.getShardLeaderElectionTimeoutInSeconds().getValue())
85 .shardTransactionCommitTimeoutInSeconds(
86 props.getShardTransactionCommitTimeoutInSeconds().getValue().intValue())
87 .shardTransactionCommitQueueCapacity(
88 props.getShardTransactionCommitQueueCapacity().getValue().intValue())
89 .persistent(props.getPersistent().booleanValue())
90 .shardIsolatedLeaderCheckIntervalInMillis(
91 props.getShardIsolatedLeaderCheckIntervalInMillis().getValue())
92 .shardElectionTimeoutFactor(props.getShardElectionTimeoutFactor().getValue())
93 .transactionCreationInitialRateLimit(props.getTransactionCreationInitialRateLimit().getValue())
94 .shardBatchedModificationCount(props.getShardBatchedModificationCount().getValue().intValue())
95 .shardCommitQueueExpiryTimeoutInSeconds(
96 props.getShardCommitQueueExpiryTimeoutInSeconds().getValue().intValue())
97 .transactionDebugContextEnabled(props.getTransactionDebugContextEnabled())
98 .customRaftPolicyImplementation(props.getCustomRaftPolicyImplementation())
99 .shardSnapshotChunkSize(props.getShardSnapshotChunkSize().getValue().intValue())
100 .useTellBasedProtocol(props.getUseTellBasedProtocol())
101 .syncIndexThreshold(props.getSyncIndexThreshold().getValue())
105 public void setBundleContext(final BundleContext bundleContext) {
106 this.bundleContext = bundleContext;