Bug 4564: Implement GetSnapshot message in ShardManager
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / config / ClusterConfigRpcService.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 package org.opendaylight.controller.cluster.datastore.config;
9
10 import java.util.concurrent.Future;
11 import org.opendaylight.controller.cluster.datastore.DistributedDataStore;
12 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
13 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.config.rev151013.AddShardReplicaInput;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.config.rev151013.ClusterConfigService;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.config.rev151013.ConvertMembersToNonvotingForAllShardsInput;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.config.rev151013.ConvertMembersToVotingForAllShardsInput;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.config.rev151013.RemoveShardReplicaInput;
19 import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
20 import org.opendaylight.yangtools.yang.common.RpcResult;
21 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
24
25 /**
26  * Implements the yang RPCs defined in the generated ClusterConfigService interface.
27  *
28  * @author Thomas Pantelis
29  */
30 public class ClusterConfigRpcService implements ClusterConfigService, AutoCloseable {
31     private static final Logger LOG = LoggerFactory.getLogger(ClusterConfigRpcService.class);
32
33     private final DistributedDataStore configDataStore;
34     private final DistributedDataStore operDataStore;
35     private RpcRegistration<ClusterConfigService> rpcRegistration;
36
37     public ClusterConfigRpcService(DistributedDataStore configDataStore, DistributedDataStore operDataStore) {
38         this.configDataStore = configDataStore;
39         this.operDataStore = operDataStore;
40     }
41
42     public void start(RpcProviderRegistry rpcProviderRegistry) {
43         LOG.debug("ClusterConfigRpcService starting");
44
45         rpcRegistration = rpcProviderRegistry.addRpcImplementation(ClusterConfigService.class, this);
46     }
47
48     @Override
49     public Future<RpcResult<Void>> addShardReplica(AddShardReplicaInput input) {
50         // TODO implement
51         return RpcResultBuilder.<Void>failed().withError(ErrorType.APPLICATION, "operation-not-supported",
52                 "Not implemented yet").buildFuture();
53     }
54
55     @Override
56     public Future<RpcResult<Void>> removeShardReplica(RemoveShardReplicaInput input) {
57         // TODO implement
58         return RpcResultBuilder.<Void>failed().withError(ErrorType.APPLICATION, "operation-not-supported",
59                 "Not implemented yet").buildFuture();
60     }
61
62     @Override
63     public Future<RpcResult<Void>> addReplicasForAllShards() {
64         // TODO implement
65         return RpcResultBuilder.<Void>failed().withError(ErrorType.APPLICATION, "operation-not-supported",
66                 "Not implemented yet").buildFuture();
67     }
68
69     @Override
70     public Future<RpcResult<Void>> removeAllShardReplicas() {
71         // TODO implement
72         return RpcResultBuilder.<Void>failed().withError(ErrorType.APPLICATION, "operation-not-supported",
73                 "Not implemented yet").buildFuture();
74     }
75
76     @Override
77     public Future<RpcResult<Void>> convertMembersToVotingForAllShards(ConvertMembersToVotingForAllShardsInput input) {
78         // TODO implement
79         return RpcResultBuilder.<Void>failed().withError(ErrorType.APPLICATION, "operation-not-supported",
80                 "Not implemented yet").buildFuture();
81     }
82
83     @Override
84     public Future<RpcResult<Void>> convertMembersToNonvotingForAllShards(
85             ConvertMembersToNonvotingForAllShardsInput input) {
86         // TODO implement
87         return RpcResultBuilder.<Void>failed().withError(ErrorType.APPLICATION, "operation-not-supported",
88                 "Not implemented yet").buildFuture();
89     }
90
91     @Override
92     public void close() {
93         if(rpcRegistration != null) {
94             rpcRegistration.close();
95         }
96     }
97 }