Java 类org.projectfloodlight.openflow.protocol.OFPortStatsReply 实例源码

项目:athena    文件:OpenFlowControllerImpl.java   
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;
}
项目:athena    文件:OpenFlowDeviceProvider.java   
@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.
    }
}
项目:athena    文件:FeatureCollectorProvider.java   
@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);
        }
项目:fresco_floodlight    文件:StatsReplySerializer.java   
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();
}
项目:iTAP-controller    文件:StatsReplySerializer.java   
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();
}
项目:SDN-Multicast    文件:StatsReplySerializer.java   
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();
}
项目:arscheduler    文件:StatsReplySerializer.java   
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();
}
项目:floodlight1.2-delay    文件:StatsReplySerializer.java   
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();
}
项目:floodlight-hardware    文件:StatsReplySerializer.java   
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();
}
项目:ACAMPController    文件:StatsReplySerializer.java   
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();
}
项目:fast-failover-demo    文件:StatsReplySerializer.java   
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();
}
项目:ravikumaran201504    文件:OpenFlowControllerImpl.java   
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;
}
项目:ravikumaran201504    文件:OpenFlowDeviceProvider.java   
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);

    }
项目:ravikumaran201504    文件:OpenFlowDeviceProvider.java   
@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;
    }
}
项目:floodlightLB    文件:StatsReplySerializer.java   
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();
}
项目:DSC    文件:StatsReplySerializer.java   
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();
}
项目:floodlight    文件:StatsReplySerializer.java   
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();
}
项目:onos    文件:OpenFlowDeviceProvider.java   
@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.
    }
}
项目:ravikumaran201504    文件:OpenFlowDeviceProvider.java   
private void pushPortMetrics(Dpid dpid, OFPortStatsReply msg) {
    DeviceId deviceId = DeviceId.deviceId(dpid.uri(dpid));

    Collection<PortStatistics> stats = buildPortStatistics(deviceId, msg);

    providerService.updatePortStatistics(deviceId, stats);
}
项目:athena    文件:OpenFlowStatisticsListener.java   
/**
 * 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);