Exemplo n.º 1
0
 // Test group remove operations
 private void testRemoveGroup(DeviceId deviceId) {
   GroupKey currKey = new DefaultGroupKey("group1RemoveBuckets".getBytes());
   Group existingGroup = groupService.getGroup(deviceId, currKey);
   groupService.removeGroup(deviceId, currKey, appId);
   List<GroupOperation> expectedGroupOps =
       Collections.singletonList(
           GroupOperation.createDeleteGroupOperation(existingGroup.id(), Group.Type.SELECT));
   if (deviceId.equals(DID)) {
     internalProvider.validate(deviceId, expectedGroupOps);
   } else {
     this.validate(deviceId, expectedGroupOps);
   }
   List<Group> groupEntries = Collections.emptyList();
   providerService.pushGroupMetrics(deviceId, groupEntries);
   internalListener.validateEvent(Collections.singletonList(GroupEvent.Type.GROUP_REMOVED));
 }
Exemplo n.º 2
0
  @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());
    }
  }