Package io.github.zhh2001.jp4.entity
Record Class CounterEntry
java.lang.Object
java.lang.Record
io.github.zhh2001.jp4.entity.CounterEntry
- Record Components:
counterName- the counter's fully-qualified P4 name (resolved from the wirecounter_idduring read response parsing); nevernullindex- the cell index within the counter array, as returned by the devicepacketCount- cumulative packet count for the cell; meaningful forPACKETSandBOTHunit countersbyteCount- cumulative byte count for the cell; meaningful forBYTESandBOTHunit counters
public record CounterEntry(String counterName, long index, long packetCount, long byteCount)
extends Record
One P4 counter cell returned by
P4Switch.readCounter. The record
carries the counter's fully-qualified P4 name, the cell index within the
counter array, and the two cumulative values BMv2 reports back:
packetCount and byteCount.
Which of the two counts is meaningful depends on the counter's unit,
available through P4Info.counter(counterName).unit(): a
BYTES counter reports byte_count and leaves packet_count at
0; a PACKETS counter does the opposite; a BOTH
counter populates both. The record stores both fields uniformly as
primitive long to keep the wire mapping unambiguous; consumers
interpret the appropriate field for their counter's unit.
Records are immutable. The canonical constructor rejects null in the
reference component; the long components carry no null surface.
- Since:
- 1.4.0
-
Constructor Summary
ConstructorsConstructorDescriptionCounterEntry(String counterName, long index, long packetCount, long byteCount) Creates an instance of aCounterEntryrecord class. -
Method Summary
Modifier and TypeMethodDescriptionlongReturns the value of thebyteCountrecord component.Returns the value of thecounterNamerecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.longindex()Returns the value of theindexrecord component.longReturns the value of thepacketCountrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
CounterEntry
Creates an instance of aCounterEntryrecord class.- Parameters:
counterName- the value for thecounterNamerecord componentindex- the value for theindexrecord componentpacketCount- the value for thepacketCountrecord componentbyteCount- the value for thebyteCountrecord component
-
-
Method Details
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
counterName
Returns the value of thecounterNamerecord component.- Returns:
- the value of the
counterNamerecord component
-
index
public long index()Returns the value of theindexrecord component.- Returns:
- the value of the
indexrecord component
-
packetCount
public long packetCount()Returns the value of thepacketCountrecord component.- Returns:
- the value of the
packetCountrecord component
-
byteCount
public long byteCount()Returns the value of thebyteCountrecord component.- Returns:
- the value of the
byteCountrecord component
-