f2bc51ebdca047e2b6d25634ed9774a2c4be01f7
[onosfw.git] /
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.pcep.controller.impl;
17
18 import org.onosproject.pcep.controller.PcepPacketStats;
19
20 /**
21  * The implementation for PCEP packet statistics.
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
30     /**
31      * Default constructor.
32      */
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
85     /**
86      * Resets wrong packet count.
87      */
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 }