From c4ad68fc5e3d8ef134125c5699724f3bd97ee642 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Mon, 26 Aug 2019 15:20:06 +0200 Subject: [PATCH] Simplify base schema lookups We are checking for notification support multiple times, this refactors the code to that only once. Change-Id: Iaf453fc1de7f22e8a38e296f442c560daf66bf93 Signed-off-by: Robert Varga --- .../sal/connect/netconf/NetconfDevice.java | 30 ++++++------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/NetconfDevice.java b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/NetconfDevice.java index 9f7afe7ae0..a56cd8c057 100644 --- a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/NetconfDevice.java +++ b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/NetconfDevice.java @@ -106,22 +106,6 @@ public class NetconfDevice // Message transformer is constructed once the schemas are available private MessageTransformer messageTransformer; - /** - * Create rpc implementation capable of handling RPC for monitoring and notifications - * even before the schemas of remote device are downloaded. - */ - static NetconfDeviceRpc getRpcForInitialization(final NetconfDeviceCommunicator listener, - final boolean notificationSupport) { - final BaseSchema baseSchema = resolveBaseSchema(notificationSupport); - - return new NetconfDeviceRpc(baseSchema.getSchemaContext(), listener, - new NetconfMessageTransformer(baseSchema.getMountPointContext(), false, baseSchema)); - } - - private static BaseSchema resolveBaseSchema(final boolean notificationSupport) { - return notificationSupport ? BaseSchema.BASE_NETCONF_CTX_WITH_NOTIFICATIONS : BaseSchema.BASE_NETCONF_CTX; - } - public NetconfDevice(final SchemaResourcesDTO schemaResourcesDTO, final RemoteDeviceId id, final RemoteDeviceHandler salFacade, final ListeningExecutorService globalProcessingExecutor, @@ -161,11 +145,11 @@ public class NetconfDevice setConnected(true); LOG.debug("{}: Session to remote device established with {}", id, remoteSessionCapabilities); - final NetconfDeviceRpc initRpc = - getRpcForInitialization(listener, remoteSessionCapabilities.isNotificationsSupported()); - final DeviceSourcesResolver task = - new DeviceSourcesResolver(remoteSessionCapabilities, id, stateSchemasResolver, initRpc, - resolveBaseSchema(remoteSessionCapabilities.isNotificationsSupported()).getSchemaContext()); + final BaseSchema baseSchema = resolveBaseSchema(remoteSessionCapabilities.isNotificationsSupported()); + final NetconfDeviceRpc initRpc = new NetconfDeviceRpc(baseSchema.getSchemaContext(), listener, + new NetconfMessageTransformer(baseSchema.getMountPointContext(), false, baseSchema)); + final DeviceSourcesResolver task = new DeviceSourcesResolver(remoteSessionCapabilities, id, + stateSchemasResolver, initRpc, baseSchema.getSchemaContext()); final ListenableFuture sourceResolverFuture = processingExecutor.submit(task); if (shouldListenOnSchemaChange(remoteSessionCapabilities)) { @@ -307,6 +291,10 @@ public class NetconfDevice notificationHandler.handleNotification(notification); } + private static BaseSchema resolveBaseSchema(final boolean notificationSupport) { + return notificationSupport ? BaseSchema.BASE_NETCONF_CTX_WITH_NOTIFICATIONS : BaseSchema.BASE_NETCONF_CTX; + } + /** * Just a transfer object containing schema related dependencies. Injected in constructor. */ -- 2.36.6