summaryrefslogtreecommitdiffstats
path: root/nat
diff options
context:
space:
mode:
authorMichal Cmarada <mcmarada@cisco.com>2019-04-01 11:39:35 +0200
committerMichal Cmarada <mcmarada@cisco.com>2019-04-08 13:39:49 +0200
commitd726d0f173544c8d0078c5f918b5d086f6e85f79 (patch)
tree640e65411731b3a25abc2e7949de68dc625cf60e /nat
parent89eeb336aebc92cd34c27b3fa325803c6478a461 (diff)
HC2VPP-406: fix build errors after ODL bump to neon
This fixes build issues after ODL bump in Honeycomb (HONEYCOMB-443). Change-Id: I3bf203dd60d12057595b15ce1ad59302dc14e2a0 Signed-off-by: Michal Cmarada <mcmarada@cisco.com>
Diffstat (limited to 'nat')
-rw-r--r--nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ExternalIpPoolCustomizer.java20
-rw-r--r--nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/MappingEntryCustomizer.java8
-rw-r--r--nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/NatInstanceCustomizer.java4
-rw-r--r--nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ifc/AbstractInterfaceNatCustomizer.java8
-rw-r--r--nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/util/MappingEntryContext.java25
-rw-r--r--nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/MappingEntryCustomizer.java2
-rw-r--r--nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/NatModuleTest.java2
-rw-r--r--nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/util/MappingEntryContextTest.java8
8 files changed, 38 insertions, 39 deletions
diff --git a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ExternalIpPoolCustomizer.java b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ExternalIpPoolCustomizer.java
index 7592db69b..7a97a68d1 100644
--- a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ExternalIpPoolCustomizer.java
+++ b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ExternalIpPoolCustomizer.java
@@ -65,11 +65,13 @@ final class ExternalIpPoolCustomizer implements
ExternalIpPoolCustomizer(@Nonnull final FutureJVppNatFacade jvppNat) {
checkNotNull(jvppNat, "jvppNat should not be null");
this.nat44DumpMgr = new DumpCacheManager.DumpCacheManagerBuilder<Nat44AddressDetailsReplyDump, Void>()
- .withExecutor((id, params) -> getReplyForRead(jvppNat.nat44AddressDump(new Nat44AddressDump()).toCompletableFuture(), id))
+ .withExecutor((id, params) -> getReplyForRead(
+ jvppNat.nat44AddressDump(new Nat44AddressDump()).toCompletableFuture(), id))
.acceptOnly(Nat44AddressDetailsReplyDump.class)
.build();
this.nat64DumpMgr = new DumpCacheManager.DumpCacheManagerBuilder<Nat64PoolAddrDetailsReplyDump, Void>()
- .withExecutor((id, params) -> getReplyForRead(jvppNat.nat64PoolAddrDump(new Nat64PoolAddrDump()).toCompletableFuture(), id))
+ .withExecutor((id, params) -> getReplyForRead(
+ jvppNat.nat64PoolAddrDump(new Nat64PoolAddrDump()).toCompletableFuture(), id))
.acceptOnly(Nat64PoolAddrDetailsReplyDump.class)
.build();
}
@@ -94,7 +96,7 @@ final class ExternalIpPoolCustomizer implements
final Long poolId = id.firstKeyOf(ExternalIpAddressPool.class).getPoolId();
final List<Nat44AddressDetails> nat44Details =
nat44DumpMgr.getDump(id, ctx.getModificationCache())
- .or(new Nat44AddressDetailsReplyDump()).nat44AddressDetails;
+ .orElse(new Nat44AddressDetailsReplyDump()).nat44AddressDetails;
final int nat44PoolCount = nat44Details.size();
// Uses ID<->address mapping as defined by getAllIds (nat44 mappings go before nat64):
@@ -104,7 +106,7 @@ final class ExternalIpPoolCustomizer implements
setPoolType(builder, NatPoolType.Nat44);
} else {
final List<Nat64PoolAddrDetails> nat64Details = nat64DumpMgr.getDump(id, ctx.getModificationCache())
- .or(new Nat64PoolAddrDetailsReplyDump()).nat64PoolAddrDetails;
+ .orElse(new Nat64PoolAddrDetailsReplyDump()).nat64PoolAddrDetails;
final int nat64PoolCount = nat64Details.size();
final int nat64PoolPosition = Math.toIntExact(poolId) - nat44PoolCount;
if (nat64PoolPosition < nat64PoolCount) {
@@ -146,16 +148,14 @@ 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
- long addressCount = nat44DumpMgr.getDump(id, ctx.getModificationCache())
- .or(new Nat44AddressDetailsReplyDump()).nat44AddressDetails.stream()
- .count();
+ long addressCount = (long) nat44DumpMgr.getDump(id, ctx.getModificationCache())
+ .orElse(new Nat44AddressDetailsReplyDump()).nat44AddressDetails.size();
// The ietf-nat model groups address pools for Nat44 and Nat64 under the same list,
// but VPP uses different APIs, so we need an other dump:
- addressCount += nat64DumpMgr.getDump(id, ctx.getModificationCache())
- .or(new Nat64PoolAddrDetailsReplyDump()).nat64PoolAddrDetails.stream()
- .count();
+ addressCount += (long) nat64DumpMgr.getDump(id, ctx.getModificationCache())
+ .orElse(new Nat64PoolAddrDetailsReplyDump()).nat64PoolAddrDetails.size();
final List<ExternalIpAddressPoolKey> ids = LongStream.range(0, addressCount)
.mapToObj(ExternalIpAddressPoolKey::new)
diff --git a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/MappingEntryCustomizer.java b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/MappingEntryCustomizer.java
index 2be7392d7..1ae452183 100644
--- a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/MappingEntryCustomizer.java
+++ b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/MappingEntryCustomizer.java
@@ -86,7 +86,7 @@ final class MappingEntryCustomizer implements Ipv4Translator, Ipv6Translator,
final int natInstanceId = id.firstKeyOf(Instance.class).getId().intValue();
final List<Nat44StaticMappingDetails> nat44Details =
nat44DumpManager.getDump(id, ctx.getModificationCache())
- .or(new Nat44StaticMappingDetailsReplyDump()).nat44StaticMappingDetails;
+ .orElse(new Nat44StaticMappingDetailsReplyDump()).nat44StaticMappingDetails;
final Optional<Nat44StaticMappingDetails> nat44StaticMappingDetails =
mappingEntryContext.findDetailsNat44(nat44Details, natInstanceId, idx, ctx.getMappingContext());
@@ -95,7 +95,7 @@ final class MappingEntryCustomizer implements Ipv4Translator, Ipv6Translator,
} else {
final List<Nat64BibDetails> nat64Details =
nat64DumpManager.getDump(id, ctx.getModificationCache())
- .or(new Nat64BibDetailsReplyDump()).nat64BibDetails;
+ .orElse(new Nat64BibDetailsReplyDump()).nat64BibDetails;
final Optional<Nat64BibDetails> nat64StaticMappingDetails =
mappingEntryContext.findDetailsNat64(nat64Details, natInstanceId, idx, ctx.getMappingContext());
@@ -153,7 +153,7 @@ final class MappingEntryCustomizer implements Ipv4Translator, Ipv6Translator,
final List<MappingEntryKey> entryKeys =
nat44DumpManager.getDump(id, context.getModificationCache())
- .or(new Nat44StaticMappingDetailsReplyDump()).nat44StaticMappingDetails.stream()
+ .orElse(new Nat44StaticMappingDetailsReplyDump()).nat44StaticMappingDetails.stream()
.filter(detail -> natInstanceId == detail.vrfId)
.map(detail -> mappingEntryContext
.getStoredOrArtificialIndex(natInstanceId, detail, context.getMappingContext()))
@@ -163,7 +163,7 @@ final class MappingEntryCustomizer implements Ipv4Translator, Ipv6Translator,
final List<MappingEntryKey> nat64Keys =
nat64DumpManager.getDump(id, context.getModificationCache())
- .or(new Nat64BibDetailsReplyDump()).nat64BibDetails.stream()
+ .orElse(new Nat64BibDetailsReplyDump()).nat64BibDetails.stream()
.filter(detail -> natInstanceId == detail.vrfId)
.map(detail -> mappingEntryContext
.getStoredOrArtificialIndex(natInstanceId, detail, context.getMappingContext()))
diff --git a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/NatInstanceCustomizer.java b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/NatInstanceCustomizer.java
index 81a978559..6d1cf812c 100644
--- a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/NatInstanceCustomizer.java
+++ b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/NatInstanceCustomizer.java
@@ -79,10 +79,10 @@ final class NatInstanceCustomizer
// Find the nat instance IDs (vrf-ids) by listing all static mappings and their VRF assignment
final List<InstanceKey> vrfIds = Stream.concat(
nat44DumpManager.getDump(id, context.getModificationCache())
- .or(new Nat44StaticMappingDetailsReplyDump()).nat44StaticMappingDetails.stream()
+ .orElse(new Nat44StaticMappingDetailsReplyDump()).nat44StaticMappingDetails.stream()
.map(detail -> detail.vrfId),
nat64DumpManager.getDump(id, context.getModificationCache())
- .or(new Nat64BibDetailsReplyDump()).nat64BibDetails.stream()
+ .orElse(new Nat64BibDetailsReplyDump()).nat64BibDetails.stream()
.map(detail -> detail.vrfId))
// V4 (nat44) and V6 (nat64) VRFs in VPP can have the same id. We store them under single nat instance,
// because the ietf-nat model does not require separate instances for nat44 and nat64 features.
diff --git a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ifc/AbstractInterfaceNatCustomizer.java b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ifc/AbstractInterfaceNatCustomizer.java
index 91e2a8bb7..2d8e4cce5 100644
--- a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ifc/AbstractInterfaceNatCustomizer.java
+++ b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/read/ifc/AbstractInterfaceNatCustomizer.java
@@ -18,7 +18,6 @@ package io.fd.hc2vpp.nat.read.ifc;
import static java.util.Objects.requireNonNull;
-import com.google.common.base.Optional;
import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.honeycomb.translate.read.ReadContext;
@@ -32,6 +31,7 @@ import io.fd.jvpp.nat.dto.Nat44InterfaceOutputFeatureDump;
import io.fd.jvpp.nat.dto.Nat64InterfaceDetailsReplyDump;
import io.fd.jvpp.nat.dto.Nat64InterfaceDump;
import io.fd.jvpp.nat.future.FutureJVppNatFacade;
+import java.util.Optional;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
import org.opendaylight.yangtools.concepts.Builder;
@@ -95,7 +95,7 @@ abstract class AbstractInterfaceNatCustomizer<C extends DataObject, B extends Bu
final Optional<Nat44InterfaceDetailsReplyDump> dump =
preRoutingNat44DumpMgr.getDump(id, ctx.getModificationCache());
- dump.or(new Nat44InterfaceDetailsReplyDump()).nat44InterfaceDetails.stream()
+ dump.orElse(new Nat44InterfaceDetailsReplyDump()).nat44InterfaceDetails.stream()
.filter(natIfcDetail -> natIfcDetail.swIfIndex == index)
.filter(natIfcDetail -> isExpectedNatType(natIfcDetail.isInside))
.findAny()
@@ -108,7 +108,7 @@ abstract class AbstractInterfaceNatCustomizer<C extends DataObject, B extends Bu
final Optional<Nat64InterfaceDetailsReplyDump> dump =
preRoutingNat64DumpMgr.getDump(id, ctx.getModificationCache());
- dump.or(new Nat64InterfaceDetailsReplyDump()).nat64InterfaceDetails.stream()
+ dump.orElse(new Nat64InterfaceDetailsReplyDump()).nat64InterfaceDetails.stream()
.filter(natIfcDetail -> natIfcDetail.swIfIndex == index)
.filter(natIfcDetail -> isExpectedNatType(natIfcDetail.isInside))
.findAny()
@@ -121,7 +121,7 @@ abstract class AbstractInterfaceNatCustomizer<C extends DataObject, B extends Bu
final Optional<Nat44InterfaceOutputFeatureDetailsReplyDump> dump =
postRoutingNat44DumpMgr.getDump(id, ctx.getModificationCache());
- dump.or(new Nat44InterfaceOutputFeatureDetailsReplyDump()).nat44InterfaceOutputFeatureDetails
+ dump.orElse(new Nat44InterfaceOutputFeatureDetailsReplyDump()).nat44InterfaceOutputFeatureDetails
.stream()
.filter(natIfcDetail -> natIfcDetail.swIfIndex == index)
.filter(natIfcDetail -> isExpectedNatType(natIfcDetail.isInside))
diff --git a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/util/MappingEntryContext.java b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/util/MappingEntryContext.java
index 14bf3f0a3..aed383b10 100644
--- a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/util/MappingEntryContext.java
+++ b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/util/MappingEntryContext.java
@@ -19,7 +19,7 @@ package io.fd.hc2vpp.nat.util;
import static com.google.common.base.Preconditions.checkArgument;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Optional;
+import java.util.Optional;
import io.fd.hc2vpp.common.translate.util.Ipv4Translator;
import io.fd.hc2vpp.common.translate.util.Ipv6Translator;
import io.fd.honeycomb.translate.MappingContext;
@@ -179,8 +179,8 @@ public class MappingEntryContext implements Ipv4Translator, Ipv6Translator {
@Nonnull final MappingContext mappingContext) {
// Find mapping entry for Index
final MappingEntry ctxMappingEntry = mappingContext.read(getTableId(natInstanceId))
- .transform(MappingTable::getMappingEntry)
- .or(Collections.emptyList())
+ .map(MappingTable::getMappingEntry)
+ .orElse(Collections.emptyList())
.stream()
.filter(entry -> entry.getIndex() == idx)
.findFirst()
@@ -201,8 +201,8 @@ public class MappingEntryContext implements Ipv4Translator, Ipv6Translator {
@Nonnull final MappingContext mappingContext) {
// Find mapping entry for Index
final MappingEntry ctxMappingEntry = mappingContext.read(getTableId(natInstanceId))
- .transform(MappingTable::getMappingEntry)
- .or(Collections.emptyList())
+ .map(MappingTable::getMappingEntry)
+ .orElse(Collections.emptyList())
.stream()
.filter(entry -> entry.getIndex() == idx)
.findFirst()
@@ -222,8 +222,8 @@ public class MappingEntryContext implements Ipv4Translator, Ipv6Translator {
@Nonnull final Nat44StaticMappingDetails details,
@Nonnull final MappingContext mappingContext) {
return mappingContext.read(getId(natInstanceId, entryToKey(details)))
- .transform(MappingEntry::getIndex)
- .or(() -> getArtificialId(details, natInstanceId, mappingContext));
+ .map(MappingEntry::getIndex)
+ .orElseGet(() -> getArtificialId(details, natInstanceId, mappingContext));
}
/**
@@ -233,8 +233,8 @@ public class MappingEntryContext implements Ipv4Translator, Ipv6Translator {
@Nonnull final Nat64BibDetails details,
@Nonnull final MappingContext mappingContext) {
return mappingContext.read(getId(natInstanceId, entryToKey(details)))
- .transform(MappingEntry::getIndex)
- .or(() -> getArtificialId(details, natInstanceId, mappingContext));
+ .map(MappingEntry::getIndex)
+ .orElseGet(() -> getArtificialId(details, natInstanceId, mappingContext));
}
/**
@@ -243,8 +243,7 @@ public class MappingEntryContext implements Ipv4Translator, Ipv6Translator {
public synchronized Optional<Long> getStoredIndex(final long natInstanceId,
@Nonnull final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.nat.rev180628.nat.instances.instance.mapping.table.MappingEntry entry,
@Nonnull final MappingContext mappingContext) {
- return mappingContext.read(getId(natInstanceId, entryToKey(entry)))
- .transform(MappingEntry::getIndex);
+ return mappingContext.read(getId(natInstanceId, entryToKey(entry))).map(MappingEntry::getIndex);
}
private long getArtificialId(final Nat44StaticMappingDetails details, final Long natInstanceId,
@@ -267,8 +266,8 @@ public class MappingEntryContext implements Ipv4Translator, Ipv6Translator {
private long findFreeIndex(final long natInstanceId, final MappingContext mappingContext) {
return mappingContext.read(getTableId(natInstanceId))
- .transform(MappingTable::getMappingEntry)
- .or(Collections.emptyList())
+ .map(MappingTable::getMappingEntry)
+ .orElse(Collections.emptyList())
.stream()
.map(MappingEntry::getIndex)
.max(Comparator.naturalOrder())
diff --git a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/MappingEntryCustomizer.java b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/MappingEntryCustomizer.java
index 924f6a6a1..9c8da8c84 100644
--- a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/MappingEntryCustomizer.java
+++ b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/MappingEntryCustomizer.java
@@ -16,7 +16,7 @@
package io.fd.hc2vpp.nat.write;
-import com.google.common.base.Optional;
+import java.util.Optional;
import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
import io.fd.hc2vpp.common.translate.util.Ipv4Translator;
import io.fd.hc2vpp.common.translate.util.Ipv6Translator;
diff --git a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/NatModuleTest.java b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/NatModuleTest.java
index c997e5c37..00986f43a 100644
--- a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/NatModuleTest.java
+++ b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/NatModuleTest.java
@@ -45,7 +45,7 @@ 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 org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesState;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesStateBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
diff --git a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/util/MappingEntryContextTest.java b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/util/MappingEntryContextTest.java
index 871225a29..86abf0e27 100644
--- a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/util/MappingEntryContextTest.java
+++ b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/util/MappingEntryContextTest.java
@@ -24,7 +24,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
-import com.google.common.base.Optional;
+import java.util.Optional;
import com.google.common.collect.Lists;
import io.fd.hc2vpp.common.translate.util.Ipv4Translator;
import io.fd.honeycomb.translate.MappingContext;
@@ -56,7 +56,7 @@ public class MappingEntryContextTest implements Ipv4Translator {
@Test
public void testAdd() throws Exception {
- when(mappingCtx.read(any(InstanceIdentifier.class))).thenReturn(Optional.absent());
+ when(mappingCtx.read(any(InstanceIdentifier.class))).thenReturn(Optional.empty());
final long natId = 7;
final long entryId = 99;
final MappingEntry entry = getEntry(natId, "192.168.1.5/32", "17.14.4.6/32");
@@ -116,7 +116,7 @@ public class MappingEntryContextTest implements Ipv4Translator {
final long entryId = 12;
final Nat44StaticMappingDetails details = getDetails(entryId, "192.168.1.5", "17.14.4.6");
final List<Nat44StaticMappingDetails> someDetails = Lists.newArrayList(details);
- when(mappingCtx.read(MappingEntryContext.getTableId(natId))).thenReturn(Optional.absent());
+ when(mappingCtx.read(MappingEntryContext.getTableId(natId))).thenReturn(Optional.empty());
ctx.findDetailsNat44(someDetails, natId, entryId, mappingCtx);
}
@@ -150,7 +150,7 @@ public class MappingEntryContextTest implements Ipv4Translator {
final MappingEntry newEntry = getEntry(newEntryId, "192.168.1.99/32", "17.14.4.99/32");
final Nat44StaticMappingDetails newDetails = getDetails(newEntryId, "192.168.1.99", "17.14.4.99");
when(mappingCtx.read(MappingEntryContext.getId(natId, MappingEntryContext.entryToKey(newEntry))))
- .thenReturn(Optional.absent());
+ .thenReturn(Optional.empty());
when(mappingCtx.read(MappingEntryContext.getTableId(natId)))
.thenReturn(Optional.of(new MappingTableBuilder()