Do not use RpcService in NETCONF components 51/107751/8
authorOleksandr Zharov <[email protected]>
Thu, 7 Sep 2023 10:32:36 +0000 (12:32 +0200)
committerIvan Hrasko <[email protected]>
Mon, 25 Sep 2023 10:25:39 +0000 (10:25 +0000)
Migrated usage of RpcService to Rpc<?,?> for NETCONF components.

JIRA: NETCONF-1116
Change-Id: I5a7fa47c961c7eb41cb71dcf08da58399d7011b5
Signed-off-by: Oleksandr Zharov <[email protected]>
apps/netconf-topology-impl/src/main/java/org/opendaylight/netconf/topology/impl/NetconfTopologyImpl.java
apps/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/NetconfTopologyManager.java
apps/netconf-topology/src/main/java/org/opendaylight/netconf/topology/spi/NetconfTopologyRPCProvider.java
netconf/tools/netconf-test-perf/src/main/java/org/opendaylight/test/endtoend/EndtoendTestService.java
netconf/tools/netconf-test-perf/src/main/java/org/opendaylight/test/endtoend/NcmountRpcs.java [moved from netconf/tools/netconf-test-perf/src/main/java/org/opendaylight/test/endtoend/NcmountServiceImpl.java with 87% similarity]
plugins/netconf-client-mdsal/src/main/java/org/opendaylight/netconf/client/mdsal/impl/NetconfSalKeystoreRpcs.java [moved from plugins/netconf-client-mdsal/src/main/java/org/opendaylight/netconf/client/mdsal/impl/NetconfSalKeystoreService.java with 80% similarity]
plugins/netconf-client-mdsal/src/test/java/org/opendaylight/netconf/client/mdsal/impl/NetconfSalKeystoreRpcsTest.java [moved from plugins/netconf-client-mdsal/src/test/java/org/opendaylight/netconf/client/mdsal/impl/NetconfSalKeystoreServiceTest.java with 91% similarity]

index c6311f92cc4197b274dc20d3c260bb104e899483..c7327ec1623e65793717a5830fbf9dc4281bdbd7 100644 (file)
@@ -33,7 +33,6 @@ import org.opendaylight.netconf.topology.spi.AbstractNetconfTopology;
 import org.opendaylight.netconf.topology.spi.NetconfClientConfigurationBuilderFactory;
 import org.opendaylight.netconf.topology.spi.NetconfNodeUtils;
 import org.opendaylight.netconf.topology.spi.NetconfTopologyRPCProvider;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev221225.NetconfNodeTopologyService;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
@@ -108,8 +107,8 @@ public class NetconfTopologyImpl extends AbstractNetconfTopology
         LOG.debug("Registering datastore listener");
         dtclReg = dataBroker.registerDataTreeChangeListener(DataTreeIdentifier.create(
             LogicalDatastoreType.CONFIGURATION, createTopologyListPath(topologyId).child(Node.class)), this);
-        rpcReg = rpcProviderService.registerRpcImplementation(NetconfNodeTopologyService.class,
-            new NetconfTopologyRPCProvider(dataBroker, encryptionService, topologyId));
+        final var nodeTopologyRpcs = new NetconfTopologyRPCProvider(dataBroker, encryptionService, topologyId);
+        rpcReg = rpcProviderService.registerRpcImplementations(nodeTopologyRpcs.getRpcClassToInstanceMap());
     }
 
     @PreDestroy
index e89aeb1be56616b983cbc547600830d61afd86f3..67ef8c19c793b13b0f8c88b9c78a67be57303feb 100644 (file)
@@ -54,7 +54,6 @@ import org.opendaylight.netconf.topology.spi.NetconfClientConfigurationBuilderFa
 import org.opendaylight.netconf.topology.spi.NetconfNodeUtils;
 import org.opendaylight.netconf.topology.spi.NetconfTopologyRPCProvider;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev221225.NetconfNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev221225.NetconfNodeTopologyService;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
