diff options
Diffstat (limited to 'infra')
41 files changed, 432 insertions, 276 deletions
diff --git a/infra/it/it-test/src/test/java/io/fd/honeycomb/data/impl/AbstractInfraTest.java b/infra/it/it-test/src/test/java/io/fd/honeycomb/data/impl/AbstractInfraTest.java index f4e6f0e98..3e25733df 100644 --- a/infra/it/it-test/src/test/java/io/fd/honeycomb/data/impl/AbstractInfraTest.java +++ b/infra/it/it-test/src/test/java/io/fd/honeycomb/data/impl/AbstractInfraTest.java @@ -28,13 +28,13 @@ import org.junit.Before; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec; +import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext; +import org.opendaylight.mdsal.binding.generator.util.BindingRuntimeContext; +import org.opendaylight.mdsal.binding.generator.util.JavassistUtils; import org.opendaylight.yangtools.binding.data.codec.api.BindingNormalizedNodeSerializer; import org.opendaylight.yangtools.binding.data.codec.gen.impl.DataObjectSerializerGenerator; import org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator; import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry; -import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext; -import org.opendaylight.yangtools.sal.binding.generator.util.BindingRuntimeContext; -import org.opendaylight.yangtools.sal.binding.generator.util.JavassistUtils; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; diff --git a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/data/ConfigAndOperationalPipelineModule.java b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/data/ConfigAndOperationalPipelineModule.java index 55f9d989c..00e3a61a8 100644 --- a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/data/ConfigAndOperationalPipelineModule.java +++ b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/data/ConfigAndOperationalPipelineModule.java @@ -25,7 +25,6 @@ import io.fd.honeycomb.data.init.DataTreeInitializer; import io.fd.honeycomb.infra.distro.data.config.WriterRegistryProvider; import io.fd.honeycomb.infra.distro.data.oper.ReadableDTDelegProvider; import io.fd.honeycomb.infra.distro.data.oper.ReaderRegistryProvider; -import io.fd.honeycomb.infra.distro.initializer.PersistedFileInitializerProvider; import io.fd.honeycomb.rpc.RpcRegistry; import io.fd.honeycomb.rpc.RpcRegistryBuilder; import io.fd.honeycomb.translate.read.registry.ReaderRegistry; @@ -66,16 +65,17 @@ public class ConfigAndOperationalPipelineModule extends PrivateModule { // DOMDataBroker wrapper on top of data tree managers HoneycombDOMDataBrokerProvider domBrokerProvider = new HoneycombDOMDataBrokerProvider(); - bind(DOMDataBroker.class).toProvider(domBrokerProvider).in(Singleton.class); + bind(DOMDataBroker.class).annotatedWith(Names.named(HONEYCOMB_CONFIG)).toProvider(domBrokerProvider).in(Singleton.class); + expose(DOMDataBroker.class).annotatedWith(Names.named(HONEYCOMB_CONFIG)); // BA version of data broker - bind(DataBroker.class).annotatedWith(Names.named(HONEYCOMB_CONFIG)).toProvider(BindingDataBrokerProvider.class) + bind(DataBroker.class).annotatedWith(Names.named(HONEYCOMB_CONFIG)).toProvider(HoneycombBindingDataBrokerProvider.class) .in(Singleton.class); expose(DataBroker.class).annotatedWith(Names.named(HONEYCOMB_CONFIG)); // Create initializer to init persisted config data bind(DataTreeInitializer.class).annotatedWith(Names.named(HONEYCOMB_CONFIG)) - .toProvider(PersistedFileInitializerProvider.PersistedConfigInitializerProvider.class) + .toProvider(PersistedConfigInitializerProvider.class) .in(Singleton.class); expose(DataTreeInitializer.class).annotatedWith(Names.named(HONEYCOMB_CONFIG)); diff --git a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombBindingDataBrokerProvider.java b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombBindingDataBrokerProvider.java new file mode 100644 index 000000000..bbcd40943 --- /dev/null +++ b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombBindingDataBrokerProvider.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fd.honeycomb.infra.distro.data; + +import static io.fd.honeycomb.infra.distro.data.ConfigAndOperationalPipelineModule.HONEYCOMB_CONFIG; + +import com.google.inject.Inject; +import com.google.inject.name.Named; +import io.fd.honeycomb.binding.init.ProviderTrait; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.binding.impl.BindingDOMDataBrokerAdapter; +import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec; +import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; + +/** + * Provides binding adapter for {@link io.fd.honeycomb.data.impl.DataBroker}. + */ +final class HoneycombBindingDataBrokerProvider extends ProviderTrait<DataBroker> { + + @Inject + @Named(HONEYCOMB_CONFIG) + private DOMDataBroker domDataBroker; + @Inject + private BindingToNormalizedNodeCodec mappingService; + + @Override + protected BindingDOMDataBrokerAdapter create() { + + return new BindingDOMDataBrokerAdapter(domDataBroker, mappingService); + } +} diff --git a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombDOMBrokerProvider.java b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombDOMBrokerProvider.java index 3c665365d..9ae9d59b8 100644 --- a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombDOMBrokerProvider.java +++ b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombDOMBrokerProvider.java @@ -16,7 +16,10 @@ package io.fd.honeycomb.infra.distro.data; +import static io.fd.honeycomb.infra.distro.data.ConfigAndOperationalPipelineModule.HONEYCOMB_CONFIG; + import com.google.inject.Inject; +import com.google.inject.name.Named; import io.fd.honeycomb.binding.init.ProviderTrait; import io.fd.honeycomb.impl.NorthboundFacadeHoneycombDOMBroker; import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; @@ -25,9 +28,10 @@ import org.opendaylight.controller.md.sal.dom.broker.impl.DOMNotificationRouter; import org.opendaylight.controller.sal.core.api.Broker; import org.opendaylight.controller.sal.core.api.model.SchemaService; -public final class HoneycombDOMBrokerProvider extends ProviderTrait<Broker> { +final class HoneycombDOMBrokerProvider extends ProviderTrait<Broker> { @Inject + @Named(HONEYCOMB_CONFIG) private DOMDataBroker domDataBroker; @Inject private SchemaService schemaService; diff --git a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/data/PersistedConfigInitializerProvider.java b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/data/PersistedConfigInitializerProvider.java new file mode 100644 index 000000000..aef0819a6 --- /dev/null +++ b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/data/PersistedConfigInitializerProvider.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fd.honeycomb.infra.distro.data; + +import static io.fd.honeycomb.infra.distro.data.ConfigAndOperationalPipelineModule.HONEYCOMB_CONFIG; + +import com.google.inject.Inject; +import com.google.inject.name.Named; +import io.fd.honeycomb.binding.init.ProviderTrait; +import io.fd.honeycomb.data.init.RestoringInitializer; +import io.fd.honeycomb.infra.distro.cfgattrs.HoneycombConfiguration; +import java.nio.file.Paths; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; +import org.opendaylight.controller.sal.core.api.model.SchemaService; + +final class PersistedConfigInitializerProvider extends ProviderTrait<RestoringInitializer> { + + @Inject + private SchemaService schemaService; + @Inject + protected HoneycombConfiguration cfgAttributes; + @Inject + @Named(HONEYCOMB_CONFIG) + private DOMDataBroker domDataBroker; + + @Override + public RestoringInitializer create() { + return new RestoringInitializer(schemaService, Paths.get(cfgAttributes.peristConfigPath), domDataBroker, + RestoringInitializer.RestorationType.valueOf(cfgAttributes.persistedConfigRestorationType), + LogicalDatastoreType.CONFIGURATION); + } +} diff --git a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/data/context/ContextPipelineModule.java b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/data/context/ContextPipelineModule.java index b0ded35bd..b004efdaa 100644 --- a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/data/context/ContextPipelineModule.java +++ b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/data/context/ContextPipelineModule.java @@ -24,7 +24,6 @@ import io.fd.honeycomb.data.init.DataTreeInitializer; import io.fd.honeycomb.infra.distro.data.BindingDataBrokerProvider; import io.fd.honeycomb.infra.distro.data.DataTreeProvider; import io.fd.honeycomb.infra.distro.data.PersistingDataTreeProvider; -import io.fd.honeycomb.infra.distro.initializer.PersistedFileInitializerProvider; import io.fd.honeycomb.translate.MappingContext; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; @@ -62,7 +61,7 @@ public class ContextPipelineModule extends PrivateModule { // Create initializer to init persisted config data bind(DataTreeInitializer.class).annotatedWith(Names.named(HONEYCOMB_CONTEXT)) - .toProvider(PersistedFileInitializerProvider.PersistedContextInitializerProvider.class) + .toProvider(PersistedContextInitializerProvider.class) .in(Singleton.class); expose(DataTreeInitializer.class).annotatedWith(Names.named(HONEYCOMB_CONTEXT)); diff --git a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/data/context/PersistedContextInitializerProvider.java b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/data/context/PersistedContextInitializerProvider.java new file mode 100644 index 000000000..b21d7b92d --- /dev/null +++ b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/data/context/PersistedContextInitializerProvider.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fd.honeycomb.infra.distro.data.context; + +import static io.fd.honeycomb.infra.distro.data.ConfigAndOperationalPipelineModule.HONEYCOMB_CONFIG; + +import com.google.inject.Inject; +import com.google.inject.name.Named; +import io.fd.honeycomb.binding.init.ProviderTrait; +import io.fd.honeycomb.data.init.RestoringInitializer; +import io.fd.honeycomb.infra.distro.cfgattrs.HoneycombConfiguration; +import java.nio.file.Paths; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; +import org.opendaylight.controller.sal.core.api.model.SchemaService; + +final class PersistedContextInitializerProvider extends ProviderTrait<RestoringInitializer> { + + @Inject + private SchemaService schemaService; + @Inject + protected HoneycombConfiguration cfgAttributes; + @Inject + @Named(HONEYCOMB_CONFIG) + private DOMDataBroker domDataBroker; + + @Override + public RestoringInitializer create() { + return new RestoringInitializer(schemaService, Paths.get(cfgAttributes.peristContextPath), domDataBroker, + RestoringInitializer.RestorationType.valueOf(cfgAttributes.persistedContextRestorationType), + LogicalDatastoreType.OPERATIONAL); + } +} diff --git a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/initializer/PersistedFileInitializerProvider.java b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/initializer/PersistedFileInitializerProvider.java deleted file mode 100644 index b2c3cbb2d..000000000 --- a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/initializer/PersistedFileInitializerProvider.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.honeycomb.infra.distro.initializer; - -import com.google.inject.Inject; -import io.fd.honeycomb.binding.init.ProviderTrait; -import io.fd.honeycomb.data.init.RestoringInitializer; -import io.fd.honeycomb.infra.distro.cfgattrs.HoneycombConfiguration; -import java.nio.file.Paths; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; -import org.opendaylight.controller.sal.core.api.model.SchemaService; - -public abstract class PersistedFileInitializerProvider extends ProviderTrait<RestoringInitializer> { - - @Inject - private SchemaService schemaService; - @Inject - protected HoneycombConfiguration cfgAttributes; - @Inject - private DOMDataBroker domDataBroker; - - @Override - public RestoringInitializer create() { - return new RestoringInitializer(schemaService, Paths.get(getPersistPath()), domDataBroker, - RestoringInitializer.RestorationType.valueOf(getRestorationType()), getDataStoreType()); - } - - public abstract String getPersistPath(); - - public abstract LogicalDatastoreType getDataStoreType(); - - public abstract String getRestorationType(); - - public static class PersistedContextInitializerProvider extends PersistedFileInitializerProvider { - public String getPersistPath() { - return cfgAttributes.peristContextPath; - } - - public LogicalDatastoreType getDataStoreType() { - return LogicalDatastoreType.OPERATIONAL; - } - - public String getRestorationType() { - return cfgAttributes.persistedContextRestorationType; - } - - } - - public static class PersistedConfigInitializerProvider extends PersistedFileInitializerProvider { - public String getPersistPath() { - return cfgAttributes.peristConfigPath; - } - - public LogicalDatastoreType getDataStoreType() { - return LogicalDatastoreType.CONFIGURATION; - } - - public String getRestorationType() { - return cfgAttributes.persistedConfigRestorationType; - } - - } -} diff --git a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/schema/ModuleInfoBackedCtxProvider.java b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/schema/ModuleInfoBackedCtxProvider.java index b810980e6..01b03c460 100644 --- a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/schema/ModuleInfoBackedCtxProvider.java +++ b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/schema/ModuleInfoBackedCtxProvider.java @@ -22,7 +22,7 @@ import com.google.common.base.MoreObjects; import com.google.inject.Inject; import io.fd.honeycomb.binding.init.ProviderTrait; import java.util.stream.Collectors; -import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext; +import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext; import org.opendaylight.yangtools.yang.binding.YangModelBindingProvider; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/schema/SchemaModule.java b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/schema/SchemaModule.java index 0799a06f3..c84724f5d 100644 --- a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/schema/SchemaModule.java +++ b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/schema/SchemaModule.java @@ -20,7 +20,7 @@ import com.google.inject.AbstractModule; import com.google.inject.Singleton; import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec; import org.opendaylight.controller.sal.core.api.model.SchemaService; -import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext; +import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext; public class SchemaModule extends AbstractModule { diff --git a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/schema/SchemaServiceProvider.java b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/schema/SchemaServiceProvider.java index 157473a6c..ec4a303d6 100644 --- a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/schema/SchemaServiceProvider.java +++ b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/schema/SchemaServiceProvider.java @@ -19,8 +19,8 @@ package io.fd.honeycomb.infra.distro.schema; import com.google.inject.Inject; import io.fd.honeycomb.binding.init.ProviderTrait; import org.opendaylight.controller.sal.core.api.model.SchemaService; +import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext; import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext; import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.model.api.SchemaContextListener; diff --git a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/schema/SerializerProvider.java b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/schema/SerializerProvider.java index ddc6667cd..dbd08a422 100644 --- a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/schema/SerializerProvider.java +++ b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/schema/SerializerProvider.java @@ -20,12 +20,12 @@ import com.google.inject.Inject; import io.fd.honeycomb.binding.init.ProviderTrait; import javassist.ClassPool; import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec; +import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext; +import org.opendaylight.mdsal.binding.generator.util.BindingRuntimeContext; +import org.opendaylight.mdsal.binding.generator.util.JavassistUtils; import org.opendaylight.yangtools.binding.data.codec.gen.impl.DataObjectSerializerGenerator; import org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator; import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry; -import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext; -import org.opendaylight.yangtools.sal.binding.generator.util.BindingRuntimeContext; -import org.opendaylight.yangtools.sal.binding.generator.util.JavassistUtils; public class SerializerProvider extends ProviderTrait<BindingToNormalizedNodeCodec> { diff --git a/infra/northbound/bgp/pom.xml b/infra/northbound/bgp/pom.xml index 2831924d4..ac5a46c33 100644 --- a/infra/northbound/bgp/pom.xml +++ b/infra/northbound/bgp/pom.xml @@ -77,17 +77,6 @@ <dependency> <groupId>org.opendaylight.bgpcep</groupId> <artifactId>bgp-rib-impl</artifactId> - <!-- TODO remove exclusion after bumping to Boron-SR4 --> - <exclusions> - <exclusion> - <groupId>org.powermock</groupId> - <artifactId>powermock</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.opendaylight.bgpcep</groupId> - <artifactId>bgp-openconfig-impl</artifactId> </dependency> <!-- ODL BGP extensions --> diff --git a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BGPDispatcherImplProvider.java b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BGPDispatcherImplProvider.java index 92b743660..c737f7493 100644 --- a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BGPDispatcherImplProvider.java +++ b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BGPDispatcherImplProvider.java @@ -22,15 +22,18 @@ import io.netty.channel.EventLoopGroup; import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionConsumerContext; import org.opendaylight.protocol.bgp.rib.impl.BGPDispatcherImpl; import org.opendaylight.protocol.bgp.rib.impl.spi.BGPDispatcher; +import org.opendaylight.protocol.bgp.rib.impl.spi.BGPPeerRegistry; final class BGPDispatcherImplProvider extends ProviderTrait<BGPDispatcher> { @Inject private BGPExtensionConsumerContext consumerContext; @Inject private EventLoopGroup threadGroup; + @Inject + private BGPPeerRegistry peerRegistry; @Override protected BGPDispatcher create() { - return new BGPDispatcherImpl(consumerContext.getMessageRegistry(), threadGroup, threadGroup); + return new BGPDispatcherImpl(consumerContext.getMessageRegistry(), threadGroup, threadGroup, peerRegistry); } } diff --git a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BGPTableTypeRegistryConsumerProvider.java b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BGPTableTypeRegistryConsumerProvider.java new file mode 100644 index 000000000..06ef5ea7a --- /dev/null +++ b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BGPTableTypeRegistryConsumerProvider.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fd.honeycomb.infra.bgp; + +import com.google.inject.Inject; +import io.fd.honeycomb.binding.init.ProviderTrait; +import java.util.Set; +import org.opendaylight.protocol.bgp.openconfig.spi.BGPTableTypeRegistryConsumer; +import org.opendaylight.protocol.bgp.openconfig.spi.SimpleBGPTableTypeRegistryProvider; + +final class BGPTableTypeRegistryConsumerProvider extends ProviderTrait<BGPTableTypeRegistryConsumer> { + @Inject + private Set<BGPTableType> tableTypes; + + @Override + protected BGPTableTypeRegistryConsumer create() { + final SimpleBGPTableTypeRegistryProvider registry = new SimpleBGPTableTypeRegistryProvider(); + tableTypes.stream().forEach(tableType -> tableType.register(registry)); + return registry; + } + + interface BGPTableType { + void register(SimpleBGPTableTypeRegistryProvider registry); + } +} diff --git a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpExtensionsModule.java b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpExtensionsModule.java index b096e3dbd..4f9ab7a61 100644 --- a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpExtensionsModule.java +++ b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpExtensionsModule.java @@ -19,12 +19,30 @@ package io.fd.honeycomb.infra.bgp; import com.google.inject.AbstractModule; import com.google.inject.Singleton; import com.google.inject.multibindings.Multibinder; +import org.opendaylight.protocol.bgp.openconfig.spi.BGPTableTypeRegistryConsumer; import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionConsumerContext; import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderActivator; import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionConsumerContext; import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderActivator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4LABELLEDUNICAST; +import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST; +import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV6LABELLEDUNICAST; +import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV6UNICAST; +import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.L2VPNEVPN; +import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.L3VPNIPV4UNICAST; +import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.L3VPNIPV6UNICAST; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.EvpnSubsequentAddressFamily; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.L2vpnAddressFamily; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev150525.LabeledUnicastSubsequentAddressFamily; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev150210.LinkstateAddressFamily; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev150210.LinkstateSubsequentAddressFamily; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev160614.LINKSTATE; +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.Ipv6AddressFamily; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.MplsLabeledVpnSubsequentAddressFamily; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily; /** * Registers BGP extensions provided by ODL implementation. @@ -41,6 +59,7 @@ final class BgpExtensionsModule extends AbstractModule { // https://github.com/google/guice/issues/906 configureRIBExtensions(); configureBGPExtensions(); + configureTableTypes(); } private void configureRIBExtensions() { @@ -69,4 +88,39 @@ final class BgpExtensionsModule extends AbstractModule { bind(BGPExtensionConsumerContext.class).toProvider(BGPExtensionConsumerContextProvider.class) .in(Singleton.class); } + + private void configureTableTypes() { + final Multibinder<BGPTableTypeRegistryConsumerProvider.BGPTableType> tableTypeBinder = + Multibinder.newSetBinder(binder(), + BGPTableTypeRegistryConsumerProvider.BGPTableType.class); + + tableTypeBinder.addBinding().toInstance(provider -> provider + .registerBGPTableType(L2vpnAddressFamily.class, EvpnSubsequentAddressFamily.class, L2VPNEVPN.class)); + + tableTypeBinder.addBinding().toInstance(provider -> provider + .registerBGPTableType(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class, IPV4UNICAST.class)); + tableTypeBinder.addBinding().toInstance(provider -> provider + .registerBGPTableType(Ipv6AddressFamily.class, UnicastSubsequentAddressFamily.class, IPV6UNICAST.class)); + + tableTypeBinder.addBinding().toInstance(provider -> provider + .registerBGPTableType(Ipv4AddressFamily.class, MplsLabeledVpnSubsequentAddressFamily.class, + L3VPNIPV4UNICAST.class)); + tableTypeBinder.addBinding().toInstance(provider -> provider + .registerBGPTableType(Ipv6AddressFamily.class, MplsLabeledVpnSubsequentAddressFamily.class, + L3VPNIPV6UNICAST.class)); + + tableTypeBinder.addBinding().toInstance(provider -> provider + .registerBGPTableType(Ipv4AddressFamily.class, LabeledUnicastSubsequentAddressFamily.class, + IPV4LABELLEDUNICAST.class)); + tableTypeBinder.addBinding().toInstance(provider -> provider + .registerBGPTableType(Ipv6AddressFamily.class, LabeledUnicastSubsequentAddressFamily.class, + IPV6LABELLEDUNICAST.class)); + + tableTypeBinder.addBinding().toInstance(provider -> provider + .registerBGPTableType(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class, + LINKSTATE.class)); + + bind(BGPTableTypeRegistryConsumer.class).toProvider(BGPTableTypeRegistryConsumerProvider.class) + .in(Singleton.class); + } } diff --git a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpModule.java b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpModule.java index 3cab508b4..943a57e1a 100644 --- a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpModule.java +++ b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpModule.java @@ -57,9 +57,8 @@ public final class BgpModule extends PrivateModule { bind(RibWriter.class).toProvider(LocRibWriterProvider.class).asEagerSingleton(); expose(RibWriter.class); - // install other BGP modules (hidden from HC user): + // install configuration module (hidden from HC user): install(new BgpConfigurationModule()); - install(new BgpExtensionsModule()); } private void configureRIB() { diff --git a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpRIBProvider.java b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpRIBProvider.java index 7fcddfc5c..a25808850 100644 --- a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpRIBProvider.java +++ b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpRIBProvider.java @@ -16,6 +16,8 @@ package io.fd.honeycomb.infra.bgp; +import static org.opendaylight.protocol.bgp.rib.impl.config.OpenConfigMappingUtil.toTableTypes; + import com.google.common.collect.ImmutableList; import com.google.inject.Inject; import io.fd.honeycomb.binding.init.ProviderTrait; @@ -30,8 +32,9 @@ 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.openconfig.spi.BGPOpenConfigMappingService; +import org.opendaylight.protocol.bgp.openconfig.spi.BGPTableTypeRegistryConsumer; import org.opendaylight.protocol.bgp.rib.impl.RIBImpl; +import org.opendaylight.protocol.bgp.rib.impl.config.OpenConfigMappingUtil; import org.opendaylight.protocol.bgp.rib.impl.spi.BGPDispatcher; import org.opendaylight.protocol.bgp.rib.impl.spi.RIB; import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionConsumerContext; @@ -64,7 +67,7 @@ final class BgpRIBProvider extends ProviderTrait<RIB> { @Inject private DOMDataBroker domBroker; @Inject - private BGPOpenConfigMappingService mappingService; + private BGPTableTypeRegistryConsumer tableTypeRegistry; @Inject private SchemaService schemaService; @@ -87,14 +90,15 @@ final class BgpRIBProvider extends ProviderTrait<RIB> { .setSendMax(cfg.bgpSendMaxMaths.get().shortValue()).build()) .build() ); - final Map<TablesKey, PathSelectionMode> pathSelectionModes = mappingService.toPathSelectionMode(afiSafi) + final Map<TablesKey, PathSelectionMode> pathSelectionModes = + OpenConfigMappingUtil.toPathSelectionMode(afiSafi, tableTypeRegistry) .entrySet().stream().collect(Collectors.toMap(entry -> new TablesKey(entry.getKey().getAfi(), entry.getKey().getSafi()), Map.Entry::getValue)); - // based on RIBImpl.createRib + // based on org.opendaylight.protocol.bgp.rib.impl.config.RibImpl.createRib final RIBImpl rib = new RIBImpl(new NoopClusterSingletonServiceProvider(), new RibId(cfg.bgpProtocolInstanceName.get()), asNumber, new BgpId(routerId), clusterId, extensions, dispatcher, codec, - new PingPongDataBroker(domBroker), mappingService.toTableTypes(afiSafi), pathSelectionModes, + new PingPongDataBroker(domBroker), toTableTypes(afiSafi, tableTypeRegistry), pathSelectionModes, extensions.getClassLoadingStrategy(), null); // required for proper RIB's CodecRegistry initialization (based on RIBImpl.start) diff --git a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpServerProvider.java b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpServerProvider.java index ba95d32a0..876a39f14 100644 --- a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpServerProvider.java +++ b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpServerProvider.java @@ -57,7 +57,7 @@ public final class BgpServerProvider extends ProviderTrait<BgpServerProvider.Bg } final InetSocketAddress address = new InetSocketAddress(bindingAddress, cfg.bgpPort.get()); LOG.debug("Creating BgpServer for {}", address); - final ChannelFuture localServer = dispatcher.createServer(peerRegistry, address); + final ChannelFuture localServer = dispatcher.createServer(address); localServer.addListener(future -> { Preconditions.checkArgument(future.isSuccess(), "Unable to start bgp server on %s", address, future.cause()); final Channel channel = localServer.channel(); diff --git a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpWritersModule.java b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpWritersModule.java index 589eeac7b..c58afc067 100644 --- a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpWritersModule.java +++ b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpWritersModule.java @@ -21,8 +21,6 @@ import com.google.inject.Singleton; import com.google.inject.multibindings.Multibinder; import io.fd.honeycomb.infra.bgp.neighbors.BgpPeerWriterFactory; import io.fd.honeycomb.translate.write.WriterFactory; -import org.opendaylight.protocol.bgp.openconfig.impl.BGPOpenConfigMappingServiceImpl; -import org.opendaylight.protocol.bgp.openconfig.spi.BGPOpenConfigMappingService; import org.opendaylight.protocol.bgp.rib.impl.StrictBGPPeerRegistry; import org.opendaylight.protocol.bgp.rib.impl.spi.BGPPeerRegistry; import org.slf4j.Logger; @@ -42,9 +40,11 @@ public final class BgpWritersModule extends AbstractModule { // https://github.com/google/guice/issues/906 // Configure peer registry - bind(BGPOpenConfigMappingService.class).toInstance(new BGPOpenConfigMappingServiceImpl()); bind(BGPPeerRegistry.class).toInstance(StrictBGPPeerRegistry.instance()); + // install extensions module (hidden from HC user until HONEYCOMB-363 is fixed): + install(new BgpExtensionsModule()); + final Multibinder<WriterFactory> binder = Multibinder.newSetBinder(binder(), WriterFactory.class); binder.addBinding().to(ApplicationRibWriterFactory.class).in(Singleton.class); binder.addBinding().to(BgpPeerWriterFactory.class).in(Singleton.class); diff --git a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/neighbors/BgpPeerWriterFactory.java b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/neighbors/BgpPeerWriterFactory.java index 064c70b57..8b7510eb8 100644 --- a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/neighbors/BgpPeerWriterFactory.java +++ b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/neighbors/BgpPeerWriterFactory.java @@ -23,7 +23,7 @@ import io.fd.honeycomb.translate.impl.write.GenericListWriter; import io.fd.honeycomb.translate.write.WriterFactory; import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder; import javax.annotation.Nonnull; -import org.opendaylight.protocol.bgp.openconfig.spi.BGPOpenConfigMappingService; +import org.opendaylight.protocol.bgp.openconfig.spi.BGPTableTypeRegistryConsumer; import org.opendaylight.protocol.bgp.rib.impl.spi.BGPPeerRegistry; import org.opendaylight.protocol.bgp.rib.impl.spi.RIB; import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafi; @@ -63,7 +63,7 @@ public final class BgpPeerWriterFactory implements WriterFactory { @Inject private RIB globalRib; @Inject - private BGPOpenConfigMappingService mappingService; + private BGPTableTypeRegistryConsumer tableTypeRegistry; @Inject private BGPPeerRegistry peerRegistry; @@ -104,7 +104,7 @@ public final class BgpPeerWriterFactory implements WriterFactory { ), new GenericListWriter<>( NEIGHBOR_ID, - new NeighborCustomizer(globalRib, peerRegistry, mappingService))); + new NeighborCustomizer(globalRib, peerRegistry, tableTypeRegistry))); } } diff --git a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/neighbors/NeighborCustomizer.java b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/neighbors/NeighborCustomizer.java index 50ae45b40..baccb9a1c 100644 --- a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/neighbors/NeighborCustomizer.java +++ b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/neighbors/NeighborCustomizer.java @@ -18,7 +18,7 @@ package io.fd.honeycomb.infra.bgp.neighbors; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; -import static org.opendaylight.protocol.bgp.openconfig.impl.util.OpenConfigUtil.APPLICATION_PEER_GROUP_NAME; +import static org.opendaylight.protocol.bgp.rib.impl.config.OpenConfigMappingUtil.isApplicationPeer; import com.google.common.annotations.VisibleForTesting; import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer; @@ -29,16 +29,14 @@ import java.util.Map; import javax.annotation.Nonnull; import javax.annotation.concurrent.GuardedBy; import javax.annotation.concurrent.ThreadSafe; -import org.opendaylight.protocol.bgp.openconfig.spi.BGPOpenConfigMappingService; +import org.opendaylight.protocol.bgp.openconfig.spi.BGPTableTypeRegistryConsumer; import org.opendaylight.protocol.bgp.rib.impl.config.AppPeer; import org.opendaylight.protocol.bgp.rib.impl.config.BgpPeer; import org.opendaylight.protocol.bgp.rib.impl.config.PeerBean; import org.opendaylight.protocol.bgp.rib.impl.spi.BGPPeerRegistry; import org.opendaylight.protocol.bgp.rib.impl.spi.RIB; -import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.BgpNeighborPeerGroupConfig; import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor; import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.NeighborKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev160614.Config2; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -52,16 +50,17 @@ final class NeighborCustomizer implements ListWriterCustomizer<Neighbor, Neighbo private static final Logger LOG = LoggerFactory.getLogger(NeighborCustomizer.class); private final RIB globalRib; private final BGPPeerRegistry peerRegistry; - private final BGPOpenConfigMappingService mappingService; + private BGPTableTypeRegistryConsumer tableTypeRegistry; + @GuardedBy("this") private final Map<InstanceIdentifier<Neighbor>, PeerBean> peers = new HashMap<>(); public NeighborCustomizer(@Nonnull final RIB globalRib, @Nonnull final BGPPeerRegistry peerRegistry, - @Nonnull final BGPOpenConfigMappingService mappingService) { + @Nonnull final BGPTableTypeRegistryConsumer tableTypeRegistry) { this.globalRib = checkNotNull(globalRib, "globalRib should not be null"); this.peerRegistry = checkNotNull(peerRegistry, "globalRib should not be null"); - this.mappingService = checkNotNull(mappingService, "globalRib should not be null"); + this.tableTypeRegistry = checkNotNull(tableTypeRegistry, "tableTypeRegistry should not be null"); } @VisibleForTesting @@ -86,10 +85,10 @@ final class NeighborCustomizer implements ListWriterCustomizer<Neighbor, Neighbo peer = new AppPeer(); } else { LOG.debug("Starting BgpPeer bean for {}: {}", id, neighbor); - peer = new BgpPeer(null, peerRegistry); + peer = new BgpPeer(null); } LOG.debug("Starting bgp peer for {}", id); - peer.start(globalRib, neighbor, mappingService, null); + peer.start(globalRib, neighbor, tableTypeRegistry, null); addPeer(id, peer); } @@ -103,7 +102,7 @@ final class NeighborCustomizer implements ListWriterCustomizer<Neighbor, Neighbo final PeerBean peer = peers.get(id); checkState(peer != null, "Could not find peer bean while updating neighbor {}", id); closePeerBean(peer); - peer.start(globalRib, dataAfter, mappingService, null); + peer.start(globalRib, dataAfter, tableTypeRegistry, null); LOG.debug("Peer instance updated {}", peer); } @@ -120,14 +119,6 @@ final class NeighborCustomizer implements ListWriterCustomizer<Neighbor, Neighbo } } - private static boolean isApplicationPeer(@Nonnull final Neighbor neighbor) { - return java.util.Optional.of(neighbor.getConfig()) - .map(config -> config.getAugmentation(Config2.class)) - .map(BgpNeighborPeerGroupConfig::getPeerGroup) - .map(APPLICATION_PEER_GROUP_NAME::equals) - .orElse(false); - } - private static void closePeerBean(final PeerBean peer) { try { peer.closeServiceInstance().get(); diff --git a/infra/northbound/bgp/src/test/java/io/fd/honeycomb/infra/bgp/neighbors/NeighborCustomizerTest.java b/infra/northbound/bgp/src/test/java/io/fd/honeycomb/infra/bgp/neighbors/NeighborCustomizerTest.java index 4f348510a..ba71cc90e 100644 --- a/infra/northbound/bgp/src/test/java/io/fd/honeycomb/infra/bgp/neighbors/NeighborCustomizerTest.java +++ b/infra/northbound/bgp/src/test/java/io/fd/honeycomb/infra/bgp/neighbors/NeighborCustomizerTest.java @@ -22,42 +22,52 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import static org.mockito.MockitoAnnotations.initMocks; -import static org.opendaylight.protocol.bgp.openconfig.impl.util.OpenConfigUtil.APPLICATION_PEER_GROUP_NAME; import io.fd.honeycomb.translate.write.WriteContext; import io.fd.honeycomb.translate.write.WriteFailedException; +import java.util.Collections; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier; -import org.opendaylight.protocol.bgp.openconfig.spi.BGPOpenConfigMappingService; +import org.opendaylight.protocol.bgp.openconfig.spi.BGPTableTypeRegistryConsumer; import org.opendaylight.protocol.bgp.rib.impl.config.PeerBean; import org.opendaylight.protocol.bgp.rib.impl.spi.BGPPeerRegistry; import org.opendaylight.protocol.bgp.rib.impl.spi.RIB; +import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafiBuilder; +import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.AfiSafisBuilder; import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.ConfigBuilder; import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor; import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.NeighborBuilder; import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.NeighborKey; import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.Neighbors; +import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST; import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.PeerType; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev160614.Config2; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev160614.Config2Builder; +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.bgp.rib.Rib; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.bgp.rib.RibKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; public class NeighborCustomizerTest { private static final IpAddress IP = new IpAddress(new Ipv4Address("10.25.1.9")); private static final InstanceIdentifier<Neighbor> ID = InstanceIdentifier.create(Neighbors.class).child(Neighbor.class, new NeighborKey(IP)); + private static final KeyedInstanceIdentifier<Rib, RibKey> RIB_IID = + InstanceIdentifier.create(BgpRib.class).child(Rib.class, new RibKey(new RibId("test-rib-id"))); @Mock private RIB globalRib; @Mock private BGPPeerRegistry peerRegistry; @Mock - private BGPOpenConfigMappingService mappingService; + private BGPTableTypeRegistryConsumer tableTypeRegistry; @Mock private WriteContext ctx; @@ -68,7 +78,8 @@ public class NeighborCustomizerTest { initMocks(this); when(globalRib.getYangRibId()).thenReturn(YangInstanceIdentifier.EMPTY); when(globalRib.getRibIServiceGroupIdentifier()).thenReturn(ServiceGroupIdentifier.create("sgid")); - customizer = new NeighborCustomizer(globalRib, peerRegistry, mappingService); + when(globalRib.getInstanceIdentifier()).thenReturn(RIB_IID); + customizer = new NeighborCustomizer(globalRib, peerRegistry, tableTypeRegistry); } @Test @@ -79,7 +90,7 @@ public class NeighborCustomizerTest { new ConfigBuilder() .addAugmentation( Config2.class, - new Config2Builder().setPeerGroup(APPLICATION_PEER_GROUP_NAME).build() + new Config2Builder().setPeerGroup("application-peers").build() ).build()) .build(); customizer.writeCurrentAttributes(ID, neighbor, ctx); @@ -90,6 +101,10 @@ public class NeighborCustomizerTest { public void testAddInternalPeer() throws WriteFailedException { final Neighbor neighbor = new NeighborBuilder() .setNeighborAddress(IP) + .setAfiSafis(new AfiSafisBuilder() + .setAfiSafi(Collections.singletonList( + new AfiSafiBuilder().setAfiSafiName(IPV4UNICAST.class).build() + )).build()) .setConfig( new ConfigBuilder() .setPeerType(PeerType.INTERNAL) @@ -108,7 +123,7 @@ public class NeighborCustomizerTest { customizer.updateCurrentAttributes(ID, before, after, ctx); verify(peer).closeServiceInstance(); verify(peer).close(); - verify(peer).start(globalRib, after, mappingService, null); + verify(peer).start(globalRib, after, tableTypeRegistry, null); } @Test diff --git a/infra/northbound/netconf/src/main/java/io/fd/honeycomb/northbound/netconf/NetconfMdsalMapperProvider.java b/infra/northbound/netconf/src/main/java/io/fd/honeycomb/northbound/netconf/NetconfMdsalMapperProvider.java index 4f0c00655..bb9264684 100644 --- a/infra/northbound/netconf/src/main/java/io/fd/honeycomb/northbound/netconf/NetconfMdsalMapperProvider.java +++ b/infra/northbound/netconf/src/main/java/io/fd/honeycomb/northbound/netconf/NetconfMdsalMapperProvider.java @@ -16,14 +16,18 @@ package io.fd.honeycomb.northbound.netconf; +import static io.fd.honeycomb.infra.distro.data.ConfigAndOperationalPipelineModule.HONEYCOMB_CONFIG; + import com.google.inject.Inject; +import com.google.inject.name.Named; import io.fd.honeycomb.binding.init.ProviderTrait; -import org.opendaylight.controller.sal.core.api.Broker; +import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; +import org.opendaylight.controller.md.sal.dom.api.DOMRpcService; import org.opendaylight.controller.sal.core.api.model.SchemaService; +import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext; import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory; import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactoryListener; import org.opendaylight.netconf.mdsal.connector.MdsalNetconfOperationServiceFactory; -import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext; public final class NetconfMdsalMapperProvider extends ProviderTrait<NetconfOperationServiceFactory> { @@ -34,14 +38,17 @@ public final class NetconfMdsalMapperProvider extends ProviderTrait<NetconfOpera @Inject private ModuleInfoBackedContext moduleInfoBackedContext; @Inject - private Broker domBroker; + @Named(HONEYCOMB_CONFIG) + private DOMDataBroker domBroker; + @Inject + private NetconfOperationServiceFactoryListener netconfOperationServiceFactoryListener; + @Inject + private DOMRpcService rpcService; @Override protected MdsalNetconfOperationServiceFactory create() { MdsalNetconfOperationServiceFactory mdsalNetconfOperationServiceFactory = - new MdsalNetconfOperationServiceFactory(schemaService, moduleInfoBackedContext); - domBroker.registerConsumer(mdsalNetconfOperationServiceFactory); - aggregator.onAddNetconfOperationServiceFactory(mdsalNetconfOperationServiceFactory); + new MdsalNetconfOperationServiceFactory(schemaService, moduleInfoBackedContext, netconfOperationServiceFactoryListener, domBroker, rpcService); return mdsalNetconfOperationServiceFactory; } } diff --git a/infra/northbound/netconf/src/main/java/io/fd/honeycomb/northbound/netconf/NetconfMonitoringMapperProvider.java b/infra/northbound/netconf/src/main/java/io/fd/honeycomb/northbound/netconf/NetconfMonitoringMapperProvider.java index 516df2aa5..e7b5edb07 100644 --- a/infra/northbound/netconf/src/main/java/io/fd/honeycomb/northbound/netconf/NetconfMonitoringMapperProvider.java +++ b/infra/northbound/netconf/src/main/java/io/fd/honeycomb/northbound/netconf/NetconfMonitoringMapperProvider.java @@ -19,24 +19,22 @@ package io.fd.honeycomb.northbound.netconf; import com.google.inject.Inject; import com.google.inject.name.Named; import io.fd.honeycomb.binding.init.ProviderTrait; -import java.lang.reflect.Constructor; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; -import org.opendaylight.controller.sal.binding.api.BindingAwareProvider; +import org.opendaylight.controller.config.yang.netconf.mdsal.monitoring.MdsalMonitoringMapperFactory; +import org.opendaylight.controller.config.yang.netconf.mdsal.monitoring.MonitoringToMdsalWriter; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService; -import org.opendaylight.netconf.mapping.api.NetconfOperationService; import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory; import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactoryListener; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - public final class NetconfMonitoringMapperProvider extends ProviderTrait<NetconfOperationServiceFactory> { private static final Logger LOG = LoggerFactory.getLogger(NetconfMonitoringMapperProvider.class); @Inject @Named(NetconfModule.HONEYCOMB_NETCONF) - private BindingAwareBroker bindingAwareBroker; + private DataBroker dataBroker; @Inject private NetconfOperationServiceFactoryListener aggregator; @Inject @@ -44,40 +42,11 @@ public final class NetconfMonitoringMapperProvider extends ProviderTrait<Netconf @Override protected NetconfOperationServiceFactory create() { - try { - final Class<?> monitoringWriterCls = Class.forName( - "org.opendaylight.controller.config.yang.netconf.mdsal.monitoring.MonitoringToMdsalWriter"); - Constructor<?> declaredConstructor = - monitoringWriterCls.getDeclaredConstructor(NetconfMonitoringService.class); - declaredConstructor.setAccessible(true); - final BindingAwareProvider writer = (BindingAwareProvider) declaredConstructor.newInstance(monitoringService); - bindingAwareBroker.registerProvider(writer); - - final Class<?> moduleClass = Class.forName( - "org.opendaylight.controller.config.yang.netconf.mdsal.monitoring.NetconfMdsalMonitoringMapperModule"); - final Class<?> monitoringMapperCls = Class.forName( - "org.opendaylight.controller.config.yang.netconf.mdsal.monitoring.NetconfMdsalMonitoringMapperModule$MdsalMonitoringMapper"); - declaredConstructor = - monitoringMapperCls.getDeclaredConstructor(NetconfMonitoringService.class); - declaredConstructor.setAccessible(true); - final NetconfOperationService mdSalMonitoringMapper = - (NetconfOperationService) declaredConstructor.newInstance(monitoringService); + LOG.trace("Initializing MonitoringToMdsalWriter"); + final MonitoringToMdsalWriter writer = new MonitoringToMdsalWriter(monitoringService, dataBroker); + writer.start(); - final Class<?> monitoringMpperFactory = Class.forName( - "org.opendaylight.controller.config.yang.netconf.mdsal.monitoring.NetconfMdsalMonitoringMapperModule$MdSalMonitoringMapperFactory"); - declaredConstructor = - monitoringMpperFactory.getDeclaredConstructor(NetconfOperationService.class, moduleClass, monitoringWriterCls); - declaredConstructor.setAccessible(true); - // The second argument is null, it should be the parent cfg-subsystem module class instance, that we dont have - // it's used only during close so dont close the factory using its close() method - final NetconfOperationServiceFactory mdSalMonitoringMapperFactory = - (NetconfOperationServiceFactory) declaredConstructor.newInstance(mdSalMonitoringMapper, null, writer); - aggregator.onAddNetconfOperationServiceFactory(mdSalMonitoringMapperFactory); - return mdSalMonitoringMapperFactory; - } catch (final ReflectiveOperationException e) { - final String msg = "Unable to instantiate operation service factory using reflection"; - LOG.error(msg, e); - throw new IllegalStateException(msg, e); - } + LOG.trace("Providing MdsalMonitoringMapperFactory"); + return new MdsalMonitoringMapperFactory(aggregator, monitoringService, writer); } } diff --git a/infra/northbound/netconf/src/main/java/io/fd/honeycomb/northbound/netconf/NetconfNotificationMapperProvider.java b/infra/northbound/netconf/src/main/java/io/fd/honeycomb/northbound/netconf/NetconfNotificationMapperProvider.java index b2155fac1..d097e3419 100644 --- a/infra/northbound/netconf/src/main/java/io/fd/honeycomb/northbound/netconf/NetconfNotificationMapperProvider.java +++ b/infra/northbound/netconf/src/main/java/io/fd/honeycomb/northbound/netconf/NetconfNotificationMapperProvider.java @@ -19,22 +19,18 @@ package io.fd.honeycomb.northbound.netconf; import com.google.inject.Inject; import com.google.inject.name.Named; import io.fd.honeycomb.binding.init.ProviderTrait; -import java.lang.reflect.Constructor; +import org.opendaylight.controller.config.yang.netconf.mdsal.notification.CapabilityChangeNotificationProducer; +import org.opendaylight.controller.config.yang.netconf.mdsal.notification.NotificationToMdsalWriter; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener; -import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; -import org.opendaylight.controller.sal.binding.api.BindingAwareProvider; import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory; import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactoryListener; import org.opendaylight.netconf.mdsal.notification.NetconfNotificationOperationServiceFactory; -import org.opendaylight.netconf.notifications.BaseNotificationPublisherRegistration; import org.opendaylight.netconf.notifications.NetconfNotificationCollector; import org.opendaylight.netconf.notifications.NetconfNotificationRegistry; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.NetconfState; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.Capabilities; -import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -61,38 +57,17 @@ public class NetconfNotificationMapperProvider extends ProviderTrait<NetconfOper @Override protected NetconfNotificationOperationServiceFactory create() { - try { - final Class<?> notificationWriter = Class.forName( - "org.opendaylight.controller.config.yang.netconf.mdsal.notification.NotificationToMdsalWriter"); - Constructor<?> declaredConstructor = - notificationWriter.getDeclaredConstructor(NetconfNotificationCollector.class); - declaredConstructor.setAccessible(true); - final BindingAwareProvider writer = - (BindingAwareProvider) declaredConstructor.newInstance(notificationCollector); - bindingAwareBroker.registerProvider(writer); + LOG.trace("Initializing NotificationToMdsalWriter"); + final NotificationToMdsalWriter writer = new NotificationToMdsalWriter(notificationCollector, dataBroker); + writer.start(); - final Class<?> notifPublisherCls = Class.forName( - "org.opendaylight.controller.config.yang.netconf.mdsal.notification.CapabilityChangeNotificationProducer"); - declaredConstructor = - notifPublisherCls.getDeclaredConstructor(BaseNotificationPublisherRegistration.class); - declaredConstructor.setAccessible(true); - final DataTreeChangeListener<Capabilities> publisher = - (DataTreeChangeListener<Capabilities>) declaredConstructor.newInstance( - notificationCollector.registerBaseNotificationPublisher()); - - ListenerRegistration<DataTreeChangeListener<Capabilities>> capabilityChangeListenerRegistration = dataBroker - .registerDataTreeChangeListener( - new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, capabilitiesIdentifier), - publisher); - NetconfNotificationOperationServiceFactory netconfNotificationOperationServiceFactory = - new NetconfNotificationOperationServiceFactory(notificationRegistry); - aggregator.onAddNetconfOperationServiceFactory(netconfNotificationOperationServiceFactory); + LOG.trace("Initializing CapabilityChangeNotificationProducer"); + final DataTreeChangeListener<Capabilities> publisher = + new CapabilityChangeNotificationProducer(notificationCollector, dataBroker); + LOG.trace("Providing NetconfNotificationOperationServiceFactory"); + NetconfNotificationOperationServiceFactory netconfNotificationOperationServiceFactory = + new NetconfNotificationOperationServiceFactory(notificationRegistry, aggregator); return netconfNotificationOperationServiceFactory; - } catch (final ReflectiveOperationException e) { - final String msg = "Unable to instantiate notification mapper using reflection"; - LOG.error(msg, e); - throw new IllegalStateException(msg, e); - } } } diff --git a/infra/northbound/restconf/pom.xml b/infra/northbound/restconf/pom.xml index 3f7427208..1f3d2db13 100644 --- a/infra/northbound/restconf/pom.xml +++ b/infra/northbound/restconf/pom.xml @@ -101,5 +101,11 @@ <artifactId>jersey-servlet</artifactId> <version>${jersey.version}</version> </dependency> + + <!-- javax.annotation --> + <dependency> + <groupId>com.google.code.findbugs</groupId> + <artifactId>jsr305</artifactId> + </dependency> </dependencies> </project>
\ No newline at end of file diff --git a/infra/notification/api/pom.xml b/infra/notification/api/pom.xml index 95a7c62bb..575564195 100644 --- a/infra/notification/api/pom.xml +++ b/infra/notification/api/pom.xml @@ -38,5 +38,9 @@ <groupId>org.opendaylight.mdsal</groupId> <artifactId>yang-binding</artifactId> </dependency> + <dependency> + <groupId>com.google.code.findbugs</groupId> + <artifactId>jsr305</artifactId> + </dependency> </dependencies> </project> diff --git a/infra/notification/impl/src/test/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/notification/impl/rev160601/NoetificationToNetconfModuleTest.java b/infra/notification/impl/src/test/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/notification/impl/rev160601/NoetificationToNetconfModuleTest.java index d9b487be7..0057c633d 100644 --- a/infra/notification/impl/src/test/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/notification/impl/rev160601/NoetificationToNetconfModuleTest.java +++ b/infra/notification/impl/src/test/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/notification/impl/rev160601/NoetificationToNetconfModuleTest.java @@ -21,9 +21,9 @@ import org.hamcrest.CoreMatchers; import org.junit.Assert; import org.junit.Test; import org.opendaylight.controller.md.sal.dom.api.DOMNotification; +import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext; import org.opendaylight.netconf.notifications.NetconfNotification; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.*; -import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfSessionStart; import org.opendaylight.yangtools.yang.binding.YangModuleInfo; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; diff --git a/infra/rpc/api/pom.xml b/infra/rpc/api/pom.xml index 4699a4c3e..0f13c35d1 100644 --- a/infra/rpc/api/pom.xml +++ b/infra/rpc/api/pom.xml @@ -34,6 +34,10 @@ <groupId>org.opendaylight.controller</groupId> <artifactId>sal-core-api</artifactId> </dependency> + <dependency> + <groupId>com.google.code.findbugs</groupId> + <artifactId>jsr305</artifactId> + </dependency> </dependencies> </project> diff --git a/infra/rpc/impl/pom.xml b/infra/rpc/impl/pom.xml index cae70f026..631b9db56 100644 --- a/infra/rpc/impl/pom.xml +++ b/infra/rpc/impl/pom.xml @@ -36,11 +36,6 @@ <version>${project.version}</version> </dependency> <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> - <scope>test</scope> - </dependency> - <dependency> <groupId>org.opendaylight.mdsal</groupId> <artifactId>mdsal-binding-dom-codec</artifactId> </dependency> @@ -65,5 +60,15 @@ <artifactId>mockito-core</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <scope>test</scope> + </dependency> </dependencies> </project> diff --git a/infra/test-utils/test-tools/src/main/java/io/fd/honeycomb/test/tools/HoneycombTestRunner.java b/infra/test-utils/test-tools/src/main/java/io/fd/honeycomb/test/tools/HoneycombTestRunner.java index 0f8b1b9af..5b6cc5af8 100644 --- a/infra/test-utils/test-tools/src/main/java/io/fd/honeycomb/test/tools/HoneycombTestRunner.java +++ b/infra/test-utils/test-tools/src/main/java/io/fd/honeycomb/test/tools/HoneycombTestRunner.java @@ -17,23 +17,22 @@ package io.fd.honeycomb.test.tools; import io.fd.honeycomb.test.tools.annotations.InjectablesProcessor; +import java.lang.annotation.Annotation; +import java.lang.reflect.Parameter; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; import org.junit.runners.BlockJUnit4ClassRunner; import org.junit.runners.model.FrameworkMethod; import org.junit.runners.model.InitializationError; import org.junit.runners.model.Statement; import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec; -import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext; +import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext; import org.opendaylight.yangtools.yang.data.util.AbstractModuleStringInstanceIdentifierCodec; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.lang.annotation.Annotation; -import java.lang.reflect.Parameter; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - public class HoneycombTestRunner extends BlockJUnit4ClassRunner implements YangContextProducer, InjectablesProcessor { private static final Logger LOG = LoggerFactory.getLogger(HoneycombTestRunner.class); diff --git a/infra/test-utils/test-tools/src/main/java/io/fd/honeycomb/test/tools/YangContextProducer.java b/infra/test-utils/test-tools/src/main/java/io/fd/honeycomb/test/tools/YangContextProducer.java index 017a68c9f..beb30f837 100644 --- a/infra/test-utils/test-tools/src/main/java/io/fd/honeycomb/test/tools/YangContextProducer.java +++ b/infra/test-utils/test-tools/src/main/java/io/fd/honeycomb/test/tools/YangContextProducer.java @@ -16,25 +16,24 @@ package io.fd.honeycomb.test.tools; +import static com.google.common.base.Preconditions.checkState; + import io.fd.honeycomb.test.tools.annotations.SchemaContextProvider; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import javassist.ClassPool; import org.apache.commons.lang3.reflect.MethodUtils; import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec; +import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext; +import org.opendaylight.mdsal.binding.generator.util.BindingRuntimeContext; +import org.opendaylight.mdsal.binding.generator.util.JavassistUtils; import org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator; import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry; -import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext; -import org.opendaylight.yangtools.sal.binding.generator.util.BindingRuntimeContext; -import org.opendaylight.yangtools.sal.binding.generator.util.JavassistUtils; import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactory; import org.opendaylight.yangtools.yang.data.util.AbstractModuleStringInstanceIdentifierCodec; import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import static com.google.common.base.Preconditions.checkState; - /** * Common logic to initialize serializers/deserializers/etc while working with yang based data */ @@ -74,7 +73,8 @@ interface YangContextProducer { new BindingNormalizedNodeCodecRegistry( StreamWriterGenerator.create(JavassistUtils.forClassPool(ClassPool.getDefault()))); codecRegistry - .onBindingRuntimeContextUpdated(BindingRuntimeContext.create(moduleInfoBackedContext, moduleInfoBackedContext.getSchemaContext())); + .onBindingRuntimeContextUpdated( + BindingRuntimeContext.create(moduleInfoBackedContext, moduleInfoBackedContext.getSchemaContext())); return new BindingToNormalizedNodeCodec(moduleInfoBackedContext, codecRegistry); } } diff --git a/infra/test-utils/test-tools/src/main/java/io/fd/honeycomb/test/tools/YangDataProcessor.java b/infra/test-utils/test-tools/src/main/java/io/fd/honeycomb/test/tools/YangDataProcessor.java index fe46410d7..7c04eac84 100644 --- a/infra/test-utils/test-tools/src/main/java/io/fd/honeycomb/test/tools/YangDataProcessor.java +++ b/infra/test-utils/test-tools/src/main/java/io/fd/honeycomb/test/tools/YangDataProcessor.java @@ -22,7 +22,7 @@ import java.util.Optional; import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec; -import org.opendaylight.yangtools.sal.binding.generator.impl.BindingSchemaContextUtils; +import org.opendaylight.mdsal.binding.generator.impl.BindingSchemaContextUtils; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; diff --git a/infra/test-utils/test-tools/src/main/java/io/fd/honeycomb/test/tools/annotations/InjectablesProcessor.java b/infra/test-utils/test-tools/src/main/java/io/fd/honeycomb/test/tools/annotations/InjectablesProcessor.java index 216d8353b..c09f26e08 100644 --- a/infra/test-utils/test-tools/src/main/java/io/fd/honeycomb/test/tools/annotations/InjectablesProcessor.java +++ b/infra/test-utils/test-tools/src/main/java/io/fd/honeycomb/test/tools/annotations/InjectablesProcessor.java @@ -16,22 +16,21 @@ package io.fd.honeycomb.test.tools.annotations; +import static io.fd.honeycomb.test.tools.annotations.InjectTestData.NO_ID; + +import java.lang.reflect.Field; +import java.lang.reflect.Parameter; +import java.util.List; +import java.util.Set; +import javax.annotation.Nonnull; import org.apache.commons.lang3.reflect.FieldUtils; -import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext; +import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.YangModuleInfo; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.util.AbstractModuleStringInstanceIdentifierCodec; -import javax.annotation.Nonnull; -import java.lang.reflect.Field; -import java.lang.reflect.Parameter; -import java.util.List; -import java.util.Set; - -import static io.fd.honeycomb.test.tools.annotations.InjectTestData.NO_ID; - /** * Common logic for @InjectTestData */ diff --git a/infra/test-utils/test-tools/src/test/java/io/fd/honeycomb/test/tools/AbstractYangDataProcessorTest.java b/infra/test-utils/test-tools/src/test/java/io/fd/honeycomb/test/tools/AbstractYangDataProcessorTest.java index 2d5f0259d..4018d441c 100644 --- a/infra/test-utils/test-tools/src/test/java/io/fd/honeycomb/test/tools/AbstractYangDataProcessorTest.java +++ b/infra/test-utils/test-tools/src/test/java/io/fd/honeycomb/test/tools/AbstractYangDataProcessorTest.java @@ -18,15 +18,14 @@ package io.fd.honeycomb.test.tools; import io.fd.honeycomb.test.tools.annotations.InjectablesProcessor; +import java.lang.reflect.InvocationTargetException; +import java.util.Collections; import org.junit.Before; import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec; +import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.data.rev150105.$YangModuleInfoImpl; -import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext; import org.opendaylight.yangtools.yang.data.util.AbstractModuleStringInstanceIdentifierCodec; -import java.lang.reflect.InvocationTargetException; -import java.util.Collections; - abstract class AbstractYangDataProcessorTest implements InjectablesProcessor, YangContextProducer { ModuleInfoBackedContext moduleInfoBackedContext; diff --git a/infra/test-utils/test-tools/src/test/java/io/fd/honeycomb/test/tools/ContainerNodeDataProcessorTest.java b/infra/test-utils/test-tools/src/test/java/io/fd/honeycomb/test/tools/ContainerNodeDataProcessorTest.java index e1dbc1803..749adec45 100644 --- a/infra/test-utils/test-tools/src/test/java/io/fd/honeycomb/test/tools/ContainerNodeDataProcessorTest.java +++ b/infra/test-utils/test-tools/src/test/java/io/fd/honeycomb/test/tools/ContainerNodeDataProcessorTest.java @@ -16,13 +16,14 @@ package io.fd.honeycomb.test.tools; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import org.junit.Test; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import static org.junit.Assert.*; - public class ContainerNodeDataProcessorTest extends AbstractYangDataProcessorTest { private ContainerNodeDataProcessor processor; diff --git a/infra/test-utils/test-tools/src/test/java/io/fd/honeycomb/test/tools/HoneycombTestRunnerContainerTest.java b/infra/test-utils/test-tools/src/test/java/io/fd/honeycomb/test/tools/HoneycombTestRunnerContainerTest.java index 1461fa377..a6a84257b 100644 --- a/infra/test-utils/test-tools/src/test/java/io/fd/honeycomb/test/tools/HoneycombTestRunnerContainerTest.java +++ b/infra/test-utils/test-tools/src/test/java/io/fd/honeycomb/test/tools/HoneycombTestRunnerContainerTest.java @@ -16,24 +16,36 @@ package io.fd.honeycomb.test.tools; +import static io.fd.honeycomb.test.tools.InjectionTestData.AUGMENT_LIST_DATA_PATH; +import static io.fd.honeycomb.test.tools.InjectionTestData.AUGMENT_LIST_RESOURCE; +import static io.fd.honeycomb.test.tools.InjectionTestData.NESTED_LIST_DATA_PATH; +import static io.fd.honeycomb.test.tools.InjectionTestData.NESTED_LIST_RESOURCE; +import static io.fd.honeycomb.test.tools.InjectionTestData.ROOT_LIST_DATA_PATH; +import static io.fd.honeycomb.test.tools.InjectionTestData.ROOT_LIST_RESOURCE; +import static io.fd.honeycomb.test.tools.InjectionTestData.SIMPLES_LIST_RESOURCE; +import static io.fd.honeycomb.test.tools.InjectionTestData.SIMPLE_LIST_DATA_PATH; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + import io.fd.honeycomb.test.tools.annotations.InjectTestData; import io.fd.honeycomb.test.tools.annotations.InjectablesProcessor; import io.fd.honeycomb.test.tools.annotations.SchemaContextProvider; +import java.util.Collections; import org.junit.Test; import org.junit.runner.RunWith; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.data.rev150105.*; +import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.data.rev150105.$YangModuleInfoImpl; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.data.rev150105.AugContainerAugmentation; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.data.rev150105.RootList; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.data.rev150105.SimpleContainer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.data.rev150105.SimpleContainerBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.data.rev150105.simple.container.NestedContainer; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.data.rev150105.simple.container.SimpleList; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.data.rev150105.simple.container.augmented.container.ListInAugment; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.data.rev150105.simple.container.simple.list.ContUnderList; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.data.rev150105.simple.container.simple.list.ContUnderListBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.data.rev150105.simple.container.simple.list.NestedList; -import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext; - -import java.util.Collections; - -import static io.fd.honeycomb.test.tools.InjectionTestData.*; -import static org.junit.Assert.*; @RunWith(HoneycombTestRunner.class) public class HoneycombTestRunnerContainerTest implements InjectablesProcessor { diff --git a/infra/test-utils/test-tools/src/test/java/io/fd/honeycomb/test/tools/ListNodeDataProcessorTest.java b/infra/test-utils/test-tools/src/test/java/io/fd/honeycomb/test/tools/ListNodeDataProcessorTest.java index 1118d3387..ddb30ef31 100644 --- a/infra/test-utils/test-tools/src/test/java/io/fd/honeycomb/test/tools/ListNodeDataProcessorTest.java +++ b/infra/test-utils/test-tools/src/test/java/io/fd/honeycomb/test/tools/ListNodeDataProcessorTest.java @@ -16,6 +16,19 @@ package io.fd.honeycomb.test.tools; +import static io.fd.honeycomb.test.tools.InjectionTestData.AUGMENT_LIST_DATA_PATH; +import static io.fd.honeycomb.test.tools.InjectionTestData.AUGMENT_LIST_RESOURCE; +import static io.fd.honeycomb.test.tools.InjectionTestData.CONTAINER_UNDER_LIST_DATA_PATH; +import static io.fd.honeycomb.test.tools.InjectionTestData.NESTED_LIST_DATA_PATH; +import static io.fd.honeycomb.test.tools.InjectionTestData.NESTED_LIST_RESOURCE; +import static io.fd.honeycomb.test.tools.InjectionTestData.ROOT_LIST_DATA_PATH; +import static io.fd.honeycomb.test.tools.InjectionTestData.ROOT_LIST_RESOURCE; +import static io.fd.honeycomb.test.tools.InjectionTestData.SIMPLES_LIST_RESOURCE; +import static io.fd.honeycomb.test.tools.InjectionTestData.SIMPLE_LIST_DATA_PATH; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import org.junit.Test; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.data.rev150105.RootList; @@ -25,9 +38,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.hc.data. import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import static io.fd.honeycomb.test.tools.InjectionTestData.*; -import static org.junit.Assert.*; - public class ListNodeDataProcessorTest extends AbstractYangDataProcessorTest { private ListNodeDataProcessor processor; diff --git a/infra/translate-api/pom.xml b/infra/translate-api/pom.xml index dc685d62c..a992a9d8a 100644 --- a/infra/translate-api/pom.xml +++ b/infra/translate-api/pom.xml @@ -53,5 +53,9 @@ <artifactId>mockito-core</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>com.google.code.findbugs</groupId> + <artifactId>jsr305</artifactId> + </dependency> </dependencies> </project> diff --git a/infra/translate-utils/pom.xml b/infra/translate-utils/pom.xml index d70c941ba..aad8af198 100644 --- a/infra/translate-utils/pom.xml +++ b/infra/translate-utils/pom.xml @@ -82,6 +82,10 @@ <artifactId>mockito-core</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + </dependency> </dependencies> <build> |