mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-16 18:02:05 +02:00
Moving PortStatistcs port number to Long to aling with Port class
Change-Id: I43ab8760dc3bf192cd2f47511819076fbf1070b6
This commit is contained in:
parent
b045ddce4a
commit
c86154a8a1
@ -16,6 +16,7 @@
|
||||
package org.onosproject.net.device;
|
||||
|
||||
import org.onosproject.net.DeviceId;
|
||||
import org.onosproject.net.PortNumber;
|
||||
|
||||
/**
|
||||
* Default implementation of immutable port statistics.
|
||||
@ -23,7 +24,7 @@ import org.onosproject.net.DeviceId;
|
||||
public final class DefaultPortStatistics implements PortStatistics {
|
||||
|
||||
private final DeviceId deviceId;
|
||||
private final int port;
|
||||
private final PortNumber portNumber;
|
||||
private final long packetsReceived;
|
||||
private final long packetsSent;
|
||||
private final long bytesReceived;
|
||||
@ -36,7 +37,7 @@ public final class DefaultPortStatistics implements PortStatistics {
|
||||
private final long durationNano;
|
||||
|
||||
private DefaultPortStatistics(DeviceId deviceId,
|
||||
int port,
|
||||
PortNumber portNumber,
|
||||
long packetsReceived,
|
||||
long packetsSent,
|
||||
long bytesReceived,
|
||||
@ -48,7 +49,7 @@ public final class DefaultPortStatistics implements PortStatistics {
|
||||
long durationSec,
|
||||
long durationNano) {
|
||||
this.deviceId = deviceId;
|
||||
this.port = port;
|
||||
this.portNumber = portNumber;
|
||||
this.packetsReceived = packetsReceived;
|
||||
this.packetsSent = packetsSent;
|
||||
this.bytesReceived = bytesReceived;
|
||||
@ -64,7 +65,7 @@ public final class DefaultPortStatistics implements PortStatistics {
|
||||
// Constructor for serializer
|
||||
private DefaultPortStatistics() {
|
||||
this.deviceId = null;
|
||||
this.port = 0;
|
||||
this.portNumber = null;
|
||||
this.packetsReceived = 0;
|
||||
this.packetsSent = 0;
|
||||
this.bytesReceived = 0;
|
||||
@ -88,7 +89,12 @@ public final class DefaultPortStatistics implements PortStatistics {
|
||||
|
||||
@Override
|
||||
public int port() {
|
||||
return this.port;
|
||||
return (int) this.portNumber.toLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PortNumber portNumber() {
|
||||
return this.portNumber;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -154,7 +160,7 @@ public final class DefaultPortStatistics implements PortStatistics {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "device: " + deviceId + ", " +
|
||||
"port: " + this.port + ", " +
|
||||
"port: " + this.portNumber + ", " +
|
||||
"pktRx: " + this.packetsReceived + ", " +
|
||||
"pktTx: " + this.packetsSent + ", " +
|
||||
"byteRx: " + this.bytesReceived + ", " +
|
||||
@ -168,7 +174,7 @@ public final class DefaultPortStatistics implements PortStatistics {
|
||||
public static final class Builder {
|
||||
|
||||
DeviceId deviceId;
|
||||
int port;
|
||||
PortNumber portNumber;
|
||||
long packetsReceived;
|
||||
long packetsSent;
|
||||
long bytesReceived;
|
||||
@ -189,9 +195,23 @@ public final class DefaultPortStatistics implements PortStatistics {
|
||||
*
|
||||
* @param port port number
|
||||
* @return builder object
|
||||
* @deprecated ONOS 1.12 Magpie
|
||||
*/
|
||||
@Deprecated
|
||||
public Builder setPort(int port) {
|
||||
this.port = port;
|
||||
this.portNumber = PortNumber.portNumber(port);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets port number.
|
||||
*
|
||||
* @param portNumber port number
|
||||
* @return builder object
|
||||
*/
|
||||
public Builder setPort(PortNumber portNumber) {
|
||||
this.portNumber = portNumber;
|
||||
|
||||
return this;
|
||||
}
|
||||
@ -336,7 +356,7 @@ public final class DefaultPortStatistics implements PortStatistics {
|
||||
public DefaultPortStatistics build() {
|
||||
return new DefaultPortStatistics(
|
||||
deviceId,
|
||||
port,
|
||||
portNumber,
|
||||
packetsReceived,
|
||||
packetsSent,
|
||||
bytesReceived,
|
||||
|
@ -15,6 +15,8 @@
|
||||
*/
|
||||
package org.onosproject.net.device;
|
||||
|
||||
import org.onosproject.net.PortNumber;
|
||||
|
||||
/**
|
||||
* Statistics of a port.
|
||||
*/
|
||||
@ -24,9 +26,18 @@ public interface PortStatistics {
|
||||
* Returns the port number.
|
||||
*
|
||||
* @return port number
|
||||
* @deprecated ONOS 1.12 Magpie please use portNumber()
|
||||
*/
|
||||
@Deprecated
|
||||
int port();
|
||||
|
||||
/**
|
||||
* Returns the port number.
|
||||
*
|
||||
* @return port number
|
||||
*/
|
||||
PortNumber portNumber();
|
||||
|
||||
/**
|
||||
* Returns the number of packets received.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user