Removed the rest of old BGP-RIB classes. 18/22718/2
authorDana Kutenicsova <dkutenic@cisco.com>
Tue, 16 Jun 2015 18:20:51 +0000 (20:20 +0200)
committerDana Kutenicsova <dkutenic@cisco.com>
Tue, 16 Jun 2015 19:10:18 +0000 (21:10 +0200)
Change-Id: Ia849ec2ee2332b957f816b4691d5fd45dd1a2942
Signed-off-by: Dana Kutenicsova <dkutenic@cisco.com>
16 files changed:
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/AdjRIBsTransactionImpl.java [deleted file]
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/RIBTables.java [deleted file]
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/spi/AdjRIBsOut.java [deleted file]
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/spi/AdjRIBsOutRegistration.java [deleted file]
bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/AbstractAdjRIBs.java [deleted file]
bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/AdjRIBsFactory.java [deleted file]
bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/AdjRIBsIn.java [deleted file]
bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/AdjRIBsTransaction.java [deleted file]
bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/BGPObjectComparator.java [deleted file]
bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/RIBEntry.java [deleted file]
bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/RIBExtensionConsumerContext.java
bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/RIBExtensionProviderContext.java
bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/SimpleRIBExtensionProviderContext.java
bgp/rib-spi/src/test/java/org/opendaylight/protocol/bgp/rib/spi/AbstractAdjRIBsTest.java [deleted file]
bgp/rib-spi/src/test/java/org/opendaylight/protocol/bgp/rib/spi/BestPathSelectionTest.java [deleted file]
bgp/rib-spi/src/test/java/org/opendaylight/protocol/bgp/rib/spi/SimpleRIBExtensionTest.java

