@Override public void aggregateStatsProcess(Dpid dpid, OFAggregateStatsReply reply) { //magic number if (reply.getXid() != 1126) { return; } AggregateStatisticsFeature asf = new AggregateStatisticsFeature(); UnitAggregateStatistics uas = new UnitAggregateStatistics(reply.getPacketCount().getValue(), reply.getByteCount().getValue(), reply.getFlowCount()); Date date = new java.sql.Timestamp(Calendar.getInstance().getTime().getTime()); uas.setDate(date); FeatureIndex fi = new FeatureIndex(); fi.setSwitchDatapathId(dpid.value()); asf.addFeatureData(fi, uas); providerService.aggregateStatsHandler(asf); }
public static void serializeAggregateReply(List<OFAggregateStatsReply> aggregateReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{ OFAggregateStatsReply aggregateReply = aggregateReplies.get(0); // There are only one aggregateReply from the switch jGen.writeObjectFieldStart("aggregate"); jGen.writeStringField("version", aggregateReply.getVersion().toString()); //return the enum name jGen.writeNumberField("flowCount", aggregateReply.getFlowCount()); jGen.writeNumberField("packetCount", aggregateReply.getPacketCount().getValue()); jGen.writeNumberField("byteCount", aggregateReply.getByteCount().getValue()); switch (aggregateReply.getVersion()) { case OF_10: jGen.writeNumberField("flags", OFStatsReplyFlagsSerializerVer10.toWireValue(aggregateReply.getFlags())); break; case OF_11: jGen.writeNumberField("flags", OFStatsReplyFlagsSerializerVer11.toWireValue(aggregateReply.getFlags())); break; case OF_12: jGen.writeNumberField("flags", OFStatsReplyFlagsSerializerVer12.toWireValue(aggregateReply.getFlags())); break; case OF_13: jGen.writeNumberField("flags", OFStatsReplyFlagsSerializerVer13.toWireValue(aggregateReply.getFlags())); break; case OF_14: jGen.writeNumberField("flags", OFStatsReplyFlagsSerializerVer14.toWireValue(aggregateReply.getFlags())); break; default: break; } jGen.writeEndObject(); // end match }
public static AggregateStatistics of(OFAggregateStatsReply statsReply) { return new AggregateStatistics(statsReply.getPacketCount(), statsReply.getByteCount(), statsReply.getFlowCount()); }
/** * Notify that the aggregate statistics event is arrived. * @param dpid the switch where the event occured. * @param reply the aggregate statistics. */ void aggregateStatsProcess(Dpid dpid, OFAggregateStatsReply reply);