use of org.onosproject.net.group.GroupBucket in project onos by opennetworkinglab.
the class GroupModBuilder method buildGroupMod.
/**
* Builds the GroupMod OF message.
*
* @return GroupMod OF message
*/
public OFGroupMod buildGroupMod() {
// Build group mod
List<OFBucket> ofBuckets = new ArrayList<OFBucket>();
for (GroupBucket bucket : buckets.buckets()) {
OFBucket ofBucket = ofBucketBuilder(bucket).build();
ofBuckets.add(ofBucket);
}
// Build the msg and return
return factory.buildGroupModify().setGroup(OFGroup.of(groupId.id())).setBuckets(ofBuckets).setGroupType(getOFGroupType(type)).setXid(xid).build();
}
use of org.onosproject.net.group.GroupBucket in project onos by opennetworkinglab.
the class GroupModBuilder method buildGroupAdd.
/**
* Builds the GroupAdd OF message.
*
* @return GroupAdd OF message
*/
public OFGroupAdd buildGroupAdd() {
// Build group add
List<OFBucket> ofBuckets = new ArrayList<OFBucket>();
for (GroupBucket bucket : buckets.buckets()) {
OFBucket ofBucket = ofBucketBuilder(bucket).build();
ofBuckets.add(ofBucket);
}
// Build the msg and return
return factory.buildGroupAdd().setGroup(OFGroup.of(groupId.id())).setBuckets(ofBuckets).setGroupType(getOFGroupType(type)).setXid(xid).build();
}
use of org.onosproject.net.group.GroupBucket in project onos by opennetworkinglab.
the class OpenFlowGroupProviderTest method groupModFailure.
@Test
public void groupModFailure() {
TestOpenFlowGroupProviderService testProviderService = (TestOpenFlowGroupProviderService) providerService;
GroupId groupId = new GroupId(1);
List<GroupBucket> bucketList = Lists.newArrayList();
TrafficTreatment.Builder builder = DefaultTrafficTreatment.builder();
builder.setOutput(PortNumber.portNumber(1));
GroupBucket bucket = DefaultGroupBucket.createSelectGroupBucket(builder.build());
bucketList.add(bucket);
GroupBuckets buckets = new GroupBuckets(bucketList);
List<GroupOperation> operationList = Lists.newArrayList();
GroupOperation operation = GroupOperation.createAddGroupOperation(groupId, GroupDescription.Type.SELECT, buckets);
operationList.add(operation);
GroupOperations operations = new GroupOperations(operationList);
provider.performGroupOperation(deviceId, operations);
OFGroupModFailedErrorMsg.Builder errorBuilder = OFFactories.getFactory(OFVersion.OF_13).errorMsgs().buildGroupModFailedErrorMsg();
OFGroupMod.Builder groupBuilder = OFFactories.getFactory(OFVersion.OF_13).buildGroupModify();
groupBuilder.setGroupType(OFGroupType.ALL);
groupBuilder.setGroup(OFGroup.of(1));
errorBuilder.setCode(OFGroupModFailedCode.GROUP_EXISTS);
errorBuilder.setXid(provider.getXidAndAdd(0) - 1);
controller.processPacket(dpid1, errorBuilder.build());
assertNotNull("Operation failed should not be null", testProviderService.failedOperation);
}
use of org.onosproject.net.group.GroupBucket in project onos by opennetworkinglab.
the class DistributedGroupStore method updateGroupEntryStatsInternal.
/**
* Updates the stats of an existing group entry.
*
* @param group the new stats
* @param existing the existing group
*/
private void updateGroupEntryStatsInternal(Group group, StoredGroupEntry existing) {
for (GroupBucket bucket : group.buckets().buckets()) {
Optional<GroupBucket> matchingBucket = existing.buckets().buckets().stream().filter((existingBucket) -> (existingBucket.equals(bucket))).findFirst();
if (matchingBucket.isPresent()) {
((StoredGroupBucketEntry) matchingBucket.get()).setPackets(bucket.packets());
((StoredGroupBucketEntry) matchingBucket.get()).setBytes(bucket.bytes());
} else {
log.warn("updateGroupEntryStatsInternal: No matching bucket {}" + " to update stats for group {}", bucket, group.id());
}
}
existing.setLife(group.life());
existing.setPackets(group.packets());
existing.setBytes(group.bytes());
existing.setReferenceCount(group.referenceCount());
existing.setFailedRetryCount(0);
}
use of org.onosproject.net.group.GroupBucket in project onos by opennetworkinglab.
the class DistributedGroupStore method updateGroupDescriptionInternal.
private void updateGroupDescriptionInternal(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) {
log.warn("updateGroupDescriptionInternal: Group not found...strange. " + "GroupKey:{} DeviceId:{} newGroupKey:{}", oldAppCookie, deviceId, newAppCookie);
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);
log.debug("updateGroupDescriptionInternal: group entry {} in device {} moving from {} to PENDING_UPDATE", oldGroup.id(), oldGroup.deviceId(), oldGroup.state());
newGroup.setState(GroupState.PENDING_UPDATE);
newGroup.setLife(oldGroup.life());
newGroup.setPackets(oldGroup.packets());
newGroup.setBytes(oldGroup.bytes());
// Update the group entry in groupkey based map.
// Update to groupid based map will happen in the
// groupkey based map update listener
log.debug("updateGroupDescriptionInternal with type {}: Group {} updated with buckets", type, newGroup.id());
getGroupStoreKeyMap().put(new GroupStoreKeyMapKey(newGroup.deviceId(), newGroup.appCookie()), newGroup);
notifyDelegate(new GroupEvent(Type.GROUP_UPDATE_REQUESTED, newGroup));
} else {
log.warn("updateGroupDescriptionInternal with type {}: Group {} No " + "change in the buckets in update", type, oldGroup.id());
}
}
Aggregations