Removes the old change API, which will be replaced by MD-SAL features.
Change-Id: I38de7ec3f57e5c42d14dcb371e02f498b4d24ad8
Signed-off-by: Robert Varga <rovarga@cisco.com>
<artifactId>bgp-concepts</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>bgp-linkstate</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>com.google.code.findbugs</groupId>
- <artifactId>jsr305</artifactId>
- <version>2.0.1</version>
- </dependency>
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- <version>${guava.version}</version>
- </dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-binding</artifactId>
<artifactId>yang-common</artifactId>
<version>${yangtools.version}</version>
</dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>${junit.version}</version>
- <scope>test</scope>
- </dependency>
</dependencies>
<build>
<extensions>true</extensions>
<configuration>
<instructions>
- <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
- <Import-Package>
- org.opendaylight.protocol.bgp.concepts,
- org.opendaylight.protocol.bgp.linkstate,
- org.opendaylight.protocol.bgp.parser,
- org.opendaylight.protocol.concepts,
- com.google.common.base,
- com.google.guava,
- org.slf4j,
- </Import-Package>
- <Export-Package>
- org.opendaylight.protocol.bgp.rib,
- </Export-Package>
+ <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
+ <Export-Package>
+ org.opendaylight.yang.gen.*
+ </Export-Package>
</instructions>
</configuration>
</plugin>
+++ /dev/null
-/*
- * 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.protocol.bgp.rib;
-
-import javax.annotation.concurrent.ThreadSafe;
-
-import org.opendaylight.protocol.concepts.InitialListenerEvents;
-import org.opendaylight.protocol.concepts.ListenerRegistration;
-
-@ThreadSafe
-public abstract class AbstractRIBChangeListener implements RIBEventListener {
- @Override
- synchronized public final void onRIBEvent(final RIBEvent event) {
- onRIBEventImpl(event);
- }
-
- abstract protected void onRIBEventImpl(final RIBEvent event);
-
- synchronized public final ListenerRegistration<RIBEventListener> register(final RIB rib) {
- InitialListenerEvents<RIBEventListener, RIBEvent> ile = rib.registerListener(this);
- for (RIBEvent e : ile.getEvents())
- onRIBEvent(e);
-
- return ile.getRegistration();
- }
-}
+++ /dev/null
-/*
- * 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.protocol.bgp.rib;
-
-import org.opendaylight.protocol.concepts.InitialListenerEvents;
-
-public interface RIB {
-
- public InitialListenerEvents<RIBEventListener, RIBEvent> registerListener(RIBEventListener listener);
-
-}
+++ /dev/null
-/*
- * 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.protocol.bgp.rib;
-
-import java.util.Collections;
-import java.util.Map;
-
-import org.opendaylight.protocol.bgp.linkstate.LinkIdentifier;
-import org.opendaylight.protocol.bgp.linkstate.NodeIdentifier;
-import org.opendaylight.protocol.bgp.linkstate.PrefixIdentifier;
-import org.opendaylight.protocol.bgp.parser.BGPLinkState;
-import org.opendaylight.protocol.bgp.parser.BGPNodeState;
-import org.opendaylight.protocol.bgp.parser.BGPPrefixState;
-import org.opendaylight.protocol.bgp.parser.BGPRouteState;
-import org.opendaylight.protocol.concepts.Prefix;
-
-import com.google.common.base.Preconditions;
-
-public final class RIBChangedEvent implements RIBEvent {
- private final Map<LinkIdentifier, BGPLinkState> links;
- private final Map<NodeIdentifier, BGPNodeState> nodes;
- private final Map<PrefixIdentifier<?>, BGPPrefixState> prefixes;
- private final Map<Prefix<?>, BGPRouteState> routes;
-
- public RIBChangedEvent(final Map<LinkIdentifier, BGPLinkState> links, final Map<NodeIdentifier, BGPNodeState> nodes,
- final Map<PrefixIdentifier<?>, BGPPrefixState> prefixes, final Map<Prefix<?>, BGPRouteState> routes) {
- super();
- this.links = Collections.unmodifiableMap(Preconditions.checkNotNull(links));
- this.nodes = Collections.unmodifiableMap(Preconditions.checkNotNull(nodes));
- this.prefixes = Collections.unmodifiableMap(Preconditions.checkNotNull(prefixes));
- this.routes = Collections.unmodifiableMap(Preconditions.checkNotNull(routes));
- }
-
- public RIBChangedEvent(final Map<Prefix<?>, BGPRouteState> routes) {
- this(Collections.<LinkIdentifier, BGPLinkState> emptyMap(), Collections.<NodeIdentifier, BGPNodeState> emptyMap(), Collections.<PrefixIdentifier<?>, BGPPrefixState> emptyMap(), routes);
- }
-
- public RIBChangedEvent(final Map<LinkIdentifier, BGPLinkState> links, final Map<NodeIdentifier, BGPNodeState> nodes,
- final Map<PrefixIdentifier<?>, BGPPrefixState> prefixes) {
- this(links, nodes, prefixes, Collections.<Prefix<?>, BGPRouteState> emptyMap());
- }
-
- /**
- * @return the links
- */
- public final Map<LinkIdentifier, BGPLinkState> getLinks() {
- return this.links;
- }
-
- /**
- * @return the nodes
- */
- public final Map<NodeIdentifier, BGPNodeState> getNodes() {
- return this.nodes;
- }
-
- /**
- * @return the prefixes
- */
- public final Map<PrefixIdentifier<?>, BGPPrefixState> getPrefixes() {
- return this.prefixes;
- }
-
- /**
- * @return the routes
- */
- public final Map<Prefix<?>, BGPRouteState> getRoutes() {
- return this.routes;
- }
-}
+++ /dev/null
-/*
- * 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.protocol.bgp.rib;
-
-public interface RIBEvent {
-
-}
+++ /dev/null
-/*
- * 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.protocol.bgp.rib;
-
-import java.util.EventListener;
-
-public interface RIBEventListener extends EventListener {
- void onRIBEvent(RIBEvent event);
-}
+++ /dev/null
-/*
- * 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.protocol.bgp.rib;
-
-import org.opendaylight.protocol.bgp.concepts.BGPTableType;
-
-public final class RIBSynchronizedEvent implements RIBEvent {
- private final BGPTableType table;
-
- public RIBSynchronizedEvent(final BGPTableType table) {
- this.table = table;
- }
-
- public BGPTableType getTable() {
- return table;
- }
-}
+++ /dev/null
-/*
- * 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.protocol.bgp.rib;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.util.Collections;
-
-import org.junit.Test;
-import org.opendaylight.protocol.bgp.concepts.BGPTableType;
-import org.opendaylight.protocol.bgp.parser.BGPRouteState;
-import org.opendaylight.protocol.concepts.Prefix;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv6AddressFamily;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.MplsLabeledVpnSubsequentAddressFamily;
-
-public class BGPEventsTest {
-
- @Test
- public void testSynchronizedEvent() {
- final BGPTableType tt = new BGPTableType(Ipv6AddressFamily.class, MplsLabeledVpnSubsequentAddressFamily.class);
- final RIBSynchronizedEvent event = new RIBSynchronizedEvent(tt);
- assertEquals(tt, event.getTable());
- }
-
- @Test
- public void testChangedEvent() {
- final RIBChangedEvent event = new RIBChangedEvent(Collections.<Prefix<?>, BGPRouteState> emptyMap());
- assertNotNull(event.getLinks());
- assertNotNull(event.getNodes());
- assertNotNull(event.getPrefixes());
- assertNotNull(event.getRoutes());
- }
-}
org.opendaylight.protocol.bgp.parser.impl,
org.opendaylight.protocol.bgp.parser.message,
org.opendaylight.protocol.bgp.parser.parameter,
- org.opendaylight.protocol.bgp.rib,
org.opendaylight.protocol.bgp.util,
org.opendaylight.protocol.util,
org.slf4j,
*/
package org.opendaylight.protocol.bgp.rib.impl;
-import java.util.ArrayList;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import java.util.Set;
import org.opendaylight.protocol.bgp.parser.BGPPrefixState;
import org.opendaylight.protocol.bgp.parser.BGPRoute;
import org.opendaylight.protocol.bgp.parser.BGPRouteState;
-import org.opendaylight.protocol.bgp.rib.RIB;
-import org.opendaylight.protocol.bgp.rib.RIBChangedEvent;
-import org.opendaylight.protocol.bgp.rib.RIBEvent;
-import org.opendaylight.protocol.bgp.rib.RIBEventListener;
-import org.opendaylight.protocol.concepts.InitialListenerEvents;
-import org.opendaylight.protocol.concepts.ListenerRegistration;
import org.opendaylight.protocol.concepts.Prefix;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev130918.LinkstateAddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
import com.google.common.base.Preconditions;
-import com.google.common.eventbus.EventBus;
-import com.google.common.eventbus.Subscribe;
@ThreadSafe
-public final class RIBImpl implements RIB {
+public final class RIBImpl {
private final RIBTable<LinkIdentifier, BGPLinkState> links = new RIBTable<>();
private final RIBTable<NodeIdentifier, BGPNodeState> nodes = new RIBTable<>();
private final RIBTable<PrefixIdentifier<?>, BGPPrefixState> prefixes = new RIBTable<>();
private final RIBTable<Prefix<?>, BGPRouteState> routes = new RIBTable<>();
- private final EventBus bus;
private final String name;
public RIBImpl(final String name) {
this.name = Preconditions.checkNotNull(name);
- this.bus = new EventBus(name);
}
synchronized void updateTables(final BGPPeer peer, final Set<BGPObject> addedObjects, final Set<?> removedObjects) {
}
}
- if (!l.isEmpty() || !n.isEmpty() || !p.isEmpty() || !r.isEmpty()) {
- this.bus.post(new RIBChangedEvent(l, n, p, r));
- }
+ // FIXME: push into MD SAL
}
synchronized void clearTable(final BGPPeer peer, final BGPTableType t) {
if (Ipv4AddressFamily.class == t.getAddressFamily() || Ipv6AddressFamily.class == t.getAddressFamily()) {
- this.bus.post(new RIBChangedEvent(this.routes.clear(peer)));
+ this.routes.clear(peer);
} else if (LinkstateAddressFamily.class == t.getAddressFamily()) {
- this.bus.post(new RIBChangedEvent(this.links.clear(peer), this.nodes.clear(peer), this.prefixes.clear(peer)));
+ this.links.clear(peer);
+ this.nodes.clear(peer);
+ this.prefixes.clear(peer);
}
}
- @Override
- synchronized public InitialListenerEvents<RIBEventListener, RIBEvent> registerListener(final RIBEventListener listener) {
- final List<RIBEvent> events = new ArrayList<>();
-
- events.add(new RIBChangedEvent(this.routes.currentState()));
- events.add(new RIBChangedEvent(this.links.currentState(), this.nodes.currentState(), this.prefixes.currentState()));
-
- final Object wrapper = new Object() {
- @Subscribe
- public void notifyListener(final RIBChangedEvent event) {
- listener.onRIBEvent(event);
- }
- };
- this.bus.register(wrapper);
-
- return new InitialListenerEvents<RIBEventListener, RIBEvent>(new ListenerRegistration<RIBEventListener>() {
- @Override
- public void close() {
- RIBImpl.this.bus.unregister(wrapper);
- }
-
- @Override
- public RIBEventListener getListener() {
- return listener;
- }
- }, events);
- }
-
@Override
public final String toString() {
return addToStringAttributes(Objects.toStringHelper(this)).toString();