import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-final class CodecsRegistryImpl implements CodecsRegistry {
+public final class CodecsRegistryImpl implements CodecsRegistry {
private static final Logger LOG = LoggerFactory.getLogger(CodecsRegistryImpl.class);
this.classContext = requireNonNull(strategy);
}
- static CodecsRegistryImpl create(final BindingCodecTreeFactory codecFactory, final GeneratedClassLoadingStrategy classStrategy) {
+ public static CodecsRegistryImpl create(final BindingCodecTreeFactory codecFactory, final GeneratedClassLoadingStrategy classStrategy) {
return new CodecsRegistryImpl(codecFactory, classStrategy);
}
import com.google.common.base.MoreObjects.ToStringHelper;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
-import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-import java.util.concurrent.Future;
import javax.annotation.Nonnull;
import javax.annotation.concurrent.GuardedBy;
import javax.annotation.concurrent.ThreadSafe;
import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService;
import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
-import org.opendaylight.mdsal.binding.dom.codec.api.BindingCodecTreeFactory;
-import org.opendaylight.mdsal.binding.generator.impl.GeneratedClassLoadingStrategy;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
import org.opendaylight.protocol.bgp.mode.api.PathSelectionMode;
import org.opendaylight.protocol.bgp.mode.impl.base.BasePathSelectionModeFactory;
import org.opendaylight.protocol.bgp.rib.spi.ExportPolicyPeerTracker;
import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionConsumerContext;
import org.opendaylight.protocol.bgp.rib.spi.RibSupportUtils;
-import org.opendaylight.protocol.bgp.rib.spi.util.ClusterSingletonServiceRegistrationHelper;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.BgpTableType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.BgpRib;
public RIBImpl(final RibId ribId, final AsNumber localAs, final BgpId localBgpId,
final ClusterIdentifier clusterId, final RIBExtensionConsumerContext extensions, final BGPDispatcher dispatcher,
- final BindingCodecTreeFactory codecFactory, final DOMDataBroker domDataBroker, final List<BgpTableType> localTables,
- @Nonnull final Map<TablesKey, PathSelectionMode> bestPathSelectionStrategies, final GeneratedClassLoadingStrategy classStrategy) {
+ final CodecsRegistryImpl codecsRegistry, final DOMDataBroker domDataBroker, final List<BgpTableType> localTables,
+ @Nonnull final Map<TablesKey, PathSelectionMode> bestPathSelectionStrategies) {
super(InstanceIdentifier.create(BgpRib.class).child(Rib.class, new RibKey(requireNonNull(ribId))),
localBgpId, localAs);
this.localAs = requireNonNull(localAs);
this.domDataBroker = requireNonNull(domDataBroker);
this.service = this.domDataBroker.getSupportedExtensions().get(DOMDataTreeChangeService.class);
this.extensions = requireNonNull(extensions);
- this.codecsRegistry = CodecsRegistryImpl.create(codecFactory, classStrategy);
+ this.codecsRegistry = codecsRegistry;
this.ribContextRegistry = RIBSupportContextRegistryImpl.create(extensions, this.codecsRegistry);
final InstanceIdentifierBuilder yangRibIdBuilder = YangInstanceIdentifier.builder().node(BgpRib.QNAME).node(Rib.QNAME);
this.yangRibId = yangRibIdBuilder.nodeWithKey(Rib.QNAME, RIB_ID_QNAME, ribId.getValue()).build();
import org.opendaylight.mdsal.dom.api.DOMSchemaService;
import org.opendaylight.protocol.bgp.mode.api.PathSelectionMode;
import org.opendaylight.protocol.bgp.openconfig.spi.BGPTableTypeRegistryConsumer;
+import org.opendaylight.protocol.bgp.rib.impl.CodecsRegistryImpl;
import org.opendaylight.protocol.bgp.rib.impl.RIBImpl;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPDispatcher;
import org.opendaylight.protocol.bgp.rib.impl.spi.CodecsRegistry;
.stream()
.collect(Collectors.toMap(entry ->
new TablesKey(entry.getKey().getAfi(), entry.getKey().getSafi()), Map.Entry::getValue));
+
+ final CodecsRegistryImpl codecsRegistry = CodecsRegistryImpl.create(codecTreeFactory,
+ this.extensions.getClassLoadingStrategy());
+
return new RIBImpl(
new RibId(bgpInstanceName),
this.asNumber,
this.clusterId,
this.extensions,
this.dispatcher,
- this.codecTreeFactory,
+ codecsRegistry,
this.domBroker,
toTableTypes(this.afiSafi, tableTypeRegistry),
- pathSelectionModes,
- this.extensions.getClassLoadingStrategy());
+ pathSelectionModes);
}
@Override
private NioEventLoopGroup boss;
private org.opendaylight.protocol.bgp.inet.BGPActivator inetActivator;
protected StrictBGPPeerRegistry serverRegistry;
+ protected CodecsRegistryImpl codecsRegistry;
@Before
public void setUp() throws Exception {
this.serverRegistry);
doReturn(Mockito.mock(ClusterSingletonServiceRegistration.class)).when(this.clusterSingletonServiceProvider)
.registerClusterSingletonService(any(ClusterSingletonService.class));
+
+ this.codecsRegistry = CodecsRegistryImpl.create(this.mappingService.getCodecFactory(),
+ this.ribExtension.getClassLoadingStrategy());
}
@After
this.a1 = new RIBActivator();
this.a1.startRIBExtensionProvider(context);
+
+ final CodecsRegistryImpl codecsRegistry = CodecsRegistryImpl.create(this.codecFactory,
+ GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy());
+
mockedMethods();
doReturn(mock(ClusterSingletonServiceRegistration.class)).when(this.clusterSingletonServiceProvider)
.registerClusterSingletonService(any(ClusterSingletonService.class));
this.rib = new RIBImpl(new RibId("test"), new AsNumber(5L), RIB_ID, CLUSTER_ID, context,
- this.dispatcher, this.codecFactory, this.dom, localTables,
+ this.dispatcher, codecsRegistry, this.dom, localTables,
Collections.singletonMap(new TablesKey(AFI, SAFI),
- BasePathSelectionModeFactory.createBestPathSelectionStrategy()),
- GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy());
+ BasePathSelectionModeFactory.createBestPathSelectionStrategy())
+ );
this.rib.onGlobalContextUpdated(schemaContext);
this.ribSupport = getRib().getRibSupportContext().getRIBSupportContext(KEY).getRibSupport();
}
final Map<TablesKey, PathSelectionMode> pathTables = ImmutableMap.of(TABLES_KEY, new AllPathSelection());
this.ribImpl = new RIBImpl(new RibId("test-rib"), AS_NUMBER, BGP_ID, null,
- this.ribExtension, this.serverDispatcher, this.mappingService.getCodecFactory(),
- getDomBroker(), TABLES_TYPE, pathTables, this.ribExtension.getClassLoadingStrategy());
+ this.ribExtension, this.serverDispatcher, this.codecsRegistry,
+ getDomBroker(), TABLES_TYPE, pathTables);
this.ribImpl.instantiateServiceInstance();
this.ribImpl.onGlobalContextUpdated(this.schemaContext);
this.ribImpl = new RIBImpl(new RibId("test-rib"),
AS_NUMBER, new BgpId(RIB_ID), null, this.ribExtension, this.serverDispatcher,
- this.mappingService.getCodecFactory(), getDomBroker(), TABLES_TYPE, pathTables,
- this.ribExtension.getClassLoadingStrategy());
+ this.codecsRegistry, getDomBroker(), TABLES_TYPE, pathTables
+ );
this.ribImpl.instantiateServiceInstance();
this.ribImpl.onGlobalContextUpdated(this.schemaContext);
final ChannelFuture channelFuture = this.serverDispatcher.createServer(new InetSocketAddress(RIB_ID, PORT));
this.ribImpl = new RIBImpl(new RibId("test-rib"),
AS_NUMBER, new BgpId(RIB_ID), null, this.ribExtension, this.serverDispatcher,
- this.mappingService.getCodecFactory(), getDomBroker(), TABLES_TYPE, pathTables,
- this.ribExtension.getClassLoadingStrategy());
+ this.codecsRegistry, getDomBroker(), TABLES_TYPE, pathTables);
this.ribImpl.instantiateServiceInstance();
this.ribImpl.onGlobalContextUpdated(this.schemaContext);
private BindingCodecTreeFactory codecFactory;
private DOMSchemaService schemaService;
+ private CodecsRegistryImpl codecsRegistry;
@Before
public void setUp() throws Exception {
this.baseact.startRIBExtensionProvider(this.ext1);
this.lsact.startRIBExtensionProvider(this.ext2);
+ this.codecsRegistry = CodecsRegistryImpl.create(this.codecFactory,
+ GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy());
}
@Override
LinkstateSubsequentAddressFamily.class));
final RIBImpl rib = new RIBImpl(new RibId(TEST_RIB_ID),
AS_NUMBER, new BgpId("127.0.0.1"), null, this.ext2, this.dispatcher,
- this.codecFactory, getDomBroker(), tables, Collections.singletonMap(TABLE_KEY,
- BasePathSelectionModeFactory.createBestPathSelectionStrategy()),
- GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy());
+ this.codecsRegistry, getDomBroker(), tables, Collections.singletonMap(TABLE_KEY,
+ BasePathSelectionModeFactory.createBestPathSelectionStrategy())
+ );
rib.instantiateServiceInstance();
assertTablesExists(tables);
rib.onGlobalContextUpdated(this.schemaService.getGlobalContext());
final List<BgpTableType> tables = ImmutableList.of(new BgpTableTypeImpl(Ipv4AddressFamily.class,
UnicastSubsequentAddressFamily.class));
final RIBImpl rib = new RIBImpl(new RibId(TEST_RIB_ID), AS_NUMBER, BGP_ID,
- null, this.ext1, this.dispatcher, this.codecFactory, getDomBroker(), tables,
- Collections.singletonMap(TABLE_KEY, BasePathSelectionModeFactory.createBestPathSelectionStrategy()),
- GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy());
+ null, this.ext1, this.dispatcher, this.codecsRegistry, getDomBroker(), tables,
+ Collections.singletonMap(TABLE_KEY, BasePathSelectionModeFactory.createBestPathSelectionStrategy())
+ );
rib.instantiateServiceInstance();
rib.onGlobalContextUpdated(this.schemaService.getGlobalContext());
assertTablesExists(tables);
final Map<TablesKey, PathSelectionMode> pathTables = ImmutableMap.of(TABLES_KEY,
BasePathSelectionModeFactory.createBestPathSelectionStrategy());
final RIBImpl ribImpl = new RIBImpl( new RibId(RIB_ID), AS_NUMBER,
- new BgpId(RIB_ID), null, this.ribExtension, this.serverDispatcher, this.mappingService.getCodecFactory(),
- this.domBroker, ImmutableList.of(this.ipv4tt), pathTables, this.ribExtension.getClassLoadingStrategy());
+ new BgpId(RIB_ID), null, this.ribExtension, this.serverDispatcher, this.codecsRegistry,
+ this.domBroker, ImmutableList.of(this.ipv4tt), pathTables);
ribImpl.instantiateServiceInstance();
ribImpl.onGlobalContextUpdated(this.schemaContext);
final Map<TablesKey, PathSelectionMode> pathTables = ImmutableMap.of(TABLES_KEY,
BasePathSelectionModeFactory.createBestPathSelectionStrategy());
final RIBImpl ribImpl = new RIBImpl( new RibId(RIB_ID), AS_NUMBER,
- new BgpId(RIB_ID), null, this.ribExtension, this.serverDispatcher, this.mappingService.getCodecFactory(),
- this.domBroker, ImmutableList.of(this.ipv4tt), pathTables, this.ribExtension.getClassLoadingStrategy());
+ new BgpId(RIB_ID), null, this.ribExtension, this.serverDispatcher, this.codecsRegistry,
+ this.domBroker, ImmutableList.of(this.ipv4tt), pathTables);
ribImpl.instantiateServiceInstance();
ribImpl.onGlobalContextUpdated(this.schemaContext);