Add missing license headers
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / config / yang / config / distributed_datastore_provider / DistributedOperationalDataStoreProviderModule.java
1 /*
2  * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.controller.config.yang.config.distributed_datastore_provider;
10
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;
16
17 public class DistributedOperationalDataStoreProviderModule extends
18     org.opendaylight.controller.config.yang.config.distributed_datastore_provider.AbstractDistributedOperationalDataStoreProviderModule {
19     private BundleContext bundleContext;
20
21     public DistributedOperationalDataStoreProviderModule(
22         org.opendaylight.controller.config.api.ModuleIdentifier identifier,
23         org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
24         super(identifier, dependencyResolver);
25     }
26
27     public DistributedOperationalDataStoreProviderModule(
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.DistributedOperationalDataStoreProviderModule oldModule,
31         java.lang.AutoCloseable oldInstance) {
32         super(identifier, dependencyResolver, oldModule, oldInstance);
33     }
34
35     @Override
36     public void customValidation() {
37         // add custom validation form module attributes here.
38     }
39
40     @Override
41     public boolean canReuseInstance(AbstractDistributedOperationalDataStoreProviderModule oldModule) {
42         return true;
43     }
44
45     @Override
46     public java.lang.AutoCloseable createInstance() {
47
48         OperationalProperties props = getOperationalProperties();
49         if(props == null) {
50             props = new OperationalProperties();
51         }
52
53         DatastoreContext datastoreContext = DatastoreContext.newBuilder()
54                 .logicalStoreType(LogicalDatastoreType.OPERATIONAL)
55                 .maxShardDataChangeExecutorPoolSize(props.getMaxShardDataChangeExecutorPoolSize().getValue().intValue())
56                 .maxShardDataChangeExecutorQueueSize(props.getMaxShardDataChangeExecutorQueueSize().getValue().intValue())
57                 .maxShardDataChangeListenerQueueSize(props.getMaxShardDataChangeListenerQueueSize().getValue().intValue())
58                 .maxShardDataStoreExecutorQueueSize(props.getMaxShardDataStoreExecutorQueueSize().getValue().intValue())
59                 .shardTransactionIdleTimeoutInMinutes(props.getShardTransactionIdleTimeoutInMinutes().getValue())
60                 .operationTimeoutInSeconds(props.getOperationTimeoutInSeconds().getValue())
61                 .shardJournalRecoveryLogBatchSize(props.getShardJournalRecoveryLogBatchSize().
62                         getValue().intValue())
63                 .shardSnapshotBatchCount(props.getShardSnapshotBatchCount().getValue().intValue())
64                 .shardSnapshotDataThresholdPercentage(props.getShardSnapshotDataThresholdPercentage().getValue().intValue())
65                 .shardHeartbeatIntervalInMillis(props.getShardHeartbeatIntervalInMillis().getValue())
66                 .shardInitializationTimeoutInSeconds(props.getShardInitializationTimeoutInSeconds().getValue())
67                 .shardLeaderElectionTimeoutInSeconds(props.getShardLeaderElectionTimeoutInSeconds().getValue())
68                 .shardTransactionCommitTimeoutInSeconds(
69                         props.getShardTransactionCommitTimeoutInSeconds().getValue().intValue())
70                 .shardTransactionCommitQueueCapacity(
71                         props.getShardTransactionCommitQueueCapacity().getValue().intValue())
72                 .persistent(props.getPersistent().booleanValue())
73                 .shardIsolatedLeaderCheckIntervalInMillis(
74                         props.getShardIsolatedLeaderCheckIntervalInMillis().getValue())
75                 .shardElectionTimeoutFactor(props.getShardElectionTimeoutFactor().getValue())
76                 .transactionCreationInitialRateLimit(props.getTransactionCreationInitialRateLimit().getValue())
77                 .shardBatchedModificationCount(props.getShardBatchedModificationCount().getValue().intValue())
78                 .shardCommitQueueExpiryTimeoutInSeconds(
79                         props.getShardCommitQueueExpiryTimeoutInSeconds().getValue().intValue())
80                 .transactionDebugContextEnabled(props.getTransactionDebugContextEnabled())
81                 .customRaftPolicyImplementation(props.getCustomRaftPolicyImplementation())
82                 .shardSnapshotChunkSize(props.getShardSnapshotChunkSize().getValue().intValue())
83                 .build();
84
85         return DistributedDataStoreFactory.createInstance(getOperationalSchemaServiceDependency(),
86                 datastoreContext, DatastoreSnapshotRestore.instance().getAndRemove(datastoreContext.getDataStoreName()),
87                 getOperationalActorSystemProviderDependency().getActorSystem(), bundleContext);
88     }
89
90     public void setBundleContext(BundleContext bundleContext) {
91         this.bundleContext = bundleContext;
92     }
93
94 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.