Bug 1435: CDS: Added support for custom commit cohort.
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / config / yang / config / cluster_admin_provider / ClusterAdminProviderModule.java
1 /*
2  * Copyright (c) 2015 Brocade Communications 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.cluster_admin_provider;
10
11 import com.google.common.base.Preconditions;
12 import org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface;
13 import org.opendaylight.controller.cluster.datastore.admin.ClusterAdminRpcService;
14 import org.opendaylight.controller.config.api.DependencyResolver;
15 import org.opendaylight.controller.config.api.ModuleIdentifier;
16
17 public class ClusterAdminProviderModule extends AbstractClusterAdminProviderModule {
18     public ClusterAdminProviderModule(ModuleIdentifier identifier, DependencyResolver dependencyResolver) {
19         super(identifier, dependencyResolver);
20     }
21
22     public ClusterAdminProviderModule(ModuleIdentifier identifier, DependencyResolver dependencyResolver,
23             ClusterAdminProviderModule oldModule, java.lang.AutoCloseable oldInstance) {
24         super(identifier, dependencyResolver, oldModule, oldInstance);
25     }
26
27     @Override
28     public void customValidation() {
29         // add custom validation form module attributes here.
30     }
31
32     @Override
33     public AutoCloseable createInstance() {
34         Preconditions.checkArgument(getConfigDataStoreDependency() instanceof DistributedDataStoreInterface,
35                 "Injected config DOMStore must be an instance of DistributedDataStoreInterface");
36         Preconditions.checkArgument(getOperDataStoreDependency() instanceof DistributedDataStoreInterface,
37                 "Injected operational DOMStore must be an instance of DistributedDataStoreInterface");
38         ClusterAdminRpcService service = new ClusterAdminRpcService(
39                 (DistributedDataStoreInterface)getConfigDataStoreDependency(),
40                 (DistributedDataStoreInterface)getOperDataStoreDependency());
41         service.start(getRpcRegistryDependency());
42         return service;
43     }
44 }