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=f5cb9dd76c2efdc07011114fa9ab90c3d83f30fb;hb=HEAD;hp=0f87998752fc82b895f5338895f6c4de0bd69478;hpb=4629e64c30400e7d4ee57d046ef4a4f9cb64c31a;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 0f8799875..f5cb9dd76 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 @@ -7,52 +7,62 @@ */ package org.opendaylight.transportpce.tapi.impl; +import java.util.ArrayList; import java.util.HashMap; -import org.eclipse.jdt.annotation.NonNull; +import java.util.List; import org.opendaylight.mdsal.binding.api.DataBroker; 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; 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.TapiNetworkModelListenerImpl; -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.impl.rpc.CreateConnectivityServiceImpl; +import org.opendaylight.transportpce.tapi.impl.rpc.DeleteConnectivityServiceImpl; +import org.opendaylight.transportpce.tapi.impl.rpc.GetConnectionDetailsImpl; +import org.opendaylight.transportpce.tapi.impl.rpc.GetConnectivityServiceDetailsImpl; +import org.opendaylight.transportpce.tapi.impl.rpc.GetConnectivityServiceListImpl; +import org.opendaylight.transportpce.tapi.impl.rpc.GetLinkDetailsImpl; +import org.opendaylight.transportpce.tapi.impl.rpc.GetNodeDetailsImpl; +import org.opendaylight.transportpce.tapi.impl.rpc.GetNodeEdgePointDetailsImpl; +import org.opendaylight.transportpce.tapi.impl.rpc.GetServiceInterfacePointDetailsImpl; +import org.opendaylight.transportpce.tapi.impl.rpc.GetServiceInterfacePointListImpl; +import org.opendaylight.transportpce.tapi.impl.rpc.GetTopologyDetailsImpl; +import org.opendaylight.transportpce.tapi.impl.rpc.GetTopologyListImpl; +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; import org.opendaylight.transportpce.tapi.topology.TapiPortMappingListener; -import org.opendaylight.transportpce.tapi.topology.TapiTopologyImpl; import org.opendaylight.transportpce.tapi.topology.TopologyUtils; import org.opendaylight.transportpce.tapi.utils.TapiContext; 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.rev220615.TransportpcePceListener; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.Network; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.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.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; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Deactivate; +import org.osgi.service.component.annotations.Reference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -62,76 +72,45 @@ import org.slf4j.LoggerFactory; * @author Gilles Thouenon (gilles.thouenon@orange.com) on behalf of Orange * */ +@Component public class TapiProvider { private static final Logger LOG = LoggerFactory.getLogger(TapiProvider.class); private static final InstanceIdentifier MAPPING_II = InstanceIdentifier.create(Network.class) .child(org.opendaylight.yang.gen.v1.http - .org.opendaylight.transportpce.portmapping.rev220316.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 ObjectRegistration rpcRegistration; - private ObjectRegistration tapiNetworkutilsServiceRpcRegistration; - private ListenerRegistration dataTreeChangeListenerRegistration; - private ListenerRegistration dataTreeChangeListenerRegistration1; - private ListenerRegistration mappingListenerListenerRegistration; - private ListenerRegistration pcelistenerRegistration; - private ListenerRegistration rendererlistenerRegistration; - private ListenerRegistration servicehandlerlistenerRegistration; - private ListenerRegistration tapinetworkmodellistenerRegistration; - private final OrgOpenroadmServiceService serviceHandler; - private final ServiceDataStoreOperations serviceDataStoreOperations; - private final TapiListener tapiListener; - private final TapiNetconfTopologyListener topologyListener; - private final TapiOrLinkListener orLinkListener; - private TapiPortMappingListener tapiPortMappingListener; private final NetworkTransactionService networkTransactionService; - private final TransportpceTapinetworkutilsService tapiNetworkUtils; - private TapiPceListenerImpl pceListenerImpl; - private TapiRendererListenerImpl rendererListenerImpl; - private TapiServiceHandlerListenerImpl serviceHandlerListenerImpl; - private final NotificationService notificationService; - private TapiNetworkModelListenerImpl tapiNetworkModelListenerImpl; + private final ServiceDataStoreOperations serviceDataStoreOperations; + private List listeners; + private Registration rpcRegistration; + private Registration pcelistenerRegistration; + private Registration rendererlistenerRegistration; + private Registration servicehandlerlistenerRegistration; + private Registration tapinetworkmodellistenerRegistration; - public TapiProvider(DataBroker dataBroker, RpcProviderService rpcProviderService, - OrgOpenroadmServiceService serviceHandler,ServiceDataStoreOperations serviceDataStoreOperations, - TapiListener tapiListener, NetworkTransactionService networkTransactionService, - TapiNetconfTopologyListener topologyListener, TapiPortMappingListener tapiPortMappingListener, - TransportpceTapinetworkutilsService tapiNetworkUtils, TapiPceListenerImpl pceListenerImpl, - TapiRendererListenerImpl rendererListenerImpl, TapiServiceHandlerListenerImpl serviceHandlerListenerImpl, - NotificationService notificationService, TapiOrLinkListener orLinkListener, - TapiNetworkModelListenerImpl tapiNetworkModelListenerImpl) { + @Activate + public TapiProvider(@Reference DataBroker dataBroker, + @Reference RpcProviderService rpcProviderService, + @Reference RpcService rpcService, + @Reference NotificationService notificationService, + @Reference NotificationPublishService notificationPublishService, + @Reference NetworkTransactionService networkTransactionService, + @Reference ServiceDataStoreOperations serviceDataStoreOperations, + @Reference TapiNetworkModelNotificationHandler tapiNetworkModelNotificationHandler, + @Reference TapiNetworkModelService tapiNetworkModelServiceImpl) { this.dataBroker = dataBroker; - this.rpcProviderService = rpcProviderService; - this.serviceHandler = serviceHandler; - this.serviceDataStoreOperations = serviceDataStoreOperations; - this.tapiListener = tapiListener; this.networkTransactionService = networkTransactionService; - this.topologyListener = topologyListener; - this.tapiPortMappingListener = tapiPortMappingListener; - this.tapiNetworkUtils = tapiNetworkUtils; - this.pceListenerImpl = pceListenerImpl; - this.rendererListenerImpl = rendererListenerImpl; - this.serviceHandlerListenerImpl = serviceHandlerListenerImpl; - this.notificationService = notificationService; - this.orLinkListener = orLinkListener; - this.tapiNetworkModelListenerImpl = tapiNetworkModelListenerImpl; - //this.notificationPublishService = notificationPublishService; - } - - /** - * Method called when the blueprint container is created. - */ - public void init() { + this.serviceDataStoreOperations = serviceDataStoreOperations; LOG.info("TapiProvider Session Initiated"); TapiContext tapiContext = new TapiContext(this.networkTransactionService); LOG.info("Empty TAPI context created: {}", tapiContext.getTapiContext()); - TapiLink tapiLink = new TapiLink(this.networkTransactionService); + TapiLink tapiLink = new TapiLinkImpl(this.networkTransactionService); TopologyUtils topologyUtils = new TopologyUtils(this.networkTransactionService, this.dataBroker, tapiLink); ConnectivityUtils connectivityUtils = new ConnectivityUtils(this.serviceDataStoreOperations, new HashMap<>(), tapiContext, this.networkTransactionService); @@ -139,60 +118,71 @@ public class TapiProvider { tapiContext, this.serviceDataStoreOperations); tapiInitialORMapping.performTopoInitialMapping(); tapiInitialORMapping.performServInitialMapping(); + 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.registerRpcImplementations( + new CreateConnectivityServiceImpl(rpcService, tapiContext, connectivityUtils, pceListenerImpl, + rendererListenerImpl), + new GetConnectivityServiceDetailsImpl(tapiContext), + new GetConnectionDetailsImpl(tapiContext), + new DeleteConnectivityServiceImpl(rpcService, tapiContext, networkTransactionService), + new GetConnectivityServiceListImpl(tapiContext), + new GetNodeDetailsImpl(tapiContext), + new GetTopologyDetailsImpl(tapiContext, topologyUtils, tapiLink, networkTransactionService), + new GetNodeEdgePointDetailsImpl(tapiContext), + new GetLinkDetailsImpl(tapiContext), + new GetTopologyListImpl(tapiContext), + new GetServiceInterfacePointDetailsImpl(tapiContext), + new GetServiceInterfacePointListImpl(tapiContext)); - rpcRegistration = rpcProviderService.registerRpcImplementation(TapiConnectivityService.class, tapi); - rpcProviderService.registerRpcImplementation(TapiTopologyService.class, topo); - rpcProviderService.registerRpcImplementation(TapiCommonService.class, topo); - dataTreeChangeListenerRegistration1 = - dataBroker.registerDataTreeChangeListener(DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION, - LINK_II), orLinkListener); - dataTreeChangeListenerRegistration = - dataBroker.registerDataTreeChangeListener(DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, - InstanceIdentifiers.NETCONF_TOPOLOGY_II.child(Node.class)), topologyListener); - mappingListenerListenerRegistration = - dataBroker.registerDataTreeChangeListener(DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION, - MAPPING_II), tapiPortMappingListener); - tapiNetworkutilsServiceRpcRegistration = - rpcProviderService.registerRpcImplementation(TransportpceTapinetworkutilsService.class, - this.tapiNetworkUtils); - @NonNull - InstanceIdentifier sipIID = InstanceIdentifier.create(ServiceInterfacePoints.class); - dataBroker.registerDataTreeChangeListener(DataTreeIdentifier.create( - LogicalDatastoreType.CONFIGURATION, sipIID), tapiListener); + this.listeners = new ArrayList<>(); + TapiNetconfTopologyListener topologyListener = new TapiNetconfTopologyListener(tapiNetworkModelServiceImpl); + TapiOrLinkListener orLinkListener = new TapiOrLinkListener(tapiLink, networkTransactionService); + TapiPortMappingListener tapiPortMappingListener = new TapiPortMappingListener(tapiNetworkModelServiceImpl); + 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.registerTreeChangeListener( + DataTreeIdentifier.of(LogicalDatastoreType.CONFIGURATION, MAPPING_II), tapiPortMappingListener)); + TapiListener tapiListener = new TapiListener(); + listeners.add(dataBroker.registerTreeChangeListener( + DataTreeIdentifier.of( + LogicalDatastoreType.CONFIGURATION, + InstanceIdentifier.create(ServiceInterfacePoints.class)), + tapiListener)); // Notification Listener - pcelistenerRegistration = notificationService.registerNotificationListener(pceListenerImpl); - rendererlistenerRegistration = notificationService.registerNotificationListener(rendererListenerImpl); - servicehandlerlistenerRegistration = - notificationService.registerNotificationListener(serviceHandlerListenerImpl); - tapinetworkmodellistenerRegistration = - notificationService.registerNotificationListener(tapiNetworkModelListenerImpl); + pcelistenerRegistration = notificationService.registerCompositeListener(pceListenerImpl.getCompositeListener()); + rendererlistenerRegistration = notificationService + .registerCompositeListener(rendererListenerImpl.getCompositeListener()); + TapiServiceNotificationHandler serviceHandlerListenerImpl = new TapiServiceNotificationHandler(dataBroker); + servicehandlerlistenerRegistration = notificationService + .registerCompositeListener(serviceHandlerListenerImpl.getCompositeListener()); + tapinetworkmodellistenerRegistration = notificationService + .registerCompositeListener(tapiNetworkModelNotificationHandler.getCompositeListener()); } /** * Method called when the blueprint container is destroyed. */ + @Deactivate public void close() { - LOG.info("TapiProvider Session Closed"); - if (dataTreeChangeListenerRegistration != null) { - dataTreeChangeListenerRegistration.close(); - } - if (mappingListenerListenerRegistration != null) { - mappingListenerListenerRegistration.close(); - } - if (dataTreeChangeListenerRegistration1 != null) { - dataTreeChangeListenerRegistration1.close(); - } - if (tapiNetworkutilsServiceRpcRegistration != null) { - tapiNetworkutilsServiceRpcRegistration.close(); - } + listeners.forEach(lis -> lis.close()); + listeners.clear(); pcelistenerRegistration.close(); rendererlistenerRegistration.close(); servicehandlerlistenerRegistration.close(); - rpcRegistration.close(); tapinetworkmodellistenerRegistration.close(); + rpcRegistration.close(); + LOG.info("TapiProvider Session Closed"); } + + public Registration getRegisteredRpcs() { + return rpcRegistration; + } + }