org.onosproject.net.group.Group Java Examples

The following examples show how to use org.onosproject.net.group.Group. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GroupManagerTest.java    From onos with Apache License 2.0 6 votes vote down vote up
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));
}
 
Example #2
Source File: TroubleshootManagerTest.java    From onos with Apache License 2.0 6 votes vote down vote up
@Override
public Iterable<Group> getGroups(DeviceId deviceId) {
    if (deviceId.equals(GROUP_FLOW_DEVICE)) {
        return ImmutableList.of(GROUP);
    } else if (deviceId.equals(TOPO_GROUP_FLOW_DEVICE)) {
        return ImmutableList.of(TOPO_GROUP);
    } else if (deviceId.equals(DUAL_LINK_1) || deviceId.equals(DUAL_LINK_2)) {
        return ImmutableList.of(DUAL_LINK_GROUP);
    } else if (deviceId.equals(MULTICAST_GROUP_FLOW_DEVICE)) {
        return ImmutableList.of(MULTICAST_GROUP);
    } else if (deviceId.equals(NO_BUCKET_DEVICE)) {
        return ImmutableList.of(NO_BUCKET_GROUP);
    } else if (deviceId.equals(DUAL_HOME_DEVICE_1)) {
        return ImmutableList.of(DUAL_HOME_GROUP);
    } else if (deviceId.equals(ACTION_ORDER_DEVICE)) {
        return ImmutableList.of(ACTION_ORDER_GROUP);
    }
    return ImmutableList.of();
}
 
Example #3
Source File: SimpleVirtualGroupStore.java    From onos with Apache License 2.0 6 votes vote down vote up
@Override
public void deleteGroupDescription(NetworkId networkId, DeviceId deviceId,
                                   GroupKey appCookie) {
    // Check if a group is existing with the provided key
    StoredGroupEntry existing = null;
    if (groupEntriesByKey.get(networkId) != null &&
            groupEntriesByKey.get(networkId).get(deviceId) != null) {
        existing = groupEntriesByKey.get(networkId).get(deviceId).get(appCookie);
    }

    if (existing == null) {
        return;
    }

    synchronized (existing) {
        existing.setState(Group.GroupState.PENDING_DELETE);
    }
    notifyDelegate(networkId,
                   new GroupEvent(GroupEvent.Type.GROUP_REMOVE_REQUESTED, existing));
}
 
Example #4
Source File: P4RuntimeReplicationGroupProgrammable.java    From onos with Apache License 2.0 6 votes vote down vote up
private void processGroupOp(Group pdGroup, GroupOperation.Type opType) {
    final PiPreEntry preEntry;
    try {
        preEntry = translator.translate(pdGroup, pipeconf);
    } catch (PiTranslationException e) {
        log.warn("Unable to translate replication group, aborting {} operation: {} [{}]",
                 opType, e.getMessage(), pdGroup);
        return;
    }
    final PiPreEntryHandle handle = (PiPreEntryHandle) preEntry.handle(deviceId);
    final PiPreEntry entryOnDevice = mirror.get(handle) == null
            ? null : mirror.get(handle).entry();
    final Lock lock = STRIPED_LOCKS.get(handle);
    lock.lock();
    try {
        processPreEntry(handle, preEntry,
                        entryOnDevice, pdGroup, opType);
    } finally {
        lock.unlock();
    }
}
 
Example #5
Source File: DistributedGroupStore.java    From onos with Apache License 2.0 6 votes vote down vote up
private void garbageCollect(DeviceId deviceId,
                            Set<Group> southboundGroupEntries,
                            Set<StoredGroupEntry> storedGroupEntries) {
    if (!garbageCollect) {
        return;
    }

    NodeId master;
    Iterator<StoredGroupEntry> it = storedGroupEntries.iterator();
    while (it.hasNext()) {
        // Mastership change can occur during this iteration
        master = mastershipService.getMasterFor(deviceId);
        if (!Objects.equals(local, master)) {
            log.warn("Tried to run garbage collector while the node was not the master");
            return;
        }
        StoredGroupEntry group = it.next();
        if (group.state() != GroupState.PENDING_DELETE && checkGroupRefCount(group)) {
            log.debug("Garbage collecting group {} on {}", group, deviceId);
            deleteGroupDescription(deviceId, group.appCookie());
            southboundGroupEntries.remove(group);
            it.remove();
        }
    }
}
 
