Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Open Networking Laboratory |
| 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.bgp.controller.impl; |
| 17 | |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 18 | import org.onosproject.bgp.controller.BgpPacketStats; |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 19 | |
| 20 | /** |
| 21 | * A representation of a packet context which allows any provider |
| 22 | * to view a packet in event, but may block the response to the |
| 23 | * event if blocked has been called. This packet context can be used |
| 24 | * to react to the packet in event with a packet out. |
| 25 | */ |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 26 | public class BgpPacketStatsImpl implements BgpPacketStats { |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 27 | |
| 28 | private int inPacketCount; |
| 29 | private int outPacketCount; |
| 30 | private int wrongPacketCount; |
| 31 | private long time; |
| 32 | |
| 33 | /** |
| 34 | * Resets parameter. |
| 35 | */ |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 36 | public BgpPacketStatsImpl() { |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 37 | this.inPacketCount = 0; |
| 38 | this.outPacketCount = 0; |
| 39 | this.wrongPacketCount = 0; |
| 40 | this.time = 0; |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Get the outgoing packet count number. |
| 45 | * |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 46 | * @return packet count |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 47 | */ |
| 48 | public int outPacketCount() { |
| 49 | return outPacketCount; |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Get the incoming packet count number. |
| 54 | * |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 55 | * @return packet count |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 56 | */ |
| 57 | public int inPacketCount() { |
| 58 | return inPacketCount; |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Get the wrong packet count number. |
| 63 | * |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 64 | * @return packet count |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 65 | */ |
| 66 | public int wrongPacketCount() { |
| 67 | return wrongPacketCount; |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Increments the received packet counter. |
| 72 | */ |
| 73 | public void addInPacket() { |
| 74 | this.inPacketCount++; |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Increments the sent packet counter. |
| 79 | */ |
| 80 | public void addOutPacket() { |
| 81 | this.outPacketCount++; |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * Increments the sent packet counter by specified value. |
| 86 | * |
| 87 | * @param value of no of packets sent |
| 88 | */ |
| 89 | public void addOutPacket(int value) { |
| 90 | this.outPacketCount = this.outPacketCount + value; |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * Increments the wrong packet counter. |
| 95 | */ |
| 96 | public void addWrongPacket() { |
| 97 | this.wrongPacketCount++; |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * Resets wrong packet count. |
| 102 | */ |
| 103 | public void resetWrongPacket() { |
| 104 | this.wrongPacketCount = 0; |
| 105 | } |
| 106 | |
| 107 | /** |
| 108 | * Get the time. |
| 109 | * |
Shashikanth VH | 6de20d3 | 2015-10-09 12:04:13 +0530 | [diff] [blame] | 110 | * @return time |
Satish K | e107e66 | 2015-09-21 19:00:17 +0530 | [diff] [blame] | 111 | */ |
| 112 | public long getTime() { |
| 113 | return this.time; |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * Sets the time. |
| 118 | * |
| 119 | * @param time value to set |
| 120 | */ |
| 121 | public void setTime(long time) { |
| 122 | this.time = time; |
| 123 | } |
| 124 | } |