From: Tony Tkacik Date: Wed, 28 May 2014 08:37:44 +0000 (+0000) Subject: Merge changes I1ba91f59,I6d69f9da,I99ddffb1,I6fdc9d42 X-Git-Tag: autorelease-tag-v20140601202136_82eb3f9~15 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=8a52609ed4f230b72c0608632f14d2c607e36e06;hp=040d3eee776e73591337781c122f11b81aa02d40 Merge changes I1ba91f59,I6d69f9da,I99ddffb1,I6fdc9d42 * changes: BUG-625: convert TopologyProvider BUG-625: convert TopologyMapping BUG-625: convert TopologyAdapter BUG-625: split off SalCompatibilityProvider --- diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/ComponentActivator.xtend b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/ComponentActivator.xtend index 57682bc6c9..d65dee6571 100644 --- a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/ComponentActivator.xtend +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/ComponentActivator.xtend @@ -13,12 +13,6 @@ import java.util.Hashtable import org.apache.felix.dm.Component import org.opendaylight.controller.clustering.services.IClusterGlobalServices import org.opendaylight.controller.sal.binding.api.BindingAwareBroker -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext -import org.opendaylight.controller.sal.binding.api.BindingAwareProvider -import org.opendaylight.controller.sal.binding.api.NotificationService -import org.opendaylight.controller.sal.binding.api.data.DataBrokerService -import org.opendaylight.controller.sal.binding.api.data.DataProviderService import org.opendaylight.controller.sal.compatibility.adsal.DataPacketServiceAdapter import org.opendaylight.controller.sal.compatibility.topology.TopologyAdapter import org.opendaylight.controller.sal.compatibility.topology.TopologyProvider @@ -39,12 +33,6 @@ import org.opendaylight.controller.sal.topology.IPluginOutTopologyService import org.opendaylight.controller.sal.utils.GlobalConstants import org.opendaylight.controller.sal.utils.INodeConnectorFactory import org.opendaylight.controller.sal.utils.INodeFactory -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsService -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsService -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.FlowTopologyDiscoveryService -import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService -import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsService import org.osgi.framework.BundleContext import static org.opendaylight.controller.sal.compatibility.NodeMapping.* @@ -204,55 +192,3 @@ class ComponentActivator extends ComponentActivatorAbstractBase { return props; } } -package class SalCompatibilityProvider implements BindingAwareProvider { - - private val ComponentActivator activator; - - new(ComponentActivator cmpAct) { - activator = cmpAct; - } - - override getFunctionality() { - // Noop - } - - override getImplementations() { - // Noop - } - - - override onSessionInitialized(ConsumerContext session) { - // Noop - } - - - override onSessionInitiated(ProviderContext session) { - val it = activator - val subscribe = session.getSALService(NotificationService) - - // Registration of Flow Service - flow.delegate = session.getRpcService(SalFlowService) - flow.dataBrokerService = session.getSALService(DataBrokerService); - subscribe.registerNotificationListener(flow); - - // Data Packet Service - subscribe.registerNotificationListener(inventory); - dataPacketService.delegate = session.getRpcService(PacketProcessingService) - - // Inventory Service - inventory.dataService = session.getSALService(DataBrokerService); - inventory.flowStatisticsService = session.getRpcService(OpendaylightFlowStatisticsService); - inventory.flowTableStatisticsService = session.getRpcService(OpendaylightFlowTableStatisticsService); - inventory.nodeConnectorStatisticsService = session.getRpcService(OpendaylightPortStatisticsService); - inventory.topologyDiscovery = session.getRpcService(FlowTopologyDiscoveryService); - inventory.dataProviderService = session.getSALService(DataProviderService) - topology.dataService = session.getSALService(DataProviderService) - tpProvider.dataService = session.getSALService(DataProviderService) - - inventory.startAdapter(); - - tpProvider.startAdapter(); - - subscribe.registerNotificationListener(dataPacket) - } -} diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/SalCompatibilityProvider.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/SalCompatibilityProvider.java new file mode 100644 index 0000000000..0ddbcaa2e0 --- /dev/null +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/SalCompatibilityProvider.java @@ -0,0 +1,88 @@ +/** + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.controller.sal.compatibility; + +import java.util.Collection; +import java.util.Collections; + +import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext; +import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext; +import org.opendaylight.controller.sal.binding.api.BindingAwareProvider; +import org.opendaylight.controller.sal.binding.api.NotificationService; +import org.opendaylight.controller.sal.binding.api.data.DataBrokerService; +import org.opendaylight.controller.sal.binding.api.data.DataProviderService; +import org.opendaylight.controller.sal.compatibility.adsal.DataPacketServiceAdapter; +import org.opendaylight.controller.sal.compatibility.topology.TopologyAdapter; +import org.opendaylight.controller.sal.compatibility.topology.TopologyProvider; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsService; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsService; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.FlowTopologyDiscoveryService; +import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService; +import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsService; +import org.opendaylight.yangtools.yang.binding.RpcService; + +import com.google.common.base.Preconditions; + +class SalCompatibilityProvider implements BindingAwareProvider { + private final ComponentActivator activator; + + public SalCompatibilityProvider(final ComponentActivator cmpAct) { + this.activator = Preconditions.checkNotNull(cmpAct); + } + + @Override + public Collection getFunctionality() { + return Collections.emptyList(); + } + + @Override + public Collection getImplementations() { + return Collections.emptyList(); + } + + @Override + public void onSessionInitialized(final ConsumerContext session) { + // No-op + } + + @Override + public void onSessionInitiated(final ProviderContext session) { + final NotificationService subscribe = session.getSALService(NotificationService.class); + + final FlowProgrammerAdapter flow = activator.getFlow(); + flow.setDelegate(session.getRpcService(SalFlowService.class)); + flow.setDataBrokerService(session.getSALService(DataBrokerService.class)); + // FIXME: remember registration for clean shutdown + subscribe.registerNotificationListener(flow); + + final InventoryAndReadAdapter inv = activator.getInventory(); + inv.setDataService(session.getSALService(DataBrokerService.class)); + inv.setFlowStatisticsService(session.getRpcService(OpendaylightFlowStatisticsService.class)); + inv.setFlowTableStatisticsService(session.getRpcService(OpendaylightFlowTableStatisticsService.class)); + inv.setNodeConnectorStatisticsService(session.getRpcService(OpendaylightPortStatisticsService.class)); + inv.setTopologyDiscovery(session.getRpcService(FlowTopologyDiscoveryService.class)); + inv.setDataProviderService(session.getSALService(DataProviderService.class)); + // FIXME: remember registration for clean shutdown + subscribe.registerNotificationListener(inv); + + final DataPacketServiceAdapter dps = activator.getDataPacketService(); + dps.setDelegate(session.getRpcService(PacketProcessingService.class)); + + final TopologyAdapter topo = activator.getTopology(); + topo.setDataService(session.getSALService(DataProviderService.class)); + + final TopologyProvider tpp = activator.getTpProvider(); + tpp.setDataService(session.getSALService(DataProviderService.class)); + + inv.startAdapter(); + tpp.startAdapter(); + + subscribe.registerNotificationListener(activator.getDataPacket()); + } +} diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyAdapter.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyAdapter.java new file mode 100644 index 0000000000..b609addae4 --- /dev/null +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyAdapter.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.controller.sal.compatibility.topology; + +import org.opendaylight.controller.md.sal.binding.util.TypeSafeDataReader; +import org.opendaylight.controller.sal.binding.api.data.DataProviderService; +import org.opendaylight.controller.sal.topology.IPluginInTopologyService; +import org.opendaylight.controller.sal.topology.IPluginOutTopologyService; +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.TopologyId; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +import com.google.common.base.Preconditions; + +public class TopologyAdapter implements IPluginInTopologyService { + private final InstanceIdentifier topology = InstanceIdentifier.builder(NetworkTopology.class) + .child(Topology.class, new TopologyKey(new TopologyId("flow:1"))).toInstance(); + + // FIXME: seems to be unused + private IPluginOutTopologyService topologyPublisher; + private DataProviderService dataService; + + public void setDataService(final DataProviderService dataService) { + this.dataService = Preconditions.checkNotNull(dataService); + } + + @Override + public void sollicitRefresh() { + final TypeSafeDataReader reader = TypeSafeDataReader.forReader(dataService); + final Topology t = reader.readOperationalData(topology); + topologyPublisher.edgeUpdate(TopologyMapping.toADEdgeUpdates(t, reader)); + } +} diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyAdapter.xtend b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyAdapter.xtend deleted file mode 100644 index 4ce57afe9e..0000000000 --- a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyAdapter.xtend +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.compatibility.topology - -import org.opendaylight.controller.md.sal.binding.util.TypeSafeDataReader -import org.opendaylight.controller.sal.binding.api.data.DataProviderService -import org.opendaylight.controller.sal.topology.IPluginInTopologyService -import org.opendaylight.controller.sal.topology.IPluginOutTopologyService -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.TopologyId -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier - -import static extension org.opendaylight.controller.sal.compatibility.topology.TopologyMapping.* - -class TopologyAdapter implements IPluginInTopologyService { - - @Property - DataProviderService dataService; - - @Property - IPluginOutTopologyService topologyPublisher; - - override sollicitRefresh() { - val path = InstanceIdentifier.builder(NetworkTopology).child(Topology,new TopologyKey(new TopologyId("flow:1"))).toInstance; - val reader = TypeSafeDataReader.forReader(dataService) - val topology = reader.readOperationalData(path) - topologyPublisher.edgeUpdate(topology.toADEdgeUpdates(reader)) - } - -} diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyMapping.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyMapping.java new file mode 100644 index 0000000000..476a71a4ac --- /dev/null +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyMapping.java @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.controller.sal.compatibility.topology; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.List; +import java.util.Set; +import java.util.concurrent.CopyOnWriteArrayList; + +import org.opendaylight.controller.md.sal.binding.util.TypeSafeDataReader; +import org.opendaylight.controller.sal.compatibility.NodeMapping; +import org.opendaylight.controller.sal.core.ConstructionException; +import org.opendaylight.controller.sal.core.Edge; +import org.opendaylight.controller.sal.core.Node; +import org.opendaylight.controller.sal.core.NodeConnector; +import org.opendaylight.controller.sal.core.Property; +import org.opendaylight.controller.sal.core.UpdateType; +import org.opendaylight.controller.sal.topology.TopoEdgeUpdate; +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef; +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.TpId; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.Function; +import com.google.common.collect.FluentIterable; + +public final class TopologyMapping { + private static final Logger LOG = LoggerFactory.getLogger(TopologyMapping.class); + + private TopologyMapping() { + throw new UnsupportedOperationException("Utility class. Instantiation is not allowed."); + } + + public static List toADEdgeUpdates(final Topology topology,final TypeSafeDataReader reader) { + final List result = new CopyOnWriteArrayList<>(); + return FluentIterable.from(topology.getLink()).transform( + new Function() { + @Override + public TopoEdgeUpdate apply(final Link input) { + try { + return toTopoEdgeUpdate(toAdEdge(input, topology), reader); + } catch (ConstructionException e) { + throw new IllegalArgumentException(String.format("Failed to construct edge update for {}", input), e); + } + }} + ).copyInto(result); + } + + public static Edge toAdEdge(final Link link, final Topology topology) throws ConstructionException { + final NodeConnector adSrc = toADNodeConnector(link.getSource().getSourceTp(), link.getSource().getSourceNode()); + final NodeConnector adDst = toADNodeConnector(link.getDestination().getDestTp(), link.getDestination().getDestNode()); + return new Edge(adSrc, adDst); + } + + public static TopoEdgeUpdate toTopoEdgeUpdate(final Edge e, final TypeSafeDataReader reader) { + return toTopoEdgeUpdate(e, UpdateType.ADDED, reader); + } + + public static TopoEdgeUpdate toTopoEdgeUpdate(final Edge e,final UpdateType type,final TypeSafeDataReader reader) { + return new TopoEdgeUpdate(e, toAdEdgeProperties(e, reader), type); + } + + public static Set toAdEdgeProperties(final Edge e,final TypeSafeDataReader reader) { + final NodeConnectorRef ncref = NodeMapping.toNodeConnectorRef(e.getTailNodeConnector()); + if(ncref == null) { + LOG.debug("Edge {} ncref {}",e,ncref); + return null; + } + + @SuppressWarnings("unchecked") + final InstanceIdentifier ncInstanceId = + (InstanceIdentifier) ncref.getValue(); + if(ncInstanceId == null) { + LOG.debug("Edge {} ncref {}",e,ncref); + return null; + } + + final org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector nc = reader.readOperationalData(ncInstanceId); + if(nc == null) { + return null; + } + return NodeMapping.toADNodeConnectorProperties(nc); + } + + public static String toADNodeId(final NodeId nodeId) { + return nodeId.getValue(); + } + + public static NodeConnector toADNodeConnector(final TpId source, final NodeId nodeId) throws ConstructionException { + checkNotNull(source); + return new NodeConnector(NodeMapping.MD_SAL_TYPE, toADNodeConnectorId(source), toADNode(nodeId)); + } + + public static String toADNodeConnectorId(final TpId nodeConnectorId) { + return nodeConnectorId.getValue(); + } + + public static Node toADNode(final NodeId nodeId) throws ConstructionException { + checkNotNull(nodeId); + return new Node(NodeMapping.MD_SAL_TYPE, toADNodeId(nodeId)); + } +} diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyMapping.xtend b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyMapping.xtend deleted file mode 100644 index 2d490564e1..0000000000 --- a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyMapping.xtend +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.compatibility.topology - -import com.google.common.collect.FluentIterable -import java.util.List -import java.util.concurrent.CopyOnWriteArrayList -import org.opendaylight.controller.md.sal.binding.util.TypeSafeDataReader -import org.opendaylight.controller.sal.core.ConstructionException -import org.opendaylight.controller.sal.core.Edge -import org.opendaylight.controller.sal.core.Node -import org.opendaylight.controller.sal.core.NodeConnector -import org.opendaylight.controller.sal.core.UpdateType -import org.opendaylight.controller.sal.topology.TopoEdgeUpdate -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.TpId -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier -import org.slf4j.LoggerFactory - -import static com.google.common.base.Preconditions.* - -import static extension org.opendaylight.controller.sal.compatibility.NodeMapping.* - -class TopologyMapping { - private static val LOG = LoggerFactory.getLogger(TopologyMapping); - private new() { - throw new UnsupportedOperationException("Utility class. Instantiation is not allowed."); - } - - public static def toADEdgeUpdates(Topology topology,TypeSafeDataReader reader) { - val List result = new CopyOnWriteArrayList() - return FluentIterable.from(topology.link).transform[toAdEdge(topology).toTopoEdgeUpdate(reader)].copyInto(result) - } - - public static def toAdEdge(Link link,Topology topology) { - val adSrc = link.source.sourceTp.toADNodeConnector(link.source.sourceNode) - val adDst = link.destination.destTp.toADNodeConnector(link.destination.destNode) - return new Edge(adSrc,adDst); - } - - public static def toTopoEdgeUpdate(Edge e,TypeSafeDataReader reader) { - return toTopoEdgeUpdate(e,UpdateType.ADDED,reader) - } - - public static def toTopoEdgeUpdate(Edge e,UpdateType type,TypeSafeDataReader reader) { - return new TopoEdgeUpdate(e,e.toAdEdgeProperties(reader),type) - } - - public static def toAdEdgeProperties(Edge e,TypeSafeDataReader reader) { - val ncref = e.tailNodeConnector.toNodeConnectorRef - if(ncref == null) { - LOG.debug("Edge {} ncref {}",e,ncref) - return null; - } - val ncInstanceId = (ncref.value as InstanceIdentifier) - if(ncInstanceId == null) { - LOG.debug("Edge {} ncref {}",e,ncref) - return null; - } - val nc = reader.readOperationalData(ncInstanceId) - if(nc == null) { - return null; - } - return nc.toADNodeConnectorProperties - } - - public static def toADNodeId(NodeId nodeId) { - checkNotNull(nodeId); - return nodeId.value - } - public static def toADNodeConnector(TpId source,NodeId nodeId) throws ConstructionException { - checkNotNull(source); - return new NodeConnector(MD_SAL_TYPE,source.toADNodeConnectorId,nodeId.toADNode) - } - - public static def toADNodeConnectorId(TpId nodeConnectorId) { - return nodeConnectorId.value - } - - public static def toADNode(NodeId nodeId) { - checkNotNull(nodeId); - return new Node(MD_SAL_TYPE,nodeId.toADNodeId); - } -} diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyProvider.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyProvider.java new file mode 100644 index 0000000000..d78bce4787 --- /dev/null +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyProvider.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.controller.sal.compatibility.topology; + +import org.opendaylight.controller.sal.binding.api.data.DataChangeListener; +import org.opendaylight.controller.sal.binding.api.data.DataProviderService; +import org.opendaylight.controller.sal.topology.IPluginOutTopologyService; +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.TopologyId; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link; +import org.opendaylight.yangtools.concepts.ListenerRegistration; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.Preconditions; + +public class TopologyProvider implements AutoCloseable{ + private static final Logger LOG = LoggerFactory.getLogger(TopologyProvider.class); + private static final InstanceIdentifier PATH = InstanceIdentifier.builder(NetworkTopology.class) + .child(Topology.class ,new TopologyKey(new TopologyId("flow:1"))) + .child(Link.class) + .toInstance(); + private TopologyCommitHandler commitHandler; + + private ListenerRegistration listenerRegistration; + private IPluginOutTopologyService topologyPublisher; + private DataProviderService dataService; + + public void startAdapter() { + if(dataService == null){ + LOG.error("dataService not set"); + return; + } + commitHandler = new TopologyCommitHandler(dataService,topologyPublisher); + listenerRegistration = dataService.registerDataChangeListener(PATH, commitHandler); + LOG.info("TopologyProvider started"); + } + + @Override + public void close() { + if (listenerRegistration != null) { + listenerRegistration.close(); + } + } + + void setTopologyPublisher(final IPluginOutTopologyService topologyPublisher) { + this.topologyPublisher = topologyPublisher; + if (commitHandler != null) { + commitHandler.setTopologyPublisher(topologyPublisher); + } + } + + public void setDataService(final DataProviderService dataService) { + this.dataService = Preconditions.checkNotNull(dataService); + } +} diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyProvider.xtend b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyProvider.xtend deleted file mode 100644 index 21f2b35f40..0000000000 --- a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyProvider.xtend +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.sal.compatibility.topology - -import org.opendaylight.controller.sal.binding.api.data.DataProviderService -import org.opendaylight.controller.sal.topology.IPluginOutTopologyService -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.TopologyId -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey -import org.opendaylight.yangtools.yang.binding.DataObject -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link -import org.slf4j.LoggerFactory -import org.opendaylight.yangtools.concepts.ListenerRegistration -import org.opendaylight.controller.sal.binding.api.data.DataChangeListener - -class TopologyProvider implements AutoCloseable{ - static val LOG = LoggerFactory.getLogger(TopologyProvider); - TopologyCommitHandler commitHandler - - @Property - IPluginOutTopologyService topologyPublisher; - - @Property - DataProviderService dataService; - - ListenerRegistration listenerRegistration - - - def void start() { - - } - def void startAdapter() { - if(dataService == null){ - LOG.error("dataService not set"); - return; - } - commitHandler = new TopologyCommitHandler(dataService,topologyPublisher); - val InstanceIdentifier path = InstanceIdentifier.builder(NetworkTopology) - .child(Topology,new TopologyKey(new TopologyId("flow:1"))) - .child(Link) - .toInstance(); - listenerRegistration = dataService.registerDataChangeListener(path,commitHandler); - LOG.info("TopologyProvider started") - } - - override close() throws Exception { - listenerRegistration.close - } - - def setTopologyPublisher(IPluginOutTopologyService topologyPublisher) { - _topologyPublisher = topologyPublisher; - if(commitHandler != null){ - commitHandler.setTopologyPublisher(topologyPublisher); - } - } - -}