summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2016-11-25 07:45:03 +0000
committerGerrit Code Review <gerrit@fd.io>2016-11-25 07:45:03 +0000
commitd690028c4ca575209449cef263e993e299e5a725 (patch)
tree8d607dab3921640f8d85b9e79ad439fba5cba865
parent9390070fbc27a80c3c9a9a68ccd5c9d4b8bc4d27 (diff)
parent0d9be1f529fe370be518be823850ad186390ff46 (diff)
Merge "HONEYCOMB-282 - Lisp factories refactoring"
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/LispModule.java15
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/AbstractLispInfraFactoryBase.java71
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/AbstractLispReaderFactoryBase.java101
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/EidTableReaderFactory.java182
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/LispStateReaderFactory.java40
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/LocatorSetReaderFactory.java (renamed from lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/LocatorSetsReaderFactory.java)25
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/MapResolverReaderFactory.java (renamed from lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/MapResolversReaderFactory.java)16
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/AbstractLispWriterFactoryBase.java94
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/EidTableWriterFactory.java143
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/LispWriterFactory.java42
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/LocatorSetWriterFactory.java (renamed from lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/LocatorSetsWriterFactory.java)23
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/MapResolverWriterFactory.java (renamed from lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/MapResolversWriterFactory.java)20
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/VniTableWriterFactory.java158
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/LispModuleTest.java8
14 files changed, 339 insertions, 599 deletions
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/LispModule.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/LispModule.java
index c9acf1d77..90ca83343 100644
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/LispModule.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/LispModule.java
@@ -16,6 +16,7 @@
package io.fd.hc2vpp.lisp;
+
import static io.fd.hc2vpp.lisp.cfgattrs.LispConfiguration.LOCAL_MAPPING_CONTEXT;
import static io.fd.hc2vpp.lisp.cfgattrs.LispConfiguration.LOCATOR_SET_CONTEXT;
import static io.fd.hc2vpp.lisp.cfgattrs.LispConfiguration.LOCATOR_SET_CONTEXT_PREFIX;
@@ -25,14 +26,20 @@ import com.google.inject.AbstractModule;
import com.google.inject.Singleton;
import com.google.inject.multibindings.Multibinder;
import com.google.inject.name.Names;
+import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.hc2vpp.lisp.cfgattrs.LispConfiguration;
import io.fd.hc2vpp.lisp.context.util.AdjacenciesMappingContext;
import io.fd.hc2vpp.lisp.context.util.ContextsReaderFactoryProvider;
import io.fd.hc2vpp.lisp.context.util.EidMappingContext;
+import io.fd.hc2vpp.lisp.translate.read.factory.EidTableReaderFactory;
import io.fd.hc2vpp.lisp.translate.read.factory.LispStateReaderFactory;
+import io.fd.hc2vpp.lisp.translate.read.factory.LocatorSetReaderFactory;
+import io.fd.hc2vpp.lisp.translate.read.factory.MapResolverReaderFactory;
+import io.fd.hc2vpp.lisp.translate.write.factory.EidTableWriterFactory;
import io.fd.hc2vpp.lisp.translate.write.factory.LispWriterFactory;
+import io.fd.hc2vpp.lisp.translate.write.factory.LocatorSetWriterFactory;
+import io.fd.hc2vpp.lisp.translate.write.factory.MapResolverWriterFactory;
import io.fd.honeycomb.translate.read.ReaderFactory;
-import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.honeycomb.translate.write.WriterFactory;
import net.jmob.guice.conf.core.ConfigurationModule;
import org.slf4j.Logger;
@@ -71,11 +78,17 @@ public class LispModule extends AbstractModule {
LOG.info("Binding reader factories");
final Multibinder<ReaderFactory> readerFactoryBinder = Multibinder.newSetBinder(binder(), ReaderFactory.class);
readerFactoryBinder.addBinding().to(LispStateReaderFactory.class);
+ readerFactoryBinder.addBinding().to(EidTableReaderFactory.class);
+ readerFactoryBinder.addBinding().to(LocatorSetReaderFactory.class);
+ readerFactoryBinder.addBinding().to(MapResolverReaderFactory.class);
LOG.info("Reader factories binded");
LOG.info("Binding writer factories");
final Multibinder<WriterFactory> writerFactoryBinder = Multibinder.newSetBinder(binder(), WriterFactory.class);
writerFactoryBinder.addBinding().to(LispWriterFactory.class);
+ writerFactoryBinder.addBinding().to(EidTableWriterFactory.class);
+ writerFactoryBinder.addBinding().to(LocatorSetWriterFactory.class);
+ writerFactoryBinder.addBinding().to(MapResolverWriterFactory.class);
LOG.info("Writer factories binded");
final Multibinder<ReaderFactory> readerBinder = Multibinder.newSetBinder(binder(), ReaderFactory.class);
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/AbstractLispInfraFactoryBase.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/AbstractLispInfraFactoryBase.java
new file mode 100644
index 000000000..cd3b1e404
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/AbstractLispInfraFactoryBase.java
@@ -0,0 +1,71 @@
+/*
+ * 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.hc2vpp.lisp.translate;
+
+import static io.fd.hc2vpp.lisp.cfgattrs.LispConfiguration.ADJACENCIES_IDENTIFICATION_CONTEXT;
+import static io.fd.hc2vpp.lisp.cfgattrs.LispConfiguration.INTERFACE_CONTEXT;
+import static io.fd.hc2vpp.lisp.cfgattrs.LispConfiguration.LOCAL_MAPPING_CONTEXT;
+import static io.fd.hc2vpp.lisp.cfgattrs.LispConfiguration.LOCATOR_SET_CONTEXT;
+import static io.fd.hc2vpp.lisp.cfgattrs.LispConfiguration.REMOTE_MAPPING_CONTEXT;
+
+import com.google.inject.Inject;
+import com.google.inject.name.Named;
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.hc2vpp.lisp.context.util.AdjacenciesMappingContext;
+import io.fd.hc2vpp.lisp.context.util.EidMappingContext;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.Lisp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.LispState;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+
+/**
+ * Basic attributes for lisp writer factories
+ */
+public abstract class AbstractLispInfraFactoryBase {
+
+ protected static final InstanceIdentifier<Lisp> LISP_CONFIG_IDENTIFIER = InstanceIdentifier.create(Lisp.class);
+ protected static final InstanceIdentifier<LispState> LISP_OPERATIONAL_IDENTIFIER =
+ InstanceIdentifier.create(LispState.class);
+
+ @Inject
+ protected FutureJVppCore vppApi;
+
+ @Inject
+ @Named(INTERFACE_CONTEXT)
+ protected NamingContext interfaceContext;
+
+ @Inject
+ @Named(LOCATOR_SET_CONTEXT)
+ protected NamingContext locatorSetContext;
+
+ @Inject
+ @Named("bridge-domain-context")
+ protected NamingContext bridgeDomainContext;
+
+ @Inject
+ @Named(LOCAL_MAPPING_CONTEXT)
+ protected EidMappingContext localMappingContext;
+
+ @Inject
+ @Named(REMOTE_MAPPING_CONTEXT)
+ protected EidMappingContext remoteMappingContext;
+
+ @Inject
+ @Named(ADJACENCIES_IDENTIFICATION_CONTEXT)
+ protected AdjacenciesMappingContext adjacenciesMappingContext;
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/AbstractLispReaderFactoryBase.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/AbstractLispReaderFactoryBase.java
deleted file mode 100644
index fe6616ddf..000000000
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/AbstractLispReaderFactoryBase.java
+++ /dev/null
@@ -1,101 +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.hc2vpp.lisp.translate.read.factory;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import io.fd.hc2vpp.lisp.context.util.EidMappingContext;
-import io.fd.hc2vpp.common.translate.util.NamingContext;
-import javax.annotation.Nonnull;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.LispState;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import io.fd.vpp.jvpp.core.future.FutureJVppCore;
-
-
-/**
- * Basic attributes for lisp reader factories
- */
-abstract class AbstractLispReaderFactoryBase {
-
- protected final InstanceIdentifier<LispState> lispStateId;
- protected final FutureJVppCore vppApi;
- protected NamingContext interfaceContext;
- protected NamingContext locatorSetContext;
- protected NamingContext bridgeDomainContext;
- protected EidMappingContext localMappingContext;
- protected EidMappingContext remoteMappingContext;
-
- protected AbstractLispReaderFactoryBase(@Nonnull final InstanceIdentifier<LispState> lispStateId,
- @Nonnull final FutureJVppCore vppApi) {
- this.lispStateId = checkNotNull(lispStateId, "Lisp state identifier is null");
- this.vppApi = checkNotNull(vppApi, "VPP api refference is null");
- }
-
- protected AbstractLispReaderFactoryBase(@Nonnull final InstanceIdentifier<LispState> lispStateId,
- @Nonnull final FutureJVppCore vppApi,
- @Nonnull final NamingContext interfaceContext,
- @Nonnull final EidMappingContext localMappingContext,
- @Nonnull final EidMappingContext remoteMappingContext) {
- this.lispStateId = checkNotNull(lispStateId, "Lisp state identifier is null");
- this.vppApi = checkNotNull(vppApi, "VPP api reference is null");
- this.interfaceContext = checkNotNull(interfaceContext,
- "Interface naming context is null,for readers that don't need this dependency,use different constructor");
- this.localMappingContext = checkNotNull(localMappingContext,
- "Local mappings reference is null,for readers that don't need this dependency use different constructor");
- this.remoteMappingContext = checkNotNull(remoteMappingContext,
- "Remote mappings reference is null,for readers that don't need this dependency use different constructor");
- }
-
- protected AbstractLispReaderFactoryBase(@Nonnull final InstanceIdentifier<LispState> lispStateId,
- @Nonnull final FutureJVppCore vppApi,
- @Nonnull final NamingContext interfaceContext,
- @Nonnull final NamingContext locatorSetContext,
- @Nonnull final EidMappingContext localMappingContext,
- @Nonnull final EidMappingContext remoteMappingContext) {
- this.lispStateId = checkNotNull(lispStateId, "Lisp state identifier is null");
- this.vppApi = checkNotNull(vppApi, "VPP api reference is null");
- this.interfaceContext = checkNotNull(interfaceContext,
- "Interface naming context is null,for readers that don't need this dependency,use different constructor");
- this.locatorSetContext = checkNotNull(locatorSetContext,
- "Locator set naming context is null,for readers that don't need this dependency,use different constructor");
- this.localMappingContext = checkNotNull(localMappingContext,
- "Local mappings reference is null,for readers that don't need this dependency use different constructor");
- this.remoteMappingContext = checkNotNull(remoteMappingContext,
- "Remote mappings reference is null,for readers that don't need this dependency use different constructor");
- }
-
- protected AbstractLispReaderFactoryBase(@Nonnull final InstanceIdentifier<LispState> lispStateId,
- @Nonnull final FutureJVppCore vppApi,
- @Nonnull final NamingContext interfaceContext,
- @Nonnull final NamingContext locatorSetContext,
- @Nonnull final NamingContext bridgeDomainContext,
- @Nonnull final EidMappingContext localMappingContext,
- @Nonnull final EidMappingContext remoteMappingContext) {
- this.lispStateId = checkNotNull(lispStateId, "Lisp state identifier is null");
- this.vppApi = checkNotNull(vppApi, "VPP api reference is null");
- this.interfaceContext = checkNotNull(interfaceContext,
- "Interface naming context is null,for readers that don't need this dependency,use different constructor");
- this.locatorSetContext = checkNotNull(locatorSetContext,
- "Locator set naming context is null,for readers that don't need this dependency,use different constructor");
- this.bridgeDomainContext = checkNotNull(bridgeDomainContext,
- "Bridge domain naming context is null,for readers that don't need this dependency,use different constructor");
- this.localMappingContext = checkNotNull(localMappingContext,
- "Local mappings reference is null,for readers that don't need this dependency use different constructor");
- this.remoteMappingContext = checkNotNull(remoteMappingContext,
- "Remote mappings reference is null,for readers that don't need this dependency use different constructor");
- }
-}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/EidTableReaderFactory.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/EidTableReaderFactory.java
index 195b0a010..405cb697f 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/EidTableReaderFactory.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/EidTableReaderFactory.java
@@ -17,11 +17,8 @@
package io.fd.hc2vpp.lisp.translate.read.factory;
-import static com.google.common.base.Preconditions.checkNotNull;
-
import com.google.common.collect.ImmutableSet;
-import io.fd.hc2vpp.lisp.context.util.AdjacenciesMappingContext;
-import io.fd.hc2vpp.lisp.context.util.EidMappingContext;
+import io.fd.hc2vpp.lisp.translate.AbstractLispInfraFactoryBase;
import io.fd.hc2vpp.lisp.translate.read.AdjacencyCustomizer;
import io.fd.hc2vpp.lisp.translate.read.BridgeDomainSubtableCustomizer;
import io.fd.hc2vpp.lisp.translate.read.LocalMappingCustomizer;
@@ -32,10 +29,7 @@ import io.fd.honeycomb.translate.impl.read.GenericListReader;
import io.fd.honeycomb.translate.impl.read.GenericReader;
import io.fd.honeycomb.translate.read.ReaderFactory;
import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder;
-import io.fd.hc2vpp.common.translate.util.NamingContext;
-import io.fd.vpp.jvpp.core.future.FutureJVppCore;
import javax.annotation.Nonnull;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.LispState;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.adjacencies.grouping.Adjacencies;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.adjacencies.grouping.AdjacenciesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.adjacencies.grouping.adjacencies.Adjacency;
@@ -46,6 +40,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.RemoteMappings;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.RemoteMappingsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.local.mappings.LocalMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.local.mappings.local.mapping.Eid;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.remote.mappings.RemoteMapping;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.remote.mappings.remote.mapping.locator.list.negative.mapping.MapReply;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.remote.mappings.remote.mapping.locator.list.positive.mapping.Rlocs;
@@ -62,121 +57,118 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
/**
* Factory that produces {@code Reader} for {@code EidTable}<br> with all its inhired child readers
*/
-final class EidTableReaderFactory extends AbstractLispReaderFactoryBase implements ReaderFactory {
-
- private final AdjacenciesMappingContext adjacenciesMappingContext;
-
- private EidTableReaderFactory(final InstanceIdentifier<LispState> lispStateId,
- final FutureJVppCore vppApi,
- final NamingContext interfaceContext,
- final NamingContext locatorSetContext,
- final NamingContext bridgeDomainContext,
- final EidMappingContext localMappingContext,
- final EidMappingContext remoteMappingContext,
- final AdjacenciesMappingContext adjacenciesMappingContext) {
- super(lispStateId, vppApi, interfaceContext, locatorSetContext, bridgeDomainContext, localMappingContext,
- remoteMappingContext);
- this.adjacenciesMappingContext = checkNotNull(adjacenciesMappingContext, "Adjacencies context cannot be null");
- }
+public final class EidTableReaderFactory extends AbstractLispInfraFactoryBase implements ReaderFactory {
- public static EidTableReaderFactory newInstance(@Nonnull final InstanceIdentifier<LispState> lispStateId,
- @Nonnull final FutureJVppCore vppApi,
- @Nonnull final NamingContext interfaceContext,
- @Nonnull final NamingContext locatorSetContext,
- @Nonnull final NamingContext bridgeDomainContext,
- @Nonnull final EidMappingContext localMappingContext,
- @Nonnull final EidMappingContext remoteMappingContext,
- @Nonnull final AdjacenciesMappingContext adjacenciesMappingContext) {
- return new EidTableReaderFactory(lispStateId, vppApi, interfaceContext, locatorSetContext, bridgeDomainContext,
- localMappingContext, remoteMappingContext, adjacenciesMappingContext);
- }
+ private static final InstanceIdentifier<EidTable> EID_TABLE_IID =
+ LISP_OPERATIONAL_IDENTIFIER.child(LispFeatureData.class).child(EidTable.class);
+
+ private static final InstanceIdentifier<VniTable> VNI_TABLE_IID = EID_TABLE_IID.child(VniTable.class);
+
+ private static final InstanceIdentifier<VrfSubtable> VRF_SUBTABLE_IID = VNI_TABLE_IID.child(VrfSubtable.class);
+
+ private static final InstanceIdentifier<BridgeDomainSubtable> BRIDGE_DOMAIN_SUBTABLE_IID =
+ VNI_TABLE_IID.child(BridgeDomainSubtable.class);
@Override
public void init(@Nonnull final ModifiableReaderRegistryBuilder registry) {
- final InstanceIdentifier<EidTable> eidTableInstanceIdentifier =
- lispStateId.child(LispFeatureData.class).child(EidTable.class);
- final InstanceIdentifier<VniTable> vniTableInstanceIdentifier =
- eidTableInstanceIdentifier.child(VniTable.class);
- final InstanceIdentifier<VrfSubtable> vrfSubtable = vniTableInstanceIdentifier.child(VrfSubtable.class);
- final InstanceIdentifier<BridgeDomainSubtable> bridgeDomainSubtable =
- vniTableInstanceIdentifier.child(BridgeDomainSubtable.class);
-
- final InstanceIdentifier<LocalMappings> vrfTableLocalMappingsInstanceIdentifier =
- vrfSubtable.child(LocalMappings.class);
- final InstanceIdentifier<RemoteMappings> vrfTableRemoteMappingsInstanceIdentifier =
- vrfSubtable.child(RemoteMappings.class);
- final InstanceIdentifier<Adjacencies> vrfTableAdjacenciesInstanceIdentifier =
- vrfSubtable.child(RemoteMappings.class).child(RemoteMapping.class).child(Adjacencies.class);
-
- final InstanceIdentifier<LocalMappings> bridgeDomainLocalMappingsInstanceIdentifier =
- bridgeDomainSubtable.child(LocalMappings.class);
- final InstanceIdentifier<RemoteMappings> bridgeDomainRemoteMappingsInstanceIdentifier =
- bridgeDomainSubtable.child(RemoteMappings.class);
- final InstanceIdentifier<Adjacencies> bridgeDomainAdjacenciesInstanceIdentifier =
- bridgeDomainSubtable.child(RemoteMappings.class).child(RemoteMapping.class).child(Adjacencies.class);
//EidTable
- registry.addStructuralReader(eidTableInstanceIdentifier, EidTableBuilder.class);
+ registry.addStructuralReader(EID_TABLE_IID, EidTableBuilder.class);
//EidTable -> VniTable
- registry.add(new GenericListReader<>(vniTableInstanceIdentifier, new VniTableCustomizer(vppApi)));
+ registry.add(new GenericListReader<>(VNI_TABLE_IID, new VniTableCustomizer(vppApi)));
//EidTable -> VniTable -> VrfSubtable
- registry.add(new GenericReader<>(vrfSubtable, new VrfSubtableCustomizer(vppApi)));
+ registry.add(new GenericReader<>(VRF_SUBTABLE_IID, new VrfSubtableCustomizer(vppApi)));
//EidTable -> VniTable -> BridgeDomainSubtable
- registry.add(new GenericReader<>(bridgeDomainSubtable,
+ registry.add(new GenericReader<>(BRIDGE_DOMAIN_SUBTABLE_IID,
new BridgeDomainSubtableCustomizer(vppApi, bridgeDomainContext)));
- //EidTable -> VniTable -> VrfSubtable -> LocalMappings
- registry.addStructuralReader(vrfTableLocalMappingsInstanceIdentifier, LocalMappingsBuilder.class);
- //EidTable -> VniTable -> BridgeDomainSubtable -> LocalMappings
- registry.addStructuralReader(bridgeDomainLocalMappingsInstanceIdentifier, LocalMappingsBuilder.class);
+ addLocalMappingSubtree(registry);
+ addRemoteMappingSubtree(registry);
+ addAdjacenciesSubtree(registry);
+ }
+
+ /**
+ * EidTable -> VniTable -> VrfSubtable -> LocalMappings
+ * EidTable -> VniTable -> BridgeDomainSubtable -> LocalMappings
+ * EidTable -> VniTable -> VrfSubtable -> LocalMappings -> LocalMapping
+ * EidTable -> VniTable -> BridgeDomainSubtable -> LocalMappings -> LocalMapping
+ */
+ private void addLocalMappingSubtree(final @Nonnull ModifiableReaderRegistryBuilder registry) {
+ final InstanceIdentifier<LocalMappings> vrfTableLocalMappingsId = VRF_SUBTABLE_IID.child(LocalMappings.class);
+
+ final InstanceIdentifier<LocalMappings> bridgeDomainLocalMappingsId =
+ BRIDGE_DOMAIN_SUBTABLE_IID.child(LocalMappings.class);
final InstanceIdentifier<LocalMapping> localMappingSubtreeId = InstanceIdentifier.create(LocalMapping.class);
- //EidTable -> VniTable -> VrfSubtable -> LocalMappings -> LocalMapping
- registry.subtreeAdd(ImmutableSet.of(localMappingSubtreeId
- .child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.local.mappings.local.mapping.Eid.class)),
- new GenericListReader<>(vrfTableLocalMappingsInstanceIdentifier.child(LocalMapping.class),
+ final ImmutableSet<InstanceIdentifier<?>> localMappingHandledChildren = ImmutableSet.of(localMappingSubtreeId
+ .child(Eid.class));
+
+ registry.addStructuralReader(vrfTableLocalMappingsId, LocalMappingsBuilder.class);
+ registry.addStructuralReader(bridgeDomainLocalMappingsId, LocalMappingsBuilder.class);
+
+ registry.subtreeAdd(localMappingHandledChildren,
+ new GenericListReader<>(vrfTableLocalMappingsId.child(LocalMapping.class),
new LocalMappingCustomizer(vppApi, locatorSetContext, localMappingContext)));
- //EidTable -> VniTable -> BridgeDomainSubtable -> LocalMappings -> LocalMapping
- registry.subtreeAdd(ImmutableSet.of(localMappingSubtreeId
- .child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.local.mappings.local.mapping.Eid.class)),
- new GenericListReader<>(bridgeDomainLocalMappingsInstanceIdentifier.child(LocalMapping.class),
+ registry.subtreeAdd(localMappingHandledChildren,
+ new GenericListReader<>(bridgeDomainLocalMappingsId.child(LocalMapping.class),
new LocalMappingCustomizer(vppApi, locatorSetContext, localMappingContext)));
+ }
- //EidTable -> VniTable -> VrfSubtable -> RemoteMappings
- registry.addStructuralReader(vrfTableRemoteMappingsInstanceIdentifier, RemoteMappingsBuilder.class);
- registry.addStructuralReader(bridgeDomainRemoteMappingsInstanceIdentifier, RemoteMappingsBuilder.class);
+ /**
+ * EidTable -> VniTable -> VrfSubtable -> RemoteMappings
+ * EidTable -> VniTable -> BridgeDomainSubtable -> RemoteMappings
+ */
+ private void addRemoteMappingSubtree(final @Nonnull ModifiableReaderRegistryBuilder registry) {
+ final InstanceIdentifier<RemoteMappings> vrfTableRemoteMappingsId =
+ VRF_SUBTABLE_IID.child(RemoteMappings.class);
+ final InstanceIdentifier<RemoteMappings> bridgeDomainRemoteMappingsId =
+ BRIDGE_DOMAIN_SUBTABLE_IID.child(RemoteMappings.class);
final InstanceIdentifier<RemoteMapping> remoteMappingSubtreeId = InstanceIdentifier.create(RemoteMapping.class);
- registry.subtreeAdd(ImmutableSet.of(remoteMappingSubtreeId
- .child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.remote.mappings.remote.mapping.Eid.class),
- remoteMappingSubtreeId.child(Rlocs.class),
- remoteMappingSubtreeId.child(Rlocs.class).child(Locator.class),
- remoteMappingSubtreeId.child(MapReply.class)),
- new GenericListReader<>(vrfTableRemoteMappingsInstanceIdentifier.child(RemoteMapping.class),
+
+ registry.addStructuralReader(vrfTableRemoteMappingsId, RemoteMappingsBuilder.class);
+ registry.addStructuralReader(bridgeDomainRemoteMappingsId, RemoteMappingsBuilder.class);
+
+ final ImmutableSet<InstanceIdentifier<?>> remoteMappingHandledChildren =
+ ImmutableSet.of(remoteMappingSubtreeId
+ .child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.remote.mappings.remote.mapping.Eid.class),
+ remoteMappingSubtreeId.child(Rlocs.class),
+ remoteMappingSubtreeId.child(Rlocs.class).child(Locator.class),
+ remoteMappingSubtreeId.child(MapReply.class));
+
+ registry.subtreeAdd(remoteMappingHandledChildren,
+ new GenericListReader<>(vrfTableRemoteMappingsId.child(RemoteMapping.class),
new RemoteMappingCustomizer(vppApi, locatorSetContext, remoteMappingContext)));
- registry.subtreeAdd(ImmutableSet.of(remoteMappingSubtreeId
- .child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.remote.mappings.remote.mapping.Eid.class),
- remoteMappingSubtreeId.child(Rlocs.class),
- remoteMappingSubtreeId.child(Rlocs.class).child(Locator.class),
- remoteMappingSubtreeId.child(MapReply.class)),
- new GenericListReader<>(bridgeDomainRemoteMappingsInstanceIdentifier.child(RemoteMapping.class),
+ registry.subtreeAdd(remoteMappingHandledChildren,
+ new GenericListReader<>(bridgeDomainRemoteMappingsId.child(RemoteMapping.class),
new RemoteMappingCustomizer(vppApi, locatorSetContext, remoteMappingContext)));
+ }
- registry.addStructuralReader(vrfTableAdjacenciesInstanceIdentifier, AdjacenciesBuilder.class);
- registry.addStructuralReader(bridgeDomainAdjacenciesInstanceIdentifier, AdjacenciesBuilder.class);
-
+ /**
+ * EidTable -> VniTable -> VrfSubtable -> RemoteMappings -> Adjacencies
+ */
+ private void addAdjacenciesSubtree(final @Nonnull ModifiableReaderRegistryBuilder registry) {
+ final InstanceIdentifier<Adjacencies> vrfTableAdjacenciesId =
+ VRF_SUBTABLE_IID.child(RemoteMappings.class).child(RemoteMapping.class).child(Adjacencies.class);
+ final InstanceIdentifier<Adjacencies> bridgeDomainAdjacenciesId =
+ BRIDGE_DOMAIN_SUBTABLE_IID.child(RemoteMappings.class).child(RemoteMapping.class)
+ .child(Adjacencies.class);
final InstanceIdentifier<Adjacency> adjacencySubtreeId = InstanceIdentifier.create(Adjacency.class);
- registry.subtreeAdd(
- ImmutableSet.of(adjacencySubtreeId.child(LocalEid.class), adjacencySubtreeId.child(RemoteEid.class)),
- new GenericListReader<>(vrfTableAdjacenciesInstanceIdentifier.child(Adjacency.class),
+ final ImmutableSet<InstanceIdentifier<?>> adjacencyHandledChildren = ImmutableSet
+ .of(adjacencySubtreeId.child(LocalEid.class), adjacencySubtreeId.child(RemoteEid.class));
+
+ registry.addStructuralReader(vrfTableAdjacenciesId, AdjacenciesBuilder.class);
+ registry.addStructuralReader(bridgeDomainAdjacenciesId, AdjacenciesBuilder.class);
+
+ registry.subtreeAdd(adjacencyHandledChildren,
+ new GenericListReader<>(vrfTableAdjacenciesId.child(Adjacency.class),
new AdjacencyCustomizer(vppApi, localMappingContext, remoteMappingContext,
adjacenciesMappingContext)));
- registry.subtreeAdd(
- ImmutableSet.of(adjacencySubtreeId.child(LocalEid.class), adjacencySubtreeId.child(RemoteEid.class)),
- new GenericListReader<>(bridgeDomainAdjacenciesInstanceIdentifier.child(Adjacency.class),
+ registry.subtreeAdd(adjacencyHandledChildren,
+ new GenericListReader<>(bridgeDomainAdjacenciesId.child(Adjacency.class),
new AdjacencyCustomizer(vppApi, localMappingContext, remoteMappingContext,
adjacenciesMappingContext)));
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/LispStateReaderFactory.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/LispStateReaderFactory.java
index 24907641f..44f1e6ba5 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/LispStateReaderFactory.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/LispStateReaderFactory.java
@@ -16,24 +16,12 @@
package io.fd.hc2vpp.lisp.translate.read.factory;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static io.fd.hc2vpp.lisp.cfgattrs.LispConfiguration.ADJACENCIES_IDENTIFICATION_CONTEXT;
-import static io.fd.hc2vpp.lisp.cfgattrs.LispConfiguration.INTERFACE_CONTEXT;
-import static io.fd.hc2vpp.lisp.cfgattrs.LispConfiguration.LOCAL_MAPPING_CONTEXT;
-import static io.fd.hc2vpp.lisp.cfgattrs.LispConfiguration.LOCATOR_SET_CONTEXT;
-import static io.fd.hc2vpp.lisp.cfgattrs.LispConfiguration.REMOTE_MAPPING_CONTEXT;
-
-import com.google.inject.Inject;
-import com.google.inject.name.Named;
-import io.fd.hc2vpp.lisp.context.util.AdjacenciesMappingContext;
-import io.fd.hc2vpp.lisp.context.util.EidMappingContext;
+import io.fd.hc2vpp.lisp.translate.AbstractLispInfraFactoryBase;
import io.fd.hc2vpp.lisp.translate.read.LispStateCustomizer;
import io.fd.hc2vpp.lisp.translate.read.PitrCfgCustomizer;
import io.fd.honeycomb.translate.impl.read.GenericReader;
import io.fd.honeycomb.translate.read.ReaderFactory;
import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder;
-import io.fd.hc2vpp.common.translate.util.NamingContext;
-import io.fd.vpp.jvpp.core.future.FutureJVppCore;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.LispState;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.lisp.feature.data.grouping.LispFeatureData;
@@ -45,24 +33,9 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
/**
* Initialize readers for {@link LispState}
*/
-public class LispStateReaderFactory extends AbstractLispReaderFactoryBase implements ReaderFactory {
-
- private final AdjacenciesMappingContext adjacenciesIdentificationContext;
+public class LispStateReaderFactory extends AbstractLispInfraFactoryBase implements ReaderFactory {
- @Inject
- public LispStateReaderFactory(final FutureJVppCore vppApi,
- @Named(INTERFACE_CONTEXT) final NamingContext interfaceContext,
- @Named(LOCATOR_SET_CONTEXT) final NamingContext locatorSetContext,
- @Named("bridge-domain-context") final NamingContext bridgeDomainContext,
- @Named(LOCAL_MAPPING_CONTEXT) final EidMappingContext localMappingContext,
- @Named(REMOTE_MAPPING_CONTEXT) final EidMappingContext remoteMappingContext,
- @Named(ADJACENCIES_IDENTIFICATION_CONTEXT) final
- AdjacenciesMappingContext adjacenciesIdentificationContext) {
- super(InstanceIdentifier.create(LispState.class), vppApi, interfaceContext, locatorSetContext,
- bridgeDomainContext, localMappingContext, remoteMappingContext);
- this.adjacenciesIdentificationContext =
- checkNotNull(adjacenciesIdentificationContext, "Adjacencies mapping context cannot be null");
- }
+ private static final InstanceIdentifier<LispState> lispStateId = InstanceIdentifier.create(LispState.class);
@Override
public void init(@Nonnull final ModifiableReaderRegistryBuilder registry) {
@@ -70,13 +43,6 @@ public class LispStateReaderFactory extends AbstractLispReaderFactoryBase implem
registry.add(new GenericReader<>(lispStateId, new LispStateCustomizer(vppApi)));
registry.addStructuralReader(lispStateId.child(LispFeatureData.class), LispFeatureDataBuilder.class);
- LocatorSetsReaderFactory.newInstance(lispStateId, vppApi, interfaceContext, locatorSetContext).init(registry);
- MapResolversReaderFactory.newInstance(lispStateId, vppApi).init(registry);
- EidTableReaderFactory
- .newInstance(lispStateId, vppApi, interfaceContext, locatorSetContext, bridgeDomainContext,
- localMappingContext, remoteMappingContext, adjacenciesIdentificationContext)
- .init(registry);
-
registry.add(new GenericReader<>(lispStateId.child(LispFeatureData.class).child(PitrCfg.class),
new PitrCfgCustomizer(vppApi)));
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/LocatorSetsReaderFactory.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/LocatorSetReaderFactory.java
index f31c30a8f..545362167 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/LocatorSetsReaderFactory.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/LocatorSetReaderFactory.java
@@ -17,48 +17,31 @@
package io.fd.hc2vpp.lisp.translate.read.factory;
+import io.fd.hc2vpp.lisp.translate.AbstractLispInfraFactoryBase;
import io.fd.hc2vpp.lisp.translate.read.InterfaceCustomizer;
import io.fd.hc2vpp.lisp.translate.read.LocatorSetCustomizer;
import io.fd.honeycomb.translate.impl.read.GenericListReader;
import io.fd.honeycomb.translate.read.ReaderFactory;
import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder;
-import io.fd.hc2vpp.common.translate.util.NamingContext;
import javax.annotation.Nonnull;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.LispState;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.lisp.feature.data.grouping.LispFeatureData;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.locator.sets.grouping.LocatorSets;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.locator.sets.grouping.LocatorSetsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.locator.sets.grouping.locator.sets.LocatorSet;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.locator.sets.grouping.locator.sets.locator.set.Interface;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import io.fd.vpp.jvpp.core.future.FutureJVppCore;
/**
* Produces reader for {@link LocatorSets} <br> and all its inhired child readers.
*/
-public class LocatorSetsReaderFactory extends AbstractLispReaderFactoryBase implements ReaderFactory {
+public class LocatorSetReaderFactory extends AbstractLispInfraFactoryBase implements ReaderFactory {
- private LocatorSetsReaderFactory(final InstanceIdentifier<LispState> lispStateId,
- final FutureJVppCore vppApi,
- final NamingContext interfaceContext,
- final NamingContext locatorSetContext) {
- super(lispStateId, vppApi);
- this.interfaceContext = interfaceContext;
- this.locatorSetContext = locatorSetContext;
- }
-
- public static final LocatorSetsReaderFactory newInstance(@Nonnull final InstanceIdentifier<LispState> lispStateId,
- @Nonnull final FutureJVppCore vppApi,
- final NamingContext interfaceContext,
- @Nonnull final NamingContext locatorSetContext) {
- return new LocatorSetsReaderFactory(lispStateId, vppApi, interfaceContext, locatorSetContext);
- }
-
@Override
public void init(@Nonnull final ModifiableReaderRegistryBuilder registry) {
- InstanceIdentifier<LocatorSets> locatorSetsInstanceIdentifier = lispStateId.child(LispFeatureData.class).child(LocatorSets.class);
+ InstanceIdentifier<LocatorSets> locatorSetsInstanceIdentifier =
+ LISP_OPERATIONAL_IDENTIFIER.child(LispFeatureData.class).child(LocatorSets.class);
InstanceIdentifier<LocatorSet> locatorSetInstanceIdentifier =
locatorSetsInstanceIdentifier.child(LocatorSet.class);
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/MapResolversReaderFactory.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/MapResolverReaderFactory.java
index 421b71640..b0c39291b 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/MapResolversReaderFactory.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/factory/MapResolverReaderFactory.java
@@ -17,39 +17,29 @@
package io.fd.hc2vpp.lisp.translate.read.factory;
+import io.fd.hc2vpp.lisp.translate.AbstractLispInfraFactoryBase;
import io.fd.hc2vpp.lisp.translate.read.MapResolverCustomizer;
import io.fd.honeycomb.translate.impl.read.GenericListReader;
import io.fd.honeycomb.translate.read.ReaderFactory;
import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder;
import javax.annotation.Nonnull;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.LispState;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.lisp.feature.data.grouping.LispFeatureData;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.map.resolvers.grouping.MapResolvers;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.map.resolvers.grouping.MapResolversBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.map.resolvers.grouping.map.resolvers.MapResolver;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import io.fd.vpp.jvpp.core.future.FutureJVppCore;
/**
* Builds reader for {@link MapResolvers}<br> and all its inhired child readers
*/
-public class MapResolversReaderFactory extends AbstractLispReaderFactoryBase implements ReaderFactory {
-
- private MapResolversReaderFactory(final InstanceIdentifier<LispState> lispStateId, final FutureJVppCore vppApi) {
- super(lispStateId, vppApi);
- }
-
- public static MapResolversReaderFactory newInstance(@Nonnull final InstanceIdentifier<LispState> lispStateId,
- @Nonnull final FutureJVppCore vppApi) {
- return new MapResolversReaderFactory(lispStateId, vppApi);
- }
+public class MapResolverReaderFactory extends AbstractLispInfraFactoryBase implements ReaderFactory {
@Override
public void init(@Nonnull final ModifiableReaderRegistryBuilder registry) {
InstanceIdentifier<MapResolvers> mapResolversInstanceIdentifier =
- lispStateId.child(LispFeatureData.class).child(MapResolvers.class);
+ LISP_OPERATIONAL_IDENTIFIER.child(LispFeatureData.class).child(MapResolvers.class);
registry.addStructuralReader(mapResolversInstanceIdentifier, MapResolversBuilder.class);
registry.add(new GenericListReader<>(mapResolversInstanceIdentifier.child(MapResolver.class),
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/AbstractLispWriterFactoryBase.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/AbstractLispWriterFactoryBase.java
deleted file mode 100644
index cf6df820d..000000000
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/AbstractLispWriterFactoryBase.java
+++ /dev/null
@@ -1,94 +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.hc2vpp.lisp.translate.write.factory;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import io.fd.hc2vpp.lisp.context.util.EidMappingContext;
-import io.fd.hc2vpp.common.translate.util.NamingContext;
-import javax.annotation.Nonnull;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.Lisp;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import io.fd.vpp.jvpp.core.future.FutureJVppCore;
-
-
-/**
- * Basic attributes for lisp writer factories
- */
-abstract class AbstractLispWriterFactoryBase {
-
- protected final InstanceIdentifier<Lisp> lispInstanceIdentifier;
- protected final FutureJVppCore vppApi;
- protected NamingContext interfaceContext;
- protected NamingContext locatorSetContext;
- protected EidMappingContext localMappingContext;
- protected EidMappingContext remoteMappingContext;
-
- protected AbstractLispWriterFactoryBase(@Nonnull final InstanceIdentifier<Lisp> lispInstanceIdentifier,
- @Nonnull final FutureJVppCore vppApi,
- NamingContext interfaceContext) {
- this.lispInstanceIdentifier = checkNotNull(lispInstanceIdentifier, "Lisp identifier is null");
- this.vppApi = checkNotNull(vppApi, "VPP Api refference is null");
- this.interfaceContext = interfaceContext;
- }
-
- protected AbstractLispWriterFactoryBase(@Nonnull final InstanceIdentifier<Lisp> lispInstanceIdentifier,
- @Nonnull final FutureJVppCore vppApi,
- NamingContext interfaceContext,
- NamingContext locatorSetContext) {
- this.lispInstanceIdentifier = checkNotNull(lispInstanceIdentifier, "Lisp identifier is null");
- this.vppApi = checkNotNull(vppApi, "VPP Api refference is null");
- this.interfaceContext = interfaceContext;
- this.locatorSetContext = locatorSetContext;
- }
-
- protected AbstractLispWriterFactoryBase(@Nonnull final InstanceIdentifier<Lisp> lispInstanceIdentifier,
- @Nonnull final FutureJVppCore vppApi,
- EidMappingContext localMappingContext,
- EidMappingContext remoteMappingContext) {
- this.lispInstanceIdentifier = checkNotNull(lispInstanceIdentifier, "Lisp identifier is null");
- this.vppApi = checkNotNull(vppApi, "VPP Api refference is null");
- this.localMappingContext = localMappingContext;
- this.remoteMappingContext = remoteMappingContext;
- }
-
- protected AbstractLispWriterFactoryBase(@Nonnull final InstanceIdentifier<Lisp> lispInstanceIdentifier,
- @Nonnull final FutureJVppCore vppApi,
- NamingContext interfaceContext,
- NamingContext locatorSetContext,
- EidMappingContext localMappingContext,
- EidMappingContext remoteMappingContext) {
- this.lispInstanceIdentifier = checkNotNull(lispInstanceIdentifier, "Lisp identifier is null");
- this.vppApi = checkNotNull(vppApi, "VPP Api refference is null");
- this.interfaceContext = interfaceContext;
- this.locatorSetContext = locatorSetContext;
- this.localMappingContext = localMappingContext;
- this.remoteMappingContext = remoteMappingContext;
- }
-
- protected AbstractLispWriterFactoryBase(@Nonnull final InstanceIdentifier<Lisp> lispInstanceIdentifier,
- @Nonnull final FutureJVppCore vppApi,
- NamingContext interfaceContext,
- EidMappingContext localMappingContext,
- EidMappingContext remoteMappingContext) {
- this.lispInstanceIdentifier = checkNotNull(lispInstanceIdentifier, "Lisp identifier is null");
- this.vppApi = checkNotNull(vppApi, "VPP Api refference is null");
- this.interfaceContext = interfaceContext;
- this.localMappingContext = localMappingContext;
- this.remoteMappingContext = remoteMappingContext;
- }
-}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/EidTableWriterFactory.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/EidTableWriterFactory.java
new file mode 100755
index 000000000..3b9c3f69a
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/EidTableWriterFactory.java
@@ -0,0 +1,143 @@
+/*
+ * 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.hc2vpp.lisp.translate.write.factory;
+
+import com.google.common.collect.ImmutableSet;
+import io.fd.hc2vpp.lisp.translate.AbstractLispInfraFactoryBase;
+import io.fd.hc2vpp.lisp.translate.write.AdjacencyCustomizer;
+import io.fd.hc2vpp.lisp.translate.write.BridgeDomainSubtableCustomizer;
+import io.fd.hc2vpp.lisp.translate.write.LocalMappingCustomizer;
+import io.fd.hc2vpp.lisp.translate.write.RemoteMappingCustomizer;
+import io.fd.hc2vpp.lisp.translate.write.VniTableCustomizer;
+import io.fd.hc2vpp.lisp.translate.write.VrfSubtableCustomizer;
+import io.fd.honeycomb.translate.impl.write.GenericListWriter;
+import io.fd.honeycomb.translate.impl.write.GenericWriter;
+import io.fd.honeycomb.translate.write.WriterFactory;
+import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.adjacencies.grouping.Adjacencies;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.adjacencies.grouping.adjacencies.Adjacency;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.adjacencies.grouping.adjacencies.adjacency.LocalEid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.adjacencies.grouping.adjacencies.adjacency.RemoteEid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.LocalMappings;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.RemoteMappings;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.local.mappings.LocalMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.local.mappings.local.mapping.Eid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.remote.mappings.RemoteMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.remote.mappings.remote.mapping.locator.list.negative.mapping.MapReply;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.remote.mappings.remote.mapping.locator.list.positive.mapping.Rlocs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.remote.mappings.remote.mapping.locator.list.positive.mapping.rlocs.Locator;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.EidTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.eid.table.VniTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.eid.table.vni.table.BridgeDomainSubtable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.eid.table.vni.table.VrfSubtable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.lisp.feature.data.grouping.LispFeatureData;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+
+/**
+ * Factory for producing writers for {@code EidTable}
+ */
+public final class EidTableWriterFactory extends AbstractLispInfraFactoryBase implements WriterFactory {
+
+ private static final InstanceIdentifier<VniTable> VNI_TABLE_ID =
+ LISP_CONFIG_IDENTIFIER.child(LispFeatureData.class).child(EidTable.class).child(VniTable.class);
+
+ private static final InstanceIdentifier<VrfSubtable> VRF_SUBTABLE_ID = VNI_TABLE_ID.child(VrfSubtable.class);
+
+ private static final InstanceIdentifier<BridgeDomainSubtable> BRIDGE_DOMAIN_SUBTABLE_ID =
+ VNI_TABLE_ID.child(BridgeDomainSubtable.class);
+
+
+ @Override
+ public void init(final ModifiableWriterRegistryBuilder registry) {
+
+ registry.add(new GenericListWriter<>(VNI_TABLE_ID, new VniTableCustomizer(vppApi)));
+
+ registry.add(new GenericWriter<>(VRF_SUBTABLE_ID, new VrfSubtableCustomizer(vppApi)));
+ registry.add(new GenericWriter<>(BRIDGE_DOMAIN_SUBTABLE_ID,
+ new BridgeDomainSubtableCustomizer(vppApi, bridgeDomainContext)));
+
+ addLocalMappingSubtree(registry);
+ addRemoteMappingSubtree(registry);
+ addAdjacenciesSubtree(registry);
+ }
+
+ /**
+ * VniTable - > VrfSubtable -> LocalMappings - > LocalMapping
+ * VniTable - > BridgeDomainSubtable -> LocalMappings - > LocalMapping
+ */
+ private void addLocalMappingSubtree(final ModifiableWriterRegistryBuilder registry) {
+ final InstanceIdentifier<LocalMapping> localMappingSubtreeId = InstanceIdentifier.create(LocalMapping.class);
+
+ final ImmutableSet<InstanceIdentifier<?>> localMappingHandledChildren =
+ ImmutableSet.of(localMappingSubtreeId.child(Eid.class));
+ registry.subtreeAdd(localMappingHandledChildren,
+ new GenericListWriter<>(VRF_SUBTABLE_ID.child(LocalMappings.class).child(LocalMapping.class),
+ new LocalMappingCustomizer(vppApi, localMappingContext)));
+
+ registry.subtreeAdd(localMappingHandledChildren,
+ new GenericListWriter<>(BRIDGE_DOMAIN_SUBTABLE_ID.child(LocalMappings.class).child(LocalMapping.class),
+ new LocalMappingCustomizer(vppApi, localMappingContext)));
+ }
+
+ /**
+ * VniTable - > VrfSubtable -> RemoteMappings - > RemoteMapping
+ * VniTable - > BridgeDomainSubtable -> RemoteMappings - > RemoteMapping
+ */
+ private void addRemoteMappingSubtree(final ModifiableWriterRegistryBuilder registry) {
+ final InstanceIdentifier<RemoteMapping> remoteMappingSubtreeId =
+ InstanceIdentifier.create(RemoteMapping.class);
+ final ImmutableSet<InstanceIdentifier<?>> remoteMappingHandledChildren =
+ ImmutableSet.of(remoteMappingSubtreeId
+ .child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.remote.mappings.remote.mapping.Eid.class),
+ remoteMappingSubtreeId.child(Rlocs.class),
+ remoteMappingSubtreeId.child(Rlocs.class).child(Locator.class),
+ remoteMappingSubtreeId.child(MapReply.class));
+
+ registry.subtreeAdd(remoteMappingHandledChildren, new GenericListWriter<>(
+ VRF_SUBTABLE_ID.child(RemoteMappings.class).child(RemoteMapping.class),
+ new RemoteMappingCustomizer(vppApi, remoteMappingContext)));
+
+ registry.subtreeAdd(remoteMappingHandledChildren, new GenericListWriter<>(
+ BRIDGE_DOMAIN_SUBTABLE_ID.child(RemoteMappings.class).child(RemoteMapping.class),
+ new RemoteMappingCustomizer(vppApi, remoteMappingContext)));
+ }
+
+ /**
+ * VniTable - > VrfSubtable -> RemoteMappings - > RemoteMapping - > Adjacencies - > Adjacency
+ * VniTable - > BridgeDomainSubtable -> RemoteMappings - > RemoteMapping - > Adjacencies - > Adjacency
+ */
+ private void addAdjacenciesSubtree(final ModifiableWriterRegistryBuilder registry) {
+ final InstanceIdentifier<Adjacency> adjacencySubtreeId = InstanceIdentifier.create(Adjacency.class);
+
+ final ImmutableSet<InstanceIdentifier<?>> adjacencyHandledChildren = ImmutableSet.of(adjacencySubtreeId
+ .child(LocalEid.class), adjacencySubtreeId.child(RemoteEid.class));
+
+ registry.subtreeAdd(adjacencyHandledChildren, new GenericListWriter<>(
+ VRF_SUBTABLE_ID.child(RemoteMappings.class).child(RemoteMapping.class)
+ .child(Adjacencies.class).child(Adjacency.class),
+ new AdjacencyCustomizer(vppApi, localMappingContext, remoteMappingContext,
+ adjacenciesMappingContext)));
+
+ registry.subtreeAdd(adjacencyHandledChildren, new GenericListWriter<>(
+ BRIDGE_DOMAIN_SUBTABLE_ID.child(RemoteMappings.class)
+ .child(RemoteMapping.class)
+ .child(Adjacencies.class).child(Adjacency.class),
+ new AdjacencyCustomizer(vppApi, localMappingContext, remoteMappingContext,
+ adjacenciesMappingContext)));
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/LispWriterFactory.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/LispWriterFactory.java
index 5bd02a2f9..d5eef4868 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/LispWriterFactory.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/LispWriterFactory.java
@@ -17,24 +17,12 @@
package io.fd.hc2vpp.lisp.translate.write.factory;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static io.fd.hc2vpp.lisp.cfgattrs.LispConfiguration.ADJACENCIES_IDENTIFICATION_CONTEXT;
-import static io.fd.hc2vpp.lisp.cfgattrs.LispConfiguration.INTERFACE_CONTEXT;
-import static io.fd.hc2vpp.lisp.cfgattrs.LispConfiguration.LOCAL_MAPPING_CONTEXT;
-import static io.fd.hc2vpp.lisp.cfgattrs.LispConfiguration.LOCATOR_SET_CONTEXT;
-import static io.fd.hc2vpp.lisp.cfgattrs.LispConfiguration.REMOTE_MAPPING_CONTEXT;
-
-import com.google.inject.Inject;
-import com.google.inject.name.Named;
-import io.fd.hc2vpp.lisp.context.util.AdjacenciesMappingContext;
-import io.fd.hc2vpp.lisp.context.util.EidMappingContext;
+import io.fd.hc2vpp.lisp.translate.AbstractLispInfraFactoryBase;
import io.fd.hc2vpp.lisp.translate.write.LispCustomizer;
import io.fd.hc2vpp.lisp.translate.write.PitrCfgCustomizer;
import io.fd.honeycomb.translate.impl.write.GenericWriter;
-import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.honeycomb.translate.write.WriterFactory;
import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder;
-import io.fd.vpp.jvpp.core.future.FutureJVppCore;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.Lisp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.lisp.feature.data.grouping.LispFeatureData;
@@ -45,37 +33,13 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
/**
* Initialize writers for {@link Lisp}
*/
-public final class LispWriterFactory extends AbstractLispWriterFactoryBase implements WriterFactory {
-
- private final NamingContext bridgeDomainContext;
- private final AdjacenciesMappingContext adjacenciesMappingContext;
-
- @Inject
- public LispWriterFactory(final FutureJVppCore vppApi,
- @Named(INTERFACE_CONTEXT) final NamingContext interfaceContext,
- @Named(LOCATOR_SET_CONTEXT) final NamingContext locatorSetContext,
- @Named("bridge-domain-context") final NamingContext bridgeDomainContext,
- @Named(LOCAL_MAPPING_CONTEXT) final EidMappingContext localMappingContext,
- @Named(REMOTE_MAPPING_CONTEXT) final EidMappingContext remoteMappingContext,
- @Named(ADJACENCIES_IDENTIFICATION_CONTEXT) final AdjacenciesMappingContext adjacenciesMappingContext) {
- super(InstanceIdentifier.create(Lisp.class), vppApi, interfaceContext, locatorSetContext, localMappingContext,
- remoteMappingContext);
- this.bridgeDomainContext = checkNotNull(bridgeDomainContext, "Bridge domain context cannot be null");
- this.adjacenciesMappingContext =
- checkNotNull(adjacenciesMappingContext, "Adjacencies mapping context cannot be null");
- }
+public final class LispWriterFactory extends AbstractLispInfraFactoryBase implements WriterFactory {
+ private final InstanceIdentifier<Lisp> lispInstanceIdentifier = InstanceIdentifier.create(Lisp.class);
@Override
public void init(@Nonnull final ModifiableWriterRegistryBuilder registry) {
registry.add(new GenericWriter<>(lispInstanceIdentifier, new LispCustomizer(vppApi)));
- VniTableWriterFactory.newInstance(lispInstanceIdentifier, vppApi, localMappingContext, remoteMappingContext,
- bridgeDomainContext, adjacenciesMappingContext)
- .init(registry);
- LocatorSetsWriterFactory.newInstance(lispInstanceIdentifier, vppApi, interfaceContext, locatorSetContext)
- .init(registry);
- MapResolversWriterFactory.newInstance(lispInstanceIdentifier, vppApi).init(registry);
-
registry.add(new GenericWriter<>(lispInstanceIdentifier.child(LispFeatureData.class).child(PitrCfg.class),
new PitrCfgCustomizer(vppApi)));
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/LocatorSetsWriterFactory.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/LocatorSetWriterFactory.java
index c4227637f..14b4aace7 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/LocatorSetsWriterFactory.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/LocatorSetWriterFactory.java
@@ -16,46 +16,29 @@
package io.fd.hc2vpp.lisp.translate.write.factory;
+import io.fd.hc2vpp.lisp.translate.AbstractLispInfraFactoryBase;
import io.fd.hc2vpp.lisp.translate.write.InterfaceCustomizer;
import io.fd.hc2vpp.lisp.translate.write.LocatorSetCustomizer;
import io.fd.honeycomb.translate.impl.write.GenericListWriter;
-import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.honeycomb.translate.write.WriterFactory;
import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder;
import javax.annotation.Nonnull;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.Lisp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.lisp.feature.data.grouping.LispFeatureData;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.locator.sets.grouping.LocatorSets;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.locator.sets.grouping.locator.sets.LocatorSet;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.locator.sets.grouping.locator.sets.locator.set.Interface;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import io.fd.vpp.jvpp.core.future.FutureJVppCore;
/**
* Factory producing writers for {@code LocatorSets}
*/
-final class LocatorSetsWriterFactory extends AbstractLispWriterFactoryBase implements WriterFactory {
-
- private LocatorSetsWriterFactory(final InstanceIdentifier<Lisp> lispInstanceIdentifier,
- final FutureJVppCore vppApi,
- final NamingContext interfaceContext,
- final NamingContext locatorSetContext) {
- super(lispInstanceIdentifier, vppApi, interfaceContext, locatorSetContext);
- }
-
- public static LocatorSetsWriterFactory newInstance(
- @Nonnull final InstanceIdentifier<Lisp> lispInstanceIdentifier,
- @Nonnull final FutureJVppCore vppApi,
- @Nonnull final NamingContext interfaceContext,
- @Nonnull final NamingContext locatorSetContext) {
- return new LocatorSetsWriterFactory(lispInstanceIdentifier, vppApi, interfaceContext, locatorSetContext);
- }
+public final class LocatorSetWriterFactory extends AbstractLispInfraFactoryBase implements WriterFactory {
@Override
public void init(@Nonnull final ModifiableWriterRegistryBuilder registry) {
InstanceIdentifier<LocatorSet> locatorSetId =
- lispInstanceIdentifier.child(LispFeatureData.class).child(LocatorSets.class).child(LocatorSet.class);
+ LISP_CONFIG_IDENTIFIER.child(LispFeatureData.class).child(LocatorSets.class).child(LocatorSet.class);
registry.add(new GenericListWriter<>(locatorSetId, new LocatorSetCustomizer(vppApi, locatorSetContext)));
registry.add(new GenericListWriter<>(locatorSetId.child(Interface.class),
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/MapResolversWriterFactory.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/MapResolverWriterFactory.java
index 8b0d7d52d..e9666c7ef 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/MapResolversWriterFactory.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/MapResolverWriterFactory.java
@@ -17,39 +17,27 @@
package io.fd.hc2vpp.lisp.translate.write.factory;
+import io.fd.hc2vpp.lisp.translate.AbstractLispInfraFactoryBase;
import io.fd.hc2vpp.lisp.translate.write.MapResolverCustomizer;
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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.Lisp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.lisp.feature.data.grouping.LispFeatureData;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.map.resolvers.grouping.MapResolvers;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.map.resolvers.grouping.map.resolvers.MapResolver;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import io.fd.vpp.jvpp.core.future.FutureJVppCore;
/**
* Factory responsible for producing writers for {@code MapResolvers}
*/
-final class MapResolversWriterFactory extends AbstractLispWriterFactoryBase implements WriterFactory {
-
- private MapResolversWriterFactory(final InstanceIdentifier<Lisp> lispInstanceIdentifier,
- final FutureJVppCore vppApi) {
- super(lispInstanceIdentifier, vppApi, null);
- }
-
- public static MapResolversWriterFactory newInstance(
- @Nonnull final InstanceIdentifier<Lisp> lispInstanceIdentifier,
- @Nonnull final FutureJVppCore vppApi) {
- return new MapResolversWriterFactory(lispInstanceIdentifier, vppApi);
- }
+public final class MapResolverWriterFactory extends AbstractLispInfraFactoryBase
+ implements WriterFactory {
@Override
public void init(@Nonnull final ModifiableWriterRegistryBuilder registry) {
registry.add(new GenericListWriter<>(
- lispInstanceIdentifier.child(LispFeatureData.class).child(MapResolvers.class).child(MapResolver.class),
+ LISP_CONFIG_IDENTIFIER.child(LispFeatureData.class).child(MapResolvers.class).child(MapResolver.class),
new MapResolverCustomizer(vppApi)));
}
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/VniTableWriterFactory.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/VniTableWriterFactory.java
deleted file mode 100755
index 64dd7d587..000000000
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/factory/VniTableWriterFactory.java
+++ /dev/null
@@ -1,158 +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.hc2vpp.lisp.translate.write.factory;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import com.google.common.collect.ImmutableSet;
-import io.fd.hc2vpp.lisp.context.util.AdjacenciesMappingContext;
-import io.fd.hc2vpp.lisp.context.util.EidMappingContext;
-import io.fd.hc2vpp.lisp.translate.write.AdjacencyCustomizer;
-import io.fd.hc2vpp.lisp.translate.write.BridgeDomainSubtableCustomizer;
-import io.fd.hc2vpp.lisp.translate.write.LocalMappingCustomizer;
-import io.fd.hc2vpp.lisp.translate.write.RemoteMappingCustomizer;
-import io.fd.hc2vpp.lisp.translate.write.VniTableCustomizer;
-import io.fd.hc2vpp.lisp.translate.write.VrfSubtableCustomizer;
-import io.fd.honeycomb.translate.impl.write.GenericListWriter;
-import io.fd.honeycomb.translate.impl.write.GenericWriter;
-import io.fd.hc2vpp.common.translate.util.NamingContext;
-import io.fd.honeycomb.translate.write.WriterFactory;
-import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder;
-import io.fd.vpp.jvpp.core.future.FutureJVppCore;
-import javax.annotation.Nonnull;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.Lisp;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.adjacencies.grouping.Adjacencies;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.adjacencies.grouping.adjacencies.Adjacency;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.adjacencies.grouping.adjacencies.adjacency.LocalEid;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.adjacencies.grouping.adjacencies.adjacency.RemoteEid;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.LocalMappings;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.RemoteMappings;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.local.mappings.LocalMapping;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.remote.mappings.RemoteMapping;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.remote.mappings.remote.mapping.locator.list.negative.mapping.MapReply;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.remote.mappings.remote.mapping.locator.list.positive.mapping.Rlocs;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.remote.mappings.remote.mapping.locator.list.positive.mapping.rlocs.Locator;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.EidTable;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.eid.table.VniTable;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.eid.table.vni.table.BridgeDomainSubtable;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.eid.table.grouping.eid.table.vni.table.VrfSubtable;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.lisp.feature.data.grouping.LispFeatureData;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-
-//TODO - HONEYCOMB-282 - refactor this and other factories for better readability
-
-/**
- * Factory for producing writers for {@code EidTable}
- */
-final class VniTableWriterFactory extends AbstractLispWriterFactoryBase implements WriterFactory {
-
- private final NamingContext bridgeDomainContext;
- private final AdjacenciesMappingContext adjacenciesMappingContext;
-
- private VniTableWriterFactory(final InstanceIdentifier<Lisp> lispInstanceIdentifier,
- final FutureJVppCore vppApi,
- final EidMappingContext localMappingContext,
- final EidMappingContext remoteMappingContext,
- final NamingContext bridgeDomainContext,
- final AdjacenciesMappingContext adjacenciesMappingContext) {
- super(lispInstanceIdentifier, vppApi, localMappingContext, remoteMappingContext);
- this.bridgeDomainContext = checkNotNull(bridgeDomainContext, "Bridge domain context cannot be null");
- this.adjacenciesMappingContext =
- checkNotNull(adjacenciesMappingContext, "Adjacencies mapping context cannot be null");
- }
-
- public static VniTableWriterFactory newInstance(
- @Nonnull final InstanceIdentifier<Lisp> lispInstanceIdentifier,
- @Nonnull final FutureJVppCore vppApi,
- @Nonnull final EidMappingContext localMappingContext,
- @Nonnull final EidMappingContext remoteMappingContext,
- @Nonnull final NamingContext bridgeDomainContext,
- @Nonnull final AdjacenciesMappingContext adjacenciesMappingContext) {
- return new VniTableWriterFactory(lispInstanceIdentifier, vppApi, localMappingContext, remoteMappingContext,
- bridgeDomainContext, adjacenciesMappingContext);
- }
-
- @Override
- public void init(final ModifiableWriterRegistryBuilder registry) {
- final InstanceIdentifier<VniTable> vniTableId =
- lispInstanceIdentifier.child(LispFeatureData.class).child(EidTable.class).child(VniTable.class);
-
- final InstanceIdentifier<VrfSubtable> vrfSubtableId = vniTableId.child(VrfSubtable.class);
- final InstanceIdentifier<BridgeDomainSubtable> bridgeDomainSubtableId =
- vniTableId.child(BridgeDomainSubtable.class);
-
- registry.add(new GenericListWriter<>(vniTableId, new VniTableCustomizer(vppApi)));
-
- registry.add(new GenericWriter<>(vrfSubtableId, new VrfSubtableCustomizer(vppApi)));
- registry.add(new GenericWriter<>(bridgeDomainSubtableId,
- new BridgeDomainSubtableCustomizer(vppApi, bridgeDomainContext)));
-
- //VniTable - > VrfSubtable -> LocalMappings - > LocalMapping
- final InstanceIdentifier<LocalMapping> localMappingSubtreeId = InstanceIdentifier.create(LocalMapping.class);
- registry.subtreeAdd(ImmutableSet.of(localMappingSubtreeId
- .child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.local.mappings.local.mapping.Eid.class)),
- new GenericListWriter<>(
- vrfSubtableId.child(LocalMappings.class).child(LocalMapping.class),
- new LocalMappingCustomizer(vppApi, localMappingContext)));
- //VniTable - > BridgeDomainSubtable -> LocalMappings - > LocalMapping
- registry.subtreeAdd(ImmutableSet.of(localMappingSubtreeId
- .child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.local.mappings.local.mapping.Eid.class)),
- new GenericListWriter<>(bridgeDomainSubtableId.child(LocalMappings.class)
- .child(LocalMapping.class),
- new LocalMappingCustomizer(vppApi, localMappingContext)));
-
- //VniTable - > VrfSubtable -> RemoteMappings - > RemoteMapping
- final InstanceIdentifier<RemoteMapping> remoteMappingSubtreeId = InstanceIdentifier.create(RemoteMapping.class);
- registry.subtreeAdd(ImmutableSet.of(remoteMappingSubtreeId
- .child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.remote.mappings.remote.mapping.Eid.class),
- remoteMappingSubtreeId.child(Rlocs.class),
- remoteMappingSubtreeId.child(Rlocs.class).child(Locator.class),
- remoteMappingSubtreeId.child(MapReply.class)),
- new GenericListWriter<>(
- vrfSubtableId.child(RemoteMappings.class).child(RemoteMapping.class),
- new RemoteMappingCustomizer(vppApi, remoteMappingContext)));
- //VniTable - > BridgeDomainSubtable -> RemoteMappings - > RemoteMapping
- registry.subtreeAdd(ImmutableSet.of(remoteMappingSubtreeId
- .child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.dp.subtable.grouping.remote.mappings.remote.mapping.Eid.class),
- remoteMappingSubtreeId.child(Rlocs.class),
- remoteMappingSubtreeId.child(Rlocs.class).child(Locator.class),
- remoteMappingSubtreeId.child(MapReply.class)),
- new GenericListWriter<>(bridgeDomainSubtableId.child(RemoteMappings.class)
- .child(RemoteMapping.class),
- new RemoteMappingCustomizer(vppApi, remoteMappingContext)));
-
- //VniTable - > VrfSubtable -> RemoteMappings - > RemoteMapping - > Adjacencies - > Adjacency
- final InstanceIdentifier<Adjacency> adjacencySubtreeId = InstanceIdentifier.create(Adjacency.class);
- registry.subtreeAdd(ImmutableSet.of(adjacencySubtreeId
- .child(LocalEid.class), adjacencySubtreeId.child(RemoteEid.class)),
- new GenericListWriter<>(
- vrfSubtableId.child(RemoteMappings.class).child(RemoteMapping.class)
- .child(Adjacencies.class).child(Adjacency.class),
- new AdjacencyCustomizer(vppApi, localMappingContext, remoteMappingContext,
- adjacenciesMappingContext)));
- //VniTable - > BridgeDomainSubtable -> RemoteMappings - > RemoteMapping - > Adjacencies - > Adjacency
- registry.subtreeAdd(ImmutableSet.of(adjacencySubtreeId
- .child(LocalEid.class), adjacencySubtreeId.child(RemoteEid.class)),
- new GenericListWriter<>(
- bridgeDomainSubtableId.child(RemoteMappings.class)
- .child(RemoteMapping.class)
- .child(Adjacencies.class).child(Adjacency.class),
- new AdjacencyCustomizer(vppApi, localMappingContext, remoteMappingContext,
- adjacenciesMappingContext)));
- }
-}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/LispModuleTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/LispModuleTest.java
index bd4a32a5c..0225c0356 100644
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/LispModuleTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/LispModuleTest.java
@@ -28,18 +28,18 @@ import com.google.inject.Inject;
import com.google.inject.name.Named;
import com.google.inject.testing.fieldbinder.Bind;
import com.google.inject.testing.fieldbinder.BoundFieldModule;
-import io.fd.honeycomb.translate.read.ReaderFactory;
+import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.honeycomb.translate.impl.read.registry.CompositeReaderRegistryBuilder;
import io.fd.honeycomb.translate.impl.write.registry.FlatWriterRegistryBuilder;
-import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.honeycomb.translate.read.ReaderFactory;
import io.fd.honeycomb.translate.write.WriterFactory;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
import java.util.HashSet;
import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import io.fd.vpp.jvpp.core.future.FutureJVppCore;
public class LispModuleTest {
@@ -76,7 +76,7 @@ public class LispModuleTest {
initMocks(this);
interfaceContext = new NamingContext("interfaceContext", "interfaceContext");
bridgeDomainContext = new NamingContext("bridgeDomainContext", "bridgeDomainContext");
- Guice.createInjector(new LispModule(), BoundFieldModule.of(this)).injectMembers(this);
+ Guice.createInjector(new io.fd.hc2vpp.lisp.LispModule(), BoundFieldModule.of(this)).injectMembers(this);
}
@Test