1 package io.fd.honeycomb.translate.v3po.interfacesstate.ip.dump;
4 import static com.google.common.base.Preconditions.checkNotNull;
6 import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor;
7 import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.DumpExecutionFailedException;
8 import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpCallFailedException;
9 import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpTimeoutException;
10 import io.fd.honeycomb.translate.v3po.interfacesstate.ip.dump.params.AddressDumpParams;
11 import io.fd.honeycomb.translate.vpp.util.ByteDataTranslator;
12 import io.fd.honeycomb.translate.vpp.util.JvppReplyConsumer;
13 import java.util.concurrent.TimeoutException;
14 import javax.annotation.Nonnull;
15 import io.fd.vpp.jvpp.VppBaseCallException;
16 import io.fd.vpp.jvpp.core.dto.IpAddressDetailsReplyDump;
17 import io.fd.vpp.jvpp.core.dto.IpAddressDump;
18 import io.fd.vpp.jvpp.core.future.FutureJVppCore;
20 public class AddressDumpExecutor
21 implements EntityDumpExecutor<IpAddressDetailsReplyDump, AddressDumpParams>, ByteDataTranslator,
24 private FutureJVppCore vppApi;
26 public AddressDumpExecutor(@Nonnull final FutureJVppCore vppApi) {
27 this.vppApi = checkNotNull(vppApi, "Vpp api refference cannot be null");
31 public IpAddressDetailsReplyDump executeDump(final AddressDumpParams params) throws DumpExecutionFailedException {
32 checkNotNull(params, "Address dump params cannot be null");
34 IpAddressDump dumpRequest = new IpAddressDump();
35 dumpRequest.isIpv6 = booleanToByte(params.isIpv6());
36 dumpRequest.swIfIndex = params.getInterfaceIndex();
39 return getReply(vppApi.ipAddressDump(dumpRequest).toCompletableFuture());
40 } catch (TimeoutException e) {
41 throw DumpTimeoutException
42 .wrapTimeoutException("Dumping or addresses ended in timeout[params : ]" + params, e);
43 } catch (VppBaseCallException e) {
44 throw DumpCallFailedException.wrapFailedCallException("Dumping of addresses failed[params : ]" + params, e);