2 * Copyright (c) 2015 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;
20 import static io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor.NO_PARAMS;
22 import com.google.common.base.Optional;
23 import io.fd.honeycomb.lisp.translate.read.dump.executor.ItrRemoteLocatorSetDumpExecutor;
24 import io.fd.honeycomb.translate.read.ReadContext;
25 import io.fd.honeycomb.translate.read.ReadFailedException;
26 import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
27 import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager;
28 import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager.DumpCacheManagerBuilder;
29 import io.fd.honeycomb.translate.vpp.util.ByteDataTranslator;
30 import io.fd.honeycomb.translate.vpp.util.FutureJVppCustomizer;
31 import io.fd.vpp.jvpp.core.dto.LispGetMapRequestItrRlocsReply;
32 import io.fd.vpp.jvpp.core.future.FutureJVppCore;
33 import javax.annotation.Nonnull;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.itr.remote.locator.sets.grouping.ItrRemoteLocatorSet;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.itr.remote.locator.sets.grouping.ItrRemoteLocatorSetBuilder;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.lisp.feature.data.grouping.LispFeatureDataBuilder;
37 import org.opendaylight.yangtools.concepts.Builder;
38 import org.opendaylight.yangtools.yang.binding.DataObject;
39 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
41 public class ItrRemoteLocatorSetCustomizer extends FutureJVppCustomizer
42 implements ReaderCustomizer<ItrRemoteLocatorSet, ItrRemoteLocatorSetBuilder>, ByteDataTranslator {
44 private static final String CACHE_KEY = ItrRemoteLocatorSetCustomizer.class.getName();
46 private final DumpCacheManager<LispGetMapRequestItrRlocsReply, Void> dumpCacheManager;
48 public ItrRemoteLocatorSetCustomizer(@Nonnull final FutureJVppCore futureJVppCore) {
49 super(futureJVppCore);
50 dumpCacheManager = new DumpCacheManagerBuilder<LispGetMapRequestItrRlocsReply, Void>()
51 .withExecutor(new ItrRemoteLocatorSetDumpExecutor(futureJVppCore)).build();
56 public ItrRemoteLocatorSetBuilder getBuilder(@Nonnull final InstanceIdentifier<ItrRemoteLocatorSet> id) {
57 return new ItrRemoteLocatorSetBuilder();
61 public void readCurrentAttributes(@Nonnull final InstanceIdentifier<ItrRemoteLocatorSet> id,
62 @Nonnull final ItrRemoteLocatorSetBuilder builder, @Nonnull final ReadContext ctx)
63 throws ReadFailedException {
65 final Optional<LispGetMapRequestItrRlocsReply> reply =
66 dumpCacheManager.getDump(id, CACHE_KEY, ctx.getModificationCache(), NO_PARAMS);
67 if (!reply.isPresent() || reply.get().locatorSetName == null) {
71 builder.setRemoteLocatorSetName(toString(reply.get().locatorSetName));
75 public void merge(@Nonnull final Builder<? extends DataObject> parentBuilder,
76 @Nonnull final ItrRemoteLocatorSet readValue) {
77 ((LispFeatureDataBuilder) parentBuilder).setItrRemoteLocatorSet(readValue);