Example #6
Source File: OpenFlowGroupProvider.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Builds a list of failover Groups whose primary live bucket failed over
 * (i.e. bucket in use has changed).
 *
 * @param dpid    DPID of switch whose port's status changed
 * @param status  new status of port
 * @return        list of groups whose primary live bucket failed over
 */
private List<Group> checkFailoverGroups(Dpid dpid, OFPortStatus status) {
    List<Group> groupList = new ArrayList<>();
    OFPortDesc desc = status.getDesc();
    PortNumber portNumber = PortNumber.portNumber(desc.getPortNo().getPortNumber());
    DeviceId id = DeviceId.deviceId(Dpid.uri(dpid));
    if (desc.isEnabled()) {
        return groupList;
    }
    Iterator<Group> iterator = groupService.getGroups(id).iterator();
    while (iterator.hasNext()) {
        Group group = iterator.next();
        if (group.type() == GroupDescription.Type.FAILOVER &&
                checkFailoverGroup(group, id, portNumber)) {
            groupList.add(group);
        }
    }
return groupList;
}
 
Example #7
Source File: DistributedGroupStore.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Removes the group entry from store.
 *
 * @param group group entry
 */
@Override
public void removeGroupEntry(Group group) {
    StoredGroupEntry existing = getStoredGroupEntry(group.deviceId(),
                                                    group.id());

    if (existing != null) {
        log.debug("removeGroupEntry: removing group entry {} in device {}",
                  group.id(),
                  group.deviceId());
        //Removal from groupid based map will happen in the
        //map update listener
        getGroupStoreKeyMap().remove(new GroupStoreKeyMapKey(existing.deviceId(),
                                                             existing.appCookie()));
        notifyDelegate(new GroupEvent(Type.GROUP_REMOVED, existing));
    } else {
        log.warn("removeGroupEntry for {} in device{} is "
                         + "not existing in our maps",
                 group.id(),
                 group.deviceId());
    }
}
 
Example #8
Source File: DistributedGroupStore.java    From onos with Apache License 2.0 6 votes vote down vote up
private int getFreeGroupIdValue(DeviceId deviceId) {
    int freeId = groupIdGen.incrementAndGet();

    while (true) {
        Group existing = getGroup(deviceId, new GroupId(freeId));
        if (existing == null) {
            existing = (
                    extraneousGroupEntriesById.get(deviceId) != null) ?
                    extraneousGroupEntriesById.get(deviceId).
                            get(new GroupId(freeId)) :
                    null;
        }
        if (existing != null) {
            freeId = groupIdGen.incrementAndGet();
        } else {
            break;
        }
    }
    log.debug("getFreeGroupIdValue: Next Free ID is {}", freeId);
    return freeId;
}
 
Example #9
Source File: SimpleGroupStoreTest.java    From onos with Apache License 2.0 6 votes vote down vote up
private void testRemoveBuckets(GroupKey currKey, GroupKey removeKey) {
    Group existingGroup = simpleGroupStore.getGroup(D1, currKey);
    List<GroupBucket> buckets = new ArrayList<>();
    buckets.addAll(existingGroup.buckets().buckets());

    List<GroupBucket> toRemoveBuckets = new ArrayList<>();

    // There should be 4 buckets in the current group
    toRemoveBuckets.add(buckets.remove(0));
    toRemoveBuckets.add(buckets.remove(1));
    GroupBuckets toRemoveGroupBuckets = new GroupBuckets(toRemoveBuckets);

    GroupBuckets remainingGroupBuckets = new GroupBuckets(buckets);
    InternalGroupStoreDelegate removeGroupDescDelegate =
            new InternalGroupStoreDelegate(removeKey,
                                           remainingGroupBuckets,
                                           GroupEvent.Type.GROUP_UPDATE_REQUESTED);
    simpleGroupStore.setDelegate(removeGroupDescDelegate);
    simpleGroupStore.updateGroupDescription(D1,
                                            currKey,
                                            UpdateType.REMOVE,
                                            toRemoveGroupBuckets,
                                            removeKey);
    simpleGroupStore.unsetDelegate(removeGroupDescDelegate);
}
 
