Srikanth Vavilapalli | 95810f5 | 2015-09-14 15:49:56 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Srikanth Vavilapalli | 95810f5 | 2015-09-14 15:49:56 -0700 | [diff] [blame] | 3 | * |
| 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 | */ |
| 16 | package org.onosproject.net.flow; |
| 17 | |
| 18 | import org.onosproject.net.DeviceId; |
| 19 | import static com.google.common.base.Preconditions.checkNotNull; |
| 20 | |
| 21 | /** |
| 22 | * Default implementation of table statistics entry interface. |
| 23 | */ |
| 24 | public 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 SHIMIZU | 8d50c8d | 2016-08-12 17:29:02 -0700 | [diff] [blame] | 55 | return "device: " + deviceId + ", " + |
| 56 | "tableId: " + this.tableId + ", " + |
| 57 | "activeEntries: " + this.activeFlowEntries + ", " + |
| 58 | "packetsLookedUp: " + this.packetsLookedupCount + ", " + |
| 59 | "packetsMatched: " + this.packetsMatchedCount; |
Srikanth Vavilapalli | 95810f5 | 2015-09-14 15:49:56 -0700 | [diff] [blame] | 60 | } |
| 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 | } |