@@ -186,8 +185,8 @@ public class NetconfTopologyManager implements ClusteredDataTreeChangeListener<N
         this.builderFactory = requireNonNull(builderFactory);
 
         dataChangeListenerRegistration = registerDataTreeChangeListener();
-        rpcReg = rpcProviderService.registerRpcImplementation(NetconfNodeTopologyService.class,
-            new NetconfTopologyRPCProvider(dataBroker, encryptionService, topologyId));
+        final var nodeTopologyRpcs = new NetconfTopologyRPCProvider(dataBroker, encryptionService, topologyId);
+        rpcReg = rpcProviderService.registerRpcImplementations(nodeTopologyRpcs.getRpcClassToInstanceMap());
     }
 
     @Override
index 8ad74f0aadb9f2446ede18228c68ac474cac4a8a..ff528c4bc820321386a22afba50f5068a1b3c9a9 100644 (file)
@@ -10,6 +10,8 @@ package org.opendaylight.netconf.topology.spi;
 import static java.util.Objects.requireNonNull;
 
 import com.google.common.annotations.VisibleForTesting;
+import com.google.common.collect.ClassToInstanceMap;
+import com.google.common.collect.ImmutableClassToInstanceMap;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
@@ -24,15 +26,16 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.device.rev230430.cr
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.device.rev230430.credentials.credentials.LoginPw;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.device.rev230430.credentials.credentials.LoginPwBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.device.rev230430.credentials.credentials.login.pw.LoginPasswordBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev221225.CreateDevice;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev221225.CreateDeviceInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev221225.CreateDeviceOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev221225.CreateDeviceOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev221225.DeleteDevice;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev221225.DeleteDeviceInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev221225.DeleteDeviceOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev221225.DeleteDeviceOutputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev221225.NetconfNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev221225.NetconfNodeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev221225.NetconfNodeTopologyService;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
@@ -41,13 +44,14 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.Rpc;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 @Deprecated
-public class NetconfTopologyRPCProvider implements NetconfNodeTopologyService {
+public class NetconfTopologyRPCProvider {
     private static final Logger LOG = LoggerFactory.getLogger(NetconfTopologyRPCProvider.class);
 
     private final @NonNull InstanceIdentifier<Topology> topologyPath;
@@ -55,20 +59,19 @@ public class NetconfTopologyRPCProvider implements NetconfNodeTopologyService {
     private final @NonNull DataBroker dataBroker;
 
     public NetconfTopologyRPCProvider(final DataBroker dataBroker, final AAAEncryptionService encryptionService,
-                                      final String topologyId) {
+            final String topologyId) {
         this.dataBroker = requireNonNull(dataBroker);
         this.encryptionService = requireNonNull(encryptionService);
         topologyPath = InstanceIdentifier.builder(NetworkTopology.class)
-                .child(Topology.class, new TopologyKey(new TopologyId(topologyId)))
-                .build();
+            .child(Topology.class, new TopologyKey(new TopologyId(topologyId)))
+            .build();
     }
 
     protected final @NonNull InstanceIdentifier<Topology> topologyPath() {
         return topologyPath;
     }
 
-    @Override
-    public final ListenableFuture<RpcResult<CreateDeviceOutput>> createDevice(final CreateDeviceInput input) {
+    private ListenableFuture<RpcResult<CreateDeviceOutput>> createDevice(final CreateDeviceInput input) {
         final NetconfNode node = encryptPassword(input);
         final SettableFuture<RpcResult<CreateDeviceOutput>> futureResult = SettableFuture.create();
         final NodeId nodeId = new NodeId(input.getNodeId());
@@ -76,8 +79,7 @@ public class NetconfTopologyRPCProvider implements NetconfNodeTopologyService {
         return futureResult;
     }
 
-    @Override
-    public final ListenableFuture<RpcResult<DeleteDeviceOutput>> deleteDevice(final DeleteDeviceInput input) {
+    private ListenableFuture<RpcResult<DeleteDeviceOutput>> deleteDevice(final DeleteDeviceInput input) {
         final NodeId nodeId = new NodeId(input.getNodeId());
 
         final InstanceIdentifier<Node> niid = topologyPath.child(Node.class, new NodeKey(nodeId));
@@ -152,4 +154,11 @@ public class NetconfTopologyRPCProvider implements NetconfNodeTopologyService {
             }
         }, MoreExecutors.directExecutor());
     }
+
+    public ClassToInstanceMap<Rpc<?, ?>> getRpcClassToInstanceMap() {
+        return ImmutableClassToInstanceMap.<Rpc<?, ?>>builder()
+            .put(CreateDevice.class, this::createDevice)
+            .put(DeleteDevice.class, this::deleteDevice)
+            .build();
+    }
 }
index 70ded9b936d54f8f37d5aa64754ebd70cd26942e..65960f88fcf9220ca209be5565c28665c9d626de 100644 (file)
@@ -12,7 +12,6 @@ import javax.inject.Inject;
 import javax.inject.Singleton;
 import org.opendaylight.mdsal.binding.api.MountPointService;
 import org.opendaylight.mdsal.binding.api.RpcProviderService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ncmount.rev150105.NcmountService;
 import org.opendaylight.yangtools.concepts.Registration;
 import org.osgi.service.component.annotations.Activate;
 import org.osgi.service.component.annotations.Component;
@@ -28,8 +27,8 @@ public class EndtoendTestService implements AutoCloseable {
     @Activate
     public EndtoendTestService(final @Reference RpcProviderService rpcProviderService,
                                final @Reference MountPointService mountPointService) {
-        registration = rpcProviderService.registerRpcImplementation(NcmountService.class,
-                new NcmountServiceImpl(mountPointService));
+        final var ncmountRpcs = new NcmountRpcs(mountPointService);
+        registration = rpcProviderService.registerRpcImplementations(ncmountRpcs.getRpcClassToInstanceMap());
     }
 
     @Override
similarity index 87%
rename from netconf/tools/netconf-test-perf/src/main/java/org/opendaylight/test/endtoend/NcmountServiceImpl.java
rename to netconf/tools/netconf-test-perf/src/main/java/org/opendaylight/test/endtoend/NcmountRpcs.java
index b80d75b5cd33c288e5a3b55a5785f3b03ca37b0f..e571750aaeca09708d9bbc12a81d1ade56a16441 100644 (file)
@@ -9,6 +9,8 @@ package org.opendaylight.test.endtoend;
 
 import static java.util.Objects.requireNonNull;
 
+import com.google.common.collect.ClassToInstanceMap;
+import com.google.common.collect.ImmutableClassToInstanceMap;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
 import java.util.Map;
@@ -36,11 +38,13 @@ import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.ip._stat
 import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.ip._static.cfg.rev130722.vrf.unicast.VrfUnicastBuilder;
 import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.xr.types.rev150119.CiscoIosXrString;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ncmount.rev150105.ListNodes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ncmount.rev150105.ListNodesInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ncmount.rev150105.ListNodesOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ncmount.rev150105.NcmountService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ncmount.rev150105.ShowNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ncmount.rev150105.ShowNodeInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ncmount.rev150105.ShowNodeOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ncmount.rev150105.WriteRoutes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ncmount.rev150105.WriteRoutesInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ncmount.rev150105.WriteRoutesOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ncmount.rev150105.WriteRoutesOutputBuilder;
@@ -48,20 +52,20 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.Rpc;
 import org.opendaylight.yangtools.yang.binding.util.BindingMap;
 import org.opendaylight.yangtools.yang.common.ErrorType;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 
-public class NcmountServiceImpl implements NcmountService {
+public class NcmountRpcs {
     private final MountPointService mountPointService;
 
-    public NcmountServiceImpl(final MountPointService mountPointService) {
+    public NcmountRpcs(final MountPointService mountPointService) {
         this.mountPointService = requireNonNull(mountPointService);
     }
 
-    @Override
-    public ListenableFuture<RpcResult<WriteRoutesOutput>> writeRoutes(final WriteRoutesInput input) {
+    private ListenableFuture<RpcResult<WriteRoutesOutput>> writeRoutes(final WriteRoutesInput input) {
         final Optional<MountPoint> optMountPoint = mountPointService.getMountPoint(
             NetconfNodeUtils.DEFAULT_TOPOLOGY_IID.child(Node.class, new NodeKey(new NodeId(input.getMountName()))));
         if (optMountPoint.isEmpty()) {
@@ -114,17 +118,23 @@ public class NcmountServiceImpl implements NcmountService {
             MoreExecutors.directExecutor());
     }
 
-    @Override
-    public ListenableFuture<RpcResult<ShowNodeOutput>> showNode(final ShowNodeInput input) {
+    private ListenableFuture<RpcResult<ShowNodeOutput>> showNode(final ShowNodeInput input) {
         return RpcResultBuilder.<ShowNodeOutput>failed()
             .withError(ErrorType.APPLICATION, "Not implemented")
             .buildFuture();
     }
 
-    @Override
-    public ListenableFuture<RpcResult<ListNodesOutput>> listNodes(final ListNodesInput input) {
+    private ListenableFuture<RpcResult<ListNodesOutput>> listNodes(final ListNodesInput input) {
         return RpcResultBuilder.<ListNodesOutput>failed()
             .withError(ErrorType.APPLICATION, "Not implemented")
             .buildFuture();
     }
+
+    public ClassToInstanceMap<Rpc<?, ?>> getRpcClassToInstanceMap() {
+        return ImmutableClassToInstanceMap.<Rpc<?, ?>>builder()
+            .put(WriteRoutes.class, this::writeRoutes)
+            .put(ShowNode.class, this::showNode)
+            .put(ListNodes.class, this::listNodes)
+            .build();
+    }
 }
@@ -9,6 +9,8 @@ package org.opendaylight.netconf.client.mdsal.impl;
 
 import static java.util.Objects.requireNonNull;
 
+import com.google.common.collect.ClassToInstanceMap;
+import com.google.common.collect.ImmutableClassToInstanceMap;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
@@ -24,23 +26,28 @@ import org.opendaylight.mdsal.binding.api.RpcProviderService;
 import org.opendaylight.mdsal.binding.api.WriteTransaction;
 import org.opendaylight.mdsal.common.api.CommitInfo;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.AddKeystoreEntry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.AddKeystoreEntryInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.AddKeystoreEntryOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.AddKeystoreEntryOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.AddPrivateKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.AddPrivateKeyInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.AddPrivateKeyOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.AddPrivateKeyOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.AddTrustedCertificate;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.AddTrustedCertificateInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.AddTrustedCertificateOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.AddTrustedCertificateOutputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.Keystore;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.NetconfKeystoreService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.RemoveKeystoreEntry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.RemoveKeystoreEntryInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.RemoveKeystoreEntryOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.RemoveKeystoreEntryOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.RemovePrivateKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.RemovePrivateKeyInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.RemovePrivateKeyOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.RemovePrivateKeyOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.RemoveTrustedCertificate;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.RemoveTrustedCertificateInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.RemoveTrustedCertificateOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.RemoveTrustedCertificateOutputBuilder;
@@ -53,6 +60,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.trusted.certificates.TrustedCertificateKey;
 import org.opendaylight.yangtools.concepts.Registration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.Rpc;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 import org.osgi.service.component.annotations.Activate;
@@ -64,8 +72,8 @@ import org.slf4j.LoggerFactory;
 
 @Singleton
 @Component(service = { })
-public final class NetconfSalKeystoreService implements NetconfKeystoreService, AutoCloseable {
-    private static final Logger LOG = LoggerFactory.getLogger(NetconfSalKeystoreService.class);
+public final class NetconfSalKeystoreRpcs implements AutoCloseable {
+    private static final Logger LOG = LoggerFactory.getLogger(NetconfSalKeystoreRpcs.class);
     private static final InstanceIdentifier<Keystore> KEYSTORE_IID = InstanceIdentifier.create(Keystore.class);
 
     // FIXME: we are populating config datastore, but there may be risks with concurrent access. We really should be
@@ -76,12 +84,12 @@ public final class NetconfSalKeystoreService implements NetconfKeystoreService,
 
     @Inject
     @Activate
-    public NetconfSalKeystoreService(@Reference final DataBroker dataBroker,
+    public NetconfSalKeystoreRpcs(@Reference final DataBroker dataBroker,
             @Reference final AAAEncryptionService encryptionService, @Reference final RpcProviderService rpcProvider) {
         this.dataBroker = requireNonNull(dataBroker);
         this.encryptionService = requireNonNull(encryptionService);
 
-        reg = rpcProvider.registerRpcImplementation(NetconfKeystoreService.class, this);
+        reg = rpcProvider.registerRpcImplementations(getRpcClassToInstanceMap());
         LOG.info("NETCONF keystore service started");
     }
 
@@ -93,8 +101,7 @@ public final class NetconfSalKeystoreService implements NetconfKeystoreService,
         LOG.info("NETCONF keystore service stopped");
     }
 
-    @Override
-    public ListenableFuture<RpcResult<RemoveKeystoreEntryOutput>> removeKeystoreEntry(
+    private ListenableFuture<RpcResult<RemoveKeystoreEntryOutput>> removeKeystoreEntry(
             final RemoveKeystoreEntryInput input) {
         LOG.debug("Removing keypairs: {}", input);
 
@@ -102,7 +109,7 @@ public final class NetconfSalKeystoreService implements NetconfKeystoreService,
 
         for (final String id : input.getKeyId()) {
             writeTransaction.delete(LogicalDatastoreType.CONFIGURATION,
-                    KEYSTORE_IID.child(KeyCredential.class, new KeyCredentialKey(id)));
+                KEYSTORE_IID.child(KeyCredential.class, new KeyCredentialKey(id)));
         }
 
         final SettableFuture<RpcResult<RemoveKeystoreEntryOutput>> rpcResult = SettableFuture.create();
@@ -124,21 +131,20 @@ public final class NetconfSalKeystoreService implements NetconfKeystoreService,
         return rpcResult;
     }
 
-    @Override
-    public ListenableFuture<RpcResult<AddKeystoreEntryOutput>> addKeystoreEntry(final AddKeystoreEntryInput input) {
+    private ListenableFuture<RpcResult<AddKeystoreEntryOutput>> addKeystoreEntry(final AddKeystoreEntryInput input) {
         LOG.debug("Adding keypairs: {}", input);
 
         final WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
         final List<KeyCredential> keypairs = input.nonnullKeyCredential().values().stream()
-                .map(keypair -> new KeyCredentialBuilder(keypair)
-                        .setPrivateKey(encryptionService.encrypt(keypair.getPrivateKey()))
-                        .setPassphrase(encryptionService.encrypt(keypair.getPassphrase()))
-                        .build())
-                .collect(Collectors.toList());
+            .map(keypair -> new KeyCredentialBuilder(keypair)
+                .setPrivateKey(encryptionService.encrypt(keypair.getPrivateKey()))
+                .setPassphrase(encryptionService.encrypt(keypair.getPassphrase()))
+                .build())
+            .collect(Collectors.toList());
 
         for (KeyCredential keypair : keypairs) {
             writeTransaction.merge(LogicalDatastoreType.CONFIGURATION,
-                    KEYSTORE_IID.child(KeyCredential.class, keypair.key()), keypair);
+                KEYSTORE_IID.child(KeyCredential.class, keypair.key()), keypair);
         }
 
         final SettableFuture<RpcResult<AddKeystoreEntryOutput>> rpcResult = SettableFuture.create();
@@ -160,14 +166,13 @@ public final class NetconfSalKeystoreService implements NetconfKeystoreService,
         return rpcResult;
     }
 
-    @Override
-    public ListenableFuture<RpcResult<AddTrustedCertificateOutput>> addTrustedCertificate(
+    private ListenableFuture<RpcResult<AddTrustedCertificateOutput>> addTrustedCertificate(
             final AddTrustedCertificateInput input) {
         final WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
 
         for (TrustedCertificate certificate : input.nonnullTrustedCertificate().values()) {
             writeTransaction.merge(LogicalDatastoreType.CONFIGURATION,
-                    KEYSTORE_IID.child(TrustedCertificate.class, certificate.key()), certificate);
+                KEYSTORE_IID.child(TrustedCertificate.class, certificate.key()), certificate);
         }
 
         final SettableFuture<RpcResult<AddTrustedCertificateOutput>> rpcResult = SettableFuture.create();
@@ -189,14 +194,13 @@ public final class NetconfSalKeystoreService implements NetconfKeystoreService,
         return rpcResult;
     }
 
-    @Override
-    public ListenableFuture<RpcResult<RemoveTrustedCertificateOutput>> removeTrustedCertificate(
+    private ListenableFuture<RpcResult<RemoveTrustedCertificateOutput>> removeTrustedCertificate(
             final RemoveTrustedCertificateInput input) {
         final WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
 
         for (final String name : input.getName()) {
             writeTransaction.delete(LogicalDatastoreType.CONFIGURATION,
-                    KEYSTORE_IID.child(TrustedCertificate.class, new TrustedCertificateKey(name)));
+                KEYSTORE_IID.child(TrustedCertificate.class, new TrustedCertificateKey(name)));
         }
 
         final SettableFuture<RpcResult<RemoveTrustedCertificateOutput>> rpcResult = SettableFuture.create();
@@ -218,13 +222,12 @@ public final class NetconfSalKeystoreService implements NetconfKeystoreService,
         return rpcResult;
     }
 
-    @Override
-    public ListenableFuture<RpcResult<AddPrivateKeyOutput>> addPrivateKey(final AddPrivateKeyInput input) {
+    private ListenableFuture<RpcResult<AddPrivateKeyOutput>> addPrivateKey(final AddPrivateKeyInput input) {
         final WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
 
         for (PrivateKey key: input.nonnullPrivateKey().values()) {
             writeTransaction.merge(LogicalDatastoreType.CONFIGURATION,
-                    KEYSTORE_IID.child(PrivateKey.class, key.key()), key);
+                KEYSTORE_IID.child(PrivateKey.class, key.key()), key);
         }
 
         final SettableFuture<RpcResult<AddPrivateKeyOutput>> rpcResult = SettableFuture.create();
@@ -246,13 +249,12 @@ public final class NetconfSalKeystoreService implements NetconfKeystoreService,
         return rpcResult;
     }
 
-    @Override
-    public ListenableFuture<RpcResult<RemovePrivateKeyOutput>> removePrivateKey(final RemovePrivateKeyInput input) {
+    private ListenableFuture<RpcResult<RemovePrivateKeyOutput>> removePrivateKey(final RemovePrivateKeyInput input) {
         final WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
 
         for (final String name : input.getName()) {
             writeTransaction.delete(LogicalDatastoreType.CONFIGURATION,
-                    KEYSTORE_IID.child(PrivateKey.class, new PrivateKeyKey(name)));
+                KEYSTORE_IID.child(PrivateKey.class, new PrivateKeyKey(name)));
         }
 
         final SettableFuture<RpcResult<RemovePrivateKeyOutput>> rpcResult = SettableFuture.create();
@@ -273,4 +275,15 @@ public final class NetconfSalKeystoreService implements NetconfKeystoreService,
 
         return rpcResult;
     }
+
+    public ClassToInstanceMap<Rpc<?, ?>> getRpcClassToInstanceMap() {
+        return ImmutableClassToInstanceMap.<Rpc<?, ?>>builder()
+            .put(RemoveKeystoreEntry.class, this::removeKeystoreEntry)
+            .put(AddKeystoreEntry.class, this::addKeystoreEntry)
+            .put(AddTrustedCertificate.class, this::addTrustedCertificate)
+            .put(RemoveTrustedCertificate.class, this::removeTrustedCertificate)
+            .put(AddPrivateKey.class, this::addPrivateKey)
+            .put(RemovePrivateKey.class, this::removePrivateKey)
+            .build();
+    }
 }
@@ -8,7 +8,6 @@
 package org.opendaylight.netconf.client.mdsal.impl;
 
 import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.times;
@@ -30,11 +29,12 @@ import org.opendaylight.mdsal.binding.api.RpcProviderService;
 import org.opendaylight.mdsal.binding.api.WriteTransaction;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.netconf.api.xml.XmlUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.AddPrivateKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.AddPrivateKeyInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.AddPrivateKeyInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.AddTrustedCertificate;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.AddTrustedCertificateInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.AddTrustedCertificateInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.NetconfKeystoreService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017._private.keys.PrivateKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017._private.keys.PrivateKeyBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017._private.keys.PrivateKeyKey;
@@ -50,7 +50,7 @@ import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
 @RunWith(MockitoJUnitRunner.StrictStubs.class)
-public class NetconfSalKeystoreServiceTest {
+public class NetconfSalKeystoreRpcsTest {
     private static final String XML_ELEMENT_PRIVATE_KEY = "private-key";
     private static final String XML_ELEMENT_NAME = "name";
     private static final String XML_ELEMENT_DATA = "data";
@@ -74,16 +74,16 @@ public class NetconfSalKeystoreServiceTest {
         doReturn(writeTx).when(dataBroker).newWriteOnlyTransaction();
         doNothing().when(writeTx)
             .merge(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(DataObject.class));
-        doReturn(rpcReg).when(rpcProvider).registerRpcImplementation(eq(NetconfKeystoreService.class), any());
+        doReturn(rpcReg).when(rpcProvider).registerRpcImplementations(any());
         doNothing().when(rpcReg).close();
     }
 
     @Test
     public void testAddPrivateKey() throws Exception {
         doReturn(emptyFluentFuture()).when(writeTx).commit();
-        try (var keystoreService = new NetconfSalKeystoreService(dataBroker, encryptionService, rpcProvider)) {
+        try (var keystoreService = new NetconfSalKeystoreRpcs(dataBroker, encryptionService, rpcProvider)) {
             final AddPrivateKeyInput input = getPrivateKeyInput();
-            keystoreService.addPrivateKey(input);
+            keystoreService.getRpcClassToInstanceMap().getInstance(AddPrivateKey.class).invoke(input).get();
 
             verify(writeTx, times(input.nonnullPrivateKey().size()))
                 .merge(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(DataObject.class));
@@ -93,9 +93,9 @@ public class NetconfSalKeystoreServiceTest {
     @Test
     public void testAddTrustedCertificate() throws Exception {
         doReturn(emptyFluentFuture()).when(writeTx).commit();
-        try (var keystoreService = new NetconfSalKeystoreService(dataBroker, encryptionService, rpcProvider)) {
-            final AddTrustedCertificateInput input = getTrustedCertificateInput();
-            keystoreService.addTrustedCertificate(input);
+        try (var keystoreService = new NetconfSalKeystoreRpcs(dataBroker, encryptionService, rpcProvider)) {
+            final var input = getTrustedCertificateInput();
+            keystoreService.getRpcClassToInstanceMap().getInstance(AddTrustedCertificate.class).invoke(input).get();
 
             verify(writeTx, times(input.nonnullTrustedCertificate().size()))
                 .merge(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(DataObject.class));