Search in sources :

Example 21 with StoredGroupEntry

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

the class SimpleVirtualGroupStore method updateGroupDescription.

@Override
public void updateGroupDescription(NetworkId networkId, DeviceId deviceId, GroupKey oldAppCookie, UpdateType type, GroupBuckets newBuckets, GroupKey newAppCookie) {
    // Check if a group is existing with the provided key
    Group oldGroup = getGroup(networkId, deviceId, oldAppCookie);
    if (oldGroup == null) {
        return;
    }
    List<GroupBucket> newBucketList = getUpdatedBucketList(oldGroup, type, newBuckets);
    if (newBucketList != null) {
        // Create a new group object from the old group
        GroupBuckets updatedBuckets = new GroupBuckets(newBucketList);
        GroupKey newCookie = (newAppCookie != null) ? newAppCookie : oldAppCookie;
        GroupDescription updatedGroupDesc = new DefaultGroupDescription(oldGroup.deviceId(), oldGroup.type(), updatedBuckets, newCookie, oldGroup.givenGroupId(), oldGroup.appId());
        StoredGroupEntry newGroup = new DefaultGroup(oldGroup.id(), updatedGroupDesc);
        newGroup.setState(Group.GroupState.PENDING_UPDATE);
        newGroup.setLife(oldGroup.life());
        newGroup.setPackets(oldGroup.packets());
        newGroup.setBytes(oldGroup.bytes());
        // Remove the old entry from maps and add new entry using new key
        ConcurrentMap<GroupKey, StoredGroupEntry> keyTable = getGroupKeyTable(networkId, oldGroup.deviceId());
        ConcurrentMap<GroupId, StoredGroupEntry> idTable = getGroupIdTable(networkId, oldGroup.deviceId());
        keyTable.remove(oldGroup.appCookie());
        idTable.remove(oldGroup.id());
        keyTable.put(newGroup.appCookie(), newGroup);
        idTable.put(newGroup.id(), newGroup);
        notifyDelegate(networkId, new GroupEvent(GroupEvent.Type.GROUP_UPDATE_REQUESTED, newGroup));
    }
}
Also used : DefaultGroup(org.onosproject.net.group.DefaultGroup) Group(org.onosproject.net.group.Group) GroupKey(org.onosproject.net.group.GroupKey) DefaultGroup(org.onosproject.net.group.DefaultGroup) GroupBuckets(org.onosproject.net.group.GroupBuckets) StoredGroupEntry(org.onosproject.net.group.StoredGroupEntry) GroupEvent(org.onosproject.net.group.GroupEvent) GroupId(org.onosproject.core.GroupId) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupDescription(org.onosproject.net.group.GroupDescription) GroupBucket(org.onosproject.net.group.GroupBucket) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription)

Example 22 with StoredGroupEntry

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

the class SimpleVirtualGroupStore method groupMissing.

private void groupMissing(NetworkId networkId, Group group) {
    switch(group.state()) {
        case PENDING_DELETE:
            log.debug("Group {} delete confirmation from device {} " + "of virtaual network {}", group, group.deviceId(), networkId);
            removeGroupEntry(networkId, 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 = 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) {
                break;
            }
            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(networkId, new GroupEvent(GroupEvent.Type.GROUP_ADD_REQUESTED, group));
            break;
        default:
            log.debug("Virtual network {} : Group {} has not been installed.", networkId, group);
            break;
    }
}
Also used : StoredGroupEntry(org.onosproject.net.group.StoredGroupEntry) GroupEvent(org.onosproject.net.group.GroupEvent)

Example 23 with StoredGroupEntry

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

the class SimpleVirtualGroupStore method deleteGroupDescription.

@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));
}
Also used : StoredGroupEntry(org.onosproject.net.group.StoredGroupEntry) GroupEvent(org.onosproject.net.group.GroupEvent)

Example 24 with StoredGroupEntry

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

the class SimpleGroupStore method deleteGroupDescription.

/**
 * Triggers deleting the existing group entry.
 *
 * @param deviceId the device ID
 * @param appCookie the group key
 */
@Override
public void deleteGroupDescription(DeviceId deviceId, GroupKey appCookie) {
    // Check if a group is existing with the provided key
    StoredGroupEntry existing = (groupEntriesByKey.get(deviceId) != null) ? groupEntriesByKey.get(deviceId).get(appCookie) : null;
    if (existing == null) {
        return;
    }
    synchronized (existing) {
        existing.setState(GroupState.PENDING_DELETE);
    }
    notifyDelegate(new GroupEvent(Type.GROUP_REMOVE_REQUESTED, existing));
}
Also used : StoredGroupEntry(org.onosproject.net.group.StoredGroupEntry) GroupEvent(org.onosproject.net.group.GroupEvent)

Example 25 with StoredGroupEntry

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

the class SimpleGroupStore method removeGroupEntry.

/**
 * 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));
    }
}
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)

Aggregations

StoredGroupEntry (org.onosproject.net.group.StoredGroupEntry)38 GroupEvent (org.onosproject.net.group.GroupEvent)26 DefaultGroup (org.onosproject.net.group.DefaultGroup)19 GroupKey (org.onosproject.net.group.GroupKey)18 GroupId (org.onosproject.core.GroupId)15 Group (org.onosproject.net.group.Group)13 GroupBucket (org.onosproject.net.group.GroupBucket)11 GroupBuckets (org.onosproject.net.group.GroupBuckets)11 DefaultGroupDescription (org.onosproject.net.group.DefaultGroupDescription)10 GroupDescription (org.onosproject.net.group.GroupDescription)10 ArrayList (java.util.ArrayList)8 StoredGroupBucketEntry (org.onosproject.net.group.StoredGroupBucketEntry)8 DeviceId (org.onosproject.net.DeviceId)6 Activate (org.osgi.service.component.annotations.Activate)6 FluentIterable (com.google.common.collect.FluentIterable)5 Sets (com.google.common.collect.Sets)5 Collection (java.util.Collection)5 HashMap (java.util.HashMap)5 Iterator (java.util.Iterator)5 List (java.util.List)5