SureshBR | 25058b7 | 2015-08-13 13:05:06 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
SureshBR | 25058b7 | 2015-08-13 13:05:06 +0530 | [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.pcep.controller.impl; |
| 17 | |
SureshBR | 25058b7 | 2015-08-13 13:05:06 +0530 | [diff] [blame] | 18 | import org.onosproject.pcep.controller.PcepPacketStats; |
Phanendra Manda | 51fb9c2 | 2015-09-01 16:17:41 +0530 | [diff] [blame] | 19 | |
SureshBR | 25058b7 | 2015-08-13 13:05:06 +0530 | [diff] [blame] | 20 | /** |
Phanendra Manda | 51fb9c2 | 2015-09-01 16:17:41 +0530 | [diff] [blame] | 21 | * The implementation for PCEP packet statistics. |
SureshBR | 25058b7 | 2015-08-13 13:05:06 +0530 | [diff] [blame] | 22 | */ |
| 23 | public class PcepPacketStatsImpl implements PcepPacketStats { |
| 24 | |
| 25 | private int inPacketCount; |
| 26 | private int outPacketCount; |
| 27 | private int wrongPacketCount; |
| 28 | private long time; |
| 29 | |
Phanendra Manda | 51fb9c2 | 2015-09-01 16:17:41 +0530 | [diff] [blame] | 30 | /** |
| 31 | * Default constructor. |
| 32 | */ |
SureshBR | 25058b7 | 2015-08-13 13:05:06 +0530 | [diff] [blame] | 33 | public PcepPacketStatsImpl() { |
| 34 | this.inPacketCount = 0; |
| 35 | this.outPacketCount = 0; |
| 36 | this.wrongPacketCount = 0; |
| 37 | this.time = 0; |
| 38 | } |
| 39 | |
| 40 | @Override |
| 41 | public int outPacketCount() { |
| 42 | return outPacketCount; |
| 43 | } |
| 44 | |
| 45 | @Override |
| 46 | public int inPacketCount() { |
| 47 | return inPacketCount; |
| 48 | } |
| 49 | |
| 50 | @Override |
| 51 | public int wrongPacketCount() { |
| 52 | return wrongPacketCount; |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Increments the received packet counter. |
| 57 | */ |
| 58 | public void addInPacket() { |
| 59 | this.inPacketCount++; |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Increments the sent packet counter. |
| 64 | */ |
| 65 | public void addOutPacket() { |
| 66 | this.outPacketCount++; |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Increments the sent packet counter by specified value. |
| 71 | * |
| 72 | * @param value of no of packets sent |
| 73 | */ |
| 74 | public void addOutPacket(int value) { |
| 75 | this.outPacketCount = this.outPacketCount + value; |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Increments the wrong packet counter. |
| 80 | */ |
| 81 | public void addWrongPacket() { |
| 82 | this.wrongPacketCount++; |
| 83 | } |
| 84 | |
Phanendra Manda | 51fb9c2 | 2015-09-01 16:17:41 +0530 | [diff] [blame] | 85 | /** |
| 86 | * Resets wrong packet count. |
| 87 | */ |
SureshBR | 25058b7 | 2015-08-13 13:05:06 +0530 | [diff] [blame] | 88 | public void resetWrongPacket() { |
| 89 | this.wrongPacketCount = 0; |
| 90 | } |
| 91 | |
| 92 | @Override |
| 93 | public long getTime() { |
| 94 | return this.time; |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * Sets the time value. |
| 99 | * |
| 100 | * @param time long value of time |
| 101 | */ |
| 102 | public void setTime(long time) { |
| 103 | this.time = time; |
| 104 | } |
| 105 | } |