blob: fd1eb1a33163047179cd94e6e0673a13b11cab4c [file] [log] [blame]
SureshBR25058b72015-08-13 13:05:06 +05301/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
SureshBR25058b72015-08-13 13:05:06 +05303 *
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.pcep.controller.impl;
17
SureshBR25058b72015-08-13 13:05:06 +053018import org.onosproject.pcep.controller.PcepPacketStats;
Phanendra Manda51fb9c22015-09-01 16:17:41 +053019
SureshBR25058b72015-08-13 13:05:06 +053020/**
Phanendra Manda51fb9c22015-09-01 16:17:41 +053021 * The implementation for PCEP packet statistics.
SureshBR25058b72015-08-13 13:05:06 +053022 */
23public class PcepPacketStatsImpl implements PcepPacketStats {
24
25 private int inPacketCount;
26 private int outPacketCount;
27 private int wrongPacketCount;
28 private long time;
29
Phanendra Manda51fb9c22015-09-01 16:17:41 +053030 /**
31 * Default constructor.
32 */
SureshBR25058b72015-08-13 13:05:06 +053033 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 Manda51fb9c22015-09-01 16:17:41 +053085 /**
86 * Resets wrong packet count.
87 */
SureshBR25058b72015-08-13 13:05:06 +053088 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}