summaryrefslogtreecommitdiffstats
path: root/nat
diff options
context:
space:
mode:
authorJan Srnicek <jsrnicek@cisco.com>2016-11-21 14:44:15 +0100
committerJan Srnicek <jsrnicek@cisco.com>2016-11-24 07:48:49 +0000
commit927fb75d969b2d39c91ae6735f0127646348b73c (patch)
tree9e7da10a07da0a5bf772be15909100405604ad40 /nat
parentf698c1ccc38646129ee4a15adacdf47942a24a52 (diff)
HONEYCOMB-289 - Type-aware read customizers
Refactoring due to https://gerrit.fd.io/r/#/c/3898/ Change-Id: I3ddcc06aca0a730db9fd727a3d2b10cd085f870e Signed-off-by: Jan Srnicek <jsrnicek@cisco.com>
Diffstat (limited to 'nat')
-rw-r--r--nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/NatReaderFactory.java2
-rw-r--r--nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ifc/IfcNatReaderFactory.java5
-rw-r--r--nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ifc/InterfaceInboundNatCustomizerTest.java21
-rw-r--r--nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ifc/InterfaceOutboundNatCustomizerTest.java5
4 files changed, 19 insertions, 14 deletions
diff --git a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/NatReaderFactory.java b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/NatReaderFactory.java
index 76c478594..497ed1c96 100644
--- a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/NatReaderFactory.java
+++ b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/NatReaderFactory.java
@@ -64,11 +64,13 @@ public class NatReaderFactory implements ReaderFactory {
this.mapEntryDumpMgr =
new DumpCacheManager.DumpCacheManagerBuilder<SnatStaticMappingDetailsReplyDump, Void>()
.withExecutor(new MappingEntryCustomizer.MappingEntryDumpExecutor(jvppSnat))
+ .acceptOnly(SnatStaticMappingDetailsReplyDump.class)
.build();
this.addressRangeDumpMgr =
new DumpCacheManager.DumpCacheManagerBuilder<SnatAddressDetailsReplyDump, Void>()
.withExecutor(new ExternalIpPoolCustomizer.AddressRangeDumpExecutor(jvppSnat))
+ .acceptOnly(SnatAddressDetailsReplyDump.class)
.build();
}
diff --git a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ifc/IfcNatReaderFactory.java b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ifc/IfcNatReaderFactory.java
index 87a70f707..641785281 100644
--- a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ifc/IfcNatReaderFactory.java
+++ b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ifc/IfcNatReaderFactory.java
@@ -19,14 +19,14 @@ package io.fd.hc2vpp.nat.read.ifc;
import com.google.inject.Inject;
import com.google.inject.name.Named;
+import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
+import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.honeycomb.translate.impl.read.GenericInitReader;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.read.ReaderFactory;
import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder;
import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager;
import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor;
-import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
-import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.vpp.jvpp.snat.dto.SnatInterfaceDetailsReplyDump;
import io.fd.vpp.jvpp.snat.dto.SnatInterfaceDump;
import io.fd.vpp.jvpp.snat.future.FutureJVppSnatFacade;
@@ -60,6 +60,7 @@ public final class IfcNatReaderFactory implements ReaderFactory {
@Named("interface-context") final NamingContext ifcContext) {
this.snatIfcDumpMgr = new DumpCacheManager.DumpCacheManagerBuilder<SnatInterfaceDetailsReplyDump, Void>()
.withExecutor(new SnatInterfaceExecutor(jvppSnat))
+ .acceptOnly(SnatInterfaceDetailsReplyDump.class)
.build();
this.ifcContext = ifcContext;
}
diff --git a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ifc/InterfaceInboundNatCustomizerTest.java b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ifc/InterfaceInboundNatCustomizerTest.java
index b5c0dab53..d4078b0ab 100644
--- a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ifc/InterfaceInboundNatCustomizerTest.java
+++ b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ifc/InterfaceInboundNatCustomizerTest.java
@@ -20,13 +20,13 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import com.google.common.collect.Lists;
+import io.fd.hc2vpp.common.test.read.ReaderCustomizerTest;
+import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.honeycomb.translate.impl.read.GenericReader;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.honeycomb.translate.util.RWUtils;
import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager;
import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor;
-import io.fd.hc2vpp.common.translate.util.NamingContext;
-import io.fd.hc2vpp.common.test.read.ReaderCustomizerTest;
import io.fd.vpp.jvpp.snat.dto.SnatInterfaceDetails;
import io.fd.vpp.jvpp.snat.dto.SnatInterfaceDetailsReplyDump;
import org.junit.Test;
@@ -60,6 +60,14 @@ public class InterfaceInboundNatCustomizerTest
super(Inbound.class, NatBuilder.class);
}
+ static <T extends ChildOf<Nat>> InstanceIdentifier<T> getId(Class<T> boundType) {
+ return InstanceIdentifier.create(InterfacesState.class)
+ .child(Interface.class, new InterfaceKey(IFC_NAME))
+ .augmentation(NatInterfaceStateAugmentation.class)
+ .child(Nat.class)
+ .child(boundType);
+ }
+
@Override
protected void setUp() throws Exception {
id = getId(Inbound.class);
@@ -68,17 +76,10 @@ public class InterfaceInboundNatCustomizerTest
Mockito.doReturn(new SnatInterfaceDetailsReplyDump()).when(natExecutor).executeDump(id, null);
dumpMgr = new DumpCacheManager.DumpCacheManagerBuilder<SnatInterfaceDetailsReplyDump, Void>()
.withExecutor(natExecutor)
+ .acceptOnly(SnatInterfaceDetailsReplyDump.class)
.build();
}
- static <T extends ChildOf<Nat>> InstanceIdentifier<T> getId(Class<T> boundType) {
- return InstanceIdentifier.create(InterfacesState.class)
- .child(Interface.class, new InterfaceKey(IFC_NAME))
- .augmentation(NatInterfaceStateAugmentation.class)
- .child(Nat.class)
- .child(boundType);
- }
-
@Test
public void testNoPresence() throws Exception {
assertFalse(getReader().read(id, ctx).isPresent());
diff --git a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ifc/InterfaceOutboundNatCustomizerTest.java b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ifc/InterfaceOutboundNatCustomizerTest.java
index 34f5b0949..30f0278cd 100644
--- a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ifc/InterfaceOutboundNatCustomizerTest.java
+++ b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/ifc/InterfaceOutboundNatCustomizerTest.java
@@ -21,13 +21,13 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import com.google.common.collect.Lists;
+import io.fd.hc2vpp.common.test.read.ReaderCustomizerTest;
+import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.honeycomb.translate.impl.read.GenericReader;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.honeycomb.translate.util.RWUtils;
import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager;
import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor;
-import io.fd.hc2vpp.common.translate.util.NamingContext;
-import io.fd.hc2vpp.common.test.read.ReaderCustomizerTest;
import io.fd.vpp.jvpp.snat.dto.SnatInterfaceDetails;
import io.fd.vpp.jvpp.snat.dto.SnatInterfaceDetailsReplyDump;
import org.junit.Test;
@@ -63,6 +63,7 @@ public class InterfaceOutboundNatCustomizerTest
Mockito.doReturn(new SnatInterfaceDetailsReplyDump()).when(abc).executeDump(id, null);
dumpMgr = new DumpCacheManager.DumpCacheManagerBuilder<SnatInterfaceDetailsReplyDump, Void>()
.withExecutor(abc)
+ .acceptOnly(SnatInterfaceDetailsReplyDump.class)
.build();
}