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

项目:open-kilda    文件:FlowsResource.java   
private Map<String, Object> buildFlowStat(final OFFlowStatsEntry entry) {
    Map<String, Object> data = new HashMap<>();
    data.put("version", entry.getVersion());
    data.put("duration-nsec", entry.getDurationNsec());
    data.put("duration-sec", entry.getDurationSec());
    data.put("hard-timeout", entry.getHardTimeout());
    data.put("idle-timeout", entry.getIdleTimeout());
    data.put("priority", entry.getPriority());
    data.put("byte-count", entry.getByteCount().getValue());
    data.put("packer-count", entry.getPacketCount().getValue());
    data.put("flags", entry.getFlags());
    data.put("cookie", Long.toHexString(entry.getCookie().getValue()));
    data.put("table-id", entry.getTableId().getValue());
    data.put("match", buildFlowMatch(entry.getMatch()));
    data.put("instructions", buildFlowInstructions(entry.getInstructions()));
    return data;
}
项目:athena    文件:FeatureCollectorProvider.java   
public double[] getPairFlowInformation(Map<OFFlowStatsEntry, FlowEntry> table,
                                       Map<OFFlowStatsEntry, Boolean> pairFlowSet) {
    double[] vals = new double[4];

    //total flow
    vals[0] = table.size();

    //pair flow
    vals[1] = pairFlowSet.size();

    //single flow
    vals[2] = vals[0] - vals[1];

    //pairflowratio flow
    if (vals[1] == 0) {
        vals[3] = 0;
    } else {
        vals[3] = vals[1] / vals[0];
    }
    return vals;
}
项目:spring-open    文件:OFSwitchImplBase.java   
@SuppressWarnings("unused")
private void analyzeStatsReply(OFMessage reply) {
    log.info("recieved stats reply (xid = {} type: {}) from sw {} ",
            reply.getXid(), reply.getType(), getStringId());
    if (reply.getType() == OFType.STATS_REPLY) {
        OFStatsReply sr = (OFStatsReply) reply;
        if (sr.getStatsType() == OFStatsType.FLOW) {
            OFFlowStatsReply fsr = (OFFlowStatsReply) sr;
            log.info("received flow stats sw {} --> {}", getStringId(), fsr);
            // fsr.getEntries().get(0).getMatch().getMatchFields()
            for (OFFlowStatsEntry e : fsr.getEntries()) {
                for (MatchField<?> mf : e.getMatch().getMatchFields()) {
                    log.info("mf is exact: {} for {}: {}",
                            e.getMatch().isExact(mf),
                            mf.id,
                            e.getMatch().get(mf));
                }
            }

        }
    }
}
项目:spring-open    文件:ControllerTest.java   
private OFStatsReply getStatisticsReply(int transactionId,
        int count, boolean moreReplies, OFVersion version) {
    OFFactory factory = OFFactories.getFactory(version);

    List<OFFlowStatsEntry> statistics = new ArrayList<OFFlowStatsEntry>();
    for (int i = 0; i < count; ++i) {
        statistics.add(factory.buildFlowStatsEntry().build());
    }
    assertEquals(statistics.size(), count);

    org.projectfloodlight.openflow.protocol.OFStatsReply.Builder
            statsReplyBuilder = factory.buildFlowStatsReply()
                .setXid(transactionId)
                .setEntries(statistics);

    if (moreReplies) {
        statsReplyBuilder.setFlags(
                Collections.singleton(OFStatsReplyFlags.REPLY_MORE));
    }

    return statsReplyBuilder.build();
}
项目:onos    文件:FlowEntryBuilder.java   
private List<OFInstruction> getInstructions(OFFlowStatsEntry entry) {
    switch (entry.getVersion()) {
        case OF_10:
            return Lists.newArrayList(
                    OFFactoryVer13.INSTANCE.instructions().applyActions(entry.getActions()));
        case OF_11:
        case OF_12:
        case OF_13:
        case OF_14:
        case OF_15:
            return entry.getInstructions();
        default:
            log.warn("Unknown OF version {}", entry.getVersion());
    }
    return Lists.newLinkedList();
}
项目:open-kilda    文件:FlowsResource.java   
@Get("json")
@SuppressWarnings("unchecked")
public Map<String, Object> getFlows() {
    Map<String, Object> response = new HashMap<>();
    String switchId = (String) this.getRequestAttributes().get("switch_id");
    logger.debug("Get flows for switch: {}", switchId);
    ISwitchManager switchManager = (ISwitchManager) getContext().getAttributes()
            .get(ISwitchManager.class.getCanonicalName());

    try {
        OFFlowStatsReply replay = switchManager.dumpFlowTable(DatapathId.of(switchId));
        logger.debug("OF_STATS: {}", replay);

        if (replay != null) {
            for (OFFlowStatsEntry entry : replay.getEntries()) {
                String key = String.format("flow-0x%s",
                        Long.toHexString(entry.getCookie().getValue()).toUpperCase());
                response.put(key, buildFlowStat(entry));
            }
        }
    } catch (IllegalArgumentException exception) {
        String messageString = "No such switch";
        logger.error("{}: {}", messageString, switchId, exception);
        MessageError responseMessage = new MessageError(DEFAULT_CORRELATION_ID, System.currentTimeMillis(),
                ErrorType.PARAMETERS_INVALID.toString(), messageString, exception.getMessage());
        response.putAll(MAPPER.convertValue(responseMessage, Map.class));
    }
    return response;
}
项目:athena    文件:OpenFlowControllerImpl.java   
private synchronized Collection<OFFlowStatsEntry> publishFlowStats(Dpid dpid,
                                                                   OFFlowStatsReply reply) {
    //TODO: Get rid of synchronized
    fullFlowStats.putAll(dpid, reply.getEntries());
    if (!reply.getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) {
        return fullFlowStats.removeAll(dpid);
    }
    return null;
}
项目:athena    文件:FlowEntryBuilder.java   
public FlowEntryBuilder(DeviceId deviceId, OFFlowStatsEntry entry, DriverService driverService) {
    this.stat = entry;
    this.match = entry.getMatch();
    this.instructions = getInstructions(entry);
    this.deviceId = deviceId;
    this.removed = null;
    this.flowMod = null;
    this.type = FlowType.STAT;
    this.driverService = driverService;
}
项目:athena    文件:FlowEntryBuilder.java   
private List<OFInstruction> getInstructions(OFFlowStatsEntry entry) {
    switch (entry.getVersion()) {
        case OF_10:
            return Lists.newArrayList(
                    OFFactoryVer13.INSTANCE.instructions().applyActions(entry.getActions()));
        case OF_11:
        case OF_12:
        case OF_13:
            return entry.getInstructions();
        default:
            log.warn("Unknown OF version {}", entry.getVersion());
    }
    return Lists.newLinkedList();
}
项目:athena    文件:FeatureCollectorProvider.java   
public Map<OFFlowStatsEntry, FlowEntry> getApplicationInfoFromInternalFlowTable(
        Dpid dpid,
        List<OFFlowStatsEntry> statsEntries) {

    //private DeviceId deviceId = DeviceId.deviceId("of:0000000000000001");
    DeviceId deviceId = DeviceId.deviceId(dpid.uri(dpid));

    /**
     *TODO optimize mechanism for comparing between incoming and internal one.
     */
    Map<OFFlowStatsEntry, FlowEntry> flowEntiresWithFlowInformation = new HashMap<>();

    Iterable<FlowEntry> internalFlowEntries = flowRuleService.getFlowEntries(deviceId);

    for (int i = 0; i < statsEntries.size(); i++) {
        OFFlowStatsEntry entry = statsEntries.get(i);
        TrafficSelector inSelector =
                featureCollectorProviderUtil.buildSelector(entry.getMatch());
        for (FlowEntry flowEntry : internalFlowEntries) {
            if (flowEntry.selector().equals(inSelector)) {
                flowEntiresWithFlowInformation.put(entry, flowEntry);
                break;
            }

        }
    }
    return flowEntiresWithFlowInformation;
}
项目:ravikumaran201504    文件:OpenFlowControllerImpl.java   
private synchronized Collection<OFFlowStatsEntry> publishFlowStats(Dpid dpid,
                                                                   OFFlowStatsReply reply) {
    //TODO: Get rid of synchronized
    fullFlowStats.putAll(dpid, reply.getEntries());
    if (!reply.getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) {
        return fullFlowStats.removeAll(dpid);
    }
    return null;
}
项目:ravikumaran201504    文件:FlowEntryBuilder.java   
public FlowEntryBuilder(Dpid dpid, OFFlowStatsEntry entry, Type tableType) {
    this.stat = entry;
    this.match = entry.getMatch();
    this.instructions = getInstructions(entry);
    this.dpid = dpid;
    this.removed = null;
    this.flowMod = null;
    this.type = FlowType.STAT;
    this.tableType = tableType;
}
项目:ravikumaran201504    文件:FlowEntryBuilder.java   
private List<OFInstruction> getInstructions(OFFlowStatsEntry entry) {
    switch (entry.getVersion()) {
        case OF_10:
            return Lists.newArrayList(
                    OFFactoryVer13.INSTANCE.instructions().applyActions(entry.getActions()));
        case OF_11:
        case OF_12:
        case OF_13:
            return entry.getInstructions();
        default:
            log.warn("Unknown OF version {}", entry.getVersion());
    }
    return Lists.newLinkedList();
}
项目:floodlight    文件:failure_detection.java   
private void deleteflowentry(DatapathId src,OFFlowStatsEntry entry){
    OFFlowMod.Builder fmb = switchService.getSwitch(src).getOFFactory().buildFlowDelete();
    fmb.setMatch(entry.getMatch()) 
    .setActions(entry.getActions())
    .setIdleTimeout(entry.getIdleTimeout())
    .setHardTimeout(entry.getHardTimeout());
    switchService.getSwitch(src).write(fmb.build());
}
项目:floodlight    文件:Massive_failure_recovery.java   
/**
 * ͳ�Ʒ�������������ɾ��ԭʼ���������ɾ������Ϊ֮����·����ȼ����ߵ������
 * @param sw
 * @param values
 * @return
 */
