2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package io.fd.honeycomb.vbd.impl;
11 import com.google.common.base.Preconditions;
12 import javax.annotation.Nonnull;
13 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
14 import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
15 import org.opendaylight.controller.md.sal.binding.api.MountPointService;
16 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vbridge.topology.rev160129.TopologyTypesVbridgeAugment;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vbridge.topology.rev160129.network.topology.topology.topology.types.VbridgeTopology;
19 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
20 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
21 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.TopologyTypes;
22 import org.opendaylight.yangtools.concepts.ListenerRegistration;
23 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
28 * Tip for the Virtual Bridge Domain implementation. This class is instantiated when the application is started
29 * and {@link #close()}d when it is shut down.
31 public final class VirtualBridgeDomainManager implements AutoCloseable {
32 private static final Logger LOG = LoggerFactory.getLogger(VirtualBridgeDomainManager.class);
33 private static final DataTreeIdentifier<VbridgeTopology> LISTEN_TREE =
34 new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION,
35 InstanceIdentifier.builder(NetworkTopology.class).child(Topology.class).child(TopologyTypes.class)
36 .augmentation(TopologyTypesVbridgeAugment.class).child(VbridgeTopology.class).build());
38 private final ListenerRegistration<TopologyMonitor> reg;
39 private boolean closed;
41 private VirtualBridgeDomainManager(final ListenerRegistration<TopologyMonitor> reg) {
42 this.reg = Preconditions.checkNotNull(reg);
45 public static VirtualBridgeDomainManager create(@Nonnull final DataBroker dataBroker,@Nonnull MountPointService mountService) {
46 final ListenerRegistration<TopologyMonitor> reg =
47 dataBroker.registerDataTreeChangeListener(LISTEN_TREE, new TopologyMonitor(dataBroker, mountService));
49 return new VirtualBridgeDomainManager(reg);
55 LOG.debug("Virtual Bridge Domain manager shut down started");
57 final TopologyMonitor monitor = reg.getInstance();
59 LOG.debug("Topology monitor {} unregistered", monitor);
63 LOG.debug("Virtual Bridge Domain manager shut down completed");