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.cluster.datastore.compat.LegacyDOMStoreAdapter;
14 import org.opendaylight.controller.config.api.DependencyResolver;
15 import org.opendaylight.controller.config.api.ModuleIdentifier;
16 import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
17 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
18 import org.osgi.framework.BundleContext;
21 public class DistributedOperationalDataStoreProviderModule
22 extends AbstractDistributedOperationalDataStoreProviderModule {
23 private BundleContext bundleContext;
25 public DistributedOperationalDataStoreProviderModule(final ModuleIdentifier identifier,
26 final DependencyResolver dependencyResolver) {
27 super(identifier, dependencyResolver);
30 public DistributedOperationalDataStoreProviderModule(final ModuleIdentifier identifier,
31 final DependencyResolver dependencyResolver,final DistributedOperationalDataStoreProviderModule oldModule,
32 final AutoCloseable oldInstance) {
33 super(identifier, dependencyResolver, oldModule, oldInstance);
37 public void customValidation() {
38 // add custom validation form module attributes here.
42 public boolean canReuseInstance(final AbstractDistributedOperationalDataStoreProviderModule oldModule) {
47 public java.lang.AutoCloseable createInstance() {
48 // The DistributedOperDataStore is provided via blueprint so wait for and return it here for
49 // backwards compatibility
50 WaitingServiceTracker<DistributedDataStoreInterface> tracker = WaitingServiceTracker.create(
51 DistributedDataStoreInterface.class, bundleContext, "(type=distributed-operational)");
52 DistributedDataStoreInterface delegate = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
53 return new LegacyDOMStoreAdapter(delegate) {
61 public static DatastoreContext newDatastoreContext() {
62 return newDatastoreContext(null);
65 private static DatastoreContext newDatastoreContext(final OperationalProperties inProps) {
66 OperationalProperties props = inProps;
68 props = new OperationalProperties();
71 return DatastoreContext.newBuilder()
72 .logicalStoreType(LogicalDatastoreType.OPERATIONAL)
73 .tempFileDirectory("./data")
74 .fileBackedStreamingThresholdInMegabytes(props.getFileBackedStreamingThresholdInMegabytes()
75 .getValue().intValue())
76 .maxShardDataChangeExecutorPoolSize(props.getMaxShardDataChangeExecutorPoolSize().getValue().intValue())
77 .maxShardDataChangeExecutorQueueSize(props.getMaxShardDataChangeExecutorQueueSize()
78 .getValue().intValue())
79 .maxShardDataChangeListenerQueueSize(props.getMaxShardDataChangeListenerQueueSize()
80 .getValue().intValue())
81 .maxShardDataStoreExecutorQueueSize(props.getMaxShardDataStoreExecutorQueueSize().getValue().intValue())
82 .shardTransactionIdleTimeoutInMinutes(props.getShardTransactionIdleTimeoutInMinutes().getValue())
83 .operationTimeoutInSeconds(props.getOperationTimeoutInSeconds().getValue())
84 .shardJournalRecoveryLogBatchSize(props.getShardJournalRecoveryLogBatchSize()
85 .getValue().intValue())
86 .shardSnapshotBatchCount(props.getShardSnapshotBatchCount().getValue().intValue())
87 .shardSnapshotDataThresholdPercentage(props.getShardSnapshotDataThresholdPercentage()
88 .getValue().intValue())
89 .shardHeartbeatIntervalInMillis(props.getShardHeartbeatIntervalInMillis().getValue())
90 .shardInitializationTimeoutInSeconds(props.getShardInitializationTimeoutInSeconds().getValue())
91 .shardLeaderElectionTimeoutInSeconds(props.getShardLeaderElectionTimeoutInSeconds().getValue())
92 .shardTransactionCommitTimeoutInSeconds(
93 props.getShardTransactionCommitTimeoutInSeconds().getValue().intValue())
94 .shardTransactionCommitQueueCapacity(
95 props.getShardTransactionCommitQueueCapacity().getValue().intValue())
96 .persistent(props.getPersistent().booleanValue())
97 .shardIsolatedLeaderCheckIntervalInMillis(
98 props.getShardIsolatedLeaderCheckIntervalInMillis().getValue())
99 .shardElectionTimeoutFactor(props.getShardElectionTimeoutFactor().getValue())
100 .transactionCreationInitialRateLimit(props.getTransactionCreationInitialRateLimit().getValue())
101 .shardBatchedModificationCount(props.getShardBatchedModificationCount().getValue().intValue())
102 .shardCommitQueueExpiryTimeoutInSeconds(
103 props.getShardCommitQueueExpiryTimeoutInSeconds().getValue().intValue())
104 .transactionDebugContextEnabled(props.getTransactionDebugContextEnabled())
105 .customRaftPolicyImplementation(props.getCustomRaftPolicyImplementation())
106 .maximumMessageSliceSize(props.getMaximumMessageSliceSize().getValue().intValue())
107 .useTellBasedProtocol(props.getUseTellBasedProtocol())
108 .syncIndexThreshold(props.getSyncIndexThreshold().getValue())
109 .backendAlivenessTimerIntervalInSeconds(props.getBackendAlivenessTimerIntervalInSeconds().getValue())
110 .frontendRequestTimeoutInSeconds(props.getFrontendRequestTimeoutInSeconds().getValue())
111 .frontendNoProgressTimeoutInSeconds(props.getFrontendNoProgressTimeoutInSeconds().getValue())
115 public void setBundleContext(final BundleContext bundleContext) {
116 this.bundleContext = bundleContext;