2 * Copyright (c) 2016 Cisco and/or its affiliates.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package io.fd.honeycomb.lisp.translate.read.dump.executor;
20 import static com.google.common.base.Preconditions.checkNotNull;
22 import io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams;
23 import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor;
24 import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.DumpExecutionFailedException;
25 import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpCallFailedException;
26 import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpTimeoutException;
27 import io.fd.honeycomb.translate.vpp.util.JvppReplyConsumer;
28 import java.util.concurrent.TimeoutException;
29 import javax.annotation.Nonnull;
30 import io.fd.vpp.jvpp.VppBaseCallException;
31 import io.fd.vpp.jvpp.core.dto.LispEidTableDetailsReplyDump;
32 import io.fd.vpp.jvpp.core.dto.LispEidTableDump;
33 import io.fd.vpp.jvpp.core.future.FutureJVppCore;
37 * Common dump executor for both local and remote mappings
39 public class MappingsDumpExecutor extends AbstractJvppDumpExecutor
40 implements EntityDumpExecutor<LispEidTableDetailsReplyDump, MappingsDumpParams>, JvppReplyConsumer {
42 public MappingsDumpExecutor(@Nonnull FutureJVppCore vppApi) {
48 public LispEidTableDetailsReplyDump executeDump(final MappingsDumpParams params)
49 throws DumpExecutionFailedException {
50 checkNotNull(params, "Params for dump request not present");
52 LispEidTableDump request = new LispEidTableDump();
53 request.eid = params.getEid();
54 request.eidSet = params.getEidSet();
55 request.eidType = params.getEidType();
56 request.prefixLength = params.getPrefixLength();
57 request.vni = params.getVni();
58 request.filter = params.getFilter();
61 return getReply(vppApi.lispEidTableDump(request).toCompletableFuture());
62 } catch (TimeoutException e) {
63 throw DumpTimeoutException
64 .wrapTimeoutException("Mappings dump execution timed out with params " + params.toString(), e);
65 } catch (VppBaseCallException e) {
66 throw DumpCallFailedException
67 .wrapFailedCallException("Mappings dump execution failed with params " + params.toString(), e);