Example #10
Source File: P4RuntimeActionGroupProgrammable.java    From onos with Apache License 2.0 6 votes vote down vote up
@Override
public void performGroupOperation(DeviceId deviceId,
                                  GroupOperations groupOps) {
    if (!setupBehaviour("performGroupOperation()")) {
        return;
    }

    groupOps.operations().forEach(op -> {
        // ONOS-7785 We need the group app cookie (which includes
        // the action profile ID) but this is not part of the
        // GroupDescription.
        Group groupOnStore = groupStore.getGroup(deviceId, op.groupId());
        if (groupOnStore == null) {
            log.warn("Unable to find group {} in store, aborting {} operation [{}]",
                     op.groupId(), op.opType(), op);
            return;
        }
        GroupDescription groupDesc = new DefaultGroupDescription(
                deviceId, groupOnStore.type(), groupOnStore.buckets(), groupOnStore.appCookie(),
                groupOnStore.id().id(), groupOnStore.appId());
        DefaultGroup groupToApply = new DefaultGroup(op.groupId(), groupDesc);
        processPdGroup(groupToApply, op.opType());
    });
}
 
Example #11
Source File: SimpleVirtualGroupStore.java    From onos with Apache License 2.0 6 votes vote down vote up
@Override
public void storeGroupDescription(NetworkId networkId, GroupDescription groupDesc) {
    // Check if a group is existing with the same key
    if (getGroup(networkId, groupDesc.deviceId(), groupDesc.appCookie()) != null) {
        return;
    }

    if (deviceAuditStatus.get(networkId) == null ||
            deviceAuditStatus.get(networkId).get(groupDesc.deviceId()) == null) {
        // Device group audit has not completed yet
        // Add this group description to pending group key table
        // Create a group entry object with Dummy Group ID
        StoredGroupEntry group = new DefaultGroup(dummyGroupId, groupDesc);
        group.setState(Group.GroupState.WAITING_AUDIT_COMPLETE);
        ConcurrentMap<GroupKey, StoredGroupEntry> pendingKeyTable =
                getPendingGroupKeyTable(networkId, groupDesc.deviceId());
        pendingKeyTable.put(groupDesc.appCookie(), group);
        return;
    }

    storeGroupDescriptionInternal(networkId, groupDesc);
}
 
Example #12
Source File: DistributedGroupStore.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Updates the stats of an existing group entry.
 *
 * @param group the new stats
 * @param existing the existing group
 */
private void updateGroupEntryStatsInternal(Group group, StoredGroupEntry existing) {
    for (GroupBucket bucket : group.buckets().buckets()) {
        Optional<GroupBucket> matchingBucket =
                existing.buckets().buckets()
                        .stream()
                        .filter((existingBucket) -> (existingBucket.equals(bucket)))
                        .findFirst();
        if (matchingBucket.isPresent()) {
            ((StoredGroupBucketEntry) matchingBucket.
                    get()).setPackets(bucket.packets());
            ((StoredGroupBucketEntry) matchingBucket.
                    get()).setBytes(bucket.bytes());
        } else {
            log.warn("updateGroupEntryStatsInternal: No matching bucket {}" +
                    " to update stats", bucket);
        }
    }
    existing.setLife(group.life());
    existing.setPackets(group.packets());
    existing.setBytes(group.bytes());
    existing.setReferenceCount(group.referenceCount());
    existing.setFailedRetryCount(0);
}
 
Example #13
Source File: MainComponent.java    From ngsdn-tutorial with Apache License 2.0 6 votes vote down vote up
/**
 * Triggers clean up of flows and groups from this app, returns false if no
 * flows or groups were found, true otherwise.
 *
 * @return false if no flows or groups were found, true otherwise
 */
private boolean cleanUp() {
    Collection<FlowRule> flows = Lists.newArrayList(
            flowRuleService.getFlowEntriesById(appId).iterator());

    Collection<Group> groups = Lists.newArrayList();
    for (Device device : deviceService.getAvailableDevices()) {
        groupService.getGroups(device.id(), appId).forEach(groups::add);
    }

    if (flows.isEmpty() && groups.isEmpty()) {
        return false;
    }

    flows.forEach(flowRuleService::removeFlowRules);
    if (!groups.isEmpty()) {
        // Wait for flows to be removed in case those depend on groups.
        sleep(1000);
        groups.forEach(g -> groupService.removeGroup(
                g.deviceId(), g.appCookie(), g.appId()));
    }

    return true;
}
 
Example #14
Source File: GroupsResourceTest.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Populates some groups used as testing data.
 */
