use of org.onosproject.core.GroupId 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));
}
}
use of org.onosproject.core.GroupId 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());
}
use of org.onosproject.core.GroupId 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));
}
use of org.onosproject.core.GroupId in project onos by opennetworkinglab.
the class SimpleGroupStore method updateGroupDescription.
/**
* Updates the existing group entry with the information
* from group description.
*
* @param deviceId the device ID
* @param oldAppCookie the current group key
* @param type update type
* @param newBuckets group buckets for updates
* @param newAppCookie optional new group key
*/
@Override
public void updateGroupDescription(DeviceId deviceId, GroupKey oldAppCookie, UpdateType type, GroupBuckets newBuckets, GroupKey newAppCookie) {
// Check if a group is existing with the provided key
Group oldGroup = getGroup(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(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(oldGroup.deviceId());
ConcurrentMap<GroupId, StoredGroupEntry> idTable = getGroupIdTable(oldGroup.deviceId());
keyTable.remove(oldGroup.appCookie());
idTable.remove(oldGroup.id());
keyTable.put(newGroup.appCookie(), newGroup);
idTable.put(newGroup.id(), newGroup);
notifyDelegate(new GroupEvent(Type.GROUP_UPDATE_REQUESTED, newGroup));
}
}
use of org.onosproject.core.GroupId in project onos by opennetworkinglab.
the class SimpleGroupStore method groupOperationFailed.
@Override
public void groupOperationFailed(DeviceId deviceId, GroupOperation operation) {
StoredGroupEntry existing = (groupEntriesById.get(deviceId) != null) ? groupEntriesById.get(deviceId).get(operation.groupId()) : null;
if (existing == null) {
log.warn("No group entry with ID {} found ", operation.groupId());
return;
}
switch(operation.opType()) {
case ADD:
notifyDelegate(new GroupEvent(Type.GROUP_ADD_FAILED, existing));
break;
case MODIFY:
notifyDelegate(new GroupEvent(Type.GROUP_UPDATE_FAILED, existing));
break;
case DELETE:
notifyDelegate(new GroupEvent(Type.GROUP_REMOVE_FAILED, existing));
break;
default:
log.warn("Unknown group operation type {}", operation.opType());
}
ConcurrentMap<GroupKey, StoredGroupEntry> keyTable = getGroupKeyTable(existing.deviceId());
ConcurrentMap<GroupId, StoredGroupEntry> idTable = getGroupIdTable(existing.deviceId());
idTable.remove(existing.id());
keyTable.remove(existing.appCookie());
}
Aggregations