blob: 0c1d08faa86479c425f0c3bd38ab00656f455d40 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
/*
* Copyright (c) 2016 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 io.fd.honeycomb.vbd.impl;
import com.google.common.base.Preconditions;
import javax.annotation.Nonnull;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
import org.opendaylight.controller.md.sal.binding.api.MountPointService;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vbridge.topology.rev160129.TopologyTypesVbridgeAugment;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vbridge.topology.rev160129.network.topology.topology.topology.types.VbridgeTopology;
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.network.topology.Topology;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.TopologyTypes;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Tip for the Virtual Bridge Domain implementation. This class is instantiated when the application is started
* and {@link #close()}d when it is shut down.
*/
public final class VirtualBridgeDomainManager implements AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(VirtualBridgeDomainManager.class);
private static final DataTreeIdentifier<VbridgeTopology> LISTEN_TREE =
new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION,
InstanceIdentifier.builder(NetworkTopology.class).child(Topology.class).child(TopologyTypes.class)
.augmentation(TopologyTypesVbridgeAugment.class).child(VbridgeTopology.class).build());
private final ListenerRegistration<TopologyMonitor> reg;
private boolean closed;
private VirtualBridgeDomainManager(final ListenerRegistration<TopologyMonitor> reg) {
this.reg = Preconditions.checkNotNull(reg);
}
public static VirtualBridgeDomainManager create(@Nonnull final DataBroker dataBroker,@Nonnull MountPointService mountService) {
final ListenerRegistration<TopologyMonitor> reg =
dataBroker.registerDataTreeChangeListener(LISTEN_TREE, new TopologyMonitor(dataBroker, mountService));
return new VirtualBridgeDomainManager(reg);
}
@Override
public void close() {
if (!closed) {
LOG.debug("Virtual Bridge Domain manager shut down started");
final TopologyMonitor monitor = reg.getInstance();
reg.close();
LOG.debug("Topology monitor {} unregistered", monitor);
monitor.close();
closed = true;
LOG.debug("Virtual Bridge Domain manager shut down completed");
}
}
}
|