private void setupMockGroups() {
    final Set<Group> groups1 = new HashSet<>();
    groups1.add(group1);
    groups1.add(group2);

    final Set<Group> groups2 = new HashSet<>();
    groups2.add(group3);
    groups2.add(group4);

    groups.put(deviceId1, groups1);
    groups.put(deviceId2, groups2);

    expect(mockGroupService.getGroups(deviceId1))
            .andReturn(groups.get(deviceId1)).anyTimes();
    expect(mockGroupService.getGroups(deviceId2))
            .andReturn(groups.get(deviceId2)).anyTimes();
}
 
Example #15
Source File: DistributedGroupStoreTest.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Tests extraneous group operations.
 */
@Test
public void testExtraneousOperations() {
    ArrayList<Group> extraneous;
    groupStore.deviceInitialAuditCompleted(deviceId1, true);

    groupStore.storeGroupDescription(groupDescription1);
    Group group1 = groupStore.getGroup(deviceId1, groupId1);

    extraneous = Lists.newArrayList(groupStore.getExtraneousGroups(deviceId1));
    assertThat(extraneous, hasSize(0));

    groupStore.addOrUpdateExtraneousGroupEntry(group1);
    extraneous = Lists.newArrayList(groupStore.getExtraneousGroups(deviceId1));
    assertThat(extraneous, hasSize(1));

    groupStore.removeExtraneousGroupEntry(group1);
    extraneous = Lists.newArrayList(groupStore.getExtraneousGroups(deviceId1));
    assertThat(extraneous, hasSize(0));
}
 
Example #16
Source File: OfdpaGroupHandlerUtility.java    From onos with Apache License 2.0 6 votes vote down vote up
static Group retrieveTopLevelGroup(List<Deque<GroupKey>> allActiveKeys,
                                   DeviceId deviceId,
                                   GroupService groupService,
                                   int nextid) {
    GroupKey topLevelGroupKey;
    if (!allActiveKeys.isEmpty()) {
        topLevelGroupKey = allActiveKeys.get(0).peekFirst();
    } else {
        log.warn("Could not determine top level group while processing"
                         + "next:{} in dev:{}", nextid, deviceId);
        return null;
    }
    Group topGroup = groupService.getGroup(deviceId, topLevelGroupKey);
    if (topGroup == null) {
        log.warn("Could not find top level group while processing "
                         + "next:{} in dev:{}", nextid, deviceId);
    }
    return topGroup;
}
 
Example #17
Source File: SimpleGroupStore.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Removes the group entry from store.
 *
 * @param group group entry
 */
@Override
public void removeGroupEntry(Group group) {
    StoredGroupEntry existing = (groupEntriesById.get(
                     group.deviceId()) != null) ?
                     groupEntriesById.get(group.deviceId()).get(group.id()) :
                     null;

    if (existing != null) {
        ConcurrentMap<GroupKey, StoredGroupEntry> keyTable =
                getGroupKeyTable(existing.deviceId());
        ConcurrentMap<GroupId, StoredGroupEntry> idTable =
                getGroupIdTable(existing.deviceId());
        idTable.remove(existing.id());
        keyTable.remove(existing.appCookie());
        notifyDelegate(new GroupEvent(Type.GROUP_REMOVED, existing));
    }
}
 
Example #18
Source File: Bmv2GroupProgrammable.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Retrieves groups of BMv2 PRE.
 *
 * @return collection of PRE groups
 */
private Collection<Group> getPreGroups() {
    if (!setupBehaviour()) {
        return Collections.emptyList();
    }
    Bmv2DeviceAgent bmv2DeviceAgent = getBmv2DeviceAgent();

    try {
        return bmv2DeviceAgent.getPreGroups().stream()
                .map(preGroup -> groupStore.getGroup(deviceId, GroupId.valueOf(preGroup.groupId())))
                .collect(Collectors.toList());
    } catch (Bmv2RuntimeException e) {
        log.error("Exception while getting Bmv2 PRE groups of {}", deviceId, e);
        return Collections.emptyList();
    }
}
 
Example #19
Source File: MainComponent.java    From onos-p4-tutorial with Apache License 2.0 6 votes vote down vote up
/**
 * Triggers clean up of flows and groups from this app, returns false if no
 * flows or groups were found, true otherwise.
 *
 * @return false if no flows or groups were found, true otherwise
 */
