summaryrefslogtreecommitdiffstats
path: root/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/cache
diff options
context:
space:
mode:
authorMichal Cmarada <mcmarada@cisco.com>2019-05-27 13:54:02 +0200
committerMichal Cmarada <mcmarada@cisco.com>2019-05-27 13:54:02 +0200
commit5543345d32514bfa38292a5080e57b915e39ea1d (patch)
tree6d759a5eb22bb020f47c299e928e7a65f7a84b2f /v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/cache
parent5c416ebacf4baad25de6213661c3cdfff31c0482 (diff)
HC2VPP-411: remove deprecated interface-state
- new ietf-interfaces obsoletes interfaces-state container, only interfaces container should be used from now on. Change-Id: Ifb24611a3dca987bdf6b029d32e01d9b1f479fe8 Signed-off-by: Michal Cmarada <mcmarada@cisco.com>
Diffstat (limited to 'v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/cache')
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/cache/InterfaceCacheDumpManager.java59
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/cache/InterfaceCacheDumpManagerImpl.java202
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/cache/InterfaceCacheDumpManagerProvider.java38
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/cache/InterfaceStatisticsManager.java26
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/cache/InterfaceStatisticsManagerImpl.java37
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/cache/InterfaceStatisticsManagerProvider.java27
6 files changed, 0 insertions, 389 deletions
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/cache/InterfaceCacheDumpManager.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/cache/InterfaceCacheDumpManager.java
deleted file mode 100644
index c570e0d80..000000000
--- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/cache/InterfaceCacheDumpManager.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2017 Cisco and/or its affiliates.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.fd.hc2vpp.v3po.interfacesstate.cache;
-
-import io.fd.honeycomb.translate.read.ReadContext;
-import io.fd.honeycomb.translate.read.ReadFailedException;
-import io.fd.jvpp.core.dto.SwInterfaceDetails;
-import java.util.stream.Stream;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- * Manager for dump data of interfaces. The main purpose of this manager is to cache common interface data between
- * various classes that process this kind of data. If reader does not use this utility, it introduces a big overhead
- * because of size/complexity of interfaces dump
- */
-public interface InterfaceCacheDumpManager {
-
- /**
- * Provides stream of all currently configured vpp interfaces
- *
- * @param identifier id of currently processed data
- * @param ctx context of current transaction
- * @return {@link Stream} of currently configured interfaces
- * @throws ReadFailedException if dumping of data was unsuccessful
- */
- @Nonnull
- Stream<SwInterfaceDetails> getInterfaces(@Nonnull final InstanceIdentifier<?> identifier,
- @Nonnull final ReadContext ctx) throws ReadFailedException;
-
- /**
- * Provides details of interface
- *
- * @param identifier id of currently processed data
- * @param ctx context of current transaction
- * @param interfaceName name of requested interface
- * @return {@link SwInterfaceDetails} of requested interface
- * @throws ReadFailedException if dumping of data was unsuccessful
- */
- @Nullable
- SwInterfaceDetails getInterfaceDetail(@Nonnull final InstanceIdentifier<?> identifier,
- @Nonnull final ReadContext ctx,
- @Nonnull final String interfaceName) throws ReadFailedException;
-}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/cache/InterfaceCacheDumpManagerImpl.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/cache/InterfaceCacheDumpManagerImpl.java
deleted file mode 100644
index f0f08d9d7..000000000
--- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/cache/InterfaceCacheDumpManagerImpl.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * Copyright (c) 2017 Cisco and/or its affiliates.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.fd.hc2vpp.v3po.interfacesstate.cache;
-
-import static io.fd.hc2vpp.common.translate.util.JvppReplyConsumer.INSTANCE;
-import static java.util.stream.Collectors.toMap;
-
-import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
-import io.fd.hc2vpp.common.translate.util.NamingContext;
-import io.fd.honeycomb.translate.ModificationCache;
-import io.fd.honeycomb.translate.read.ReadContext;
-import io.fd.honeycomb.translate.read.ReadFailedException;
-import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager;
-import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor;
-import io.fd.honeycomb.translate.util.read.cache.StaticCacheKeyFactory;
-import io.fd.jvpp.core.dto.SwInterfaceDetails;
-import io.fd.jvpp.core.dto.SwInterfaceDetailsReplyDump;
-import io.fd.jvpp.core.dto.SwInterfaceDump;
-import io.fd.jvpp.core.future.FutureJVppCore;
-import io.fd.jvpp.core.types.InterfaceIndex;
-import java.util.Map;
-import java.util.concurrent.CompletableFuture;
-import java.util.stream.Stream;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Manager for dump data of interfaces/sub-interfaces
- */
-final class InterfaceCacheDumpManagerImpl implements InterfaceCacheDumpManager {
-
- private static final Logger LOG = LoggerFactory.getLogger(InterfaceCacheDumpManagerImpl.class);
-
- // byNameIndex must be cached, not held as reference here, to have it destroyed with cache after transaction
- static final String BY_NAME_INDEX_KEY = InterfaceCacheDumpManagerImpl.class.getName() + "_byNameIndex";
- private NamingContext namingContext;
- private final DumpCacheManager<SwInterfaceDetailsReplyDump, String> specificDumpManager;
- private final DumpCacheManager<SwInterfaceDetailsReplyDump, Void> fullDumpManager;
-
- InterfaceCacheDumpManagerImpl(@Nonnull final FutureJVppCore jvpp,
- @Nonnull final NamingContext namingContext) {
- this.namingContext = namingContext;
- specificDumpManager = specificInterfaceDumpManager(jvpp);
- fullDumpManager = fullInterfaceDumpManager(jvpp,
- new StaticCacheKeyFactory(InterfaceCacheDumpManagerImpl.class.getName() + "_dump", SwInterfaceDetailsReplyDump.class));
- }
-
- @Override
- @Nonnull
- public synchronized Stream<SwInterfaceDetails> getInterfaces(@Nonnull final InstanceIdentifier<?> identifier,
- @Nonnull final ReadContext ctx)
- throws ReadFailedException {
- LOG.debug("Reading all interfaces[{}]", identifier);
- return initMapAndGet(identifier, ctx).entrySet().stream().map(Map.Entry::getValue);
- }
-
- @Override
- @Nullable
- public synchronized SwInterfaceDetails getInterfaceDetail(@Nonnull final InstanceIdentifier<?> identifier,
- @Nonnull final ReadContext ctx,
- @Nonnull final String interfaceName)
- throws ReadFailedException {
- final Map<String, SwInterfaceDetails> interfaceIndex = getMap(ctx);
-
- // does not attempt to cover cases with concurrent updates, as tx should be atomic
- if (interfaceIndex != null) {
- // tries to find interface in map
- return interfaceIndex.get(interfaceName);
- } else {
- // if map is not present, use specific dump(it will be cached standard way, under key constructed from IID)
- return dumpSpecificDetail(identifier, ctx, interfaceName);
- }
- }
-
- private SwInterfaceDetails dumpSpecificDetail(@Nonnull final InstanceIdentifier<?> identifier,
- @Nonnull final ReadContext ctx,
- @Nonnull final String interfaceName)
- throws ReadFailedException {
- LOG.debug("Interface {} not present in cached data, performing specific dump[{}]", interfaceName,
- identifier);
- final SwInterfaceDetailsReplyDump reply =
- specificDumpManager.getDump(identifier, ctx.getModificationCache(), interfaceName)
- .orElse(new SwInterfaceDetailsReplyDump());
-
- if (reply.swInterfaceDetails.isEmpty()) {
- return null;
- }
-
- return reply.swInterfaceDetails.get(0);
- }
-
- private Map<String, SwInterfaceDetails> initMapAndGet(final InstanceIdentifier<?> identifier, final ReadContext ctx)
- throws ReadFailedException {
-
- final ModificationCache cache = ctx.getModificationCache();
- if (!cache.containsKey(BY_NAME_INDEX_KEY)) {
- LOG.debug("Performing dump[{}]", identifier);
- final SwInterfaceDetailsReplyDump dump =
- fullDumpManager.getDump(identifier, cache)
- .orElse(new SwInterfaceDetailsReplyDump());
-
- // naming context initialization must be done here, as it is uses getName in next step, therefore it would
- // create artificial mapping for every interface, because this happens before interface dump is processed
- dump.swInterfaceDetails.forEach((elt) -> {
- // Store interface name from VPP in context if not yet present
- if (!namingContext.containsName(elt.swIfIndex, ctx.getMappingContext())) {
- namingContext.addName(elt.swIfIndex, ByteDataTranslator.INSTANCE.toString(elt.interfaceName),
- ctx.getMappingContext());
- }
- LOG.trace("Interface with name: {}, VPP name: {} and index: {} found in VPP",
- getInterfaceName(ctx, elt),
- elt.interfaceName,
- elt.swIfIndex);
- });
-
- final Map<String, SwInterfaceDetails> freshIndex = dump.swInterfaceDetails.stream()
- .collect(toMap(detail -> getInterfaceName(ctx, detail),
- detail -> detail));
- putMap(freshIndex, ctx);
- }
-
- return getMap(ctx);
- }
-
- private String getInterfaceName(final ReadContext ctx, final SwInterfaceDetails elt) {
- return namingContext.getName(elt.swIfIndex, ctx.getMappingContext());
- }
-
- private static Map<String, SwInterfaceDetails> getMap(final ReadContext ctx) {
- return (Map<String, SwInterfaceDetails>) ctx.getModificationCache().get(BY_NAME_INDEX_KEY);
- }
-
- private static void putMap(final Map<String, SwInterfaceDetails> map, final ReadContext ctx) {
- ctx.getModificationCache().put(BY_NAME_INDEX_KEY, map);
- }
-
-
- private static DumpCacheManager<SwInterfaceDetailsReplyDump, Void> fullInterfaceDumpManager(
- final FutureJVppCore jvpp,
- final StaticCacheKeyFactory cacheKeyFactory) {
- return new DumpCacheManager.DumpCacheManagerBuilder<SwInterfaceDetailsReplyDump, Void>()
- .withExecutor(fullInterfaceDumpExecutor(jvpp))
- .withCacheKeyFactory(cacheKeyFactory)
- .acceptOnly(SwInterfaceDetailsReplyDump.class)
- .build();
- }
-
- private static DumpCacheManager<SwInterfaceDetailsReplyDump, String> specificInterfaceDumpManager(
- final FutureJVppCore jvpp) {
- return new DumpCacheManager.DumpCacheManagerBuilder<SwInterfaceDetailsReplyDump, String>()
- .withExecutor(specificInterfaceDumpExecutor(jvpp))
- .acceptOnly(SwInterfaceDetailsReplyDump.class)
- .build();
- }
-
- private static EntityDumpExecutor<SwInterfaceDetailsReplyDump, Void> fullInterfaceDumpExecutor(
- final FutureJVppCore api) {
- return (identifier, params) -> {
- final SwInterfaceDump request = new SwInterfaceDump();
- request.swIfIndex = new InterfaceIndex();
- request.swIfIndex.interfaceindex = ~0;
- request.nameFilter = "".getBytes();
- request.nameFilterValid = 0;
-
- final CompletableFuture<SwInterfaceDetailsReplyDump>
- swInterfaceDetailsReplyDumpCompletableFuture = api.swInterfaceDump(request).toCompletableFuture();
- return INSTANCE.getReplyForRead(swInterfaceDetailsReplyDumpCompletableFuture, identifier);
- };
- }
-
- private static EntityDumpExecutor<SwInterfaceDetailsReplyDump, String> specificInterfaceDumpExecutor(
- final FutureJVppCore api) {
- return (identifier, ifaceName) -> {
- final SwInterfaceDump request = new SwInterfaceDump();
- request.swIfIndex = new InterfaceIndex();
- request.swIfIndex.interfaceindex =~0;
- request.nameFilter = ifaceName.getBytes();
- request.nameFilterValid = 1;
-
- final CompletableFuture<SwInterfaceDetailsReplyDump>
- swInterfaceDetailsReplyDumpCompletableFuture = api.swInterfaceDump(request).toCompletableFuture();
- return INSTANCE.getReplyForRead(swInterfaceDetailsReplyDumpCompletableFuture, identifier);
- };
- }
-}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/cache/InterfaceCacheDumpManagerProvider.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/cache/InterfaceCacheDumpManagerProvider.java
deleted file mode 100644
index b5a010670..000000000
--- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/cache/InterfaceCacheDumpManagerProvider.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2017 Cisco and/or its affiliates.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.fd.hc2vpp.v3po.interfacesstate.cache;
-
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-import io.fd.hc2vpp.common.translate.util.NamingContext;
-import io.fd.jvpp.core.future.FutureJVppCore;
-import javax.inject.Named;
-
-public class InterfaceCacheDumpManagerProvider implements Provider<InterfaceCacheDumpManager> {
-
- @Inject
- private FutureJVppCore jvpp;
-
- @Inject
- @Named("interface-context")
- private NamingContext namingContext;
-
- @Override
- public InterfaceCacheDumpManager get() {
- return new InterfaceCacheDumpManagerImpl(jvpp, namingContext);
- }
-}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/cache/InterfaceStatisticsManager.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/cache/InterfaceStatisticsManager.java
deleted file mode 100644
index 0c5e36248..000000000
--- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/cache/InterfaceStatisticsManager.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2019 PANTHEON.tech.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.fd.hc2vpp.v3po.interfacesstate.cache;
-
-public interface InterfaceStatisticsManager {
-
- boolean isStatisticsEnabled();
-
- void enableStatistics();
-
- void disableStatistics();
-}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/cache/InterfaceStatisticsManagerImpl.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/cache/InterfaceStatisticsManagerImpl.java
deleted file mode 100644
index 0543fe745..000000000
--- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/cache/InterfaceStatisticsManagerImpl.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2019 PANTHEON.tech.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.fd.hc2vpp.v3po.interfacesstate.cache;
-
-public class InterfaceStatisticsManagerImpl implements InterfaceStatisticsManager {
-
- private boolean isEnabled;
-
- @Override
- public boolean isStatisticsEnabled() {
- return isEnabled;
- }
-
- @Override
- public void enableStatistics() {
- isEnabled = true;
- }
-
- @Override
- public void disableStatistics() {
- isEnabled = false;
- }
-}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/cache/InterfaceStatisticsManagerProvider.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/cache/InterfaceStatisticsManagerProvider.java
deleted file mode 100644
index 7306efcfd..000000000
--- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/cache/InterfaceStatisticsManagerProvider.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2019 PANTHEON.tech.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.fd.hc2vpp.v3po.interfacesstate.cache;
-
-import com.google.inject.Provider;
-
-public class InterfaceStatisticsManagerProvider implements Provider<InterfaceStatisticsManager> {
-
- @Override
- public InterfaceStatisticsManager get() {
- return new InterfaceStatisticsManagerImpl();
- }
-}