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;
19 import static com.google.common.base.Preconditions.checkNotNull;
21 import io.fd.honeycomb.lisp.translate.read.dump.executor.params.LocatorDumpParams;
22 import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor;
23 import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.DumpExecutionFailedException;
24 import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpCallFailedException;
25 import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpTimeoutException;
26 import io.fd.honeycomb.translate.vpp.util.JvppReplyConsumer;
27 import java.util.concurrent.TimeoutException;
28 import javax.annotation.Nonnull;
29 import org.openvpp.jvpp.VppBaseCallException;
30 import org.openvpp.jvpp.core.dto.LispLocatorDetailsReplyDump;
31 import org.openvpp.jvpp.core.dto.LispLocatorDump;
32 import org.openvpp.jvpp.core.future.FutureJVppCore;
36 * Executor for dumping of locators
38 public class LocatorDumpExecutor extends AbstractDumpExecutor
39 implements EntityDumpExecutor<LispLocatorDetailsReplyDump, LocatorDumpParams>, JvppReplyConsumer {
42 public LocatorDumpExecutor(@Nonnull final FutureJVppCore vppApi) {
47 public LispLocatorDetailsReplyDump executeDump(final LocatorDumpParams params) throws DumpExecutionFailedException {
48 checkNotNull(params, "Params for dump request not present");
50 LispLocatorDump request = new LispLocatorDump();
51 request.lsIndex = params.getLocatorSetIndex();
52 //flag that lsIndex is set
53 request.isIndexSet = (byte) 1;
56 return getReply(vppApi.lispLocatorDump(request).toCompletableFuture());
57 } catch (TimeoutException e) {
58 throw DumpTimeoutException
59 .wrapTimeoutException("Locator dump ended in timeout with params" + params.toString(), e);
60 } catch (VppBaseCallException e) {
61 throw DumpCallFailedException
62 .wrapFailedCallException("Locator dump failed with params" + params.toString(), e);