private boolean cleanUp() {
    Collection<FlowRule> flows = Lists.newArrayList(
            flowRuleService.getFlowEntriesById(appId).iterator());

    Collection<Group> groups = Lists.newArrayList();
    for (Device device : deviceService.getAvailableDevices()) {
        groupService.getGroups(device.id(), appId).forEach(groups::add);
    }

    if (flows.isEmpty() && groups.isEmpty()) {
        return false;
    }

    flows.forEach(flowRuleService::removeFlowRules);
    if (!groups.isEmpty()) {
        // Wait for flows to be removed in case those depend on groups.
        sleep(1000);
        groups.forEach(g -> groupService.removeGroup(
                g.deviceId(), g.appCookie(), g.appId()));
    }

    return true;
}
 
Example #20
Source File: GroupsListCommand.java    From onos with Apache License 2.0 5 votes vote down vote up
private JsonNode json(Map<Device, List<Group>> sortedGroups) {
    ArrayNode result = mapper().createArrayNode();

    sortedGroups.forEach((device, groups) ->
            groups.forEach(group ->
                    result.add(jsonForEntity(group, Group.class))));

    return result;
}
 
Example #21
Source File: PiTranslationServiceImpl.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public PiActionProfileGroup translate(Group original, PiPipeconf pipeconf)
        throws PiTranslationException {
    checkNotNull(original);
    checkNotNull(pipeconf);
    return PiGroupTranslatorImpl
            .translate(original, pipeconf, getDevice(original.deviceId()));
}
 
Example #22
Source File: TroubleshootLoadFileCommand.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public void loadGroupNib() throws IOException {
    InputStream stream = new FileInputStream(new File(rootDir + "groups.json"));
    JsonNode jsonTree = mapper().readTree(stream);
    Set<Group> groups = new HashSet<>();

    // note: the parsing structure depends on GroupsListCommand
    groups.addAll(codec(Group.class).decode((ArrayNode) jsonTree, this));

    GroupNib groupNib = GroupNib.getInstance();
    groupNib.setGroups(groups);

    stream.close();
}
 
Example #23
Source File: P4RuntimeReplicationGroupProgrammable.java    From onos with Apache License 2.0 5 votes vote down vote up
private boolean preEntryWrite(PiPreEntryHandle handle,
                              PiPreEntry preEntry,
                              Group pdGroup,
                              P4RuntimeClient.UpdateType opType) {
    switch (opType) {
        case DELETE:
            if (writeEntryOnDevice(preEntry, DELETE)) {
                mirror.remove(handle);
                translator.forget(handle);
                return true;
            } else {
                return false;
            }
        case INSERT:
        case MODIFY:
            if (writeEntryOnDevice(preEntry, opType)) {
                mirror.put(handle, preEntry);
                translator.learn(handle, new PiTranslatedEntity<>(
                        pdGroup, preEntry, handle));
                return true;
            } else {
                return false;
            }
        default:
            log.warn("Unknown operation type {}, cannot apply group", opType);
            return false;
    }
}
 
Example #24
Source File: SimpleGroupStore.java    From onos with Apache License 2.0 5 votes vote down vote up
private void groupMissing(Group group) {
    switch (group.state()) {
        case PENDING_DELETE:
            log.debug("Group {} delete confirmation from device {}",
                      group, group.deviceId());
            removeGroupEntry(group);
            break;
        case ADDED:
        case PENDING_ADD:
        case PENDING_UPDATE:
            log.debug("Group {} is in store but not on device {}",
                      group, group.deviceId());
            StoredGroupEntry existing = (groupEntriesById.get(
                          group.deviceId()) != null) ?
                          groupEntriesById.get(group.deviceId()).get(group.id()) :
                          null;
            log.trace("groupMissing: group "
                    + "entry {} in device {} moving "
                    + "from {} to PENDING_ADD",
                    existing.id(),
                    existing.deviceId(),
                    existing.state());
            existing.setState(Group.GroupState.PENDING_ADD);
            notifyDelegate(new GroupEvent(GroupEvent.Type.GROUP_ADD_REQUESTED,
                                          group));
            break;
        default:
            log.debug("Group {} has not been installed.", group);
            break;
    }
}
 
Example #25
Source File: PointToPointIntentCompiler.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Removes intents from installables list, depending on the values
 * of instance variables erasePrimary and eraseBackup. Flow rule intents
 * that contain the manufactured fast failover flow rules are never deleted.
 * The contents are simply modified as necessary. If cleanUpIntents size
 * is greater than 1 (failover intent), then one whole path from previous
 * installables must be still viable.
 *
 * @param cleanUpIntents   list of installable intents
 */
