X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Ftopology-manager%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fmd%2Fcontroller%2Ftopology%2Fmanager%2FFlowCapableTopologyProvider.java;fp=opendaylight%2Fmd-sal%2Ftopology-manager%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fmd%2Fcontroller%2Ftopology%2Fmanager%2FFlowCapableTopologyProvider.java;h=0000000000000000000000000000000000000000;hb=8644c0d5f1b10c02f68702f023c07ea939885176;hp=556047091c1a779f6af251d9da0e00c50f6c6536;hpb=fdda2ebadfe3729e21448fe8f44a506aa67b5da9;p=controller.git diff --git a/opendaylight/md-sal/topology-manager/src/main/java/org/opendaylight/md/controller/topology/manager/FlowCapableTopologyProvider.java b/opendaylight/md-sal/topology-manager/src/main/java/org/opendaylight/md/controller/topology/manager/FlowCapableTopologyProvider.java deleted file mode 100644 index 556047091c..0000000000 --- a/opendaylight/md-sal/topology-manager/src/main/java/org/opendaylight/md/controller/topology/manager/FlowCapableTopologyProvider.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2013 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.md.controller.topology.manager; - -import java.util.concurrent.ExecutionException; - -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.sal.binding.api.AbstractBindingAwareProvider; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; -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.TopologyBuilder; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.NotificationListener; -import org.osgi.framework.BundleContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class FlowCapableTopologyProvider extends AbstractBindingAwareProvider implements AutoCloseable { - private final static Logger LOG = LoggerFactory.getLogger(FlowCapableTopologyProvider.class); - private ListenerRegistration listenerRegistration; - private Thread thread; - - /** - * Gets called on start of a bundle. - * - * @param session - */ - @Override - public synchronized void onSessionInitiated(final ProviderContext session) { - final DataBroker dataBroker = session.getSALService(DataBroker.class); - final NotificationProviderService notificationService = session.getSALService(NotificationProviderService.class); - - final String name = "flow:1"; - final TopologyKey key = new TopologyKey(new TopologyId(name)); - final InstanceIdentifier path = InstanceIdentifier - .create(NetworkTopology.class) - .child(Topology.class, key); - - final OperationProcessor processor = new OperationProcessor(dataBroker); - final FlowCapableTopologyExporter listener = new FlowCapableTopologyExporter(processor, path); - this.listenerRegistration = notificationService.registerNotificationListener(listener); - - final ReadWriteTransaction tx = dataBroker.newReadWriteTransaction(); - tx.put(LogicalDatastoreType.OPERATIONAL, path, new TopologyBuilder().setKey(key).build(), true); - try { - tx.submit().get(); - } catch (InterruptedException | ExecutionException e) { - LOG.warn("Initial topology export failed, continuing anyway", e); - } - - thread = new Thread(processor); - thread.setDaemon(true); - thread.setName("FlowCapableTopologyExporter-" + name); - thread.start(); - } - - @Override - public synchronized void close() throws InterruptedException { - LOG.info("FlowCapableTopologyProvider stopped."); - if (this.listenerRegistration != null) { - try { - this.listenerRegistration.close(); - } catch (Exception e) { - LOG.error("Failed to close listener registration", e); - } - listenerRegistration = null; - } - if (thread != null) { - thread.interrupt(); - thread.join(); - thread = null; - } - } - - /** - * Gets called during stop bundle - * - * @param context The execution context of the bundle being stopped. - */ - @Override - public void stopImpl(final BundleContext context) { - try { - this.close(); - } catch (InterruptedException e) { - LOG.error("Failed to stop provider", e); - } - } -}