blob: 61964a03fb5663c886891d95b8c81c08d9fecc25 [file] [log] [blame]
SureshBR25058b72015-08-13 13:05:06 +05301/*
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 */
16package org.onosproject.pcep.controller.impl;
17
18
19import org.onosproject.pcep.controller.PcepPacketStats;
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 */
26public class PcepPacketStatsImpl implements PcepPacketStats {
27
28 private int inPacketCount;
29 private int outPacketCount;
30 private int wrongPacketCount;
31 private long time;
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 public void resetWrongPacket() {
86 this.wrongPacketCount = 0;
87 }
88
89 @Override
90 public long getTime() {
91 return this.time;
92 }
93
94 /**
95 * Sets the time value.
96 *
97 * @param time long value of time
98 */
99 public void setTime(long time) {
100 this.time = time;
101 }
102}