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

项目:onos    文件:DefaultOFSwitch.java   
private OFPortStatsEntry portStatsEntry(PortStatistics portStatistic) {
    OFPortStatsEntry ofPortStatsEntry = FACTORY.buildPortStatsEntry()
            .setPortNo(OFPort.of(portStatistic.port()))
            .setTxBytes(U64.of(portStatistic.bytesSent()))
            .setTxPackets(U64.of(portStatistic.packetsSent()))
            .setTxDropped(U64.of(portStatistic.packetsTxDropped()))
            .setTxErrors(U64.of(portStatistic.packetsTxErrors()))
            .setRxBytes(U64.of(portStatistic.bytesReceived()))
            .setRxPackets(U64.of(portStatistic.packetsReceived()))
            .setRxDropped(U64.of(portStatistic.packetsRxDropped()))
            .setRxErrors(U64.of(portStatistic.packetsRxErrors()))
            .setDurationSec(portStatistic.durationSec())
            .setDurationNsec(portStatistic.durationNano())
            .build();
    return ofPortStatsEntry;
}
项目: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   
private Collection<PortStatistics> buildPortStatistics(DeviceId deviceId,
                                                       List<OFPortStatsEntry> entries) {
    HashSet<PortStatistics> stats = Sets.newHashSet();

    for (OFPortStatsEntry entry : entries) {
        try {
            if (entry == null || entry.getPortNo() == null || 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.getVersion() == OFVersion.OF_10 ? 0 : entry.getDurationSec())
                    .setDurationNano(entry.getVersion() == OFVersion.OF_10 ? 0 : entry.getDurationNsec())
                    .build();

            stats.add(stat);
        } catch (Exception e) {
            LOG.warn("Unable to process port stats", e);
        }
    }

    return Collections.unmodifiableSet(stats);
}
项目: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);

    }
项目: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();
}
项目:spring-open    文件:OFPortStatsEntrySerializer.java   
@Override
public void serialize(OFPortStatsEntryMod portStatModEntry, JsonGenerator jGen,
        SerializerProvider sp) throws IOException, JsonGenerationException {

    IOFSwitch sw = portStatModEntry.getSwitch();
    OFPortStatsEntry portStatEntry = portStatModEntry.getPortStatsEntry();
    jGen.writeStartObject();
    jGen.writeNumberField("portNumber", portStatEntry.getPortNo().getPortNumber());
    jGen.writeStringField("portStatus", ((OFSwitchImplBase) sw).portEnabled(
            portStatEntry.getPortNo().getPortNumber()) ? "up" : "down");
    jGen.writeNumberField("receivePackets", portStatEntry.getRxPackets().getValue());
    jGen.writeNumberField("transmitPackets", portStatEntry.getTxPackets().getValue());
    jGen.writeNumberField("receiveBytes", portStatEntry.getRxBytes().getValue());
    jGen.writeNumberField("transmitBytes", portStatEntry.getTxBytes().getValue());
    jGen.writeNumberField("receiveDropped", portStatEntry.getRxDropped().getValue());
    jGen.writeNumberField("transmitDropped", portStatEntry.getTxDropped().getValue());
    jGen.writeNumberField("receiveErrors", portStatEntry.getRxErrors().getValue());
    jGen.writeNumberField("transmitErrors", portStatEntry.getTxErrors().getValue());
    jGen.writeNumberField("receiveFrameErrors", portStatEntry.getRxFrameErr()
            .getValue());
    jGen.writeNumberField("receiveOverrunErrors", portStatEntry.getRxOverErr()
            .getValue());
    jGen.writeNumberField("receiveCRCErrors", portStatEntry.getRxCrcErr().getValue());
    jGen.writeNumberField("collisions", portStatEntry.getCollisions().getValue());

    jGen.writeEndObject();
}
项目:athena    文件:OpenFlowDeviceProvider.java   
private void pushPortMetrics(Dpid dpid, List<OFPortStatsEntry> portStatsEntries) {
    DeviceId deviceId = DeviceId.deviceId(Dpid.uri(dpid));
    Collection<PortStatistics> stats = buildPortStatistics(deviceId, portStatsEntries);
    providerService.updatePortStatistics(deviceId, stats);
}
项目:spring-open    文件:OFPortStatsEntryMod.java   
public OFPortStatsEntryMod(OFPortStatsEntry portStatsEntry, IOFSwitch switch1) {
    this.portStatsEntry = portStatsEntry;
    this.sw = switch1;
}
项目:spring-open    文件:OFPortStatsEntryMod.java   
public OFPortStatsEntry getPortStatsEntry() {
    return portStatsEntry;
}
项目:onos    文件:OpenFlowDeviceProvider.java   
private void pushPortMetrics(Dpid dpid, List<OFPortStatsEntry> portStatsEntries) {
    DeviceId deviceId = DeviceId.deviceId(Dpid.uri(dpid));
    Collection<PortStatistics> stats =
            buildPortStatistics(deviceId, ImmutableList.copyOf(portStatsEntries));
    providerService.updatePortStatistics(deviceId, stats);
}
项目: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.
    }
}