HONEYCOMB-145 - Utility Class Refactoring
[honeycomb.git] / lisp / lisp2vpp / src / main / java / io / fd / honeycomb / lisp / translate / read / dump / executor / LocatorSetsDumpExecutor.java
1 /*
2  * Copyright (c) 2016 Cisco and/or its affiliates.
3  *
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:
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 package io.fd.honeycomb.lisp.translate.read.dump.executor;
18
19
20 import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor;
21 import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.DumpExecutionFailedException;
22 import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpCallFailedException;
23 import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpTimeoutException;
24 import io.fd.honeycomb.translate.v3po.util.JvppReplyConsumer;
25 import java.util.concurrent.TimeoutException;
26 import javax.annotation.Nonnull;
27 import org.openvpp.jvpp.VppBaseCallException;
28 import org.openvpp.jvpp.core.dto.LispLocatorSetDetailsReplyDump;
29 import org.openvpp.jvpp.core.dto.LispLocatorSetDump;
30 import org.openvpp.jvpp.core.future.FutureJVppCore;
31
32
33 public class LocatorSetsDumpExecutor extends AbstractDumpExecutor
34         implements EntityDumpExecutor<LispLocatorSetDetailsReplyDump, Void>, JvppReplyConsumer {
35
36     public LocatorSetsDumpExecutor(@Nonnull FutureJVppCore api) {
37         super(api);
38     }
39
40     @Override
41     public LispLocatorSetDetailsReplyDump executeDump(final Void params) throws DumpExecutionFailedException {
42
43         LispLocatorSetDump request = new LispLocatorSetDump();
44         //only local
45         request.filter = 1;
46
47         try {
48             return getReply(vppApi.lispLocatorSetDump(request).toCompletableFuture());
49         } catch (TimeoutException e) {
50             throw DumpTimeoutException.wrapTimeoutException("Locator sets dump ended in timeout", e);
51         } catch (VppBaseCallException e) {
52             throw DumpCallFailedException.wrapFailedCallException("Locator sets dump failed", e);
53         }
54     }
55 }