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));
}
}
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;
}
}
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));
}
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));
}
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));
}
}
Aggregations