From bcfe015f24775d94741b093b3ec2c58e1baac3cc Mon Sep 17 00:00:00 2001 From: Gaurav Agrawal Date: Mon, 18 Sep 2017 10:52:15 +0530 Subject: Replace deprecated APIs with newer one Replace following deprecated API 1) NotificationProviderService replaced with NotificationPublishService 2) InstanceIdentifier toInstance() replace with build() 3) setProperties replaced with setYangMappingProperties Change-Id: I89fba42e88363c5e1e5b23fe272d2754361aee25 Issue-Id: SDNC-89 Signed-off-by: Gaurav Agrawal --- .../main/java/org/onap/sdnc/vnfapi/VnfSdnUtil.java | 2 +- .../java/org/onap/sdnc/vnfapi/vnfapiProvider.java | 35 +++++++++++----------- .../impl/rev140523/VnfapiProviderModule.java | 2 +- .../src/main/resources/initial/vnfapi-provider.xml | 6 ++-- .../src/main/yang/vnfapi-provider-impl.yang | 8 +++-- 5 files changed, 28 insertions(+), 25 deletions(-) diff --git a/vnfapi/provider/src/main/java/org/onap/sdnc/vnfapi/VnfSdnUtil.java b/vnfapi/provider/src/main/java/org/onap/sdnc/vnfapi/VnfSdnUtil.java index a206a8bc..c4d8c52f 100644 --- a/vnfapi/provider/src/main/java/org/onap/sdnc/vnfapi/VnfSdnUtil.java +++ b/vnfapi/provider/src/main/java/org/onap/sdnc/vnfapi/VnfSdnUtil.java @@ -59,7 +59,7 @@ public class VnfSdnUtil extends MdsalHelper { input = new FileInputStream(propFile); properties.load(input); LOG.info("Loaded properties from " + propFileName ); - setProperties(properties); + setYangMappingProperties(properties); } catch (Exception e) { LOG.error("Failed to load properties " + propFileName +"\n",e); } finally { diff --git a/vnfapi/provider/src/main/java/org/onap/sdnc/vnfapi/vnfapiProvider.java b/vnfapi/provider/src/main/java/org/onap/sdnc/vnfapi/vnfapiProvider.java index 60d7e886..9dd1a2a2 100644 --- a/vnfapi/provider/src/main/java/org/onap/sdnc/vnfapi/vnfapiProvider.java +++ b/vnfapi/provider/src/main/java/org/onap/sdnc/vnfapi/vnfapiProvider.java @@ -41,7 +41,7 @@ import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.common.api.data.OptimisticLockFailedException; import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.NetworkTopologyOperationInput; import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.NetworkTopologyOperationInputBuilder; @@ -165,19 +165,18 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL private ListenerRegistration dclServices; protected DataBroker dataBroker; - protected NotificationProviderService notificationService; + protected NotificationPublishService notificationService; protected RpcProviderRegistry rpcRegistry; protected BindingAwareBroker.RpcRegistration rpcRegistration; - public vnfapiProvider(DataBroker dataBroker2, - NotificationProviderService notificationProviderService, + public vnfapiProvider(DataBroker dataBroker2, NotificationPublishService notificationPublishService, RpcProviderRegistry rpcProviderRegistry) { this.log.info( "Creating provider for " + appName ); executor = Executors.newFixedThreadPool(1); dataBroker = dataBroker2; - notificationService = notificationProviderService; + notificationService = notificationPublishService; rpcRegistry = rpcProviderRegistry; initialize(); @@ -550,7 +549,7 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL // See if any data exists yet for this siid, if so grab it. InstanceIdentifier serviceInstanceIdentifier = InstanceIdentifier.builder(Vnfs.class) - .child(VnfList.class, new VnfListKey(siid)).toInstance(); + .child(VnfList.class, new VnfListKey(siid)).build(); ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction(); Optional data = null; try { @@ -590,7 +589,7 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL // See if any data exists yet for this siid, if so grab it. InstanceIdentifier vnfInstanceIdentifier = InstanceIdentifier.builder(VnfInstances.class) - .child(VnfInstanceList.class, new VnfInstanceListKey(siid)).toInstance(); + .child(VnfInstanceList.class, new VnfInstanceListKey(siid)).build(); ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction(); Optional data = null; try { @@ -630,7 +629,7 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL // See if any data exists yet for this siid, if so grab it. InstanceIdentifier vfModuleIdentifier = InstanceIdentifier.builder(VfModules.class) - .child(VfModuleList.class, new VfModuleListKey(siid)).toInstance(); + .child(VfModuleList.class, new VfModuleListKey(siid)).build(); ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction(); Optional data = null; try { @@ -670,7 +669,7 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL // See if any data exists yet for this name/type, if so grab it. InstanceIdentifier preloadInstanceIdentifier = InstanceIdentifier.builder(PreloadVnfs.class) - .child(VnfPreloadList.class, new VnfPreloadListKey(preload_name, preload_type)).toInstance(); + .child(VnfPreloadList.class, new VnfPreloadListKey(preload_name, preload_type)).build(); ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction(); Optional data = null; try { @@ -707,7 +706,7 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL // See if any data exists yet for this name/type, if so grab it. InstanceIdentifier preloadInstanceIdentifier = InstanceIdentifier.builder(PreloadVnfInstances.class) - .child(VnfInstancePreloadList.class, new VnfInstancePreloadListKey(preload_name, preload_type)).toInstance(); + .child(VnfInstancePreloadList.class, new VnfInstancePreloadListKey(preload_name, preload_type)).build(); ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction(); Optional data = null; try { @@ -742,7 +741,7 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL // See if any data exists yet for this name/type, if so grab it. InstanceIdentifier preloadInstanceIdentifier = InstanceIdentifier.builder(PreloadVfModules.class) - .child(VfModulePreloadList.class, new VfModulePreloadListKey(preload_name, preload_type)).toInstance(); + .child(VfModulePreloadList.class, new VfModulePreloadListKey(preload_name, preload_type)).build(); ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction(); Optional data = null; try { @@ -770,7 +769,7 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL InstanceIdentifier.InstanceIdentifierBuilder vnfListIdBuilder = InstanceIdentifier.builder(Vnfs.class) .child(VnfList.class, entry.getKey()); - InstanceIdentifier path = vnfListIdBuilder.toInstance(); + InstanceIdentifier path = vnfListIdBuilder.build(); int tries = 2; while(true) { @@ -804,7 +803,7 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL InstanceIdentifier.InstanceIdentifierBuilder vnfListIdBuilder = InstanceIdentifier.builder(Vnfs.class) .child(VnfList.class, entry.getKey()); - InstanceIdentifier path = vnfListIdBuilder.toInstance(); + InstanceIdentifier path = vnfListIdBuilder.build(); int tries = 2; while (true) { @@ -835,7 +834,7 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL InstanceIdentifier.InstanceIdentifierBuilder vnfInstanceListIdBuilder = InstanceIdentifier.builder(VnfInstances.class) .child(VnfInstanceList.class, entry.getKey()); - InstanceIdentifier path = vnfInstanceListIdBuilder.toInstance(); + InstanceIdentifier path = vnfInstanceListIdBuilder.build(); int tries = 2; while(true) { @@ -870,7 +869,7 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL InstanceIdentifier.InstanceIdentifierBuilder vfModuleListIdBuilder = InstanceIdentifier.builder(VfModules.class) .child(VfModuleList.class, entry.getKey()); - InstanceIdentifier path = vfModuleListIdBuilder.toInstance(); + InstanceIdentifier path = vfModuleListIdBuilder.build(); int tries = 2; while(true) { @@ -905,7 +904,7 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL InstanceIdentifier.InstanceIdentifierBuilder vnfListIdBuilder = InstanceIdentifier.builder(PreloadVnfs.class) .child(VnfPreloadList.class, entry.getKey()); - InstanceIdentifier path = vnfListIdBuilder.toInstance(); + InstanceIdentifier path = vnfListIdBuilder.build(); int tries = 2; while(true) { try { @@ -940,7 +939,7 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL InstanceIdentifier.InstanceIdentifierBuilder vnfInstanceListIdBuilder = InstanceIdentifier.builder(PreloadVnfInstances.class) .child(VnfInstancePreloadList.class, entry.getKey()); - InstanceIdentifier path = vnfInstanceListIdBuilder.toInstance(); + InstanceIdentifier path = vnfInstanceListIdBuilder.build(); int tries = 2; while(true) { try { @@ -975,7 +974,7 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL InstanceIdentifier.InstanceIdentifierBuilder vfModuleListIdBuilder = InstanceIdentifier.builder(PreloadVfModules.class) .child(VfModulePreloadList.class, entry.getKey()); - InstanceIdentifier path = vfModuleListIdBuilder.toInstance(); + InstanceIdentifier path = vfModuleListIdBuilder.build(); int tries = 2; while(true) { try { diff --git a/vnfapi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/onap/sdnc/vnfapi/provider/impl/rev140523/VnfapiProviderModule.java b/vnfapi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/onap/sdnc/vnfapi/provider/impl/rev140523/VnfapiProviderModule.java index 4094800a..5150d085 100644 --- a/vnfapi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/onap/sdnc/vnfapi/provider/impl/rev140523/VnfapiProviderModule.java +++ b/vnfapi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/onap/sdnc/vnfapi/provider/impl/rev140523/VnfapiProviderModule.java @@ -40,7 +40,7 @@ public class VnfapiProviderModule extends org.opendaylight.yang.gen.v1.org.onap. @Override public java.lang.AutoCloseable createInstance() { final vnfapiProvider provider = new vnfapiProvider(getDataBrokerDependency() - , getNotificationServiceDependency() + , getNotificationPublishAdapterDependency() , getRpcRegistryDependency()); return new AutoCloseable() { diff --git a/vnfapi/provider/src/main/resources/initial/vnfapi-provider.xml b/vnfapi/provider/src/main/resources/initial/vnfapi-provider.xml index 01f156d3..3883f674 100644 --- a/vnfapi/provider/src/main/resources/initial/vnfapi-provider.xml +++ b/vnfapi/provider/src/main/resources/initial/vnfapi-provider.xml @@ -50,9 +50,9 @@ - - binding:binding-notification-service - + + binding:binding-new-notification-publish-service + binding-notification-broker diff --git a/vnfapi/provider/src/main/yang/vnfapi-provider-impl.yang b/vnfapi/provider/src/main/yang/vnfapi-provider-impl.yang index c472b65d..183fa901 100644 --- a/vnfapi/provider/src/main/yang/vnfapi-provider-impl.yang +++ b/vnfapi/provider/src/main/yang/vnfapi-provider-impl.yang @@ -6,6 +6,10 @@ module vnfapi-provider-impl { import config { prefix config; revision-date 2013-04-05; } import opendaylight-md-sal-binding { prefix mdsal; revision-date 2013-10-28; } + import opendaylight-sal-binding-broker-impl { + prefix binding-impl; + revision-date 2013-10-28; + } description "This module contains the base YANG definitions for @@ -39,11 +43,11 @@ module vnfapi-provider-impl { } } - container notification-service { + container notification-publish-adapter { uses config:service-ref { refine type { mandatory true; - config:required-identity mdsal:binding-notification-service; + config:required-identity binding-impl:binding-new-notification-publish-service; } } } -- cgit 1.2.3-korg