X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=tapi%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Ftapi%2Fimpl%2FTapiProvider.java;h=6c3f77a858427a7d85acbdd1f8297331e30a7b2b;hb=b1b3bafd549bb501937cea5c976d5344608b6ed3;hp=dc03a1f3e0c0c2933003a51d5bff7381036b5dea;hpb=4d94935b354ae96badf10d8f70dd293a34f8c2d2;p=transportpce.git diff --git a/tapi/src/main/java/org/opendaylight/transportpce/tapi/impl/TapiProvider.java b/tapi/src/main/java/org/opendaylight/transportpce/tapi/impl/TapiProvider.java index dc03a1f3e..6c3f77a85 100644 --- a/tapi/src/main/java/org/opendaylight/transportpce/tapi/impl/TapiProvider.java +++ b/tapi/src/main/java/org/opendaylight/transportpce/tapi/impl/TapiProvider.java @@ -15,6 +15,7 @@ import org.opendaylight.mdsal.binding.api.DataTreeIdentifier; import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.mdsal.binding.api.NotificationService; import org.opendaylight.mdsal.binding.api.RpcProviderService; +import org.opendaylight.mdsal.binding.api.RpcService; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.transportpce.common.InstanceIdentifiers; import org.opendaylight.transportpce.common.NetworkUtils; @@ -22,9 +23,10 @@ import org.opendaylight.transportpce.common.network.NetworkTransactionService; import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations; import org.opendaylight.transportpce.tapi.connectivity.ConnectivityUtils; import org.opendaylight.transportpce.tapi.connectivity.TapiConnectivityImpl; -import org.opendaylight.transportpce.tapi.listeners.TapiPceListenerImpl; -import org.opendaylight.transportpce.tapi.listeners.TapiRendererListenerImpl; -import org.opendaylight.transportpce.tapi.listeners.TapiServiceHandlerListenerImpl; +import org.opendaylight.transportpce.tapi.listeners.TapiNetworkModelNotificationHandler; +import org.opendaylight.transportpce.tapi.listeners.TapiPceNotificationHandler; +import org.opendaylight.transportpce.tapi.listeners.TapiRendererNotificationHandler; +import org.opendaylight.transportpce.tapi.listeners.TapiServiceNotificationHandler; import org.opendaylight.transportpce.tapi.topology.TapiNetconfTopologyListener; import org.opendaylight.transportpce.tapi.topology.TapiNetworkModelService; import org.opendaylight.transportpce.tapi.topology.TapiOrLinkListener; @@ -36,26 +38,15 @@ import org.opendaylight.transportpce.tapi.utils.TapiInitialORMapping; import org.opendaylight.transportpce.tapi.utils.TapiLink; import org.opendaylight.transportpce.tapi.utils.TapiLinkImpl; import org.opendaylight.transportpce.tapi.utils.TapiListener; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.TransportpcePceListener; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.Network; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.network.Nodes; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.TransportpceRendererListener; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev201125.TransportpceServicehandlerListener; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.tapinetworkutils.rev210408.TransportpceTapinetworkutilsService; -import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.OrgOpenroadmServiceService; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev231221.Network; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev231221.network.Nodes; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NetworkId; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.Networks; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.NetworkKey; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Network1; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.TapiCommonService; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.TapiConnectivityService; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.TapiNotificationListener; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.TapiTopologyService; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.tapi.rev180928.ServiceInterfacePoints; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.tapi.rev230728.ServiceInterfacePoints; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.concepts.ObjectRegistration; import org.opendaylight.yangtools.concepts.Registration; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.osgi.service.component.annotations.Activate; @@ -78,47 +69,34 @@ public class TapiProvider { private static final InstanceIdentifier MAPPING_II = InstanceIdentifier.create(Network.class) .child(org.opendaylight.yang.gen.v1.http - .org.opendaylight.transportpce.portmapping.rev220922.network.Nodes.class); + .org.opendaylight.transportpce.portmapping.rev231221.network.Nodes.class); private static final InstanceIdentifier LINK_II = InstanceIdentifier.create(Networks.class).child( org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network.class, new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID))).augmentation(Network1.class) .child(Link.class); private final DataBroker dataBroker; - private final RpcProviderService rpcProviderService; - private final NotificationService notificationService; private final NetworkTransactionService networkTransactionService; - private final OrgOpenroadmServiceService serviceHandler; private final ServiceDataStoreOperations serviceDataStoreOperations; - private final TransportpceTapinetworkutilsService tapiNetworkUtils; - private TapiNotificationListener tapiNetworkModelListenerImpl; - private ObjectRegistration rpcRegistration; - private ObjectRegistration tapiNetworkutilsServiceRpcRegistration; private List listeners; - private ListenerRegistration pcelistenerRegistration; - private ListenerRegistration rendererlistenerRegistration; - private ListenerRegistration servicehandlerlistenerRegistration; - private ListenerRegistration tapinetworkmodellistenerRegistration; + private List rpcRegistrations = new ArrayList<>(); + private Registration pcelistenerRegistration; + private Registration rendererlistenerRegistration; + private Registration servicehandlerlistenerRegistration; + private Registration tapinetworkmodellistenerRegistration; @Activate public TapiProvider(@Reference DataBroker dataBroker, @Reference RpcProviderService rpcProviderService, + @Reference RpcService rpcService, @Reference NotificationService notificationService, @Reference NotificationPublishService notificationPublishService, @Reference NetworkTransactionService networkTransactionService, - @Reference OrgOpenroadmServiceService serviceHandler, @Reference ServiceDataStoreOperations serviceDataStoreOperations, - @Reference TransportpceTapinetworkutilsService tapiNetworkUtils, - @Reference TapiNotificationListener tapiNetworkModelListenerImpl, + @Reference TapiNetworkModelNotificationHandler tapiNetworkModelNotificationHandler, @Reference TapiNetworkModelService tapiNetworkModelServiceImpl) { this.dataBroker = dataBroker; - this.rpcProviderService = rpcProviderService; - this.notificationService = notificationService; this.networkTransactionService = networkTransactionService; - this.serviceHandler = serviceHandler; this.serviceDataStoreOperations = serviceDataStoreOperations; - this.tapiNetworkUtils = tapiNetworkUtils; - this.tapiNetworkModelListenerImpl = tapiNetworkModelListenerImpl; - LOG.info("TapiProvider Session Initiated"); TapiContext tapiContext = new TapiContext(this.networkTransactionService); LOG.info("Empty TAPI context created: {}", tapiContext.getTapiContext()); @@ -130,47 +108,43 @@ public class TapiProvider { tapiContext, this.serviceDataStoreOperations); tapiInitialORMapping.performTopoInitialMapping(); tapiInitialORMapping.performServInitialMapping(); - TapiPceListenerImpl pceListenerImpl = new TapiPceListenerImpl(dataBroker); - TapiRendererListenerImpl rendererListenerImpl = new TapiRendererListenerImpl(dataBroker, + TapiPceNotificationHandler pceListenerImpl = new TapiPceNotificationHandler(dataBroker, connectivityUtils); + TapiRendererNotificationHandler rendererListenerImpl = new TapiRendererNotificationHandler(dataBroker, notificationPublishService); - TapiConnectivityImpl tapi = new TapiConnectivityImpl(this.serviceHandler, tapiContext, connectivityUtils, - pceListenerImpl, rendererListenerImpl); - TapiTopologyImpl topo = new TapiTopologyImpl(this.dataBroker, tapiContext, topologyUtils, tapiLink); - - rpcRegistration = rpcProviderService.registerRpcImplementation(TapiConnectivityService.class, tapi); - rpcProviderService.registerRpcImplementation(TapiTopologyService.class, topo); - rpcProviderService.registerRpcImplementation(TapiCommonService.class, topo); + TapiConnectivityImpl tapiConnectivity = new TapiConnectivityImpl(rpcService, tapiContext, + connectivityUtils, pceListenerImpl, rendererListenerImpl, networkTransactionService); + rpcRegistrations.add(rpcProviderService.registerRpcImplementations(tapiConnectivity.registerRPCs())); + TapiTopologyImpl topo = new TapiTopologyImpl(networkTransactionService, tapiContext, topologyUtils, tapiLink); + rpcRegistrations.add(rpcProviderService.registerRpcImplementations(topo.registerRPCs())); this.listeners = new ArrayList<>(); TapiNetconfTopologyListener topologyListener = new TapiNetconfTopologyListener(tapiNetworkModelServiceImpl); TapiOrLinkListener orLinkListener = new TapiOrLinkListener(tapiLink, networkTransactionService); TapiPortMappingListener tapiPortMappingListener = new TapiPortMappingListener(tapiNetworkModelServiceImpl); - listeners.add(dataBroker.registerDataTreeChangeListener( - DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION, LINK_II), orLinkListener)); - listeners.add(dataBroker.registerDataTreeChangeListener( - DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, InstanceIdentifiers.NETCONF_TOPOLOGY_II + listeners.add(dataBroker.registerTreeChangeListener( + DataTreeIdentifier.of(LogicalDatastoreType.CONFIGURATION, LINK_II), orLinkListener)); + listeners.add(dataBroker.registerTreeChangeListener( + DataTreeIdentifier.of(LogicalDatastoreType.OPERATIONAL, InstanceIdentifiers.NETCONF_TOPOLOGY_II .child(Node.class)), topologyListener)); - listeners.add(dataBroker.registerDataTreeChangeListener( - DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION, MAPPING_II), tapiPortMappingListener)); - tapiNetworkutilsServiceRpcRegistration = - rpcProviderService.registerRpcImplementation(TransportpceTapinetworkutilsService.class, - this.tapiNetworkUtils); + listeners.add(dataBroker.registerTreeChangeListener( + DataTreeIdentifier.of(LogicalDatastoreType.CONFIGURATION, MAPPING_II), tapiPortMappingListener)); TapiListener tapiListener = new TapiListener(); - listeners.add(dataBroker.registerDataTreeChangeListener( - DataTreeIdentifier.create( + listeners.add(dataBroker.registerTreeChangeListener( + DataTreeIdentifier.of( LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(ServiceInterfacePoints.class)), tapiListener)); // Notification Listener - pcelistenerRegistration = notificationService.registerNotificationListener(pceListenerImpl); - rendererlistenerRegistration = notificationService.registerNotificationListener(rendererListenerImpl); - TapiServiceHandlerListenerImpl serviceHandlerListenerImpl = new TapiServiceHandlerListenerImpl(dataBroker); + pcelistenerRegistration = notificationService.registerCompositeListener(pceListenerImpl.getCompositeListener()); + rendererlistenerRegistration = notificationService + .registerCompositeListener(rendererListenerImpl.getCompositeListener()); + TapiServiceNotificationHandler serviceHandlerListenerImpl = new TapiServiceNotificationHandler(dataBroker); servicehandlerlistenerRegistration = notificationService - .registerNotificationListener(serviceHandlerListenerImpl); + .registerCompositeListener(serviceHandlerListenerImpl.getCompositeListener()); tapinetworkmodellistenerRegistration = notificationService - .registerNotificationListener(tapiNetworkModelListenerImpl); + .registerCompositeListener(tapiNetworkModelNotificationHandler.getCompositeListener()); } /** @@ -180,14 +154,18 @@ public class TapiProvider { public void close() { listeners.forEach(lis -> lis.close()); listeners.clear(); - if (tapiNetworkutilsServiceRpcRegistration != null) { - tapiNetworkutilsServiceRpcRegistration.close(); - } pcelistenerRegistration.close(); rendererlistenerRegistration.close(); servicehandlerlistenerRegistration.close(); - rpcRegistration.close(); tapinetworkmodellistenerRegistration.close(); + for (Registration reg : rpcRegistrations) { + reg.close(); + } LOG.info("TapiProvider Session Closed"); } + + public List getRegisteredRpcs() { + return rpcRegistrations; + } + }