blob: 921f9ac80088afe00a13ab3cf39a15a3ca06cd0b [file] [log] [blame]
Srikanth Vavilapalli95810f52015-09-14 15:49:56 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
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() {
55 StringBuilder sb = new StringBuilder("device: " + deviceId + ", ");
56
57 sb.append("tableId: " + this.tableId + ", ");
58 sb.append("activeEntries: " + this.activeFlowEntries + ", ");
59 sb.append("packetsLookedUp: " + this.packetsLookedupCount + ", ");
60 sb.append("packetsMatched: " + this.packetsMatchedCount);
61
62 return sb.toString();
63 }
64
65 @Override
66 public int tableId() {
67 return tableId;
68 }
69
70 @Override
71 public long activeFlowEntries() {
72 return activeFlowEntries;
73 }
74
75 @Override
76 public long packetsLookedup() {
77 return packetsLookedupCount;
78 }
79
80 @Override
81 public long packetsMatched() {
82 return packetsMatchedCount;
83 }
84
85 @Override
86 public DeviceId deviceId() {
87 return deviceId;
88 }
89}