protected long sumflows(DatapathId sw, List<OFFlowStatsReply> values){
    long sum=0;
    OFFlowStatsReply value=values.get(0);
    List<OFFlowStatsEntry> entries = value.getEntries();
    for(OFFlowStatsEntry entry: entries){
        long bc = entry.getByteCount().getValue();
        sum += bc;
        deleteflowentry(sw,entry);
    }
    return sum;
}
项目:floodlight    文件:Massive_failure_recovery.java   
/**
 * ɾ��ԭʼ������
 * @param src
 * @param entry
 */
private void deleteflowentry(DatapathId src,OFFlowStatsEntry entry){
    OFFlowMod.Builder fmb = switchService.getSwitch(src).getOFFactory().buildFlowDelete();
    fmb.setMatch(entry.getMatch())
    //.setActions(entry.getActions())
    .setActions(((OFInstructionApplyActions)entry.getInstructions().get(0)).getActions())
    .setIdleTimeout(entry.getIdleTimeout())
    .setHardTimeout(entry.getHardTimeout());
    switchService.getSwitch(src).write(fmb.build());
}
项目:openflowj-otn    文件:ActionUtils.java   
public static List<OFAction> getActions(OFFlowStatsEntry e) {
    if(e.getVersion() == OFVersion.OF_10) {
        return e.getActions();
    } else {
        for(OFInstruction i: e.getInstructions()) {
            if(i.getType() == OFInstructionType.APPLY_ACTIONS) {
                return ((OFInstructionApplyActions) i).getActions();
            }
        }
        return ImmutableList.of();
    }
}
项目:Engine    文件:FlowEntryBuilder.java   
public FlowEntryBuilder(DeviceId deviceId, OFFlowStatsEntry entry, DriverService driverService) {
    this.stat = entry;
    this.match = entry.getMatch();
    this.instructions = getInstructions(entry);
    this.deviceId = deviceId;
    this.removed = null;
    this.flowMod = null;
    this.type = FlowType.STAT;
    this.driverService = driverService;
}
项目:Engine    文件:FlowEntryBuilder.java   
private List<OFInstruction> getInstructions(OFFlowStatsEntry entry) {
    switch (entry.getVersion()) {
        case OF_10:
            return Lists.newArrayList(
                    OFFactoryVer13.INSTANCE.instructions().applyActions(entry.getActions()));
        case OF_11:
        case OF_12:
        case OF_13:
            return entry.getInstructions();
        default:
            log.warn("Unknown OF version {}", entry.getVersion());
    }
    return Lists.newLinkedList();
}
项目:spring-open    文件:FlowSynchronizerTest.java   
/**
 * Create single OFFlowStatisticsReply object which is actually obtained from switch.
 *
 * @param cookie Cookie value, which indicates ID of FlowEntry installed to switch.
 * @return Created object.
 */
