blob: 53423d38856849476697f95ab5925a7d7855efe3 [file] [log] [blame]
Srikanth Vavilapalli95810f52015-09-14 15:49:56 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
Srikanth Vavilapalli95810f52015-09-14 15:49:56 -07003 *
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 */
16package org.onosproject.net.flow;
17
18import org.onosproject.net.DeviceId;
19import static com.google.common.base.Preconditions.checkNotNull;
20
21/**
22 * Default implementation of table statistics entry interface.
23 */
24public final class DefaultTableStatisticsEntry implements TableStatisticsEntry {
25
26 private final DeviceId deviceId;
27 private final int tableId;
28 private final long activeFlowEntries;
29 private final long packetsLookedupCount;
30 private final long packetsMatchedCount;
31
32 /**
33 * Default table statistics constructor.
34 *
35 * @param deviceId device identifier
36 * @param tableId table identifier
37 * @param activeFlowEntries number of active flow entries in the table
38 * @param packetsLookedupCount number of packets looked up in table
39 * @param packetsMatchedCount number of packets that hit table
40 */
41 public DefaultTableStatisticsEntry(DeviceId deviceId,
42 int tableId,
43 long activeFlowEntries,
44 long packetsLookedupCount,
45 long packetsMatchedCount) {
46 this.deviceId = checkNotNull(deviceId);
47 this.tableId = tableId;
48 this.activeFlowEntries = activeFlowEntries;
49 this.packetsLookedupCount = packetsLookedupCount;
50 this.packetsMatchedCount = packetsMatchedCount;
51 }
52
53 @Override
54 public String toString() {
Sho SHIMIZU8d50c8d2016-08-12 17:29:02 -070055 return "device: " + deviceId + ", " +
56 "tableId: " + this.tableId + ", " +
57 "activeEntries: " + this.activeFlowEntries + ", " +
58 "packetsLookedUp: " + this.packetsLookedupCount + ", " +
59 "packetsMatched: " + this.packetsMatchedCount;
Srikanth Vavilapalli95810f52015-09-14 15:49:56 -070060 }
61
62 @Override
63 public int tableId() {
64 return tableId;
65 }
66
67 @Override
68 public long activeFlowEntries() {
69 return activeFlowEntries;
70 }
71
72 @Override
73 public long packetsLookedup() {
74 return packetsLookedupCount;
75 }
76
77 @Override
78 public long packetsMatched() {
79 return packetsMatchedCount;
80 }
81
82 @Override
83 public DeviceId deviceId() {
84 return deviceId;
85 }
86}