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.trait;
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.vpp.util.JvppReplyConsumer;
24 import io.fd.vpp.jvpp.core.dto.LispLocatorDetailsReplyDump;
25 import io.fd.vpp.jvpp.core.dto.LispLocatorDump;
26 import io.fd.vpp.jvpp.core.future.FutureJVppCore;
27 import javax.annotation.Nonnull;
30 * Provides common logic for reading of locators
32 public interface LocatorReader extends JvppReplyConsumer {
34 default EntityDumpExecutor<LispLocatorDetailsReplyDump, LocatorDumpParams> createLocatorDumpExecutor(
35 @Nonnull final FutureJVppCore vppApi) {
36 return (identifier, params) -> {
37 checkNotNull(params, "Params for dump request not present");
38 final LispLocatorDump request = new LispLocatorDump();
39 request.lsIndex = params.getLocatorSetIndex();
40 //flag that lsIndex is set
41 request.isIndexSet = (byte) 1;
43 return getReplyForRead(vppApi.lispLocatorDump(request).toCompletableFuture(), identifier);