Search in sources :

Example 6 with GroupEvent

use of org.onosproject.net.group.GroupEvent in project onos by opennetworkinglab.

the class SimpleVirtualGroupStore method removeGroupEntry.

@Override
public void removeGroupEntry(NetworkId networkId, Group group) {
    StoredGroupEntry existing = null;
    if (groupEntriesById.get(networkId) != null && groupEntriesById.get(networkId).get(group.deviceId()) != null) {
        existing = groupEntriesById.get(networkId).get(group.deviceId()).get(group.id());
    }
    if (existing != null) {
        ConcurrentMap<GroupKey, StoredGroupEntry> keyTable = getGroupKeyTable(networkId, existing.deviceId());
        ConcurrentMap<GroupId, StoredGroupEntry> idTable = getGroupIdTable(networkId, existing.deviceId());
        idTable.remove(existing.id());
        keyTable.remove(existing.appCookie());
        notifyDelegate(networkId, new GroupEvent(GroupEvent.Type.GROUP_REMOVED, existing));
    }
}
Also used : GroupKey(org.onosproject.net.group.GroupKey) StoredGroupEntry(org.onosproject.net.group.StoredGroupEntry) GroupEvent(org.onosproject.net.group.GroupEvent) GroupId(org.onosproject.core.GroupId)

Example 7 with GroupEvent

use of org.onosproject.net.group.GroupEvent in project onos by opennetworkinglab.

the class SimpleVirtualGroupStore method groupOperationFailed.

@Override
public void groupOperationFailed(NetworkId networkId, DeviceId deviceId, GroupOperation operation) {
    StoredGroupEntry existing = null;
    if (groupEntriesById.get(networkId) != null && groupEntriesById.get(networkId).get(deviceId) != null) {
        existing = groupEntriesById.get(networkId).get(deviceId).get(operation.groupId());
    }
    if (existing == null) {
        log.warn("No group entry with ID {} found ", operation.groupId());
        return;
    }
    switch(operation.opType()) {
        case ADD:
            notifyDelegate(networkId, new GroupEvent(GroupEvent.Type.GROUP_ADD_FAILED, existing));
            break;
        case MODIFY:
            notifyDelegate(networkId, new GroupEvent(GroupEvent.Type.GROUP_UPDATE_FAILED, existing));
            break;
        case DELETE:
            notifyDelegate(networkId, new GroupEvent(GroupEvent.Type.GROUP_REMOVE_FAILED, existing));
            break;
        default:
            log.warn("Unknown group operation type {}", operation.opType());
    }
    ConcurrentMap<GroupKey, StoredGroupEntry> keyTable = getGroupKeyTable(networkId, existing.deviceId());
    ConcurrentMap<GroupId, StoredGroupEntry> idTable = getGroupIdTable(networkId, existing.deviceId());
    idTable.remove(existing.id());
    keyTable.remove(existing.appCookie());
}
Also used : GroupKey(org.onosproject.net.group.GroupKey) StoredGroupEntry(org.onosproject.net.group.StoredGroupEntry) GroupEvent(org.onosproject.net.group.GroupEvent) GroupId(org.onosproject.core.GroupId)

Example 8 with GroupEvent

use of org.onosproject.net.group.GroupEvent in project onos by opennetworkinglab.

the class SimpleVirtualGroupStore method notifyOfFailovers.

@Override
public void notifyOfFailovers(NetworkId networkId, Collection<Group> failoverGroups) {
    List<GroupEvent> failoverEvents = new ArrayList<>();
    failoverGroups.forEach(group -> {
        if (group.type() == Group.Type.FAILOVER) {
            failoverEvents.add(new GroupEvent(GroupEvent.Type.GROUP_BUCKET_FAILOVER, group));
        }
    });
    notifyDelegate(networkId, failoverEvents);
}
Also used : ArrayList(java.util.ArrayList) GroupEvent(org.onosproject.net.group.GroupEvent)

Example 9 with GroupEvent

use of org.onosproject.net.group.GroupEvent in project onos by opennetworkinglab.

the class SimpleVirtualGroupStore method purgeGroupEntries.

@Override
public void purgeGroupEntries(NetworkId networkId) {
    if (groupEntriesById.get(networkId) != null) {
        groupEntriesById.get((networkId)).values().forEach(groupEntries -> {
            groupEntries.entrySet().forEach(entry -> {
                notifyDelegate(networkId, new GroupEvent(GroupEvent.Type.GROUP_REMOVED, entry.getValue()));
            });
        });
        groupEntriesById.get(networkId).clear();
        groupEntriesByKey.get(networkId).clear();
    }
}
Also used : GroupEvent(org.onosproject.net.group.GroupEvent)

Example 10 with GroupEvent

use of org.onosproject.net.group.GroupEvent in project onos by opennetworkinglab.

the class SimpleGroupStore method storeGroupDescriptionInternal.

private void storeGroupDescriptionInternal(GroupDescription groupDesc) {
    // Check if a group is existing with the same key
    if (getGroup(groupDesc.deviceId(), groupDesc.appCookie()) != null) {
        return;
    }
    GroupId id = null;
    if (groupDesc.givenGroupId() == null) {
        // Get a new group identifier
        id = new GroupId(getFreeGroupIdValue(groupDesc.deviceId()));
    } else {
        id = new GroupId(groupDesc.givenGroupId());
    }
    // Create a group entry object
    StoredGroupEntry group = new DefaultGroup(id, groupDesc);
    // Insert the newly created group entry into concurrent key and id maps
    ConcurrentMap<GroupKey, StoredGroupEntry> keyTable = getGroupKeyTable(groupDesc.deviceId());
    keyTable.put(groupDesc.appCookie(), group);
    ConcurrentMap<GroupId, StoredGroupEntry> idTable = getGroupIdTable(groupDesc.deviceId());
    idTable.put(id, group);
    notifyDelegate(new GroupEvent(GroupEvent.Type.GROUP_ADD_REQUESTED, group));
}
Also used : DefaultGroup(org.onosproject.net.group.DefaultGroup) GroupKey(org.onosproject.net.group.GroupKey) StoredGroupEntry(org.onosproject.net.group.StoredGroupEntry) GroupEvent(org.onosproject.net.group.GroupEvent) GroupId(org.onosproject.core.GroupId)

Aggregations

GroupEvent (org.onosproject.net.group.GroupEvent)32 StoredGroupEntry (org.onosproject.net.group.StoredGroupEntry)23 GroupId (org.onosproject.core.GroupId)13 DefaultGroup (org.onosproject.net.group.DefaultGroup)12 GroupKey (org.onosproject.net.group.GroupKey)11 Group (org.onosproject.net.group.Group)10 DefaultGroupDescription (org.onosproject.net.group.DefaultGroupDescription)5 GroupBucket (org.onosproject.net.group.GroupBucket)5 GroupBuckets (org.onosproject.net.group.GroupBuckets)5 GroupDescription (org.onosproject.net.group.GroupDescription)5 ArrayList (java.util.ArrayList)4 GroupOperation (org.onosproject.net.group.GroupOperation)4 StoredGroupBucketEntry (org.onosproject.net.group.StoredGroupBucketEntry)4 FluentIterable (com.google.common.collect.FluentIterable)2 Sets (com.google.common.collect.Sets)2 Collection (java.util.Collection)2 HashMap (java.util.HashMap)2 Iterator (java.util.Iterator)2 List (java.util.List)2 Map (java.util.Map)2