本文整理汇总了Java中org.projectfloodlight.openflow.protocol.OFPortStatsReply类的典型用法代码示例。如果您正苦于以下问题:Java OFPortStatsReply类的具体用法?Java OFPortStatsReply怎么用?Java OFPortStatsReply使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OFPortStatsReply类属于org.projectfloodlight.openflow.protocol包,在下文中一共展示了OFPortStatsReply类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: publishPortStats
import org.projectfloodlight.openflow.protocol.OFPortStatsReply; //导入依赖的package包/类
private synchronized Collection<OFPortStatsEntry> publishPortStats(Dpid dpid,
OFPortStatsReply reply) {
fullPortStats.putAll(dpid, reply.getEntries());
if (!reply.getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) {
return fullPortStats.removeAll(dpid);
}
return null;
}
示例2: handleMessage
import org.projectfloodlight.openflow.protocol.OFPortStatsReply; //导入依赖的package包/类
@Override
public void handleMessage(Dpid dpid, OFMessage msg) {
if (isDisabled) {
return;
}
try {
switch (msg.getType()) {
case STATS_REPLY:
if (((OFStatsReply) msg).getStatsType() == OFStatsType.PORT) {
OFPortStatsReply portStatsReply = (OFPortStatsReply) msg;
List<OFPortStatsEntry> portStatsReplyList = portStatsReplies.get(dpid);
if (portStatsReplyList == null) {
portStatsReplyList = Lists.newCopyOnWriteArrayList();
}
portStatsReplyList.addAll(portStatsReply.getEntries());
portStatsReplies.put(dpid, portStatsReplyList);
if (!portStatsReply.getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) {
List<OFPortStatsEntry> statsEntries = portStatsReplies.get(dpid);
if (statsEntries != null) {
pushPortMetrics(dpid, statsEntries);
statsEntries.clear();
}
}
}
break;
case ERROR:
if (((OFErrorMsg) msg).getErrType() == OFErrorType.PORT_MOD_FAILED) {
LOG.error("port mod failed");
}
default:
break;
}
} catch (IllegalStateException e) {
// system is shutting down and the providerService is no longer
// valid. Messages cannot be processed.
}
}
示例3: portStatsProcess
import org.projectfloodlight.openflow.protocol.OFPortStatsReply; //导入依赖的package包/类
@Override
public void portStatsProcess(Dpid dpid, OFPortStatsReply reply) {
//magic number
if (reply.getXid() != 1128) {
return;
}
PortStatisticsFeature psf = new PortStatisticsFeature();
List<OFPortStatsEntry> opse = reply.getEntries();
Date date = new java.sql.Timestamp(Calendar.getInstance().getTime().getTime());
for (OFPortStatsEntry p : opse) {
UnitPortStatistics ups = new UnitPortStatistics(p.getRxPackets().getValue(),
p.getTxPackets().getValue(), p.getRxBytes().getValue(),
p.getTxBytes().getValue(), p.getRxDropped().getValue(),
p.getTxDropped().getValue(), p.getRxErrors().getValue(),
p.getTxErrors().getValue(), p.getRxFrameErr().getValue(),
p.getRxOverErr().getValue(), p.getRxCrcErr().getValue(),
p.getCollisions().getValue());
ups.setDate(date);
FeatureIndex fi = new FeatureIndex();
fi.setSwitchDatapathId((dpid.value()));
fi.setSwitchPortId(p.getPortNo().getPortNumber());
// extract rich feature -> store to UnitFlowstatistics
ups = (UnitPortStatistics) extractRichFeature(fi, ups, AthenaFeatureField.PORT_STATS);
psf.addFeatureData(fi, ups);
}
// to print LFT
// printPortStatsLFT(pStatisticsLF);
providerService.portStatsHandler(psf);
}
示例4: serializePortReply
import org.projectfloodlight.openflow.protocol.OFPortStatsReply; //导入依赖的package包/类
public static void serializePortReply(List<OFPortStatsReply> portReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
jGen.writeFieldName("port_reply");
jGen.writeStartArray();
for (OFPortStatsReply portReply : portReplies) {
jGen.writeStartObject();
jGen.writeStringField("version", portReply.getVersion().toString()); //return the enum name
jGen.writeFieldName("port");
jGen.writeStartArray();
for(OFPortStatsEntry entry : portReply.getEntries()) {
jGen.writeStartObject();
jGen.writeStringField("portNumber",entry.getPortNo().toString());
jGen.writeNumberField("receivePackets", entry.getRxPackets().getValue());
jGen.writeNumberField("transmitPackets", entry.getTxPackets().getValue());
jGen.writeNumberField("receiveBytes", entry.getRxBytes().getValue());
jGen.writeNumberField("transmitBytes", entry.getTxBytes().getValue());
jGen.writeNumberField("receiveDropped", entry.getRxDropped().getValue());
jGen.writeNumberField("transmitDropped", entry.getTxDropped().getValue());
jGen.writeNumberField("receiveErrors", entry.getRxErrors().getValue());
jGen.writeNumberField("transmitErrors", entry.getTxErrors().getValue());
jGen.writeNumberField("receiveFrameErrors", entry.getRxFrameErr().getValue());
jGen.writeNumberField("receiveOverrunErrors", entry.getRxOverErr().getValue());
jGen.writeNumberField("receiveCRCErrors", entry.getRxCrcErr().getValue());
jGen.writeNumberField("collisions", entry.getCollisions().getValue());
if (OFVersion.OF_13 == entry.getVersion()) {
jGen.writeNumberField("durationSec", entry.getDurationSec());
jGen.writeNumberField("durationNsec", entry.getDurationNsec());
}
jGen.writeEndObject();
}
jGen.writeEndArray();
jGen.writeEndObject();
}
jGen.writeEndArray();
}
示例5: serializePortReply
import org.projectfloodlight.openflow.protocol.OFPortStatsReply; //导入依赖的package包/类
public static void serializePortReply(List<OFPortStatsReply> portReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
OFPortStatsReply portReply = portReplies.get(0); // we will get only one PortReply and it will contains many OFPortStatsEntry ?
jGen.writeStringField("version", portReply.getVersion().toString()); //return the enum name
jGen.writeFieldName("port");
jGen.writeStartArray();
for(OFPortStatsEntry entry : portReply.getEntries()) {
jGen.writeStartObject();
jGen.writeStringField("portNumber",entry.getPortNo().toString());
jGen.writeNumberField("receivePackets", entry.getRxPackets().getValue());
jGen.writeNumberField("transmitPackets", entry.getTxPackets().getValue());
jGen.writeNumberField("receiveBytes", entry.getRxBytes().getValue());
jGen.writeNumberField("transmitBytes", entry.getTxBytes().getValue());
jGen.writeNumberField("receiveDropped", entry.getRxDropped().getValue());
jGen.writeNumberField("transmitDropped", entry.getTxDropped().getValue());
jGen.writeNumberField("receiveErrors", entry.getRxErrors().getValue());
jGen.writeNumberField("transmitErrors", entry.getTxErrors().getValue());
jGen.writeNumberField("receiveFrameErrors", entry.getRxFrameErr().getValue());
jGen.writeNumberField("receiveOverrunErrors", entry.getRxOverErr().getValue());
jGen.writeNumberField("receiveCRCErrors", entry.getRxCrcErr().getValue());
jGen.writeNumberField("collisions", entry.getCollisions().getValue());
if (OFVersion.OF_13 == entry.getVersion()) {
jGen.writeNumberField("durationSec", entry.getDurationSec());
jGen.writeNumberField("durationNsec", entry.getDurationNsec());
}
jGen.writeEndObject();
}
jGen.writeEndArray();
}
示例6: serializePortReply
import org.projectfloodlight.openflow.protocol.OFPortStatsReply; //导入依赖的package包/类
public static void serializePortReply(List<OFPortStatsReply> portReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
jGen.writeFieldName("port_reply");
jGen.writeStartArray();
for (OFPortStatsReply portReply : portReplies) {
jGen.writeStartObject();
jGen.writeStringField("version", portReply.getVersion().toString()); //return the enum name
jGen.writeFieldName("port");
jGen.writeStartArray();
for(OFPortStatsEntry entry : portReply.getEntries()) {
jGen.writeStartObject();
jGen.writeStringField("portNumber",entry.getPortNo().toString());
jGen.writeNumberField("receivePackets", entry.getRxPackets().getValue());
jGen.writeNumberField("transmitPackets", entry.getTxPackets().getValue());
jGen.writeNumberField("receiveBytes", entry.getRxBytes().getValue());
jGen.writeNumberField("transmitBytes", entry.getTxBytes().getValue());
jGen.writeNumberField("receiveDropped", entry.getRxDropped().getValue());
jGen.writeNumberField("transmitDropped", entry.getTxDropped().getValue());
jGen.writeNumberField("receiveErrors", entry.getRxErrors().getValue());
jGen.writeNumberField("transmitErrors", entry.getTxErrors().getValue());
jGen.writeNumberField("receiveFrameErrors", entry.getRxFrameErr().getValue());
jGen.writeNumberField("receiveOverrunErrors", entry.getRxOverErr().getValue());
jGen.writeNumberField("receiveCRCErrors", entry.getRxCrcErr().getValue());
jGen.writeNumberField("collisions", entry.getCollisions().getValue());
if (OFVersion.OF_13 == entry.getVersion()) {
jGen.writeNumberField("durationSec", entry.getDurationSec());
jGen.writeNumberField("durationNsec", entry.getDurationNsec());
}
jGen.writeEndObject();
}
jGen.writeEndArray();
jGen.writeEndObject();
}
jGen.writeEndArray();
}
示例7: publishPortStats
import org.projectfloodlight.openflow.protocol.OFPortStatsReply; //导入依赖的package包/类
private synchronized Collection<OFPortStatsEntry> publishPortStats(Dpid dpid,
OFPortStatsReply reply) {
fullPortStats.putAll(dpid, reply.getEntries());
if (!reply.getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) {
return fullPortStats.removeAll(dpid);
}
return null;
}
示例8: buildPortStatistics
import org.projectfloodlight.openflow.protocol.OFPortStatsReply; //导入依赖的package包/类
private Collection<PortStatistics> buildPortStatistics(DeviceId deviceId, OFPortStatsReply msg) {
HashSet<PortStatistics> stats = Sets.newHashSet();
for (OFPortStatsEntry entry: msg.getEntries()) {
if (entry.getPortNo().getPortNumber() < 0) {
continue;
}
DefaultPortStatistics.Builder builder = DefaultPortStatistics.builder();
DefaultPortStatistics stat = builder.setDeviceId(deviceId)
.setPort(entry.getPortNo().getPortNumber())
.setPacketsReceived(entry.getRxPackets().getValue())
.setPacketsSent(entry.getTxPackets().getValue())
.setBytesReceived(entry.getRxBytes().getValue())
.setBytesSent(entry.getTxBytes().getValue())
.setPacketsRxDropped(entry.getRxDropped().getValue())
.setPacketsTxDropped(entry.getTxDropped().getValue())
.setPacketsRxErrors(entry.getRxErrors().getValue())
.setPacketsTxErrors(entry.getTxErrors().getValue())
.setDurationSec(entry.getDurationSec())
.setDurationNano(entry.getDurationNsec())
.build();
stats.add(stat);
}
return Collections.unmodifiableSet(stats);
}
示例9: handleMessage
import org.projectfloodlight.openflow.protocol.OFPortStatsReply; //导入依赖的package包/类
@Override
public void handleMessage(Dpid dpid, OFMessage msg) {
switch (msg.getType()) {
case STATS_REPLY:
if (((OFStatsReply) msg).getStatsType() == OFStatsType.PORT) {
pushPortMetrics(dpid, (OFPortStatsReply) msg);
}
break;
default:
break;
}
}
示例10: handleMessage
import org.projectfloodlight.openflow.protocol.OFPortStatsReply; //导入依赖的package包/类
@Override
public void handleMessage(Dpid dpid, OFMessage msg) {
if (isDisabled) {
return;
}
try {
switch (msg.getType()) {
case STATS_REPLY:
if (((OFStatsReply) msg).getStatsType() == OFStatsType.PORT) {
OFPortStatsReply portStatsReply = (OFPortStatsReply) msg;
List<OFPortStatsEntry> portStatsReplyList = portStatsReplies.get(dpid);
if (portStatsReplyList == null) {
portStatsReplyList = Lists.newCopyOnWriteArrayList();
}
portStatsReplyList.addAll(portStatsReply.getEntries());
portStatsReplies.put(dpid, portStatsReplyList);
if (!portStatsReply.getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) {
List<OFPortStatsEntry> statsEntries = portStatsReplies.get(dpid);
if (statsEntries != null) {
pushPortMetrics(dpid, statsEntries);
statsEntries.clear();
}
}
} else if (((OFStatsReply) msg).getStatsType() == OFStatsType.EXPERIMENTER) {
OpenFlowSwitch sw = controller.getSwitch(dpid);
if (sw == null) {
LOG.error("Switch {} is not found", dpid);
break;
}
if (sw instanceof OpenFlowOpticalSwitch) {
// Optical switch uses experimenter stats message to update power
List<PortDescription> portDescs =
((OpenFlowOpticalSwitch) sw).processExpPortStats(msg);
if (!portDescs.isEmpty()) {
providerService.updatePorts(DeviceId.deviceId(Dpid.uri(dpid)), portDescs);
}
}
}
break;
case ERROR:
if (((OFErrorMsg) msg).getErrType() == OFErrorType.PORT_MOD_FAILED) {
LOG.error("port mod failed");
}
break;
default:
break;
}
} catch (IllegalStateException e) {
// system is shutting down and the providerService is no longer
// valid. Messages cannot be processed.
}
}
示例11: pushPortMetrics
import org.projectfloodlight.openflow.protocol.OFPortStatsReply; //导入依赖的package包/类
private void pushPortMetrics(Dpid dpid, OFPortStatsReply msg) {
DeviceId deviceId = DeviceId.deviceId(dpid.uri(dpid));
Collection<PortStatistics> stats = buildPortStatistics(deviceId, msg);
providerService.updatePortStatistics(deviceId, stats);
}
示例12: portStatsProcess
import org.projectfloodlight.openflow.protocol.OFPortStatsReply; //导入依赖的package包/类
/**
* Notify that the port statistics event is arrived.
* @param dpid the switch where the event occured.
* @param reply the port statistics.
*/
void portStatsProcess(Dpid dpid, OFPortStatsReply reply);