diff options
author | Jan Srnicek <jsrnicek@cisco.com> | 2016-10-10 09:14:09 +0200 |
---|---|---|
committer | Jan Srnicek <jsrnicek@cisco.com> | 2016-10-10 09:14:09 +0200 |
commit | db58176a8e714515ebcdd07372640c27fe980a79 (patch) | |
tree | d1927b711714bc03fda311c09d306112b130260e /v3po/v3po2vpp/src/main/java/io | |
parent | 60071c191bbb22ba48831f74ad2095acfa84f7d1 (diff) |
HONEYCOMB-252 - Reduced scope of dump executors
Change-Id: Ia426f855b13323369bcc7ec2cde0861421950476
Signed-off-by: Jan Srnicek <jsrnicek@cisco.com>
Diffstat (limited to 'v3po/v3po2vpp/src/main/java/io')
4 files changed, 18 insertions, 43 deletions
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4AddressCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4AddressCustomizer.java index f07ef3d57..23e8eac41 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4AddressCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4AddressCustomizer.java @@ -23,7 +23,6 @@ import io.fd.honeycomb.translate.read.ReadContext; import io.fd.honeycomb.translate.read.ReadFailedException; import io.fd.honeycomb.translate.spi.read.ListReaderCustomizer; import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager; -import io.fd.honeycomb.translate.v3po.interfacesstate.ip.dump.AddressDumpExecutor; import io.fd.honeycomb.translate.v3po.interfacesstate.ip.dump.params.AddressDumpParams; import io.fd.honeycomb.translate.vpp.util.FutureJVppCustomizer; import io.fd.honeycomb.translate.vpp.util.NamingContext; @@ -61,7 +60,7 @@ public class Ipv4AddressCustomizer extends FutureJVppCustomizer super(futureJVppCore); this.interfaceContext = checkNotNull(interfaceContext, "interfaceContext should not be null"); this.dumpManager = new DumpCacheManager.DumpCacheManagerBuilder<IpAddressDetailsReplyDump, AddressDumpParams>() - .withExecutor(new AddressDumpExecutor(futureJVppCore)) + .withExecutor(createExecutor(futureJVppCore)) .build(); } diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4Reader.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4Reader.java index 383cb4284..a5d13bb98 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4Reader.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4Reader.java @@ -20,8 +20,12 @@ import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.base.Optional; import io.fd.honeycomb.translate.util.RWUtils; +import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor; +import io.fd.honeycomb.translate.v3po.interfacesstate.ip.dump.params.AddressDumpParams; import io.fd.honeycomb.translate.vpp.util.Ipv4Translator; import io.fd.honeycomb.translate.vpp.util.JvppReplyConsumer; +import io.fd.vpp.jvpp.core.dto.IpAddressDump; +import io.fd.vpp.jvpp.core.future.FutureJVppCore; import java.util.Collections; import java.util.List; import java.util.function.Function; @@ -65,4 +69,16 @@ interface Ipv4Reader extends Ipv4Translator, JvppReplyConsumer { return Optional.absent(); } + default EntityDumpExecutor<IpAddressDetailsReplyDump, AddressDumpParams> createExecutor( + @Nonnull final FutureJVppCore vppApi) { + return (identifier, params) -> { + checkNotNull(params, "Address dump params cannot be null"); + + final IpAddressDump dumpRequest = new IpAddressDump(); + dumpRequest.isIpv6 = booleanToByte(params.isIpv6()); + dumpRequest.swIfIndex = params.getInterfaceIndex(); + + return getReplyForRead(vppApi.ipAddressDump(dumpRequest).toCompletableFuture(), identifier); + }; + } } diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/SubInterfaceIpv4AddressCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/SubInterfaceIpv4AddressCustomizer.java index f7ab6d8a1..8eb2c92de 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/SubInterfaceIpv4AddressCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/SubInterfaceIpv4AddressCustomizer.java @@ -23,7 +23,6 @@ import io.fd.honeycomb.translate.read.ReadContext; import io.fd.honeycomb.translate.read.ReadFailedException; import io.fd.honeycomb.translate.spi.read.ListReaderCustomizer; import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager; -import io.fd.honeycomb.translate.v3po.interfacesstate.ip.dump.AddressDumpExecutor; import io.fd.honeycomb.translate.v3po.interfacesstate.ip.dump.params.AddressDumpParams; import io.fd.honeycomb.translate.vpp.util.FutureJVppCustomizer; import io.fd.honeycomb.translate.vpp.util.NamingContext; @@ -63,7 +62,7 @@ public class SubInterfaceIpv4AddressCustomizer extends FutureJVppCustomizer super(futureJVppCore); this.interfaceContext = checkNotNull(interfaceContext, "interfaceContext should not be null"); this.dumpManager = new DumpCacheManager.DumpCacheManagerBuilder<IpAddressDetailsReplyDump, AddressDumpParams>() - .withExecutor(new AddressDumpExecutor(futureJVppCore)) + .withExecutor(createExecutor(futureJVppCore)) .build(); } diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/dump/AddressDumpExecutor.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/dump/AddressDumpExecutor.java deleted file mode 100644 index 764717db4..000000000 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/dump/AddressDumpExecutor.java +++ /dev/null @@ -1,39 +0,0 @@ -package io.fd.honeycomb.translate.v3po.interfacesstate.ip.dump; - - -import static com.google.common.base.Preconditions.checkNotNull; - -import io.fd.honeycomb.translate.read.ReadFailedException; -import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor; -import io.fd.honeycomb.translate.v3po.interfacesstate.ip.dump.params.AddressDumpParams; -import io.fd.honeycomb.translate.vpp.util.ByteDataTranslator; -import io.fd.honeycomb.translate.vpp.util.JvppReplyConsumer; -import io.fd.vpp.jvpp.core.dto.IpAddressDetailsReplyDump; -import io.fd.vpp.jvpp.core.dto.IpAddressDump; -import io.fd.vpp.jvpp.core.future.FutureJVppCore; -import javax.annotation.Nonnull; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -public class AddressDumpExecutor - implements EntityDumpExecutor<IpAddressDetailsReplyDump, AddressDumpParams>, ByteDataTranslator, - JvppReplyConsumer { - - private FutureJVppCore vppApi; - - public AddressDumpExecutor(@Nonnull final FutureJVppCore vppApi) { - this.vppApi = checkNotNull(vppApi, "Vpp api refference cannot be null"); - } - - @Override - @Nonnull - public IpAddressDetailsReplyDump executeDump(final InstanceIdentifier<?> identifier, final AddressDumpParams params) - throws ReadFailedException { - checkNotNull(params, "Address dump params cannot be null"); - - IpAddressDump dumpRequest = new IpAddressDump(); - dumpRequest.isIpv6 = booleanToByte(params.isIpv6()); - dumpRequest.swIfIndex = params.getInterfaceIndex(); - - return getReplyForRead(vppApi.ipAddressDump(dumpRequest).toCompletableFuture(), identifier); - } -} |