private void removeAndUpdateIntents(List<Intent> cleanUpIntents,
                                    PointToPointIntent pointIntent) {
    ListIterator<Intent> iterator = cleanUpIntents.listIterator();
    while (iterator.hasNext()) {
        Intent cIntent = iterator.next();
        if (cIntent instanceof FlowRuleIntent) {
            FlowRuleIntent fIntent = (FlowRuleIntent) cIntent;
            if (fIntent.type() == PathIntent.ProtectionType.PRIMARY && erasePrimary) {
                // remove primary path's flow rule intents
                iterator.remove();
            } else if (fIntent.type() == PathIntent.ProtectionType.BACKUP && eraseBackup) {
                //remove backup path's flow rule intents
                iterator.remove();
            } else if (fIntent.type() == PathIntent.ProtectionType.BACKUP && erasePrimary) {
                // promote backup path's flow rule intents to primary
                iterator.set(new FlowRuleIntent(fIntent, PathIntent.ProtectionType.PRIMARY));
            }
        }
    }
    // remove buckets whose watchports are disabled if the failover group exists
    Group group = groupService.getGroup(pointIntent.filteredIngressPoint().connectPoint().deviceId(),
                                        makeGroupKey(pointIntent.id()));
    if (group != null) {
        updateFailoverGroup(pointIntent);
    }
}
 
Example #26
Source File: P4RuntimeGroupProgrammable.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public Collection<Group> getGroups() {
    try {
        return doGetGroups();
    } catch (Throwable ex) {
        log.error("Unhandled exception on getGroups", ex);
        return Collections.emptyList();
    }
}
 
Example #27
Source File: Bmv2GroupProgrammable.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Makes a decision between two methodologies over group type.
 * A group of ALL type is evaluated by GroupProgrammable of BMv2;
 * it is passed on to GroupProgrammable of P4Runtime otherwise.
 *
 * @param deviceId ID of the device on which the group is being accommodated.
 * @param groupOp  group operation
 */
private void processGroupOp(DeviceId deviceId, GroupOperation groupOp) {
    final Group group = groupStore.getGroup(deviceId, groupOp.groupId());

    if (isPreGroup(group)) {
        processPreGroupOp(deviceId, groupOp);
    } else {
        //means the group is managed via P4Runtime.
        super.performGroupOperation(deviceId,
                                    new GroupOperations(Arrays.asList(new GroupOperation[]{groupOp})));
    }
}
 
Example #28
Source File: SimpleVirtualGroupStore.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public Group getGroup(NetworkId networkId, DeviceId deviceId, GroupId groupId) {
    if (groupEntriesById.get(networkId) != null &&
            groupEntriesById.get(networkId).get(deviceId) != null) {
        return groupEntriesById.get(networkId).get(deviceId).get(groupId);
    }
    return null;
}
 
Example #29
Source File: DistributedGroupStore.java    From onos with Apache License 2.0 5 votes vote down vote up
private Group getMatchingExtraneousGroupbyBuckets(DeviceId deviceId,
                                                  GroupBuckets buckets) {
    ConcurrentMap<GroupId, Group> extraneousMap =
            extraneousGroupEntriesById.get(deviceId);
    if (extraneousMap == null) {
        return null;
    }

    for (Group extraneousGroup : extraneousMap.values()) {
        if (extraneousGroup.buckets().equals(buckets)) {
            return extraneousGroup;
        }
    }
    return null;
}
 
Example #30
Source File: SimpleVirtualGroupStore.java    From onos with Apache License 2.0 5 votes vote down vote up
private int getFreeGroupIdValue(NetworkId networkId, DeviceId deviceId) {
    int freeId = groupIdGen.incrementAndGet();

    while (true) {
        Group existing = null;
        if (groupEntriesById.get(networkId) != null &&
                groupEntriesById.get(networkId).get(deviceId) != null) {
            existing = groupEntriesById.get(networkId).get(deviceId)
                            .get(new GroupId(freeId));
        }

        if (existing == null) {
            if (extraneousGroupEntriesById.get(networkId) != null &&
                    extraneousGroupEntriesById.get(networkId).get(deviceId) != null) {
                existing = extraneousGroupEntriesById.get(networkId).get(deviceId)
                                .get(new GroupId(freeId));
            }
        }

        if (existing != null) {
            freeId = groupIdGen.incrementAndGet();
        } else {
            break;
        }
    }
    return freeId;
}