Search in sources :

Example 6 with StoredGroupEntry

use of org.onosproject.net.group.StoredGroupEntry 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 StoredGroupEntry

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

the class SimpleVirtualGroupStore method storeGroupDescriptionInternal.

private void storeGroupDescriptionInternal(NetworkId networkId, GroupDescription groupDesc) {
    // Check if a group is existing with the same key
    if (getGroup(networkId, groupDesc.deviceId(), groupDesc.appCookie()) != null) {
        return;
    }
    GroupId id = null;
    if (groupDesc.givenGroupId() == null) {
        // Get a new group identifier
        id = new GroupId(getFreeGroupIdValue(networkId, 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(networkId, groupDesc.deviceId());
    keyTable.put(groupDesc.appCookie(), group);
    ConcurrentMap<GroupId, StoredGroupEntry> idTable = getGroupIdTable(networkId, groupDesc.deviceId());
    idTable.put(id, group);
    notifyDelegate(networkId, 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)

Example 8 with StoredGroupEntry

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

the class SimpleVirtualGroupStore method deviceInitialAuditCompleted.

@Override
public void deviceInitialAuditCompleted(NetworkId networkId, DeviceId deviceId, boolean completed) {
    deviceAuditStatus.computeIfAbsent(networkId, k -> new HashMap<>());
    HashMap<DeviceId, Boolean> deviceAuditStatusByNetwork = deviceAuditStatus.get(networkId);
    synchronized (deviceAuditStatusByNetwork) {
        if (completed) {
            log.debug("deviceInitialAuditCompleted: AUDIT " + "completed for device {}", deviceId);
            deviceAuditStatusByNetwork.put(deviceId, true);
            // Execute all pending group requests
            ConcurrentMap<GroupKey, StoredGroupEntry> pendingGroupRequests = getPendingGroupKeyTable(networkId, deviceId);
            for (Group group : pendingGroupRequests.values()) {
                GroupDescription tmp = new DefaultGroupDescription(group.deviceId(), group.type(), group.buckets(), group.appCookie(), group.givenGroupId(), group.appId());
                storeGroupDescriptionInternal(networkId, tmp);
            }
            getPendingGroupKeyTable(networkId, deviceId).clear();
        } else {
            if (deviceAuditStatusByNetwork.get(deviceId)) {
                log.debug("deviceInitialAuditCompleted: Clearing AUDIT " + "status for device {}", deviceId);
                deviceAuditStatusByNetwork.put(deviceId, false);
            }
        }
    }
}
Also used : DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupDescription(org.onosproject.net.group.GroupDescription) DefaultGroup(org.onosproject.net.group.DefaultGroup) Group(org.onosproject.net.group.Group) DeviceId(org.onosproject.net.DeviceId) GroupKey(org.onosproject.net.group.GroupKey) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) StoredGroupEntry(org.onosproject.net.group.StoredGroupEntry)

Example 9 with StoredGroupEntry

use of org.onosproject.net.group.StoredGroupEntry 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 10 with StoredGroupEntry

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

the class SimpleVirtualGroupStore method storeGroupDescription.

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

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