diff --git a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/AdjRIBsTransactionImpl.java b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/AdjRIBsTransactionImpl.java
deleted file mode 100644 (file)
index ccb8bda..0000000
+++ /dev/null
@@ -1,79 +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.protocol.bgp.rib.impl;
-
-import com.google.common.base.Preconditions;
-import com.google.common.util.concurrent.CheckedFuture;
-import java.util.Map;
-import java.util.Map.Entry;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.protocol.bgp.rib.impl.spi.AdjRIBsOut;
-import org.opendaylight.protocol.bgp.rib.spi.AdjRIBsTransaction;
-import org.opendaylight.protocol.bgp.rib.spi.BGPObjectComparator;
-import org.opendaylight.protocol.bgp.rib.spi.Peer;
-import org.opendaylight.protocol.bgp.rib.spi.RouteEncoder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.Route;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.Tables;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.tables.Attributes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.tables.AttributesBuilder;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Deprecated
-class AdjRIBsTransactionImpl implements AdjRIBsTransaction {
-    private static final Logger LOG = LoggerFactory.getLogger(AdjRIBsTransactionImpl.class);
-    private final BGPObjectComparator comparator;
-    private final WriteTransaction trans;
-    private final Map<Peer, AdjRIBsOut> ribs;
-
-    AdjRIBsTransactionImpl(final Map<Peer, AdjRIBsOut> ribs, final BGPObjectComparator comparator, final WriteTransaction writeTransaction) {
-        this.comparator = Preconditions.checkNotNull(comparator);
-        this.trans = Preconditions.checkNotNull(writeTransaction);
-        this.ribs = Preconditions.checkNotNull(ribs);
-    }
-
-    @Override
-    public void setUptodate(final InstanceIdentifier<Tables> basePath, final boolean uptodate) {
-        final InstanceIdentifier<Attributes> aid = basePath.child(Attributes.class);
-        this.trans.merge(LogicalDatastoreType.OPERATIONAL, aid, new AttributesBuilder().setUptodate(uptodate).build());
-        LOG.debug("Table {} switching uptodate to {}", basePath, uptodate);
-    }
-
-    public CheckedFuture<Void, TransactionCommitFailedException> commit() {
-        return this.trans.submit();
-    }
-
-    @Override
-    public BGPObjectComparator comparator() {
-        return this.comparator;
-    }
-
-    @Override
-    public <K, V extends Route> void advertise(final RouteEncoder ribOut, final K key, final InstanceIdentifier<V> id, final Peer advertizingPeer, final V obj) {
-        this.trans.put(LogicalDatastoreType.OPERATIONAL, id, obj, true);
-        for (final Entry<Peer, AdjRIBsOut> e : this.ribs.entrySet()) {
-            if (e.getKey() != advertizingPeer) {
-                e.getValue().put(ribOut, key, obj);
-                LOG.trace("Advertizing to peer {}", e.getKey());
-            } else {
-                LOG.trace("Not advertizing to peer {}", e.getKey());
-            }
-        }
-    }
-
-    @Override
-    public <K, V extends Route> void withdraw(final RouteEncoder ribOut, final K key, final InstanceIdentifier<V> id) {
-        this.trans.delete(LogicalDatastoreType.OPERATIONAL, id);
-        for (final AdjRIBsOut r : this.ribs.values()) {
-            r.put(ribOut, key, null);
-        }
-    }
-}
diff --git a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/RIBTables.java b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/RIBTables.java
deleted file mode 100644 (file)
index 0c98ae1..0000000
+++ /dev/null
@@ -1,70 +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.protocol.bgp.rib.impl;
-
-import com.google.common.base.Preconditions;
-import java.util.HashMap;
-import java.util.Map;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.protocol.bgp.rib.RibReference;
-import org.opendaylight.protocol.bgp.rib.spi.AdjRIBsFactory;
-import org.opendaylight.protocol.bgp.rib.spi.AdjRIBsIn;
-import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionConsumerContext;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.bgp.rib.rib.LocRib;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.Tables;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.TablesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.TablesKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.tables.AttributesBuilder;
-import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Deprecated
-final class RIBTables {
-
-    private static final Logger LOG = LoggerFactory.getLogger(RIBTables.class);
-
-    private final Map<TablesKey, AdjRIBsIn<?, ?>> tables = new HashMap<>();
-    private final RIBExtensionConsumerContext registry;
-
-    RIBTables(final RIBExtensionConsumerContext extensions) {
-        this.registry = Preconditions.checkNotNull(extensions);
-    }
-
-    public synchronized AdjRIBsIn<?, ?> get(final TablesKey key) {
-        LOG.debug("Looking for key {} in tables {}", key, this.tables);
-        final AdjRIBsIn<?, ?> ret = this.tables.get(key);
-        LOG.trace("Key found {}", ret);
-        return ret;
-    }
-
-    public synchronized AdjRIBsIn<?, ?> create(final WriteTransaction trans, final RibReference rib, final TablesKey key) {
-        if (this.tables.containsKey(key)) {
-            LOG.warn("Duplicate create request for key {}", key);
-            return this.tables.get(key);
-        }
-
-        final AdjRIBsFactory f = this.registry.getAdjRIBsInFactory(key.getAfi(), key.getSafi());
-        if (f == null) {
-            LOG.debug("RIBsInFactory not found for key {}, returning null", key);
-            return null;
-        }
-
-        final KeyedInstanceIdentifier<Tables, TablesKey> basePath = rib.getInstanceIdentifier().child(LocRib.class).child(Tables.class, key);
-        final AdjRIBsIn<?, ?> table = Preconditions.checkNotNull(f.createAdjRIBs(basePath));
-        LOG.debug("Table {} created for key {}", table, key);
-        this.tables.put(key, table);
-
-        trans.put(LogicalDatastoreType.OPERATIONAL, basePath,
-                new TablesBuilder().setAfi(key.getAfi()).setSafi(key.getSafi())
-                .setAttributes(new AttributesBuilder().setUptodate(Boolean.TRUE).build()).build());
-
-        return table;
-    }
-}
diff --git a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/spi/AdjRIBsOut.java b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/spi/AdjRIBsOut.java
deleted file mode 100644 (file)
index 6385faa..0000000
+++ /dev/null
@@ -1,16 +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.protocol.bgp.rib.impl.spi;
-
-import org.opendaylight.protocol.bgp.rib.spi.RouteEncoder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.Route;
-
-@Deprecated
-public interface AdjRIBsOut {
-    void put(final RouteEncoder ribOut, final Object key, final Route newValue);
-}
diff --git a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/spi/AdjRIBsOutRegistration.java b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/spi/AdjRIBsOutRegistration.java
deleted file mode 100644 (file)
index 2f59903..0000000
+++ /dev/null
@@ -1,17 +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.protocol.bgp.rib.impl.spi;
-
-import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
-
-@Deprecated
-public abstract class AdjRIBsOutRegistration extends AbstractObjectRegistration<AdjRIBsOut> {
-    protected AdjRIBsOutRegistration(final AdjRIBsOut instance) {
-        super(instance);
-    }
-}
diff --git a/bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/AbstractAdjRIBs.java b/bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/AbstractAdjRIBs.java
deleted file mode 100644 (file)
index 0f25bda..0000000
+++ /dev/null
@@ -1,257 +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.protocol.bgp.rib.spi;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.MoreObjects.ToStringHelper;
-import com.google.common.base.Preconditions;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Map.Entry;
-import javax.annotation.Nullable;
-import javax.annotation.concurrent.GuardedBy;
-import javax.annotation.concurrent.ThreadSafe;
-import org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.Update;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.UpdateBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.Attributes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.AttributesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.Attributes1;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.Attributes1Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.Attributes2;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.Attributes2Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.BgpTableType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.update.attributes.MpReachNlriBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.update.attributes.MpUnreachNlriBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.Route;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.Tables;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.TablesKey;
-import org.opendaylight.yangtools.yang.binding.Identifiable;
-import org.opendaylight.yangtools.yang.binding.Identifier;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Deprecated
-@ThreadSafe
-public abstract class AbstractAdjRIBs<I, D extends Identifiable<K> & Route, K extends Identifier<D>> implements AdjRIBsIn<I, D>, RouteEncoder {
-    protected abstract static class RIBEntryData<I, D extends Identifiable<K> & Route, K extends Identifier<D>> {
-        private final Attributes attributes;
-        private final Peer peer;
-
-        protected RIBEntryData(final Peer peer, final Attributes attributes) {
-            this.attributes = Preconditions.checkNotNull(attributes);
-            this.peer = Preconditions.checkNotNull(peer);
-        }
-
-        public Attributes getAttributes() {
-            return this.attributes;
-        }
-
-        public Peer getPeer() {
-            return this.peer;
-        }
-
-        /**
-         * Create a data object given the key and target instance identifier.
-         *
-         * @param key Route key
-         * @param id Data store target identifier
-         * @return Data object to be written to the data store.
-         */
-        protected abstract D getDataObject(I key, K id);
-
-        @Override
-        public final String toString() {
-            return addToStringAttributes(MoreObjects.toStringHelper(this)).toString();
-        }
-
-        protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
-            return toStringHelper.add("attributes", this.attributes);
-        }
-    }
-
-    private static final Logger LOG = LoggerFactory.getLogger(AbstractAdjRIBs.class);
-    private final KeyedInstanceIdentifier<Tables, TablesKey> basePath;
-    private final BgpTableType tableType;
-    private final Update eor;
-
-    @GuardedBy("this")
-    private final Map<I, RIBEntry<I, D, K>> entries = new HashMap<>();
-
-    @GuardedBy("this")
-    private final Map<Peer, Boolean> peers = new HashMap<>();
-
-    protected AbstractAdjRIBs(final KeyedInstanceIdentifier<Tables, TablesKey> basePath) {
-        this.basePath = Preconditions.checkNotNull(basePath);
-        this.tableType = new BgpTableTypeImpl(basePath.getKey().getAfi(), basePath.getKey().getSafi());
-        this.eor = new UpdateBuilder().setAttributes(new AttributesBuilder().addAugmentation(
-            Attributes1.class, new Attributes1Builder().setMpReachNlri(new MpReachNlriBuilder(this.tableType)
-                .build()).build()).build()).build();
-    }
-
-    @Override
-    public final synchronized void clear(final AdjRIBsTransaction trans, final Peer peer) {
-        final Iterator<Entry<I, RIBEntry<I, D, K>>> i = this.entries.entrySet().iterator();
-        while (i.hasNext()) {
-            final Entry<I, RIBEntry<I, D, K>> e = i.next();
-
-            if (e.getValue().removeState(trans, peer)) {
-                i.remove();
-            }
-        }
-
-        this.peers.remove(peer);
-        trans.setUptodate(getBasePath(), !this.peers.values().contains(Boolean.FALSE));
-    }
-
-    public final synchronized void addAllEntries(final AdjRIBsTransaction trans) {
-        for (final Entry<I, RIBEntry<I, D, K>> e : this.entries.entrySet()) {
-            final RIBEntry<I, D, K> entry = e.getValue();
-            final RIBEntryData<I, D, K> state = entry.currentState;
-            trans.advertise(this, e.getKey(), entry.name, state.peer, state.getDataObject(entry.getKey(), entry.name.getKey()));
-        }
-    }
-
-    /**
-     * Construct a datastore identifier for an entry key.
-     *
-     * @param basePath datastore base path under which the entry to be stored
-     * @param id object identifier
-     * @return Data store identifier, may not be null
-     *
-     * @deprecated Please override {@link #identifierForKey(Object)} instead. The basePath
-     *             argument is constant for a particular instance and is the one your
-     *             constructor specifies.
-     */
-    @Deprecated
-    protected abstract KeyedInstanceIdentifier<D, K> identifierForKey(InstanceIdentifier<Tables> basePath, I id);
-
-    /**
-     * Return the base path specified at construction time.
-     *
-     * @return Base path.
-     */
-    protected final KeyedInstanceIdentifier<Tables, TablesKey> getBasePath() {
-        return this.basePath;
-    }
-
-    /**
-     * Construct a datastore identifier for an entry key.
-     *
-     * @param id object identifier
-     * @return Data store identifier, may not be null
-     */
-    protected KeyedInstanceIdentifier<D, K> identifierForKey(final I id) {
-        return identifierForKey(getBasePath(), id);
-    }
-
-    public void addWith(final MpUnreachNlriBuilder builder, final InstanceIdentifier<?> key) {
-        this.addWithdrawal(builder, keyForIdentifier(this.routeIdentifier(key)));
-    }
-
-    /**
-     * Transform a withdrawn identifier into a the corresponding NLRI in MP_UNREACH attribute.
-     * @param builder MpUnreachNlriBuilder
-     * @param id Route key
-     */
-    protected abstract void addWithdrawal(MpUnreachNlriBuilder builder, I id);
-
-    /**
-     * Creates router identifier out of instance identifier
-     * @param id instance identifier
-     * @return router identifier
-     */
-    @Nullable
-    public abstract KeyedInstanceIdentifier<D, K> routeIdentifier(InstanceIdentifier<?> id);
-
-    /**
-     * Craates route key out of instance identifier
-     * @param id instance identifier
-     * @return route key
-     */
-    public abstract I keyForIdentifier(KeyedInstanceIdentifier<D, K> id);
-
-    /**
-     * Common backend for {@link AdjRIBsIn#addRoutes(AdjRIBsTransaction, Peer, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.update.attributes.MpReachNlri, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.Attributes)} implementations.
-     *
-     * If a new route is added, check first for its existence in Map of entries.
-     * If the route is already there, change it's state. Then check for peer in
-     * Map of peers, if it's not there, add it.
-     *
-     * @param trans Transaction context
-     * @param peer Originating peer
-     * @param id Data store instance identifier
-     * @param data Data object to be written
-     */
-    protected final synchronized void add(final AdjRIBsTransaction trans, final Peer peer, final I id, final RIBEntryData<I, D, K> data) {
-        LOG.debug("Adding state {} for {} peer {}", data, id, peer);
-
-        RIBEntry<I, D, K> e = this.entries.get(Preconditions.checkNotNull(id));
-        if (e == null) {
-            e = new RIBEntry<I, D, K>(this, id);
-            this.entries.put(id, e);
-        }
-
-        e.setState(trans, peer, data);
-        if (!this.peers.containsKey(peer)) {
-            this.peers.put(peer, Boolean.FALSE);
-            trans.setUptodate(getBasePath(), Boolean.FALSE);
-        }
-    }
-
-    /**
-     * Common backend for {@link AdjRIBsIn#removeRoutes(AdjRIBsTransaction, Peer, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.update.attributes.MpUnreachNlri)} implementations.
-     *
-     * @param trans Transaction context
-     * @param peer Originating peer
-     * @param id Data store instance identifier
-     */
-    protected final synchronized void remove(final AdjRIBsTransaction trans, final Peer peer, final I id) {
-        final RIBEntry<I, D, K> e = this.entries.get(id);
-        if (e != null && e.removeState(trans, peer)) {
-            LOG.debug("Removed last state, removing entry for {}", id);
-            this.entries.remove(id);
-        }
-    }
-
-    @Override
-    public final void markUptodate(final AdjRIBsTransaction trans, final Peer peer) {
-        this.peers.put(peer, Boolean.TRUE);
-        trans.setUptodate(getBasePath(), !this.peers.values().contains(Boolean.FALSE));
-    }
-
-    @Override
-    public final Update endOfRib() {
-        return this.eor;
-    }
-
-    @Override
-    public Update updateMessageFor(final Object key, final Route route) {
-        final UpdateBuilder ub = new UpdateBuilder();
-        final AttributesBuilder pab = new AttributesBuilder();
-
-        if (route != null) {
-            final MpReachNlriBuilder reach = new MpReachNlriBuilder(this.tableType);
-
-            addAdvertisement(reach, (D)route);
-            pab.fieldsFrom(route.getAttributes());
-            pab.addAugmentation(Attributes1.class, new Attributes1Builder().setMpReachNlri(reach.build()).build()).build();
-        } else {
-            final MpUnreachNlriBuilder unreach = new MpUnreachNlriBuilder(this.tableType);
-            addWithdrawal(unreach, (I)key);
-            pab.addAugmentation(Attributes2.class, new Attributes2Builder().setMpUnreachNlri(unreach.build()).build()).build();
-        }
-
-        ub.setAttributes(pab.build());
-        return ub.build();
-    }
-
-}
diff --git a/bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/AdjRIBsFactory.java b/bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/AdjRIBsFactory.java
deleted file mode 100644 (file)
index da6fe97..0000000
+++ /dev/null
@@ -1,24 +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.protocol.bgp.rib.spi;
-
-import javax.annotation.Nonnull;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.Tables;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.TablesKey;
-import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-
-@Deprecated
-public interface AdjRIBsFactory {
-    /*
-     * Create an instance of route tables for the specified backend data store. Note that the
-     * AFI/SAFI is encoded as the key of the instance identifier.
-     *
-     * @param basePath datastore identifier of local the table.
-     */
-    AdjRIBsIn<?, ?> createAdjRIBs(@Nonnull KeyedInstanceIdentifier<Tables, TablesKey> basePath);
-}
diff --git a/bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/AdjRIBsIn.java b/bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/AdjRIBsIn.java
deleted file mode 100644 (file)
index fd24045..0000000
+++ /dev/null
@@ -1,63 +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.protocol.bgp.rib.spi;
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.Update;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.Attributes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.update.attributes.MpReachNlri;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.update.attributes.MpReachNlriBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.update.attributes.MpUnreachNlri;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.Route;
-
-@Deprecated
-public interface AdjRIBsIn<K, V extends Route> {
-
-    /**
-     * Adds routes to this adjacency rib.
-     * @param trans data-store transaction
-     * @param peer advertising peer
-     * @param nlri routes
-     * @param attributes route attributes
-     */
-    void addRoutes(final AdjRIBsTransaction trans, final Peer peer, final MpReachNlri nlri, final Attributes attributes);
-
-    /**
-     * Removes routes from this adjacency rib.
-     * @param trans data-store transaction
-     * @param peer advertising peer
-     * @param nlri routes
-     */
-    void removeRoutes(final AdjRIBsTransaction trans, final Peer peer, final MpUnreachNlri nlri);
-
-    /**
-     * Clears adjacency rib tables.
-     * @param trans data-store transaction
-     * @param peer advertising peer
-     */
-    void clear(final AdjRIBsTransaction trans, final Peer peer);
-
-    /**
-     * Marks true or false the state of this adjacency rib.
-     * @param trans data-store transaction
-     * @param peer advertising peer
-     */
-    void markUptodate(final AdjRIBsTransaction trans, final Peer peer);
-
-    /**
-     * Transform an advertised data object into the corresponding NLRI in MP_REACH attribute.
-     * @param builder MP_REACH attribute builder
-     * @param data Data object
-     */
-    void addAdvertisement(final MpReachNlriBuilder builder, final V data);
-
-    /**
-     * Creates end-of-rib message for this adjacency rib.
-     * @return BGP Update message
-     */
-    Update endOfRib();
-}
diff --git a/bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/AdjRIBsTransaction.java b/bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/AdjRIBsTransaction.java
deleted file mode 100644 (file)
index bd6bc18..0000000
+++ /dev/null
@@ -1,24 +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.protocol.bgp.rib.spi;
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.Route;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.Tables;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- * An execution context for a single LocRib transaction.
- */
-@Deprecated
-public interface AdjRIBsTransaction {
-
-    BGPObjectComparator comparator();
-    void setUptodate(InstanceIdentifier<Tables> basePath, boolean uptodate);
-    <K, T extends Route> void advertise(RouteEncoder ribOut, K key, InstanceIdentifier<T> id, Peer peer, T obj);
-    <K, T extends Route> void withdraw(RouteEncoder ribOut, K key, InstanceIdentifier<T> id);
-}
diff --git a/bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/BGPObjectComparator.java b/bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/BGPObjectComparator.java
deleted file mode 100644 (file)
index f8fef39..0000000
+++ /dev/null
@@ -1,166 +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.protocol.bgp.rib.spi;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
-import java.io.Serializable;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.List;
-import org.opendaylight.protocol.bgp.rib.spi.AbstractAdjRIBs.RIBEntryData;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.Attributes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.attributes.as.path.Segments;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpOrigin;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.as.path.segment.c.segment.AListCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.as.path.segment.c.segment.ASetCase;
-
-/**
- * This comparator is intended to implement BGP Best Path Selection algorithm, as described at
- * <a href="http://www.cisco.com/en/US/tech/tk365/technologies_tech_note09186a0080094431.shtml">here</a>
- */
-@Deprecated
-public final class BGPObjectComparator implements Comparator<RIBEntryData<?, ?, ?>>, Serializable {
-
-    private static final long serialVersionUID = 3299599519482155374L;
-
-    private final AsNumber ourAS;
-
-    public BGPObjectComparator(final AsNumber ourAs) {
-        this.ourAS = Preconditions.checkNotNull(ourAs);
-    }
-
-    @Override
-    public int compare(final RIBEntryData<?, ?, ?> newObject, final RIBEntryData<?, ?, ?> oldObject) {
-        if (newObject == oldObject) {
-            return 0;
-        }
-        if (newObject == null) {
-            return 1;
-        }
-        if (oldObject == null) {
-            return -1;
-        }
-
-        final Attributes newPath = newObject.getAttributes();
-        final Attributes oldPath = oldObject.getAttributes();
-        if (newPath.equals(oldPath) && Arrays.equals(newObject.getPeer().getRawIdentifier(), oldObject.getPeer().getRawIdentifier())) {
-            return 0;
-        }
-
-        // 1. prefer path with accessible nexthop
-        // - we assume that all nexthops are accessible
-
-        // 2. prefer path with higher LOCAL_PREF
-        if ((newPath.getLocalPref() != null || oldPath.getLocalPref() != null)
-                && (newPath.getLocalPref() != null && !newPath.getLocalPref().equals(oldPath.getLocalPref()))) {
-            return newPath.getLocalPref().getPref().compareTo(oldPath.getLocalPref().getPref());
-        }
-
-        // 3. prefer learned path
-        // - we assume that all paths are learned
-
-        // 4. prefer the path with the shortest AS_PATH.
-        if (!newPath.getAsPath().equals(oldPath.getAsPath())) {
-            final Integer i1 = countAsPath(newPath.getAsPath().getSegments());
-            final Integer i2 = countAsPath(oldPath.getAsPath().getSegments());
-            return i2.compareTo(i1);
-        }
-
-        // 5. prefer the path with the lowest origin type
-        // - IGP is lower than Exterior Gateway Protocol (EGP), and EGP is lower than INCOMPLETE
-        if (!newPath.getOrigin().equals(oldPath.getOrigin())) {
-            if (newPath.getOrigin().getValue().equals(BgpOrigin.Igp)) {
-                return 1;
-            }
-            if (oldPath.getOrigin().getValue().equals(BgpOrigin.Igp)) {
-                return -1;
-            }
-            if (newPath.getOrigin().getValue().equals(BgpOrigin.Egp)) {
-                return 1;
-            } else {
-                return -1;
-            }
-        }
-
-        // 6. prefer the path with the lowest multi-exit discriminator (MED)
-        if ((newPath.getMultiExitDisc() != null || oldPath.getMultiExitDisc() != null)
-                && (newPath.getMultiExitDisc() != null && !newPath.getMultiExitDisc().equals(oldPath.getMultiExitDisc()))) {
-            return oldPath.getMultiExitDisc().getMed().compareTo(newPath.getMultiExitDisc().getMed());
-        }
-
-        // 7. prefer eBGP over iBGP paths
-        // EBGP is peering between two different AS, whereas IBGP is between same AS (Autonomous System).
-        final AsNumber first = getPeerAs(newPath.getAsPath().getSegments());
-        final AsNumber second = getPeerAs(oldPath.getAsPath().getSegments());
-        if ((first != null || second != null) && (first != null && !first.equals(second))) {
-            if (first.equals(this.ourAS)) {
-                return -1;
-            }
-            if (second == null || second.equals(this.ourAS)) {
-                return 1;
-            }
-        }
-
-        // 8. Prefer the path with the lowest IGP metric to the BGP next hop.
-        // - no next hop metric is advertized
-
-        // 9. When both paths are external, prefer the path that was received first (the oldest one).
-        // if (first.equals(this.ourAS) && second.equals(this.ourAS)) {
-        // FIXME: do we have a way how to determine which one was received first?
-
-        // 10. Prefer the route that comes from the BGP router with the lowest router ID.
-        // The router ID is the highest IP address on the router, with preference given to loopback addresses.
-        // If a path contains route reflector (RR) attributes, the originator ID is substituted for the router ID in the
-        // path selection process.
-
-        // RFC5004 states that this algorithm should end here and select existing path over new path in the
-        // best path selection process. Benefits are listed in the RFC: @see http://tools.ietf.org/html/rfc500
-        // - This algorithm SHOULD NOT be applied when either path is from a BGP Confederation peer.
-        //  - not applicable, we don't deal with confederation peers
-        // - The algorithm SHOULD NOT be applied when both paths are from peers with an identical BGP identifier (i.e., there exist parallel BGP sessions between two BGP speakers).
-        //  - not applicable, BUG-2631 prevents parallel sessions to be created.
-
-        return -1;
-    }
-
-    private static int countAsPath(final List<Segments> segments) {
-        // an AS_SET counts as 1, no matter how many ASs are in the set.
-        int count = 0;
-        boolean setPresent = false;
-        for (final Segments s : segments) {
-            if (s.getCSegment() instanceof ASetCase) {
-                setPresent = true;
-            } else {
-                final AListCase list = (AListCase) s.getCSegment();
-                count += list.getAList().getAsSequence().size();
-            }
-        }
-        return (setPresent) ? ++count : count;
-    }
-
-    private static AsNumber getPeerAs(final List<Segments> segments) {
-        if (segments.size() == 0) {
-            return null;
-        }
-        final AListCase first = (AListCase) segments.get(0).getCSegment();
-        return first.getAList().getAsSequence().get(0).getAs();
-    }
-
-    @VisibleForTesting
-    public static int compareByteArrays(final byte[] byteOne, final byte[] byteTwo) {
-        for (int i = 0; i < byteOne.length; i++) {
-            final int res = Byte.compare(byteOne[i], byteTwo[i]);
-            if (res != 0) {
-                return res;
-            }
-        }
-        return 0;
-    }
-}
diff --git a/bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/RIBEntry.java b/bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/RIBEntry.java
deleted file mode 100644 (file)
index e60107a..0000000
+++ /dev/null
@@ -1,128 +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.protocol.bgp.rib.spi;
-
-import com.google.common.base.Preconditions;
-import java.util.HashMap;
-import java.util.Map;
-import javax.annotation.concurrent.GuardedBy;
-import org.opendaylight.protocol.bgp.rib.spi.AbstractAdjRIBs.RIBEntryData;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.Route;
-import org.opendaylight.yangtools.yang.binding.Identifiable;
-import org.opendaylight.yangtools.yang.binding.Identifier;
-import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * A single RIB table entry, which holds multiple versions of the entry's state and elects the authoritative based
- * on ordering specified by the supplied comparator.
- *
- */
-@Deprecated
-final class RIBEntry<I, D extends Identifiable<K> & Route, K extends Identifier<D>> {
-    private static final Logger LOG = LoggerFactory.getLogger(RIBEntry.class);
-    private static final int DEFAULT_MAP_SIZE = 2;
-
-    /*
-     * TODO: we could dramatically optimize performance by using the comparator
-     *       to retain the candidate states ordered -- thus selection would occur
-     *       automatically through insertion, without the need of a second walk.
-     */
-    private final Map<Peer, RIBEntryData<I, D, K>> candidates = new HashMap<>(DEFAULT_MAP_SIZE);
-
-    /**
-     *
-     */
-    private final AbstractAdjRIBs<I, D, K> parent;
-    private final I key;
-
-    @GuardedBy("this")
-    KeyedInstanceIdentifier<D, K> name;
-    @GuardedBy("this")
-    AbstractAdjRIBs.RIBEntryData<I, D, K> currentState;
-
-    RIBEntry(final AbstractAdjRIBs<I, D, K> parent, final I key) {
-        this.parent = Preconditions.checkNotNull(parent);
-        this.key = Preconditions.checkNotNull(key);
-    }
-
-    I getKey() {
-        return key;
-    }
-
-    private KeyedInstanceIdentifier<D, K> getName() {
-        if (this.name == null) {
-            this.name = parent.identifierForKey(this.key);
-            LOG.trace("Entry {} grew key {}", this, this.name);
-        }
-        return this.name;
-    }
-
-    /**
-     * Based on given comparator, finds a new best candidate for initial route.
-     *
-     * @param comparator
-     * @param initial
-     * @return candidate for founded initial route
-     */
-    private RIBEntryData<I, D, K> findCandidate(final BGPObjectComparator comparator, final RIBEntryData<I, D, K> initial) {
-        RIBEntryData<I, D, K> newState = initial;
-        for (final AbstractAdjRIBs.RIBEntryData<I, D, K> s : this.candidates.values()) {
-            if (newState == null || comparator.compare(newState, s) > 0) {
-                newState = s;
-            }
-        }
-
-        return newState;
-    }
-
-    /**
-     * Advertize newly elected best candidate to datastore.
-     *
-     * @param transaction
-     * @param candidate
-     */
-    private void electCandidate(final AdjRIBsTransaction transaction, final RIBEntryData<I, D, K> candidate) {
-        LOG.trace("Electing state {} to supersede {}", candidate, this.currentState);
-
-        if (this.currentState == null || !this.currentState.equals(candidate)) {
-            LOG.trace("Elected new state for {}: {}", getName(), candidate);
-            transaction.advertise(parent, this.key, getName(), candidate.getPeer(), candidate.getDataObject(this.key, getName().getKey()));
-            this.currentState = candidate;
-        }
-    }
-
-    /**
-     * Removes RIBEntry from database. If we are removing best path, elect another candidate (using BPS).
-     * If there are no other candidates, remove the path completely.
-     * @param transaction
-     * @param peer
-     * @return true if the list of the candidates for this path is empty
-     */
-    synchronized boolean removeState(final AdjRIBsTransaction transaction, final Peer peer) {
-        final RIBEntryData<I, D, K> data = this.candidates.remove(peer);
-        LOG.trace("Removed data {}", data);
-
-        final AbstractAdjRIBs.RIBEntryData<I, D, K> candidate = findCandidate(transaction.comparator(), null);
-        if (candidate != null) {
-            electCandidate(transaction, candidate);
-        } else {
-            LOG.trace("Final candidate disappeared, removing entry {}", getName());
-            transaction.withdraw(parent, this.key, getName());
-        }
-
-        return this.candidates.isEmpty();
-    }
-
-    synchronized void setState(final AdjRIBsTransaction transaction, final Peer peer, final RIBEntryData<I, D, K> state) {
-        this.candidates.put(Preconditions.checkNotNull(peer), Preconditions.checkNotNull(state));
-        electCandidate(transaction, findCandidate(transaction.comparator(), state));
-    }
-
-}
index 41ff5fac740d1b3da49ebb7f0f9dd1d3ac97dfc3..0b2cfe7cd3fd8c3696080ac693a83688a9363a14 100644 (file)
@@ -21,14 +21,6 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
  * exposes an entry point for locating the AFI/SAFI-specific implementation handler.
  */
 public interface RIBExtensionConsumerContext {
-    /**
-     * Acquire a RIB implementation factory for a AFI/SAFI combination.
-     * @param afi Address Family Identifier
-     * @param safi Subsequent Address Family identifier
-     * @return RIB implementation factory, or null if the AFI/SAFI is
-     *         not implemented.
-     */
-    @Nullable AdjRIBsFactory getAdjRIBsInFactory(@Nonnull Class<? extends AddressFamily> afi, @Nonnull Class<? extends SubsequentAddressFamily> safi);
 
     /**
      * Acquire a RIB implementation factory for a AFI/SAFI combination.
index 4198d64947bc95b18b0e10e3f1ac75e0829aafed..0c50c842fdf0e41b7ea7d7bf21142034d5732e45 100644 (file)
@@ -16,16 +16,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.type
  * exposes an interface for registration of factories for creating AdjRIBsIn instances, which handle the specifics.
  */
 public interface RIBExtensionProviderContext extends RIBExtensionConsumerContext {
-    /**
-     * Register a AdjRIBsInFactory for a particular AFI/SAFI combination.
-     *
-     * @param afi Address Family identifier
-     * @param safi Subsequent Address Family identifier
-     * @param factory AdjRIBsInFactory
-     * @return Registration handle. Call its close() method to remove it.
-     */
-    AutoCloseable registerAdjRIBsInFactory(Class<? extends AddressFamily> afi, Class<? extends SubsequentAddressFamily> safi,
-            AdjRIBsFactory factory);
 
     /**
      * Register a RIBSupport instance for a particular AFI/SAFI combination.
index 82f2c9b1d220f854457eeceedb8cd324937e9ce3..6411147c554ddffe80d172b47555442dd4158b7f 100644 (file)
@@ -7,13 +7,12 @@
  */
 package org.opendaylight.protocol.bgp.rib.spi;
 
-
 import com.google.common.base.Preconditions;
+
 import java.util.HashSet;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
-import org.opendaylight.protocol.concepts.AbstractRegistration;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.TablesKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.AddressFamily;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.SubsequentAddressFamily;
@@ -29,40 +28,11 @@ public class SimpleRIBExtensionProviderContext implements RIBExtensionProviderCo
 
     private static final Logger LOG = LoggerFactory.getLogger(SimpleRIBExtensionProviderContext.class);
 
-    private final ConcurrentMap<TablesKey, AdjRIBsFactory> factories = new ConcurrentHashMap<>();
     private final ConcurrentMap<TablesKey, RIBSupport> supports = new ConcurrentHashMap<>();
     private final ConcurrentMap<NodeIdentifierWithPredicates, RIBSupport> domSupports = new ConcurrentHashMap<>();
 
     private final ModuleInfoBackedContext classLoadingStrategy = ModuleInfoBackedContext.create();
 
-
-    @Override
-    public final synchronized AbstractRegistration registerAdjRIBsInFactory(final Class<? extends AddressFamily> afi,
-            final Class<? extends SubsequentAddressFamily> safi, final AdjRIBsFactory factory) {
-        final TablesKey key = new TablesKey(afi, safi);
-
-        if (this.factories.containsKey(key)) {
-            throw new IllegalArgumentException("Specified AFI/SAFI combination is already registered");
-        }
-
-        this.factories.put(key, factory);
-
-        return new AbstractRegistration() {
-            @Override
-            protected void removeRegistration() {
-                synchronized (SimpleRIBExtensionProviderContext.this) {
-                    SimpleRIBExtensionProviderContext.this.factories.remove(key);
-                }
-            }
-        };
-    }
-
-    @Override
-    public final synchronized AdjRIBsFactory getAdjRIBsInFactory(final Class<? extends AddressFamily> afi,
-            final Class<? extends SubsequentAddressFamily> safi) {
-        return this.factories.get(new TablesKey(afi, safi));
-    }
-
     @Override
     public <T extends RIBSupport> RIBSupportRegistration<T> registerRIBSupport(final Class<? extends AddressFamily> afi,
             final Class<? extends SubsequentAddressFamily> safi, final T support) {
diff --git a/bgp/rib-spi/src/test/java/org/opendaylight/protocol/bgp/rib/spi/AbstractAdjRIBsTest.java b/bgp/rib-spi/src/test/java/org/opendaylight/protocol/bgp/rib/spi/AbstractAdjRIBsTest.java
deleted file mode 100644 (file)
index 897acaf..0000000
+++ /dev/null
@@ -1,235 +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.protocol.bgp.rib.spi;
-
-import com.google.common.collect.Maps;
-import java.util.AbstractMap;
-import java.util.Map;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Matchers;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.ipv4.routes.Ipv4Routes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.ipv4.routes.ipv4.routes.Ipv4Route;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.ipv4.routes.ipv4.routes.Ipv4RouteBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.ipv4.routes.ipv4.routes.Ipv4RouteKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.Update;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.Attributes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.AttributesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.Attributes1;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.Attributes2;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.update.attributes.MpReachNlri;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.update.attributes.MpReachNlriBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.update.attributes.MpUnreachNlri;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.update.attributes.MpUnreachNlriBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.BgpRib;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.RibId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.Route;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.bgp.rib.Rib;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.bgp.rib.RibKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.bgp.rib.rib.LocRib;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.Tables;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.TablesKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-
-public class AbstractAdjRIBsTest {
-
-    private static final AsNumber TEST_AS_NUMBER = new AsNumber(35L);
-
-    private static final Ipv4Prefix IPV4_PREFIX1 = new Ipv4Prefix("1.1.1.1/32");
-
-    private static final Ipv4Prefix IPV4_PREFIX2 = new Ipv4Prefix("2.2.2.2/32");
-
-    private static final InstanceIdentifier<Rib> RIB_IID = InstanceIdentifier.builder(BgpRib.class).child(Rib.class, new RibKey(new RibId("test-rib"))).build();
-
-    private static final KeyedInstanceIdentifier<Tables, TablesKey> TABLES_IID = RIB_IID.child(LocRib.class).child(Tables.class, new TablesKey(Ipv4AddressFamily.class,
-            UnicastSubsequentAddressFamily.class));
-
-    @Mock
-    private AdjRIBsTransaction ribsTx;
-    @Mock
-    private Peer peer;
-
-    private final Map<InstanceIdentifier<?>, Map.Entry<DataObject, Boolean>> store = Maps.newHashMap();
-
-    private final BGPObjectComparator bgpComparator = new BGPObjectComparator(TEST_AS_NUMBER);
-
-    @Before
-    public void setUp() {
-        MockitoAnnotations.initMocks(this);
-        Mockito.doReturn("").when(this.peer).toString();
-        Mockito.doReturn(this.bgpComparator).when(this.ribsTx).comparator();
-        Mockito.doAnswer(new Answer<Void>() {
-            @SuppressWarnings({ "unchecked", "rawtypes" })
-            @Override
-            public Void answer(final InvocationOnMock invocation) throws Throwable {
-                final Object[] args = invocation.getArguments();
-                final InstanceIdentifier<Route> ii = (InstanceIdentifier<Route>) args[2];
-                final Route data = (Route) args[4];
-                AbstractAdjRIBsTest.this.store.put(ii, new AbstractMap.SimpleEntry(data, false));
-                return null;
-            }
-
-        }).when(this.ribsTx).advertise(Mockito.<RouteEncoder>any(), Mockito.any(), Mockito.<InstanceIdentifier<Route>>any(), Mockito.<Peer>any(), Mockito.any(Route.class));
-
-        Mockito.doAnswer(new Answer<Void>() {
-            @SuppressWarnings("unchecked")
-            @Override
-            public Void answer(final InvocationOnMock invocation) throws Throwable {
-                final Object[] args = invocation.getArguments();
-                final InstanceIdentifier<Route> ii = (InstanceIdentifier<Route>) args[2];
-                AbstractAdjRIBsTest.this.store.remove(ii);
-                return null;
-            }
-
-        }).when(this.ribsTx).withdraw(Mockito.<RouteEncoder>any(), Mockito.any(), Mockito.<InstanceIdentifier<Route>>any());
-
-        Mockito.doAnswer(new Answer<Void>() {
-            @SuppressWarnings("unchecked")
-            @Override
-            public Void answer(final InvocationOnMock invocation) throws Throwable {
-                final Object[] args = invocation.getArguments();
-                final InstanceIdentifier<Tables> basePath = (InstanceIdentifier<Tables>) args[0];
-                final Boolean uptodate = (Boolean) args[1];
-                @SuppressWarnings("rawtypes")
-                final Map.Entry<DataObject, Boolean> entry = new AbstractMap.SimpleEntry(null, uptodate);
-                AbstractAdjRIBsTest.this.store.put(basePath, entry);
-                return null;
-            }
-        }).when(this.ribsTx).setUptodate(Matchers.<InstanceIdentifier<Tables>>any(), Mockito.anyBoolean());
-    }
-
-    @Test
-    public void testAdjRibs() {
-        final TestAdjRIBs adjsRib = new TestAdjRIBs(TABLES_IID);
-        adjsRib.add(this.ribsTx, this.peer, IPV4_PREFIX1, new TestAdjRIBs.TestIpv4RIBEntryData(this.peer, new AttributesBuilder().build()));
-        Mockito.verify(this.ribsTx, Mockito.times(1)).advertise(Mockito.<RouteEncoder>any(), Mockito.any(), Mockito.<InstanceIdentifier<Route>>any(), Mockito.<Peer>any(), Mockito.any(Route.class));
-        Mockito.verify(this.ribsTx, Mockito.times(1)).setUptodate(Matchers.<InstanceIdentifier<Tables>>any(), Mockito.anyBoolean());
-        Assert.assertEquals(2, this.store.size());
-        Assert.assertFalse(this.store.get(TABLES_IID).getValue());
-
-        adjsRib.markUptodate(this.ribsTx, this.peer);
-        Mockito.verify(this.ribsTx, Mockito.times(2)).setUptodate(Matchers.<InstanceIdentifier<Tables>>any(), Mockito.anyBoolean());
-        Assert.assertEquals(2, this.store.size());
-        Assert.assertTrue(this.store.get(TABLES_IID).getValue());
-
-        adjsRib.remove(this.ribsTx, this.peer, IPV4_PREFIX1);
-        Mockito.verify(this.ribsTx, Mockito.times(1)).withdraw(Mockito.<RouteEncoder>any(), Mockito.any(), Mockito.<InstanceIdentifier<Route>>any());
-        Assert.assertEquals(1, this.store.size());
-
-        adjsRib.add(this.ribsTx, this.peer, IPV4_PREFIX1, new TestAdjRIBs.TestIpv4RIBEntryData(this.peer, new AttributesBuilder().build()));
-        adjsRib.add(this.ribsTx, this.peer, IPV4_PREFIX2, new TestAdjRIBs.TestIpv4RIBEntryData(this.peer, new AttributesBuilder().build()));
-        Mockito.verify(this.ribsTx, Mockito.times(3)).advertise(Mockito.<RouteEncoder>any(), Mockito.any(), Mockito.<InstanceIdentifier<Route>>any(), Mockito.<Peer>any(), Mockito.any(Route.class));
-
-        adjsRib.addAllEntries(this.ribsTx);
-        Mockito.verify(this.ribsTx, Mockito.times(5)).advertise(Mockito.<RouteEncoder>any(), Mockito.any(), Mockito.<InstanceIdentifier<Route>>any(), Mockito.<Peer>any(), Mockito.any(Route.class));
-        Assert.assertEquals(3, this.store.size());
-
-        adjsRib.clear(this.ribsTx, this.peer);
-        Mockito.verify(this.ribsTx, Mockito.times(3)).setUptodate(Matchers.<InstanceIdentifier<Tables>>any(), Mockito.anyBoolean());
-        Assert.assertEquals(1, this.store.size());
-    }
-
-    @Test
-    public void testEndOfRib() {
-        final TestAdjRIBs adjsRib = new TestAdjRIBs(TABLES_IID);
-        final Update endOfRib = adjsRib.endOfRib();
-        final Attributes1 attr1 = endOfRib.getAttributes().getAugmentation(Attributes1.class);
-        Assert.assertNotNull(attr1);
-        Assert.assertEquals(Ipv4AddressFamily.class, attr1.getMpReachNlri().getAfi());
-        Assert.assertEquals(UnicastSubsequentAddressFamily.class, attr1.getMpReachNlri().getSafi());
-    }
-
-    @Test
-    public void testUpdateMsgFor() {
-        final TestAdjRIBs adjsRib = new TestAdjRIBs(TABLES_IID);
-        final Update update1 = adjsRib.updateMessageFor(IPV4_PREFIX1, new Ipv4RouteBuilder().setAttributes(new AttributesBuilder().build()).build());
-        final Attributes1 attr1 = update1.getAttributes().getAugmentation(Attributes1.class);
-        Assert.assertNotNull(attr1);
-        Assert.assertEquals(Ipv4AddressFamily.class, attr1.getMpReachNlri().getAfi());
-        Assert.assertEquals(UnicastSubsequentAddressFamily.class, attr1.getMpReachNlri().getSafi());
-
-        final Update update2 = adjsRib.updateMessageFor(IPV4_PREFIX2, null);
-        final Attributes2 attr2 = update2.getAttributes().getAugmentation(Attributes2.class);
-        Assert.assertNotNull(attr2);
-        Assert.assertEquals(Ipv4AddressFamily.class, attr2.getMpUnreachNlri().getAfi());
-        Assert.assertEquals(UnicastSubsequentAddressFamily.class, attr2.getMpUnreachNlri().getSafi());
-    }
-
-    private static final class TestAdjRIBs extends AbstractAdjRIBs<Ipv4Prefix, Ipv4Route, Ipv4RouteKey> {
-
-        private static final class TestIpv4RIBEntryData extends RIBEntryData<Ipv4Prefix, Ipv4Route, Ipv4RouteKey> {
-
-            private final Attributes attributes;
-
-            protected TestIpv4RIBEntryData(final Peer peer, final Attributes attributes) {
-                super(peer, attributes);
-                this.attributes = attributes;
-            }
-
-            @Override
-            protected Ipv4Route getDataObject(final Ipv4Prefix key, final Ipv4RouteKey id) {
-                return new Ipv4RouteBuilder().setKey(id).setAttributes(new AttributesBuilder(this.attributes).build()).build();
-            }
-
-        }
-
-        protected TestAdjRIBs(final KeyedInstanceIdentifier<Tables, TablesKey> basePath) {
-            super(basePath);
-        }
-
-        @Override
-        public void addRoutes(final AdjRIBsTransaction trans, final Peer peer, final MpReachNlri nlri, final Attributes attributes) {
-            return;
-        }
-
-        @Override
-        public void removeRoutes(final AdjRIBsTransaction trans, final Peer peer, final MpUnreachNlri nlri) {
-            return;
-        }
-
-        @Override
-        public void addAdvertisement(final MpReachNlriBuilder builder, final Ipv4Route data) {
-            return;
-        }
-
-        @Override
-        protected KeyedInstanceIdentifier<Ipv4Route, Ipv4RouteKey> identifierForKey(
-                final InstanceIdentifier<Tables> basePath, final Ipv4Prefix id) {
-            return basePath.child((Class)Ipv4Routes.class).child(Ipv4Route.class,
-                    new Ipv4RouteKey(id));
-        }
-
-        @Override
-        protected void addWithdrawal(final MpUnreachNlriBuilder builder, final Ipv4Prefix id) {
-            return;
-        }
-
-        @Override
-        public KeyedInstanceIdentifier<Ipv4Route, Ipv4RouteKey> routeIdentifier(final InstanceIdentifier<?> id) {
-            return null;
-        }
-
-        @Override
-        public Ipv4Prefix keyForIdentifier(final KeyedInstanceIdentifier<Ipv4Route, Ipv4RouteKey> id) {
-            return null;
-        }
-    }
-}
diff --git a/bgp/rib-spi/src/test/java/org/opendaylight/protocol/bgp/rib/spi/BestPathSelectionTest.java b/bgp/rib-spi/src/test/java/org/opendaylight/protocol/bgp/rib/spi/BestPathSelectionTest.java
deleted file mode 100644 (file)
index e7e7512..0000000
+++ /dev/null
@@ -1,211 +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.protocol.bgp.rib.spi;
-
-import static org.junit.Assert.assertTrue;
-
-import com.google.common.collect.Lists;
-import java.util.ArrayList;
-import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.ipv4.routes.ipv4.routes.Ipv4Route;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.ipv4.routes.ipv4.routes.Ipv4RouteBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.ipv4.routes.ipv4.routes.Ipv4RouteKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.Attributes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.AttributesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.attributes.AsPathBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.attributes.ClusterIdBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.attributes.LocalPrefBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.attributes.MultiExitDiscBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.attributes.OriginBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.attributes.as.path.Segments;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.attributes.as.path.SegmentsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.update.attributes.MpReachNlri;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.update.attributes.MpReachNlriBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.update.attributes.MpUnreachNlri;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.update.attributes.MpUnreachNlriBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.Tables;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.TablesKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpOrigin;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.ClusterIdentifier;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.as.path.segment.c.segment.AListCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.as.path.segment.c.segment.ASetCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.as.path.segment.c.segment.a.list._case.AListBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.as.path.segment.c.segment.a.list._case.a.list.AsSequence;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.as.path.segment.c.segment.a.list._case.a.list.AsSequenceBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.as.path.segment.c.segment.a.set._case.ASetBuilder;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-
-/**
- * @see <a href="http://www.cisco.com/c/en/us/support/docs/ip/border-gateway-protocol-bgp/13753-25.html">BGP Best Path
- *      Selection</a>
- */
-public class BestPathSelectionTest {
-
-    @Mock
-    private Peer peer;
-
-    // new Ipv4Address("192.150.20.38"), new Ipv4Address("192.150.20.38")
-    private final BGPObjectComparator comparator = new BGPObjectComparator(new AsNumber(40L));
-
-    private Attributes attr1;
-    private Attributes attr2;
-    private Attributes attr3;
-    private Attributes attr4;
-    private Attributes attr5;
-    private Attributes attr6;
-    private Attributes attr7;
-
-    @Before
-    public void setUp() {
-        MockitoAnnotations.initMocks(this);
-        Mockito.doReturn("test").when(this.peer).toString();
-        Mockito.doReturn(new byte[]{1}).when(this.peer).getRawIdentifier();
-
-        final AsPathBuilder asBuilder1 = new AsPathBuilder();
-        final AsPathBuilder asBuilder2 = new AsPathBuilder();
-        List<Segments> segs = new ArrayList<>();
-        final List<AsNumber> ases = Lists.newArrayList(new AsNumber(100L), new AsNumber(30L));
-        final List<AsSequence> seqs = Lists.newArrayList(new AsSequenceBuilder().setAs(new AsNumber(50L)).build());
-        segs.add(new SegmentsBuilder().setCSegment(new AListCaseBuilder().setAList(new AListBuilder().setAsSequence(seqs).build()).build()).build());
-        asBuilder1.setSegments(segs);
-        segs = new ArrayList<>();
-        segs.add(new SegmentsBuilder().setCSegment(new AListCaseBuilder().setAList(new AListBuilder().setAsSequence(seqs).build()).build()).build());
-        segs.add(new SegmentsBuilder().setCSegment(new ASetCaseBuilder().setASet(new ASetBuilder().setAsSet(ases).build()).build()).build());
-        asBuilder2.setSegments(segs);
-
-        final List<ClusterIdentifier> clusters = new ArrayList<>();
-        clusters.add(new ClusterIdentifier(new Ipv4Address("0.0.0.0")));
-        clusters.add(new ClusterIdentifier(new Ipv4Address("0.0.0.0")));
-
-        final AttributesBuilder builder = new AttributesBuilder();
-        builder.setLocalPref(new LocalPrefBuilder().setPref(100L).build());
-        this.attr1 = builder.build();
-        builder.setLocalPref(new LocalPrefBuilder().setPref(230L).build());
-        builder.setAsPath(asBuilder2.build());
-        this.attr2 = builder.build();
-        builder.setAsPath(asBuilder1.build());
-        builder.setOrigin(new OriginBuilder().setValue(BgpOrigin.Incomplete).build());
-        this.attr3 = builder.build();
-        builder.setOrigin(new OriginBuilder().setValue(BgpOrigin.Egp).build());
-        builder.setMultiExitDisc(new MultiExitDiscBuilder().setMed(15L).build());
-        this.attr4 = builder.build();
-        builder.setMultiExitDisc(new MultiExitDiscBuilder().setMed(12L).build());
-        this.attr5 = builder.build();
-        builder.setAsPath(new AsPathBuilder().setSegments(new ArrayList<Segments>()).build());
-        builder.setClusterId(new ClusterIdBuilder().setCluster(new ArrayList<ClusterIdentifier>()).build());
-        this.attr6 = builder.build();
-        builder.setClusterId(new ClusterIdBuilder().setCluster(clusters).build());
-        this.attr7 = builder.build();
-    }
-
-    @Test
-    public void testCompare() {
-        assertTrue(this.comparator.compare(new TestIpv4AdjRIBsIn.TestIpv4RIBEntryData(this.peer, this.attr1),
-            new TestIpv4AdjRIBsIn.TestIpv4RIBEntryData(this.peer, this.attr2)) < 0);
-        assertTrue(this.comparator.compare(new TestIpv4AdjRIBsIn.TestIpv4RIBEntryData(this.peer, this.attr2),
-            new TestIpv4AdjRIBsIn.TestIpv4RIBEntryData(this.peer, this.attr1)) > 0);
-
-        assertTrue(this.comparator.compare(new TestIpv4AdjRIBsIn.TestIpv4RIBEntryData(this.peer, this.attr2),
-            new TestIpv4AdjRIBsIn.TestIpv4RIBEntryData(this.peer, this.attr3)) < 0);
-        assertTrue(this.comparator.compare(new TestIpv4AdjRIBsIn.TestIpv4RIBEntryData(this.peer, this.attr3),
-            new TestIpv4AdjRIBsIn.TestIpv4RIBEntryData(this.peer, this.attr2)) > 0);
-
-        assertTrue(this.comparator.compare(new TestIpv4AdjRIBsIn.TestIpv4RIBEntryData(this.peer, this.attr3),
-            new TestIpv4AdjRIBsIn.TestIpv4RIBEntryData(this.peer, this.attr4)) < 0);
-        assertTrue(this.comparator.compare(new TestIpv4AdjRIBsIn.TestIpv4RIBEntryData(this.peer, this.attr4),
-            new TestIpv4AdjRIBsIn.TestIpv4RIBEntryData(this.peer, this.attr3)) > 0);
-
-        assertTrue(this.comparator.compare(new TestIpv4AdjRIBsIn.TestIpv4RIBEntryData(this.peer, this.attr4),
-            new TestIpv4AdjRIBsIn.TestIpv4RIBEntryData(this.peer, this.attr5)) < 0);
-        assertTrue(this.comparator.compare(new TestIpv4AdjRIBsIn.TestIpv4RIBEntryData(this.peer, this.attr5),
-            new TestIpv4AdjRIBsIn.TestIpv4RIBEntryData(this.peer, this.attr4)) > 0);
-
-        assertTrue(this.comparator.compare(new TestIpv4AdjRIBsIn.TestIpv4RIBEntryData(this.peer, this.attr5),
-            new TestIpv4AdjRIBsIn.TestIpv4RIBEntryData(this.peer, this.attr6)) < 0);
-        assertTrue(this.comparator.compare(new TestIpv4AdjRIBsIn.TestIpv4RIBEntryData(this.peer, this.attr6),
-            new TestIpv4AdjRIBsIn.TestIpv4RIBEntryData(this.peer, this.attr5)) > 0);
-
-        assertTrue(this.comparator.compare(new TestIpv4AdjRIBsIn.TestIpv4RIBEntryData(this.peer, this.attr6),
-            new TestIpv4AdjRIBsIn.TestIpv4RIBEntryData(this.peer, this.attr7)) < 0);
-    }
-
-    @Test
-    public void testByteCompare() {
-        assertTrue(BGPObjectComparator.compareByteArrays(new byte[] { (byte) 192, (byte) 150, 20, 38 }, new byte[] { (byte) 192,
-            (byte) 168, 25, 1 }) < 0);
-        assertTrue(BGPObjectComparator.compareByteArrays(new byte[] { (byte) 192, (byte) 168, 25, 1 }, new byte[] { (byte) 192, (byte) 150,
-            20, 38 }) > 0);
-    }
-
-    private static final class TestIpv4AdjRIBsIn extends AbstractAdjRIBs<Ipv4Prefix, Ipv4Route, Ipv4RouteKey> {
-        TestIpv4AdjRIBsIn(final KeyedInstanceIdentifier<Tables, TablesKey> basePath) {
-            super(basePath);
-        }
-
-        private static final class TestIpv4RIBEntryData extends RIBEntryData<Ipv4Prefix, Ipv4Route, Ipv4RouteKey> {
-
-            private final Attributes attributes;
-
-            protected TestIpv4RIBEntryData(final Peer peer, final Attributes attributes) {
-                super(peer, attributes);
-                this.attributes = attributes;
-            }
-
-            @Override
-            protected Ipv4Route getDataObject(final Ipv4Prefix key, final Ipv4RouteKey id) {
-                return new Ipv4RouteBuilder().setKey(id).setAttributes(new AttributesBuilder(this.attributes).build()).build();
-            }
-
-        }
-
-        @Override
-        public KeyedInstanceIdentifier<Ipv4Route, Ipv4RouteKey> identifierForKey(final InstanceIdentifier<Tables> basePath, final Ipv4Prefix key) {
-            return null;
-        }
-
-        @Override
-        public void removeRoutes(final AdjRIBsTransaction trans, final Peer peer, final MpUnreachNlri nlri) {
-            return;
-        }
-
-        @Override
-        public void addAdvertisement(final MpReachNlriBuilder builder, final Ipv4Route data) {
-            // no-op
-        }
-
-        @Override
-        public void addWithdrawal(final MpUnreachNlriBuilder builder, final Ipv4Prefix id) {
-            // no-op
-        }
-
-        @Override
-        public KeyedInstanceIdentifier<Ipv4Route, Ipv4RouteKey> routeIdentifier(final InstanceIdentifier<?> id) {
-            return null;
-        }
-
-        @Override
-        public Ipv4Prefix keyForIdentifier(final KeyedInstanceIdentifier<Ipv4Route, Ipv4RouteKey> id) {
-            return null;
-        }
-
-        @Override
-        public void addRoutes(final AdjRIBsTransaction trans, final Peer peer, final MpReachNlri nlri, final Attributes attributes) {
-            // TODO Auto-generated method stub
-
-        }
-    }
-}
index 3a6020e4823986eea0a93d13186035ad84589e52..d6bb5388bd72eaf6f93c646a9d1e7beb1e55b3e0 100644 (file)
@@ -5,7 +5,6 @@
  * 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.spi;
 
 import com.google.common.collect.Lists;
@@ -13,35 +12,34 @@ import java.util.List;
 import org.junit.Assert;
 import org.junit.Test;
 import org.mockito.Mockito;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.Tables;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.TablesKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.bgp.rib.rib.loc.rib.tables.routes.Ipv4RoutesCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.ipv4.routes.Ipv4Routes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.ipv4.routes.ipv4.routes.Ipv4Route;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily;
-import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 
 public class SimpleRIBExtensionTest {
 
     @Test
     public void testExtensionProvider() {
         final ServiceLoaderRIBExtensionConsumerContext ctx = ServiceLoaderRIBExtensionConsumerContext.createConsumerContext();
-        Assert.assertNull(ctx.getAdjRIBsInFactory(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class));
+        Assert.assertNull(ctx.getRIBSupport(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class));
         final TestActivator act = new TestActivator();
         act.startRIBExtensionProvider(ctx);
-        Assert.assertNotNull(ctx.getAdjRIBsInFactory(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class));
+        Assert.assertNotNull(ctx.getRIBSupport(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class));
         act.close();
-        Assert.assertNull(ctx.getAdjRIBsInFactory(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class));
+        Assert.assertNull(ctx.getRIBSupport(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class));
         ctx.close();
     }
 
     private final class TestActivator extends AbstractRIBExtensionProviderActivator {
         @Override
         protected List<AutoCloseable> startRIBExtensionProviderImpl(final RIBExtensionProviderContext context) {
-            return Lists.newArrayList(context.registerAdjRIBsInFactory(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class, new AdjRIBsFactory() {
-                @Override
-                public AdjRIBsIn<?, ?> createAdjRIBs(final KeyedInstanceIdentifier<Tables, TablesKey> basePath) {
-                    return Mockito.mock(AbstractAdjRIBs.class);
-                }
-            }));
+            RIBSupport support = Mockito.mock(RIBSupport.class);
+            Mockito.doReturn(Ipv4Route.class).when(support).routesListClass();
+            Mockito.doReturn(Ipv4Routes.class).when(support).routesContainerClass();
+            Mockito.doReturn(Ipv4RoutesCase.class).when(support).routesCaseClass();
+            return Lists.newArrayList((AutoCloseable)context.registerRIBSupport(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class, support));
         }
     }
 }