private OFFlowStatsReply createReply(long cookie) {
    OFFlowStatsEntry entry = factory10.buildFlowStatsEntry()
            .setCookie(U64.of(cookie))
            .setPriority(1)
            .setMatch(factory10.buildMatch().build())
            .build();
    OFFlowStatsReply stat = factory10.buildFlowStatsReply()
            .setEntries(Collections.singletonList(entry)).build();

    return stat;
}
项目:onos    文件:OpenFlowControllerImpl.java   
private synchronized Collection<OFFlowStatsEntry> publishFlowStats(Dpid dpid,
                                                                   OFFlowStatsReply reply) {
    //TODO: Get rid of synchronized
    fullFlowStats.putAll(dpid, reply.getEntries());
    if (!reply.getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) {
        return fullFlowStats.removeAll(dpid);
    }
    return null;
}
项目:onos    文件:FlowEntryBuilder.java   
public FlowEntryBuilder(DeviceId deviceId, OFFlowStatsEntry entry, DriverHandler driverHandler) {
    this.stat = entry;
    this.match = entry.getMatch();
    this.instructions = getInstructions(entry);
    this.deviceId = deviceId;
    this.removed = null;
    this.flowMod = null;
    this.type = FlowType.STAT;
    this.driverHandler = driverHandler;
    this.afsc = null;
    this.lightWeightStat = null;
}
项目:loxigen-artifacts    文件:ActionUtils.java   
public static List<OFAction> getActions(OFFlowStatsEntry e) {
    if(e.getVersion() == OFVersion.OF_10) {
        return e.getActions();
    } else {
        for(OFInstruction i: e.getInstructions()) {
            if(i.getType() == OFInstructionType.APPLY_ACTIONS) {
                return ((OFInstructionApplyActions) i).getActions();
            }
        }
        return ImmutableList.of();
    }
}
项目:athena    文件:FeatureCollectorProvider.java   
public Map<OFFlowStatsEntry, Boolean> getPairFlowSet(Map<OFFlowStatsEntry, FlowEntry> table) {
    Map<OFFlowStatsEntry, Boolean> pairFlowSet = new HashMap<>();
    Map<OFFlowStatsEntry, int[]> pairFlowInfo = new HashMap<>();
    for (Map.Entry<OFFlowStatsEntry, FlowEntry> entry : table.entrySet()) {
        OFFlowStatsEntry e = entry.getKey();
        Match match = e.getMatch();
        //0 - src, 1 - dst, 2 - proto
        int[] vals = new int[3];
        vals[0] = 0;
        vals[1] = 0;
        vals[2] = 0;
        for (MatchField<?> field : match.getMatchFields()) {
            switch (field.id) {
                case IPV4_SRC:
                    vals[0] = match.get(MatchField.IPV4_SRC).getInt();
                    break;
                case IPV4_DST:
                    vals[1] = match.get(MatchField.IPV4_DST).getInt();
                    break;
                case IP_PROTO:
                    vals[2] = match.get(MatchField.IP_PROTO).getIpProtocolNumber();
                    break;
                default:
                    break;
            }
        }
        if (vals[0] == 0 || vals[1] == 0) {
            continue;
        }
        pairFlowInfo.put(e, vals);
    }

    //extract pairflow
    for (Map.Entry<OFFlowStatsEntry, int[]> entryCur : pairFlowInfo.entrySet()) {
        boolean pairflow = false;
        int[] valsCur = entryCur.getValue();

        for (Map.Entry<OFFlowStatsEntry, int[]> entryTar : pairFlowInfo.entrySet()) {
            int[] valsTar = entryTar.getValue();

            //src(cur) == dst(tar), src(cur) == dst(tar), proto ==
            if ((valsCur[0] == valsTar[1]) &&
                    (valsCur[1] == valsTar[0]) &&
                    (valsCur[2] == valsTar[2])
                    ) {
                pairflow = true;
                break;
            }
        }

        if (pairflow) {
            pairFlowSet.put(entryCur.getKey(), true);
        }
    }
    return pairFlowSet;
}
项目:fresco_floodlight    文件:StatsReplySerializer.java   
public static void serializeFlowReply(List<OFFlowStatsReply> flowReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
    /* start the array before each reply */
    jGen.writeFieldName("flows"); 
    jGen.writeStartArray();
    for (OFFlowStatsReply flowReply : flowReplies) { // for each flow stats reply
        List<OFFlowStatsEntry> entries = flowReply.getEntries();
        for (OFFlowStatsEntry entry : entries) { // for each flow
            jGen.writeStartObject();
            // list flow stats/info
            jGen.writeStringField("version", entry.getVersion().toString()); // return the enum name
            jGen.writeNumberField("cookie", entry.getCookie().getValue());
            jGen.writeStringField("tableId", entry.getTableId().toString());
            jGen.writeNumberField("packetCount", entry.getPacketCount().getValue());
            jGen.writeNumberField("byteCount", entry.getByteCount().getValue());
            jGen.writeNumberField("durationSeconds", entry.getDurationSec());
            jGen.writeNumberField("durationNSeconds", entry.getDurationNsec());
            jGen.writeNumberField("priority", entry.getPriority());
            jGen.writeNumberField("idleTimeoutSec", entry.getIdleTimeout());
            jGen.writeNumberField("hardTimeoutSec", entry.getHardTimeout());
            switch (entry.getVersion()) {
            case OF_10:
                // flags not supported
                break;
            case OF_11:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer11.toWireValue(entry.getFlags()));
                break;
            case OF_12:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer12.toWireValue(entry.getFlags()));
                break;
            case OF_13:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer13.toWireValue(entry.getFlags()));
                break;
            case OF_14:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer14.toWireValue(entry.getFlags()));
                break;
            default:
                logger.error("Could not decode OFVersion {}", entry.getVersion());
                break;
            }

            MatchSerializer.serializeMatch(jGen, entry.getMatch());

            // handle OF1.1+ instructions with actions within
            if (entry.getVersion() == OFVersion.OF_10) {
                jGen.writeObjectFieldStart("actions");
                OFActionListSerializer.serializeActions(jGen, entry.getActions());
                jGen.writeEndObject();
            } else {
                OFInstructionListSerializer.serializeInstructionList(jGen, entry.getInstructions());
            }

            jGen.writeEndObject();
        } // end for each OFFlowStatsReply entry */
    } // end for each OFStatsReply
    //jGen.writeEndObject();
    jGen.writeEndArray();
}
项目:iTAP-controller    文件:StatsReplySerializer.java   
public static void serializeFlowReply(List<OFFlowStatsReply> flowReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
    /* start the array before each reply */
    jGen.writeFieldName("flows"); 
    jGen.writeStartArray();
    for (OFFlowStatsReply flowReply : flowReplies) { // for each flow stats reply
        List<OFFlowStatsEntry> entries = flowReply.getEntries();
        for (OFFlowStatsEntry entry : entries) { // for each flow
            jGen.writeStartObject();
            // list flow stats/info
            jGen.writeStringField("version", entry.getVersion().toString()); // return the enum name
            jGen.writeNumberField("cookie", entry.getCookie().getValue());
            jGen.writeStringField("tableId", entry.getTableId().toString());
            jGen.writeNumberField("packetCount", entry.getPacketCount().getValue());
            jGen.writeNumberField("byteCount", entry.getByteCount().getValue());
            jGen.writeNumberField("durationSeconds", entry.getDurationSec());
            jGen.writeNumberField("priority", entry.getPriority());
            jGen.writeNumberField("idleTimeoutSec", entry.getIdleTimeout());
            jGen.writeNumberField("hardTimeoutSec", entry.getHardTimeout());
            switch (entry.getVersion()) {
            case OF_10:
                // flags not supported
                break;
            case OF_11:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer11.toWireValue(entry.getFlags()));
                break;
            case OF_12:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer12.toWireValue(entry.getFlags()));
                break;
            case OF_13:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer13.toWireValue(entry.getFlags()));
                break;
            case OF_14:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer14.toWireValue(entry.getFlags()));
                break;
            default:
                logger.error("Could not decode OFVersion {}", entry.getVersion());
                break;
            }

            MatchSerializer.serializeMatch(jGen, entry.getMatch());

            // handle OF1.1+ instructions with actions within
            if (entry.getVersion() == OFVersion.OF_10) {
                jGen.writeObjectFieldStart("actions");
                OFActionListSerializer.serializeActions(jGen, entry.getActions());
                jGen.writeEndObject();
            } else {
                OFInstructionListSerializer.serializeInstructionList(jGen, entry.getInstructions());
            }

            jGen.writeEndObject();
        } // end for each OFFlowStatsReply entry */
    } // end for each OFStatsReply
    //jGen.writeEndObject();
    jGen.writeEndArray();
}
项目:SDN-Multicast    文件:StatsReplySerializer.java   
public static void serializeFlowReply(List<OFFlowStatsReply> flowReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
    /* start the array before each reply */
    jGen.writeFieldName("flows"); 
    jGen.writeStartArray();
    for (OFFlowStatsReply flowReply : flowReplies) { // for each flow stats reply
        List<OFFlowStatsEntry> entries = flowReply.getEntries();
        for (OFFlowStatsEntry entry : entries) { // for each flow
            jGen.writeStartObject();
            // list flow stats/info
            jGen.writeStringField("version", entry.getVersion().toString()); // return the enum name
            jGen.writeNumberField("cookie", entry.getCookie().getValue());
            jGen.writeStringField("tableId", entry.getTableId().toString());
            jGen.writeNumberField("packetCount", entry.getPacketCount().getValue());
            jGen.writeNumberField("byteCount", entry.getByteCount().getValue());
            jGen.writeNumberField("durationSeconds", entry.getDurationSec());
            jGen.writeNumberField("durationNSeconds", entry.getDurationNsec());
            jGen.writeNumberField("priority", entry.getPriority());
            jGen.writeNumberField("idleTimeoutSec", entry.getIdleTimeout());
            jGen.writeNumberField("hardTimeoutSec", entry.getHardTimeout());
            switch (entry.getVersion()) {
            case OF_10:
                // flags not supported
                break;
            case OF_11:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer11.toWireValue(entry.getFlags()));
                break;
            case OF_12:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer12.toWireValue(entry.getFlags()));
                break;
            case OF_13:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer13.toWireValue(entry.getFlags()));
                break;
            case OF_14:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer14.toWireValue(entry.getFlags()));
                break;
            default:
                logger.error("Could not decode OFVersion {}", entry.getVersion());
                break;
            }

            MatchSerializer.serializeMatch(jGen, entry.getMatch());

            // handle OF1.1+ instructions with actions within
            if (entry.getVersion() == OFVersion.OF_10) {
                jGen.writeObjectFieldStart("actions");
                OFActionListSerializer.serializeActions(jGen, entry.getActions());
                jGen.writeEndObject();
            } else {
                OFInstructionListSerializer.serializeInstructionList(jGen, entry.getInstructions());
            }

            jGen.writeEndObject();
        } // end for each OFFlowStatsReply entry */
    } // end for each OFStatsReply
    //jGen.writeEndObject();
    jGen.writeEndArray();
}
项目:arscheduler    文件:StatsReplySerializer.java   
public static void serializeFlowReply(List<OFFlowStatsReply> flowReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
    /* start the array before each reply */
    jGen.writeFieldName("flows"); 
    jGen.writeStartArray();
    for (OFFlowStatsReply flowReply : flowReplies) { // for each flow stats reply
        List<OFFlowStatsEntry> entries = flowReply.getEntries();
        for (OFFlowStatsEntry entry : entries) { // for each flow
            jGen.writeStartObject();
            // list flow stats/info
            jGen.writeStringField("version", entry.getVersion().toString()); // return the enum name
            jGen.writeNumberField("cookie", entry.getCookie().getValue());
            jGen.writeStringField("tableId", entry.getTableId().toString());
            jGen.writeNumberField("packetCount", entry.getPacketCount().getValue());
            jGen.writeNumberField("byteCount", entry.getByteCount().getValue());
            jGen.writeNumberField("durationSeconds", entry.getDurationSec());
            jGen.writeNumberField("durationNSeconds", entry.getDurationNsec());
            jGen.writeNumberField("priority", entry.getPriority());
            jGen.writeNumberField("idleTimeoutSec", entry.getIdleTimeout());
            jGen.writeNumberField("hardTimeoutSec", entry.getHardTimeout());
            switch (entry.getVersion()) {
            case OF_10:
                // flags not supported
                break;
            case OF_11:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer11.toWireValue(entry.getFlags()));
                break;
            case OF_12:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer12.toWireValue(entry.getFlags()));
                break;
            case OF_13:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer13.toWireValue(entry.getFlags()));
                break;
            case OF_14:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer14.toWireValue(entry.getFlags()));
                break;
            default:
                logger.error("Could not decode OFVersion {}", entry.getVersion());
                break;
            }

            MatchSerializer.serializeMatch(jGen, entry.getMatch());

            // handle OF1.1+ instructions with actions within
            if (entry.getVersion() == OFVersion.OF_10) {
                jGen.writeObjectFieldStart("actions");
                OFActionListSerializer.serializeActions(jGen, entry.getActions());
                jGen.writeEndObject();
            } else {
                OFInstructionListSerializer.serializeInstructionList(jGen, entry.getInstructions());
            }

            jGen.writeEndObject();
        } // end for each OFFlowStatsReply entry */
    } // end for each OFStatsReply
    //jGen.writeEndObject();
    jGen.writeEndArray();
}
项目:floodlight1.2-delay    文件:StatsReplySerializer.java   
public static void serializeFlowReply(List<OFFlowStatsReply> flowReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
    /* start the array before each reply */
    jGen.writeFieldName("flows"); 
    jGen.writeStartArray();
    for (OFFlowStatsReply flowReply : flowReplies) { // for each flow stats reply
        List<OFFlowStatsEntry> entries = flowReply.getEntries();
        for (OFFlowStatsEntry entry : entries) { // for each flow
            jGen.writeStartObject();
            // list flow stats/info
            jGen.writeStringField("version", entry.getVersion().toString()); // return the enum name
            jGen.writeNumberField("cookie", entry.getCookie().getValue());
            jGen.writeStringField("tableId", entry.getTableId().toString());
            jGen.writeNumberField("packetCount", entry.getPacketCount().getValue());
            jGen.writeNumberField("byteCount", entry.getByteCount().getValue());
            jGen.writeNumberField("durationSeconds", entry.getDurationSec());
            jGen.writeNumberField("durationNSeconds", entry.getDurationNsec());
            jGen.writeNumberField("priority", entry.getPriority());
            jGen.writeNumberField("idleTimeoutSec", entry.getIdleTimeout());
            jGen.writeNumberField("hardTimeoutSec", entry.getHardTimeout());
            switch (entry.getVersion()) {
            case OF_10:
                // flags not supported
                break;
            case OF_11:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer11.toWireValue(entry.getFlags()));
                break;
            case OF_12:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer12.toWireValue(entry.getFlags()));
                break;
            case OF_13:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer13.toWireValue(entry.getFlags()));
                break;
            case OF_14:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer14.toWireValue(entry.getFlags()));
                break;
            default:
                logger.error("Could not decode OFVersion {}", entry.getVersion());
                break;
            }

            MatchSerializer.serializeMatch(jGen, entry.getMatch());

            // handle OF1.1+ instructions with actions within
            if (entry.getVersion() == OFVersion.OF_10) {
                jGen.writeObjectFieldStart("actions");
                OFActionListSerializer.serializeActions(jGen, entry.getActions());
                jGen.writeEndObject();
            } else {
                OFInstructionListSerializer.serializeInstructionList(jGen, entry.getInstructions());
            }

            jGen.writeEndObject();
        } // end for each OFFlowStatsReply entry */
    } // end for each OFStatsReply
    //jGen.writeEndObject();
    jGen.writeEndArray();
}
项目:floodlight-hardware    文件:StatsReplySerializer.java   
public static void serializeFlowReply(List<OFFlowStatsReply> flowReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
    /* start the array before each reply */
    jGen.writeFieldName("flows");
    jGen.writeStartArray();
    for (OFFlowStatsReply flowReply : flowReplies) { // for each flow stats reply
        List<OFFlowStatsEntry> entries = flowReply.getEntries();
        for (OFFlowStatsEntry entry : entries) { // for each flow
            jGen.writeStartObject();
            // list flow stats/info
            jGen.writeStringField("version", entry.getVersion().toString()); // return the enum name
            jGen.writeNumberField("cookie", entry.getCookie().getValue());
            jGen.writeStringField("tableId", entry.getTableId().toString());
            jGen.writeNumberField("packetCount", entry.getPacketCount().getValue());
            jGen.writeNumberField("byteCount", entry.getByteCount().getValue());
            jGen.writeNumberField("durationSeconds", entry.getDurationSec());
            jGen.writeNumberField("durationNSeconds", entry.getDurationNsec());
            jGen.writeNumberField("priority", entry.getPriority());
            jGen.writeNumberField("idleTimeoutSec", entry.getIdleTimeout());
            jGen.writeNumberField("hardTimeoutSec", entry.getHardTimeout());
            switch (entry.getVersion()) {
            case OF_10:
                // flags not supported
                break;
            case OF_11:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer11.toWireValue(entry.getFlags()));
                break;
            case OF_12:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer12.toWireValue(entry.getFlags()));
                break;
            case OF_13:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer13.toWireValue(entry.getFlags()));
                break;
            case OF_14:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer14.toWireValue(entry.getFlags()));
                break;
            default:
                logger.error("Could not decode OFVersion {}", entry.getVersion());
                break;
            }

            MatchSerializer.serializeMatch(jGen, entry.getMatch());

            // handle OF1.1+ instructions with actions within
            if (entry.getVersion() == OFVersion.OF_10) {
                jGen.writeObjectFieldStart("actions");
                OFActionListSerializer.serializeActions(jGen, entry.getActions());
                jGen.writeEndObject();
            } else {
                OFInstructionListSerializer.serializeInstructionList(jGen, entry.getInstructions());
            }

            jGen.writeEndObject();
        } // end for each OFFlowStatsReply entry */
    } // end for each OFStatsReply
    //jGen.writeEndObject();
    jGen.writeEndArray();
}
项目:ACAMPController    文件:StatsReplySerializer.java   
public static void serializeFlowReply(List<OFFlowStatsReply> flowReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
    /* start the array before each reply */
    jGen.writeFieldName("flows"); 
    jGen.writeStartArray();
    for (OFFlowStatsReply flowReply : flowReplies) { // for each flow stats reply
        List<OFFlowStatsEntry> entries = flowReply.getEntries();
        for (OFFlowStatsEntry entry : entries) { // for each flow
            jGen.writeStartObject();
            // list flow stats/info
            jGen.writeStringField("version", entry.getVersion().toString()); // return the enum name
            jGen.writeNumberField("cookie", entry.getCookie().getValue());
            jGen.writeStringField("tableId", entry.getTableId().toString());
            jGen.writeNumberField("packetCount", entry.getPacketCount().getValue());
            jGen.writeNumberField("byteCount", entry.getByteCount().getValue());
            jGen.writeNumberField("durationSeconds", entry.getDurationSec());
            jGen.writeNumberField("durationNSeconds", entry.getDurationNsec());
            jGen.writeNumberField("priority", entry.getPriority());
            jGen.writeNumberField("idleTimeoutSec", entry.getIdleTimeout());
            jGen.writeNumberField("hardTimeoutSec", entry.getHardTimeout());
            switch (entry.getVersion()) {
            case OF_10:
                // flags not supported
                break;
            case OF_11:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer11.toWireValue(entry.getFlags()));
                break;
            case OF_12:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer12.toWireValue(entry.getFlags()));
                break;
            case OF_13:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer13.toWireValue(entry.getFlags()));
                break;
            case OF_14:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer14.toWireValue(entry.getFlags()));
                break;
            default:
                logger.error("Could not decode OFVersion {}", entry.getVersion());
                break;
            }

            MatchSerializer.serializeMatch(jGen, entry.getMatch());

            // handle OF1.1+ instructions with actions within
            if (entry.getVersion() == OFVersion.OF_10) {
                jGen.writeObjectFieldStart("actions");
                OFActionListSerializer.serializeActions(jGen, entry.getActions());
                jGen.writeEndObject();
            } else {
                OFInstructionListSerializer.serializeInstructionList(jGen, entry.getInstructions());
            }

            jGen.writeEndObject();
        } // end for each OFFlowStatsReply entry */
    } // end for each OFStatsReply
    //jGen.writeEndObject();
    jGen.writeEndArray();
}
项目:fast-failover-demo    文件:StatsReplySerializer.java   
public static void serializeFlowReply(List<OFFlowStatsReply> flowReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
    /* start the array before each reply */
    jGen.writeFieldName("flows"); 
    jGen.writeStartArray();
    for (OFFlowStatsReply flowReply : flowReplies) { // for each flow stats reply
        List<OFFlowStatsEntry> entries = flowReply.getEntries();
        for (OFFlowStatsEntry entry : entries) { // for each flow
            jGen.writeStartObject();
            // list flow stats/info
            jGen.writeStringField("version", entry.getVersion().toString()); // return the enum name
            jGen.writeNumberField("cookie", entry.getCookie().getValue());
            jGen.writeStringField("tableId", entry.getTableId().toString());
            jGen.writeNumberField("packetCount", entry.getPacketCount().getValue());
            jGen.writeNumberField("byteCount", entry.getByteCount().getValue());
            jGen.writeNumberField("durationSeconds", entry.getDurationSec());
            jGen.writeNumberField("priority", entry.getPriority());
            jGen.writeNumberField("idleTimeoutSec", entry.getIdleTimeout());
            jGen.writeNumberField("hardTimeoutSec", entry.getHardTimeout());
            switch (entry.getVersion()) {
            case OF_10:
                // flags not supported
                break;
            case OF_11:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer11.toWireValue(entry.getFlags()));
                break;
            case OF_12:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer12.toWireValue(entry.getFlags()));
                break;
            case OF_13:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer13.toWireValue(entry.getFlags()));
                break;
            case OF_14:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer14.toWireValue(entry.getFlags()));
                break;
            default:
                logger.error("Could not decode OFVersion {}", entry.getVersion());
                break;
            }

            MatchSerializer.serializeMatch(jGen, entry.getMatch());

            // handle OF1.1+ instructions with actions within
            if (entry.getVersion() == OFVersion.OF_10) {
                jGen.writeObjectFieldStart("actions");
                OFActionListSerializer.serializeActions(jGen, entry.getActions());
                jGen.writeEndObject();
            } else {
                OFInstructionListSerializer.serializeInstructionList(jGen, entry.getInstructions());
            }

            jGen.writeEndObject();
        } // end for each OFFlowStatsReply entry */
    } // end for each OFStatsReply
    //jGen.writeEndObject();
    jGen.writeEndArray();
}
项目:floodlightLB    文件:StatsReplySerializer.java   
public static void serializeFlowReply(List<OFFlowStatsReply> flowReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
    /* start the array before each reply */
    jGen.writeFieldName("flows"); 
    jGen.writeStartArray();
    for (OFFlowStatsReply flowReply : flowReplies) { // for each flow stats reply
        List<OFFlowStatsEntry> entries = flowReply.getEntries();
        for (OFFlowStatsEntry entry : entries) { // for each flow
            jGen.writeStartObject();
            // list flow stats/info
            jGen.writeStringField("version", entry.getVersion().toString()); // return the enum name
            jGen.writeNumberField("cookie", entry.getCookie().getValue());
            jGen.writeStringField("tableId", entry.getTableId().toString());
            jGen.writeNumberField("packetCount", entry.getPacketCount().getValue());
            jGen.writeNumberField("byteCount", entry.getByteCount().getValue());
            jGen.writeNumberField("durationSeconds", entry.getDurationSec());
            jGen.writeNumberField("priority", entry.getPriority());
            jGen.writeNumberField("idleTimeoutSec", entry.getIdleTimeout());
            jGen.writeNumberField("hardTimeoutSec", entry.getHardTimeout());
            switch (entry.getVersion()) {
            case OF_10:
                // flags not supported
                break;
            case OF_11:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer11.toWireValue(entry.getFlags()));
                break;
            case OF_12:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer12.toWireValue(entry.getFlags()));
                break;
            case OF_13:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer13.toWireValue(entry.getFlags()));
                break;
            case OF_14:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer14.toWireValue(entry.getFlags()));
                break;
            default:
                logger.error("Could not decode OFVersion {}", entry.getVersion());
                break;
            }

            MatchSerializer.serializeMatch(jGen, entry.getMatch());

            // handle OF1.1+ instructions with actions within
            if (entry.getVersion() == OFVersion.OF_10) {
                jGen.writeObjectFieldStart("actions");
                OFActionListSerializer.serializeActions(jGen, entry.getActions());
                jGen.writeEndObject();
            } else {
                OFInstructionListSerializer.serializeInstructionList(jGen, entry.getInstructions());
            }

            jGen.writeEndObject();
        } // end for each OFFlowStatsReply entry */
    } // end for each OFStatsReply
    //jGen.writeEndObject();
    jGen.writeEndArray();
}
项目:DSC    文件:StatsReplySerializer.java   
public static void serializeFlowReply(List<OFFlowStatsReply> flowReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
    /* start the array before each reply */
    jGen.writeFieldName("flows"); 
    jGen.writeStartArray();
    for (OFFlowStatsReply flowReply : flowReplies) { // for each flow stats reply
        List<OFFlowStatsEntry> entries = flowReply.getEntries();
        for (OFFlowStatsEntry entry : entries) { // for each flow
            jGen.writeStartObject();
            // list flow stats/info
            jGen.writeStringField("version", entry.getVersion().toString()); // return the enum name
            jGen.writeNumberField("cookie", entry.getCookie().getValue());
            jGen.writeStringField("tableId", entry.getTableId().toString());
            jGen.writeNumberField("packetCount", entry.getPacketCount().getValue());
            jGen.writeNumberField("byteCount", entry.getByteCount().getValue());
            jGen.writeNumberField("durationSeconds", entry.getDurationSec());
            jGen.writeNumberField("priority", entry.getPriority());
            jGen.writeNumberField("idleTimeoutSec", entry.getIdleTimeout());
            jGen.writeNumberField("hardTimeoutSec", entry.getHardTimeout());
            switch (entry.getVersion()) {
            case OF_10:
                // flags not supported
                break;
            case OF_11:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer11.toWireValue(entry.getFlags()));
                break;
            case OF_12:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer12.toWireValue(entry.getFlags()));
                break;
            case OF_13:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer13.toWireValue(entry.getFlags()));
                break;
            case OF_14:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer14.toWireValue(entry.getFlags()));
                break;
            default:
                logger.error("Could not decode OFVersion {}", entry.getVersion());
                break;
            }

            MatchSerializer.serializeMatch(jGen, entry.getMatch());

            // handle OF1.1+ instructions with actions within
            if (entry.getVersion() == OFVersion.OF_10) {
                jGen.writeObjectFieldStart("actions");
                OFActionListSerializer.serializeActions(jGen, entry.getActions());
                jGen.writeEndObject();
            } else {
                OFInstructionListSerializer.serializeInstructionList(jGen, entry.getInstructions());
            }

            jGen.writeEndObject();
        } // end for each OFFlowStatsReply entry */
    } // end for each OFStatsReply
    //jGen.writeEndObject();
    jGen.writeEndArray();
}
项目:floodlight    文件:StatsReplySerializer.java   
public static void serializeFlowReply(List<OFFlowStatsReply> flowReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
    for (OFFlowStatsReply flowReply : flowReplies) { // for each flow stats reply
        //Dose the switch will reply multiple OFFlowStatsReply ?
        //Or we juse need to use the first item of the list.
        List<OFFlowStatsEntry> entries = flowReply.getEntries();
        jGen.writeFieldName("flows");
        jGen.writeStartArray();
        for (OFFlowStatsEntry entry : entries) { // for each flow
            jGen.writeStartObject();
            // list flow stats/info
            jGen.writeStringField("version", entry.getVersion().toString()); // return the enum name
            jGen.writeNumberField("cookie", entry.getCookie().getValue());
            jGen.writeStringField("tableId", entry.getTableId().toString());
            jGen.writeNumberField("packetCount", entry.getPacketCount().getValue());
            jGen.writeNumberField("byteCount", entry.getByteCount().getValue());
            jGen.writeNumberField("durationSeconds", entry.getDurationSec());
            jGen.writeNumberField("priority", entry.getPriority());
            jGen.writeNumberField("idleTimeoutSec", entry.getIdleTimeout());
            jGen.writeNumberField("hardTimeoutSec", entry.getHardTimeout());
            switch (entry.getVersion()) {
            case OF_10:
                // flags not supported
                break;
            case OF_11:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer11.toWireValue(entry.getFlags()));
                break;
            case OF_12:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer12.toWireValue(entry.getFlags()));
                break;
            case OF_13:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer13.toWireValue(entry.getFlags()));
                break;
            case OF_14:
                jGen.writeNumberField("flags", OFFlowModFlagsSerializerVer14.toWireValue(entry.getFlags()));
                break;
            default:
                logger.error("Could not decode OFVersion {}", entry.getVersion());
                break;
            }

            MatchSerializer.serializeMatch(jGen, entry.getMatch());

            // handle OF1.1+ instructions with actions within
            if (entry.getVersion() == OFVersion.OF_10) {
                jGen.writeObjectFieldStart("actions");
                OFActionListSerializer.serializeActions(jGen, entry.getActions());
                jGen.writeEndObject();
            } else {
                OFInstructionListSerializer.serializeInstructionList(jGen, entry.getInstructions());
            }

            jGen.writeEndObject();
        } // end for each OFFlowStatsReply entry
        jGen.writeEndArray();
    } // end for each OFStatsReply
}
项目:spring-open    文件:OFFlowStatsEntryMod.java   
public  OFFlowStatsEntryMod(OFFlowStatsEntry FlowStatsEntry, IOFSwitch sw1) {
    this.FlowStatsEntry = FlowStatsEntry;
    this.sw = sw1;
}
项目:spring-open    文件:OFFlowStatsEntryMod.java   
public OFFlowStatsEntry getFlowStatsEntry() {
    return this.FlowStatsEntry;
}
项目:spring-open    文件:SwitchResourceBase.java   
protected List<?> getSwitchStatisticsForTable(long switchId,
        OFStatsType statType, String tableType) {
    IFloodlightProviderService floodlightProvider =
            (IFloodlightProviderService) getContext().getAttributes().
            get(IFloodlightProviderService.class.getCanonicalName());
    IOFSwitch sw = floodlightProvider.getSwitches().get(switchId);
    Future<List<OFStatsReply>> future;
    List<OFStatsReply> values = null;
    //getting tableId from CPqD driver
    TableId tableId;
    if (sw != null) {
        if ((tableId = ((OFSwitchImplSpringOpenTTP) sw).getTableId(tableType)) == null) {
            log.error("Invalid tableType {} " + tableType);
            return null;
        }
        OFStatsRequest<?> req = null;
        if (statType == OFStatsType.FLOW) {
            log.debug("Switch Flow Stats req for table {} sent to switch {}",
                    tableType,sw.getStringId());
            OFMatchV3 match = sw.getFactory().buildMatchV3()
                    .setOxmList(OFOxmList.EMPTY).build();
            req = sw.getFactory()
                    .buildFlowStatsRequest()
                    .setMatch(match)
                    .setOutPort(OFPort.ANY)
                    .setTableId(tableId)
                    .setXid(sw.getNextTransactionId()).build();
            List<OFFlowStatsEntryMod> flowStats = new ArrayList<OFFlowStatsEntryMod>();
            try {
                future = sw.getStatistics(req);
                values = future.get(10, TimeUnit.SECONDS);
                for(OFStatsReply value : values){
                    for (OFFlowStatsEntry entry : ((OFFlowStatsReply)value).getEntries()) {
                        OFFlowStatsEntryMod entryMod = new OFFlowStatsEntryMod(entry, sw);
                        flowStats.add(entryMod);
                    }
                }
                log.debug("Switch flow Stats Entries for table {} from switch {} are {}",
                        tableType, sw.getStringId(), flowStats);
            } catch (Exception e) {
                log.error("Failure retrieving per table statistics from switch " + sw, e);
            }
            return flowStats;
        }
    }
    //should never get to this point
    log.error("Failure retrieving  {} table statistics from switch {}",tableType, sw);
    return null;
}
项目:onos    文件:FlowEntryBuilder.java   
public FlowEntryBuilder(DeviceId deviceId, OFFlowStatsEntry entry, DriverService driverService) {
    this(deviceId, entry, getDriver(deviceId, driverService));
}