public void validateEvent(List<GroupEvent.Type> expectedEvents) {
   int i = 0;
   System.err.println("events :" + events);
   for (GroupEvent e : events) {
     assertEquals("unexpected event", expectedEvents.get(i), e.type());
     i++;
   }
   assertEquals("mispredicted number of events", expectedEvents.size(), events.size());
   events.clear();
 }
示例#2
0
    @Override
    public void event(GroupEvent event) {
      if (event.type() == GroupEvent.Type.GROUP_ADDED) {
        GroupKey key = event.subject().appCookie();

        NextObjective obj = pendingGroups.getIfPresent(key);
        if (obj != null) {
          flowObjectiveStore.putNextGroup(obj.id(), new OLTPipelineGroup(key));
          pass(obj);
          pendingGroups.invalidate(key);
        }
      }
    }
示例#3
0
    @Override
    public void notify(GroupEvent event) {
      final Group group = event.subject();
      GroupProvider groupProvider = getProvider(group.deviceId());
      GroupOperations groupOps = null;
      switch (event.type()) {
        case GROUP_ADD_REQUESTED:
          log.debug("GROUP_ADD_REQUESTED for Group {} on device {}", group.id(), group.deviceId());
          GroupOperation groupAddOp =
              GroupOperation.createAddGroupOperation(group.id(), group.type(), group.buckets());
          groupOps = new GroupOperations(Collections.singletonList(groupAddOp));
          groupProvider.performGroupOperation(group.deviceId(), groupOps);
          break;

        case GROUP_UPDATE_REQUESTED:
          log.debug(
              "GROUP_UPDATE_REQUESTED for Group {} on device {}", group.id(), group.deviceId());
          GroupOperation groupModifyOp =
              GroupOperation.createModifyGroupOperation(group.id(), group.type(), group.buckets());
          groupOps = new GroupOperations(Collections.singletonList(groupModifyOp));
          groupProvider.performGroupOperation(group.deviceId(), groupOps);
          break;

        case GROUP_REMOVE_REQUESTED:
          log.debug(
              "GROUP_REMOVE_REQUESTED for Group {} on device {}", group.id(), group.deviceId());
          GroupOperation groupDeleteOp =
              GroupOperation.createDeleteGroupOperation(group.id(), group.type());
          groupOps = new GroupOperations(Collections.singletonList(groupDeleteOp));
          groupProvider.performGroupOperation(group.deviceId(), groupOps);
          break;

        case GROUP_ADDED:
        case GROUP_UPDATED:
        case GROUP_REMOVED:
        case GROUP_ADD_FAILED:
        case GROUP_UPDATE_FAILED:
        case GROUP_REMOVE_FAILED:
          post(event);
          break;

        default:
          break;
      }
    }