mirror of
https://github.com/opennetworkinglab/onos.git
synced 2026-05-05 20:26:16 +02:00
Remove deprecated Port Statistics APIs
- Builder set of port number as an integer - Query port number as an integer Change-Id: Id4b4380c75237f293d2cc28a102748d416cf5c01
This commit is contained in:
parent
8efe27882c
commit
5ec42085af
@ -501,7 +501,7 @@ public final class DefaultOFSwitch implements OFSwitch {
|
||||
|
||||
private OFPortStatsEntry portStatsEntry(PortStatistics portStatistic) {
|
||||
OFPortStatsEntry ofPortStatsEntry = FACTORY.buildPortStatsEntry()
|
||||
.setPortNo(OFPort.of(portStatistic.port()))
|
||||
.setPortNo(OFPort.of((int) portStatistic.portNumber().toLong()))
|
||||
.setTxBytes(U64.of(portStatistic.bytesSent()))
|
||||
.setTxPackets(U64.of(portStatistic.packetsSent()))
|
||||
.setTxDropped(U64.of(portStatistic.packetsTxDropped()))
|
||||
|
||||
@ -91,11 +91,6 @@ public final class DefaultPortStatistics extends AbstractAnnotated implements Po
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int port() {
|
||||
return (int) this.portNumber.toLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PortNumber portNumber() {
|
||||
return this.portNumber;
|
||||
@ -196,20 +191,6 @@ public final class DefaultPortStatistics extends AbstractAnnotated implements Po
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets port number.
|
||||
*
|
||||
* @param port port number
|
||||
* @return builder object
|
||||
* @deprecated ONOS 1.12 Magpie
|
||||
*/
|
||||
@Deprecated
|
||||
public Builder setPort(int port) {
|
||||
this.portNumber = PortNumber.portNumber(port);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets port number.
|
||||
*
|
||||
|
||||
@ -26,15 +26,6 @@ import static org.onosproject.net.DefaultAnnotations.EMPTY;
|
||||
*/
|
||||
public interface PortStatistics extends Annotated {
|
||||
|
||||
/**
|
||||
* Returns the port number.
|
||||
*
|
||||
* @return port number
|
||||
* @deprecated ONOS 1.12 Magpie please use portNumber()
|
||||
*/
|
||||
@Deprecated
|
||||
int port();
|
||||
|
||||
/**
|
||||
* Returns the port number.
|
||||
*
|
||||
|
||||
@ -23,6 +23,7 @@ import org.junit.Test;
|
||||
import org.onosproject.net.NetTestTools;
|
||||
|
||||
import com.google.common.testing.EqualsTester;
|
||||
import org.onosproject.net.PortNumber;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
@ -45,7 +46,7 @@ public class DefaultPortStatisticsTest {
|
||||
.setPacketsRxErrors(8)
|
||||
.setPacketsTxDropped(9)
|
||||
.setPacketsTxErrors(10)
|
||||
.setPort(80)
|
||||
.setPort(PortNumber.portNumber(80))
|
||||
.setDeviceId(NetTestTools.did("1"))
|
||||
.build();
|
||||
|
||||
@ -60,7 +61,7 @@ public class DefaultPortStatisticsTest {
|
||||
.setPacketsRxErrors(8)
|
||||
.setPacketsTxDropped(9)
|
||||
.setPacketsTxErrors(11)
|
||||
.setPort(80)
|
||||
.setPort(PortNumber.portNumber(80))
|
||||
.setDeviceId(NetTestTools.did("1"))
|
||||
.build();
|
||||
|
||||
@ -84,7 +85,7 @@ public class DefaultPortStatisticsTest {
|
||||
assertThat(stats1.packetsRxErrors(), is(8L));
|
||||
assertThat(stats1.packetsTxDropped(), is(9L));
|
||||
assertThat(stats1.packetsTxErrors(), is(10L));
|
||||
assertThat(stats1.port(), is(80));
|
||||
assertThat(stats1.portNumber().toLong(), is(80L));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -32,7 +32,7 @@ public final class PortStatisticsCodec extends AnnotatedCodec<PortStatistics> {
|
||||
checkNotNull(entry, "Port Statistics cannot be null");
|
||||
|
||||
final ObjectNode result = context.mapper().createObjectNode()
|
||||
.put("port", entry.port())
|
||||
.put("port", entry.portNumber().toLong())
|
||||
.put("packetsReceived", entry.packetsReceived())
|
||||
.put("packetsSent", entry.packetsSent())
|
||||
.put("bytesReceived", entry.bytesReceived())
|
||||
|
||||
@ -447,7 +447,7 @@ public class SimpleDeviceStore
|
||||
|
||||
if (prvStatsMap != null) {
|
||||
for (PortStatistics newStats : newStatsCollection) {
|
||||
PortNumber port = PortNumber.portNumber(newStats.port());
|
||||
PortNumber port = newStats.portNumber();
|
||||
PortStatistics prvStats = prvStatsMap.get(port);
|
||||
DefaultPortStatistics.Builder builder = DefaultPortStatistics.builder();
|
||||
PortStatistics deltaStats = builder.build();
|
||||
@ -459,7 +459,7 @@ public class SimpleDeviceStore
|
||||
}
|
||||
} else {
|
||||
for (PortStatistics newStats : newStatsCollection) {
|
||||
PortNumber port = PortNumber.portNumber(newStats.port());
|
||||
PortNumber port = newStats.portNumber();
|
||||
newStatsMap.put(port, newStats);
|
||||
}
|
||||
}
|
||||
@ -480,7 +480,7 @@ public class SimpleDeviceStore
|
||||
}
|
||||
DefaultPortStatistics.Builder builder = DefaultPortStatistics.builder();
|
||||
DefaultPortStatistics deltaStats = builder.setDeviceId(deviceId)
|
||||
.setPort(newStats.port())
|
||||
.setPort(newStats.portNumber())
|
||||
.setPacketsReceived(newStats.packetsReceived() - prvStats.packetsReceived())
|
||||
.setPacketsSent(newStats.packetsSent() - prvStats.packetsSent())
|
||||
.setBytesReceived(newStats.bytesReceived() - prvStats.bytesReceived())
|
||||
|
||||
@ -35,7 +35,6 @@ import org.slf4j.Logger;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.onosproject.net.PortNumber.portNumber;
|
||||
import static org.onosproject.net.device.DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED;
|
||||
import static org.onosproject.net.device.DeviceEvent.Type.DEVICE_REMOVED;
|
||||
import static org.onosproject.net.device.DeviceEvent.Type.PORT_STATS_UPDATED;
|
||||
@ -140,7 +139,7 @@ public class PortStatisticsManager implements PortStatisticsService {
|
||||
|
||||
// Updates the port stats for the specified port
|
||||
private void updatePortData(DeviceId deviceId, PortStatistics stats) {
|
||||
ConnectPoint cp = new ConnectPoint(deviceId, portNumber(stats.port()));
|
||||
ConnectPoint cp = new ConnectPoint(deviceId, stats.portNumber());
|
||||
DataPoint c = current.get(cp);
|
||||
|
||||
// Create a new data point and make it the current one
|
||||
|
||||
@ -140,7 +140,7 @@ public final class PortProtoTranslator {
|
||||
public static PortStatistics translate(PortStatisticsProto portStatistics) {
|
||||
// TODO implement adding missing fields
|
||||
return DefaultPortStatistics.builder()
|
||||
.setPort(portStatistics.getPort())
|
||||
.setPort(PortNumber.portNumber(portStatistics.getPort()))
|
||||
.setPacketsReceived(portStatistics.getPacketsReceived())
|
||||
.setPacketsSent(portStatistics.getPacketsSent())
|
||||
.build();
|
||||
@ -155,7 +155,7 @@ public final class PortProtoTranslator {
|
||||
public static PortStatisticsProto translate(PortStatistics portStatistics) {
|
||||
// TODO implement adding missing fields
|
||||
return PortStatisticsProto.newBuilder()
|
||||
.setPort(portStatistics.port())
|
||||
.setPort((int) portStatistics.portNumber().toLong())
|
||||
.setPacketsReceived(portStatistics.packetsReceived())
|
||||
.setPacketsSent(portStatistics.packetsSent())
|
||||
.build();
|
||||
|
||||
@ -534,7 +534,7 @@ public class ECDeviceStore
|
||||
|
||||
if (prvStatsMap != null) {
|
||||
for (PortStatistics newStats : newStatsCollection) {
|
||||
PortNumber port = PortNumber.portNumber(newStats.port());
|
||||
PortNumber port = newStats.portNumber();
|
||||
PortStatistics prvStats = prvStatsMap.get(port);
|
||||
DefaultPortStatistics.Builder builder = DefaultPortStatistics.builder();
|
||||
PortStatistics deltaStats = builder.build();
|
||||
@ -546,7 +546,7 @@ public class ECDeviceStore
|
||||
}
|
||||
} else {
|
||||
for (PortStatistics newStats : newStatsCollection) {
|
||||
PortNumber port = PortNumber.portNumber(newStats.port());
|
||||
PortNumber port = newStats.portNumber();
|
||||
newStatsMap.put(port, newStats);
|
||||
}
|
||||
}
|
||||
@ -576,7 +576,7 @@ public class ECDeviceStore
|
||||
}
|
||||
DefaultPortStatistics.Builder builder = DefaultPortStatistics.builder();
|
||||
DefaultPortStatistics deltaStats = builder.setDeviceId(deviceId)
|
||||
.setPort(newStats.port())
|
||||
.setPort(newStats.portNumber())
|
||||
.setPacketsReceived(newStats.packetsReceived() - prvStats.packetsReceived())
|
||||
.setPacketsSent(newStats.packetsSent() - prvStats.packetsSent())
|
||||
.setBytesReceived(newStats.bytesReceived() - prvStats.bytesReceived())
|
||||
|
||||
@ -901,7 +901,7 @@ public class GossipDeviceStore
|
||||
|
||||
if (prvStatsMap != null) {
|
||||
for (PortStatistics newStats : newStatsCollection) {
|
||||
PortNumber port = PortNumber.portNumber(newStats.port());
|
||||
PortNumber port = newStats.portNumber();
|
||||
PortStatistics prvStats = prvStatsMap.get(port);
|
||||
DefaultPortStatistics.Builder builder = DefaultPortStatistics.builder();
|
||||
PortStatistics deltaStats = builder.build();
|
||||
@ -913,7 +913,7 @@ public class GossipDeviceStore
|
||||
}
|
||||
} else {
|
||||
for (PortStatistics newStats : newStatsCollection) {
|
||||
PortNumber port = PortNumber.portNumber(newStats.port());
|
||||
PortNumber port = newStats.portNumber();
|
||||
newStatsMap.put(port, newStats);
|
||||
}
|
||||
}
|
||||
@ -943,7 +943,7 @@ public class GossipDeviceStore
|
||||
}
|
||||
DefaultPortStatistics.Builder builder = DefaultPortStatistics.builder();
|
||||
DefaultPortStatistics deltaStats = builder.setDeviceId(deviceId)
|
||||
.setPort(newStats.port())
|
||||
.setPort(newStats.portNumber())
|
||||
.setPacketsReceived(newStats.packetsReceived() - prvStats.packetsReceived())
|
||||
.setPacketsSent(newStats.packetsSent() - prvStats.packetsSent())
|
||||
.setBytesReceived(newStats.bytesReceived() - prvStats.bytesReceived())
|
||||
|
||||
@ -109,7 +109,7 @@ public class CiscoNxosPortStatistics extends AbstractHandlerBehaviour implements
|
||||
long packetsTxErrors = deviceInterface.get(ETH_OUTERR1).asLong();
|
||||
|
||||
DefaultPortStatistics.Builder builder = DefaultPortStatistics.builder();
|
||||
defaultPortStatistics = builder.setPort((int) portNumber.toLong())
|
||||
defaultPortStatistics = builder.setPort(portNumber)
|
||||
.setPacketsReceived(packetsReceived)
|
||||
.setPacketsSent(packetsSent)
|
||||
.setBytesReceived(bytesReceived)
|
||||
|
||||
@ -23,6 +23,7 @@ import org.dom4j.DocumentHelper;
|
||||
import org.dom4j.Element;
|
||||
import org.onosproject.net.DefaultAnnotations;
|
||||
import org.onosproject.net.DeviceId;
|
||||
import org.onosproject.net.PortNumber;
|
||||
import org.onosproject.net.device.DefaultPortDescription;
|
||||
import org.onosproject.net.device.DefaultPortStatistics;
|
||||
import org.onosproject.net.device.PortDescription;
|
||||
@ -261,7 +262,7 @@ public final class HuaweiXmlParser {
|
||||
.getText());
|
||||
|
||||
return builder.setDeviceId(id)
|
||||
.setPort(port)
|
||||
.setPort(PortNumber.portNumber(port))
|
||||
.setPacketsReceived(packetReceived)
|
||||
.setPacketsSent(packetSent)
|
||||
.setBytesReceived(bytesReceived)
|
||||
|
||||
@ -848,7 +848,7 @@ public class ServerDevicesDiscovery extends BasicServerDriver
|
||||
DefaultPortStatistics.Builder nicBuilder = DefaultPortStatistics.builder();
|
||||
|
||||
nicBuilder.setDeviceId(deviceId)
|
||||
.setPort((int) portNumber)
|
||||
.setPort(PortNumber.portNumber(portNumber))
|
||||
.setPacketsReceived(rxCount)
|
||||
.setPacketsSent(txCount)
|
||||
.setBytesReceived(rxBytes)
|
||||
|
||||
@ -109,7 +109,7 @@ public final class DefaultMonitoringStatistics implements MonitoringStatistics {
|
||||
public PortStatistics nicStatistics(int nicId) {
|
||||
checkArgument(nicId >= 0, "NIC ID must be a non-negative integer");
|
||||
for (PortStatistics ns : this.nicStatistics) {
|
||||
if (ns.port() == nicId) {
|
||||
if (ns.portNumber().toLong() == nicId) {
|
||||
return ns;
|
||||
}
|
||||
}
|
||||
|
||||
@ -750,7 +750,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
|
||||
}
|
||||
DefaultPortStatistics.Builder builder = DefaultPortStatistics.builder();
|
||||
DefaultPortStatistics stat = builder.setDeviceId(deviceId)
|
||||
.setPort(entry.getPortNo().getPortNumber())
|
||||
.setPort(PortNumber.portNumber(entry.getPortNo().getPortNumber()))
|
||||
.setPacketsReceived(entry.getRxPackets().getValue())
|
||||
.setPacketsSent(entry.getTxPackets().getValue())
|
||||
.setBytesReceived(entry.getRxBytes().getValue())
|
||||
|
||||
@ -131,7 +131,7 @@ public class PortViewMessageHandler extends UiMessageHandler {
|
||||
}
|
||||
|
||||
private void populateRow(TableModel.Row row, PortStatistics stat) {
|
||||
row.cell(ID, stat.port())
|
||||
row.cell(ID, stat.portNumber().toLong())
|
||||
.cell(PKT_RX, stat.packetsReceived())
|
||||
.cell(PKT_TX, stat.packetsSent())
|
||||
.cell(BYTES_RX, stat.bytesReceived())
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user