summaryrefslogtreecommitdiffstats
path: root/nat
diff options
context:
space:
mode:
authorJan Srnicek <jsrnicek@cisco.com>2016-11-03 09:37:28 +0100
committerMaros Marsalek <mmarsale@cisco.com>2016-11-03 10:51:24 +0000
commit918847c2202e943ca8e3e8c1ff1b8d3617cb502d (patch)
treec9ec38b9522e593ca2a1834b85a609ac0be6d6f1 /nat
parente4813a654f93763577e792e4b67353fb27948580 (diff)
HONEYCOMB-259 - CacheKeyFactory
Provides logic for creating scoped keys Change-Id: I126bcb9255b4f8a3f2585f50e6e718948581e7f0 Signed-off-by: Jan Srnicek <jsrnicek@cisco.com>
Diffstat (limited to 'nat')
-rw-r--r--nat/nat2vpp/src/main/java/io/fd/honeycomb/nat/read/ExternalIpPoolCustomizer.java7
-rw-r--r--nat/nat2vpp/src/main/java/io/fd/honeycomb/nat/read/MappingEntryCustomizer.java9
-rw-r--r--nat/nat2vpp/src/main/java/io/fd/honeycomb/nat/read/NatInstanceCustomizer.java7
-rw-r--r--nat/nat2vpp/src/main/java/io/fd/honeycomb/nat/read/NatReaderFactory.java19
4 files changed, 25 insertions, 17 deletions
diff --git a/nat/nat2vpp/src/main/java/io/fd/honeycomb/nat/read/ExternalIpPoolCustomizer.java b/nat/nat2vpp/src/main/java/io/fd/honeycomb/nat/read/ExternalIpPoolCustomizer.java
index 959bfbdc1..0650280f1 100644
--- a/nat/nat2vpp/src/main/java/io/fd/honeycomb/nat/read/ExternalIpPoolCustomizer.java
+++ b/nat/nat2vpp/src/main/java/io/fd/honeycomb/nat/read/ExternalIpPoolCustomizer.java
@@ -73,10 +73,11 @@ final class ExternalIpPoolCustomizer implements
final Long poolId = id.firstKeyOf(ExternalIpAddressPool.class).getPoolId();
final SnatAddressDetails details =
- dumpMgr.getDump(id, getClass().getName(), ctx.getModificationCache(), null)
+ dumpMgr.getDump(id, ctx.getModificationCache(), null)
.or(new SnatAddressDetailsReplyDump()).snatAddressDetails.get(Math.toIntExact(poolId));
- builder.setExternalIpPool(new Ipv4Prefix(arrayToIpv4AddressNoZoneReversed(details.ipAddress).getValue() + "/32"));
+ builder.setExternalIpPool(
+ new Ipv4Prefix(arrayToIpv4AddressNoZoneReversed(details.ipAddress).getValue() + "/32"));
builder.setPoolId(poolId);
LOG.trace("External IP pool: {}. Read as: {}", id, builder);
@@ -100,7 +101,7 @@ final class ExternalIpPoolCustomizer implements
// That's why the write and read is not symmetrical in terms of data structure, instead,
// this customizer also returns every single address as a 32 prefix and assigns an artificial key to them
- final long addressCount = dumpMgr.getDump(id, getClass().getName(), ctx.getModificationCache(), null)
+ final long addressCount = dumpMgr.getDump(id, ctx.getModificationCache(), null)
.or(new SnatAddressDetailsReplyDump()).snatAddressDetails.stream()
.count();
diff --git a/nat/nat2vpp/src/main/java/io/fd/honeycomb/nat/read/MappingEntryCustomizer.java b/nat/nat2vpp/src/main/java/io/fd/honeycomb/nat/read/MappingEntryCustomizer.java
index c525cb9da..df0a8e886 100644
--- a/nat/nat2vpp/src/main/java/io/fd/honeycomb/nat/read/MappingEntryCustomizer.java
+++ b/nat/nat2vpp/src/main/java/io/fd/honeycomb/nat/read/MappingEntryCustomizer.java
@@ -58,8 +58,9 @@ final class MappingEntryCustomizer implements Ipv4Translator,
private final DumpCacheManager<SnatStaticMappingDetailsReplyDump, Void> dumpCacheManager;
private final MappingEntryContext mappingEntryContext;
- MappingEntryCustomizer(final DumpCacheManager<SnatStaticMappingDetailsReplyDump, Void> dumpCacheManager,
- final MappingEntryContext mappingEntryContext) {
+ MappingEntryCustomizer(
+ final DumpCacheManager<SnatStaticMappingDetailsReplyDump, Void> dumpCacheManager,
+ final MappingEntryContext mappingEntryContext) {
this.dumpCacheManager = dumpCacheManager;
this.mappingEntryContext = mappingEntryContext;
}
@@ -79,7 +80,7 @@ final class MappingEntryCustomizer implements Ipv4Translator,
final int idx = id.firstKeyOf(MappingEntry.class).getIndex().intValue();
final int natInstanceId = id.firstKeyOf(NatInstance.class).getId().intValue();
final List<SnatStaticMappingDetails> details =
- dumpCacheManager.getDump(id, getClass().getName(), ctx.getModificationCache(), null)
+ dumpCacheManager.getDump(id, ctx.getModificationCache(), null)
.or(new SnatStaticMappingDetailsReplyDump()).snatStaticMappingDetails;
final SnatStaticMappingDetails snatStaticMappingDetails =
mappingEntryContext.findDetails(details, natInstanceId, idx, ctx.getMappingContext());
@@ -116,7 +117,7 @@ final class MappingEntryCustomizer implements Ipv4Translator,
LOG.trace("Listing IDs for all mapping-entries within nat-instance(vrf):{}", natInstanceId);
final List<MappingEntryKey> entryKeys =
- dumpCacheManager.getDump(id, getClass().getName(), context.getModificationCache(), null)
+ dumpCacheManager.getDump(id, context.getModificationCache(), null)
.or(new SnatStaticMappingDetailsReplyDump()).snatStaticMappingDetails.stream()
.filter(detail -> natInstanceId == detail.vrfId)
.map(detail -> mappingEntryContext
diff --git a/nat/nat2vpp/src/main/java/io/fd/honeycomb/nat/read/NatInstanceCustomizer.java b/nat/nat2vpp/src/main/java/io/fd/honeycomb/nat/read/NatInstanceCustomizer.java
index 0c089e454..56965f7b4 100644
--- a/nat/nat2vpp/src/main/java/io/fd/honeycomb/nat/read/NatInstanceCustomizer.java
+++ b/nat/nat2vpp/src/main/java/io/fd/honeycomb/nat/read/NatInstanceCustomizer.java
@@ -46,7 +46,8 @@ final class NatInstanceCustomizer implements InitializingListReaderCustomizer<Na
private final DumpCacheManager<SnatStaticMappingDetailsReplyDump, Void> dumpCacheManager;
- NatInstanceCustomizer(final DumpCacheManager<SnatStaticMappingDetailsReplyDump, Void> dumpCacheManager) {
+ NatInstanceCustomizer(
+ final DumpCacheManager<SnatStaticMappingDetailsReplyDump, Void> dumpCacheManager) {
this.dumpCacheManager = dumpCacheManager;
}
@@ -72,10 +73,10 @@ final class NatInstanceCustomizer implements InitializingListReaderCustomizer<Na
// Find the nat instance IDs (vrf-ids) by listing all static mappings and their VRF assignment
final List<NatInstanceKey> vrfIds =
- dumpCacheManager.getDump(id, getClass().getName(), context.getModificationCache(), null)
+ dumpCacheManager.getDump(id, context.getModificationCache(), null)
.or(new SnatStaticMappingDetailsReplyDump()).snatStaticMappingDetails.stream()
.map(detail -> detail.vrfId)
- .map(vrfId -> new NatInstanceKey((long)vrfId))
+ .map(vrfId -> new NatInstanceKey((long) vrfId))
.collect(Collectors.toList());
// Add default vrf id if not present
diff --git a/nat/nat2vpp/src/main/java/io/fd/honeycomb/nat/read/NatReaderFactory.java b/nat/nat2vpp/src/main/java/io/fd/honeycomb/nat/read/NatReaderFactory.java
index a44d1117e..ff0d1880c 100644
--- a/nat/nat2vpp/src/main/java/io/fd/honeycomb/nat/read/NatReaderFactory.java
+++ b/nat/nat2vpp/src/main/java/io/fd/honeycomb/nat/read/NatReaderFactory.java
@@ -47,7 +47,8 @@ public class NatReaderFactory implements ReaderFactory {
private static final InstanceIdentifier<NatState> NAT_OPER_ID = InstanceIdentifier.create(NatState.class);
private static final InstanceIdentifier<NatInstances> NAT_INSTANCES_ID = NAT_OPER_ID.child(NatInstances.class);
private static final InstanceIdentifier<NatInstance> NAT_INSTANCE_ID = NAT_INSTANCES_ID.child(NatInstance.class);
- private static final InstanceIdentifier<NatCurrentConfig> CURRENT_CONFIG = NAT_INSTANCE_ID.child(NatCurrentConfig.class);
+ private static final InstanceIdentifier<NatCurrentConfig> CURRENT_CONFIG =
+ NAT_INSTANCE_ID.child(NatCurrentConfig.class);
private static final InstanceIdentifier<MappingTable> MAP_TABLE_ID = NAT_INSTANCE_ID.child(MappingTable.class);
private static final InstanceIdentifier<MappingEntry> MAP_ENTRY_ID = MAP_TABLE_ID.child(MappingEntry.class);
@@ -55,16 +56,20 @@ public class NatReaderFactory implements ReaderFactory {
private final DumpCacheManager<SnatStaticMappingDetailsReplyDump, Void> mapEntryDumpMgr;
private final DumpCacheManager<SnatAddressDetailsReplyDump, Void> addressRangeDumpMgr;
+
@Inject
public NatReaderFactory(final FutureJVppSnatFacade jvppSnat,
final MappingEntryContext mappingEntryContext) {
this.mappingEntryContext = mappingEntryContext;
- this.mapEntryDumpMgr = new DumpCacheManager.DumpCacheManagerBuilder<SnatStaticMappingDetailsReplyDump, Void>()
- .withExecutor(new MappingEntryCustomizer.MappingEntryDumpExecutor(jvppSnat))
- .build();
- this.addressRangeDumpMgr = new DumpCacheManager.DumpCacheManagerBuilder<SnatAddressDetailsReplyDump, Void>()
- .withExecutor(new ExternalIpPoolCustomizer.AddressRangeDumpExecutor(jvppSnat))
- .build();
+ this.mapEntryDumpMgr =
+ new DumpCacheManager.DumpCacheManagerBuilder<SnatStaticMappingDetailsReplyDump, Void>()
+ .withExecutor(new MappingEntryCustomizer.MappingEntryDumpExecutor(jvppSnat))
+ .build();
+
+ this.addressRangeDumpMgr =
+ new DumpCacheManager.DumpCacheManagerBuilder<SnatAddressDetailsReplyDump, Void>()
+ .withExecutor(new ExternalIpPoolCustomizer.AddressRangeDumpExecutor(jvppSnat))
+ .build();
}
@Override