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.DatastoreSnapshotRestore;
13 import org.opendaylight.controller.cluster.datastore.DistributedDataStoreFactory;
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 java.lang.AutoCloseable createInstance() {
47 DatastoreContext datastoreContext = newDatastoreContext(getConfigProperties());
49 return DistributedDataStoreFactory.createInstance(getConfigSchemaServiceDependency(),
50 datastoreContext, DatastoreSnapshotRestore.instance(),
51 getConfigActorSystemProviderDependency(), bundleContext);
54 public static DatastoreContext newDatastoreContext() {
55 return newDatastoreContext(null);
58 private static DatastoreContext newDatastoreContext(ConfigProperties inProps) {
59 ConfigProperties props = inProps;
61 props = new ConfigProperties();
64 return DatastoreContext.newBuilder()
65 .logicalStoreType(LogicalDatastoreType.CONFIGURATION)
66 .maxShardDataChangeExecutorPoolSize(props.getMaxShardDataChangeExecutorPoolSize().getValue().intValue())
67 .maxShardDataChangeExecutorQueueSize(props.getMaxShardDataChangeExecutorQueueSize().getValue().intValue())
68 .maxShardDataChangeListenerQueueSize(props.getMaxShardDataChangeListenerQueueSize().getValue().intValue())
69 .maxShardDataStoreExecutorQueueSize(props.getMaxShardDataStoreExecutorQueueSize().getValue().intValue())
70 .shardTransactionIdleTimeoutInMinutes(props.getShardTransactionIdleTimeoutInMinutes().getValue())
71 .operationTimeoutInSeconds(props.getOperationTimeoutInSeconds().getValue())
72 .shardJournalRecoveryLogBatchSize(props.getShardJournalRecoveryLogBatchSize().
73 getValue().intValue())
74 .shardSnapshotBatchCount(props.getShardSnapshotBatchCount().getValue().intValue())
75 .shardSnapshotDataThresholdPercentage(props.getShardSnapshotDataThresholdPercentage().getValue().intValue())
76 .shardHeartbeatIntervalInMillis(props.getShardHeartbeatIntervalInMillis().getValue())
77 .shardInitializationTimeoutInSeconds(props.getShardInitializationTimeoutInSeconds().getValue())
78 .shardLeaderElectionTimeoutInSeconds(props.getShardLeaderElectionTimeoutInSeconds().getValue())
79 .shardTransactionCommitTimeoutInSeconds(
80 props.getShardTransactionCommitTimeoutInSeconds().getValue().intValue())
81 .shardTransactionCommitQueueCapacity(
82 props.getShardTransactionCommitQueueCapacity().getValue().intValue())
83 .persistent(props.getPersistent().booleanValue())
84 .shardIsolatedLeaderCheckIntervalInMillis(
85 props.getShardIsolatedLeaderCheckIntervalInMillis().getValue())
86 .shardElectionTimeoutFactor(props.getShardElectionTimeoutFactor().getValue())
87 .transactionCreationInitialRateLimit(props.getTransactionCreationInitialRateLimit().getValue())
88 .shardBatchedModificationCount(props.getShardBatchedModificationCount().getValue().intValue())
89 .shardCommitQueueExpiryTimeoutInSeconds(
90 props.getShardCommitQueueExpiryTimeoutInSeconds().getValue().intValue())
91 .transactionDebugContextEnabled(props.getTransactionDebugContextEnabled())
92 .customRaftPolicyImplementation(props.getCustomRaftPolicyImplementation())
93 .shardSnapshotChunkSize(props.getShardSnapshotChunkSize().getValue().intValue())
97 public void setBundleContext(BundleContext bundleContext) {
98 this.bundleContext = bundleContext;