2 * Copyright (c) 2019 PANTHEON.tech.
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.hc2vpp.v3po.interfacesstate.cache;
19 import io.fd.vpp.jvpp.core.dto.VnetPerInterfaceCombinedCounters;
20 import java.time.LocalDateTime;
21 import java.util.HashMap;
22 import javax.annotation.Nullable;
24 public class InterfaceCacheStatisticsDumpManagerImpl implements InterfaceCacheStatisticsDumpManager {
26 private final HashMap<Integer, InterfaceCacheStatisticsSample> statistics;
28 public InterfaceCacheStatisticsDumpManagerImpl() {
29 statistics = new HashMap<>();
34 public InterfaceCacheStatisticsSample getStatisticsData(final int ifcSwIndex) {
35 return statistics.getOrDefault(ifcSwIndex, null);
39 public void setStatisticsData(final VnetPerInterfaceCombinedCounters data, LocalDateTime captureTime,
40 final int ifcSwIndex) {
41 statistics.put(ifcSwIndex, new InterfaceCacheStatisticsSample(data, captureTime));
46 public int[] getEnabledInterfaces() {
47 return statistics.keySet().stream().mapToInt(i -> i).toArray();
51 public void disableInterface(final int ifcSwIndex) {
52 statistics.remove(ifcSwIndex);
56 public void disableAll() {
61 public void enableInterface(final int index) {
63 new InterfaceCacheStatisticsSample(new VnetPerInterfaceCombinedCounters(), LocalDateTime.now()));