@Test public void groupStatsEvent() { TestOpenFlowGroupProviderService testProviderService = (TestOpenFlowGroupProviderService) providerService; OFGroupStatsReply.Builder rep1 = OFFactories.getFactory(OFVersion.OF_13).buildGroupStatsReply(); rep1.setXid(1); controller.processPacket(dpid1, rep1.build()); OFGroupDescStatsReply.Builder rep2 = OFFactories.getFactory(OFVersion.OF_13).buildGroupDescStatsReply(); assertNull("group entries is not set yet", testProviderService.getGroupEntries()); rep2.setXid(2); controller.processPacket(dpid1, rep2.build()); assertNotNull("group entries should be set", testProviderService.getGroupEntries()); }
/*** * Serializes Group Desc Reply * @author Naveen * @param groupDescReplies * @param jGen * @throws IOException * @throws JsonProcessingException */ public static void serializeGroupDescReply(List<OFGroupDescStatsReply> groupDescReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{ OFGroupDescStatsReply groupDescReply = groupDescReplies.get(0); jGen.writeStringField("version", groupDescReply.getVersion().toString()); //return the enum name jGen.writeFieldName("groupDesc"); jGen.writeStartArray(); for(OFGroupDescStatsEntry entry : groupDescReply.getEntries()) { jGen.writeStartObject(); jGen.writeStringField("groupType",entry.getGroupType().toString()); jGen.writeStringField("groupNumber",entry.getGroup().toString()); jGen.writeFieldName("buckets"); jGen.writeStartArray(); for(OFBucket buckets : entry.getBuckets()) { jGen.writeStartObject(); jGen.writeNumberField("weight", buckets.getWeight()); jGen.writeNumberField("watchPortNumber", buckets.getWatchPort().getPortNumber()); jGen.writeStringField("watchGroup", buckets.getWatchGroup().toString()); OFActionListSerializer.serializeActions(jGen, buckets.getActions()); jGen.writeEndObject(); }//End of for loop - buckets jGen.writeEndArray();//end of buckets jGen.writeEndObject();//end of group Desc iteration }//End of for loop - GroupDescStats jGen.writeEndArray();//end of group Desc }
private synchronized Collection<OFGroupDescStatsEntry> publishGroupDescStats(Dpid dpid, OFGroupDescStatsReply reply) { //TODO: Get rid of synchronized fullGroupDescStats.putAll(dpid, reply.getEntries()); if (!reply.getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) { return fullGroupDescStats.removeAll(dpid); } return null; }
private void processStatsReply(OFStatsReply sr) { switch (sr.getStatsType()) { case AGGREGATE: break; case DESC: break; case EXPERIMENTER: break; case FLOW: break; case GROUP_DESC: processGroupDesc((OFGroupDescStatsReply) sr); break; case GROUP_FEATURES: processGroupFeatures((OFGroupFeaturesStatsReply) sr); break; case METER_CONFIG: break; case METER_FEATURES: break; case PORT_DESC: break; case TABLE_FEATURES: break; default: break; } }
private void processGroupDesc(OFGroupDescStatsReply gdsr) { log.info("Sw: {} Group Desc {} in driverState {} ", getStringId(), gdsr, driverState); if (driverState == DriverState.AUDIT_GROUPS) { auditBucketToGroupIds = new ConcurrentHashMap<List<BucketInfo>, List<Integer>>(); for (OFGroupDescStatsEntry entry : gdsr.getEntries()) { int groupId = entry.getGroup().getGroupNumber(); OFGroupType groupType = entry.getGroupType(); List<OFBucket> buckets = entry.getBuckets(); List<BucketInfo> driverBuckets = new ArrayList<BucketInfo>(); for (OFBucket bucket : buckets) { driverBuckets.add(getDriverBucketFromOFBucket(bucket)); } Collections.sort(driverBuckets); List<Integer> groupIds = auditBucketToGroupIds.get(driverBuckets); if (groupIds == null) groupIds = new ArrayList<Integer>(); groupIds.add(groupId); auditBucketToGroupIds.put(driverBuckets, groupIds); ecmpGroups.put(groupId, new EcmpInfo(groupId, groupType, driverBuckets)); } log.debug("processGroupDesc: Groups that are present in " + "switch {} are {} ", getStringId(), ecmpGroups); } else { // TODO -- actually do verification } try { nextDriverState(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
private void processGroupDesc(OFGroupDescStatsReply gdsr) { log.info("Sw: {} Group Desc {}", getStringId(), gdsr); }