@Override public void next(NextObjective nextObjective) { if (nextObjective.type() != NextObjective.Type.BROADCAST) { log.error("OLT only supports broadcast groups."); fail(nextObjective, ObjectiveError.BADPARAMS); } if (nextObjective.next().size() != 1) { log.error("OLT only supports singleton broadcast groups."); fail(nextObjective, ObjectiveError.BADPARAMS); } TrafficTreatment treatment = nextObjective.next().stream().findFirst().get(); GroupBucket bucket = DefaultGroupBucket.createAllGroupBucket(treatment); GroupKey key = new DefaultGroupKey(appKryo.serialize(nextObjective.id())); GroupDescription groupDesc = new DefaultGroupDescription( deviceId, GroupDescription.Type.ALL, new GroupBuckets(Collections.singletonList(bucket)), key, null, nextObjective.appId()); pendingGroups.put(key, nextObjective); switch (nextObjective.op()) { case ADD: groupService.addGroup(groupDesc); break; case REMOVE: groupService.removeGroup(deviceId, key, nextObjective.appId()); break; case ADD_TO_EXISTING: case REMOVE_FROM_EXISTING: // TODO: handle addition to group when caller signals it. break; default: log.warn("Unknown next objective operation: {}", nextObjective.op()); } }
@Override public byte[] data() { return appKryo.serialize(key); }