use of org.onosproject.net.group.DefaultGroupDescription in project onos by opennetworkinglab.
the class AbstractCorsaPipeline method next.
@Override
public void next(NextObjective nextObjective) {
switch(nextObjective.type()) {
case SIMPLE:
Collection<TrafficTreatment> treatments = nextObjective.next();
if (treatments.size() == 1) {
TrafficTreatment treatment = treatments.iterator().next();
CorsaTrafficTreatment corsaTreatment = processNextTreatment(treatment);
final GroupKey key = new DefaultGroupKey(appKryo.serialize(nextObjective.id()));
if (corsaTreatment.type() == CorsaTrafficTreatmentType.GROUP) {
GroupBucket bucket = DefaultGroupBucket.createIndirectGroupBucket(corsaTreatment.treatment());
GroupBuckets buckets = new GroupBuckets(Collections.singletonList(bucket));
// group id == null, let group service determine group id
GroupDescription groupDescription = new DefaultGroupDescription(deviceId, GroupDescription.Type.INDIRECT, buckets, key, null, nextObjective.appId());
groupService.addGroup(groupDescription);
pendingGroups.put(key, nextObjective);
} else if (corsaTreatment.type() == CorsaTrafficTreatmentType.ACTIONS) {
pendingNext.put(nextObjective.id(), nextObjective);
flowObjectiveStore.putNextGroup(nextObjective.id(), new CorsaGroup(key));
nextObjective.context().ifPresent(context -> context.onSuccess(nextObjective));
}
}
break;
case HASHED:
case BROADCAST:
case FAILOVER:
fail(nextObjective, ObjectiveError.UNSUPPORTED);
log.warn("Unsupported next objective type {}", nextObjective.type());
break;
default:
fail(nextObjective, ObjectiveError.UNKNOWN);
log.warn("Unknown next objective type {}", nextObjective.type());
}
}
use of org.onosproject.net.group.DefaultGroupDescription in project onos by opennetworkinglab.
the class GroupManagerTest method testGroupCreationBeforeAudit.
// Test Group creation before AUDIT process
private void testGroupCreationBeforeAudit(DeviceId deviceId) {
PortNumber[] ports1 = { PortNumber.portNumber(31), PortNumber.portNumber(32) };
PortNumber[] ports2 = { PortNumber.portNumber(41), PortNumber.portNumber(42) };
GroupKey key = new DefaultGroupKey("group1BeforeAudit".getBytes());
List<GroupBucket> buckets = new ArrayList<>();
List<PortNumber> outPorts = new ArrayList<>();
outPorts.addAll(Arrays.asList(ports1));
outPorts.addAll(Arrays.asList(ports2));
for (PortNumber portNumber : outPorts) {
TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
tBuilder.setOutput(portNumber).setEthDst(MacAddress.valueOf("00:00:00:00:00:02")).setEthSrc(MacAddress.valueOf("00:00:00:00:00:01")).pushMpls().setMpls(MplsLabel.mplsLabel(106));
buckets.add(DefaultGroupBucket.createSelectGroupBucket(tBuilder.build()));
}
GroupBuckets groupBuckets = new GroupBuckets(buckets);
GroupDescription newGroupDesc = new DefaultGroupDescription(deviceId, Group.Type.SELECT, groupBuckets, key, null, appId);
groupService.addGroup(newGroupDesc);
assertEquals(null, groupService.getGroup(deviceId, key));
assertEquals(0, Iterables.size(groupService.getGroups(deviceId, appId)));
}
use of org.onosproject.net.group.DefaultGroupDescription in project onos by opennetworkinglab.
the class GroupManagerTest method groupOperationFaliure.
private void groupOperationFaliure(DeviceId deviceId) {
PortNumber[] ports1 = { PortNumber.portNumber(31), PortNumber.portNumber(32) };
PortNumber[] ports2 = { PortNumber.portNumber(41), PortNumber.portNumber(42) };
// Test Group creation before AUDIT process
GroupKey key = new DefaultGroupKey("group1BeforeAudit".getBytes());
List<GroupBucket> buckets = new ArrayList<>();
List<PortNumber> outPorts = new ArrayList<>();
outPorts.addAll(Arrays.asList(ports1));
outPorts.addAll(Arrays.asList(ports2));
for (PortNumber portNumber : outPorts) {
TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
tBuilder.setOutput(portNumber).setEthDst(MacAddress.valueOf("00:00:00:00:00:02")).setEthSrc(MacAddress.valueOf("00:00:00:00:00:01")).pushMpls().setMpls(MplsLabel.mplsLabel(106));
buckets.add(DefaultGroupBucket.createSelectGroupBucket(tBuilder.build()));
}
GroupBuckets groupBuckets = new GroupBuckets(buckets);
GroupDescription newGroupDesc = new DefaultGroupDescription(deviceId, Group.Type.SELECT, groupBuckets, key, null, appId);
groupService.addGroup(newGroupDesc);
// Test initial group audit process
GroupId gId1 = new GroupId(1);
Group group1 = createSouthboundGroupEntry(gId1, Arrays.asList(ports1), 0, deviceId);
GroupId gId2 = new GroupId(2);
// Non zero reference count will make the group manager to queue
// the extraneous groups until reference count is zero.
Group group2 = createSouthboundGroupEntry(gId2, Arrays.asList(ports2), 2, deviceId);
List<Group> groupEntries = Arrays.asList(group1, group2);
providerService.pushGroupMetrics(deviceId, groupEntries);
Group createdGroup = groupService.getGroup(deviceId, key);
// Group Add failure test
GroupOperation groupAddOp = GroupOperation.createAddGroupOperation(createdGroup.id(), createdGroup.type(), createdGroup.buckets());
providerService.groupOperationFailed(deviceId, groupAddOp);
internalListener.validateEvent(Collections.singletonList(GroupEvent.Type.GROUP_ADD_FAILED));
// Group Mod failure test
groupService.addGroup(newGroupDesc);
createdGroup = groupService.getGroup(deviceId, key);
assertNotNull(createdGroup);
GroupOperation groupModOp = GroupOperation.createModifyGroupOperation(createdGroup.id(), createdGroup.type(), createdGroup.buckets());
providerService.groupOperationFailed(deviceId, groupModOp);
internalListener.validateEvent(Collections.singletonList(GroupEvent.Type.GROUP_UPDATE_FAILED));
// Group Delete failure test
groupService.addGroup(newGroupDesc);
createdGroup = groupService.getGroup(deviceId, key);
assertNotNull(createdGroup);
GroupOperation groupDelOp = GroupOperation.createDeleteGroupOperation(createdGroup.id(), createdGroup.type());
providerService.groupOperationFailed(deviceId, groupDelOp);
internalListener.validateEvent(Collections.singletonList(GroupEvent.Type.GROUP_REMOVE_FAILED));
}
use of org.onosproject.net.group.DefaultGroupDescription in project onos by opennetworkinglab.
the class SimpleGroupStore method deviceInitialAuditCompleted.
@Override
public void deviceInitialAuditCompleted(DeviceId deviceId, boolean completed) {
synchronized (deviceAuditStatus) {
if (completed) {
log.debug("deviceInitialAuditCompleted: AUDIT " + "completed for device {}", deviceId);
deviceAuditStatus.put(deviceId, true);
// Execute all pending group requests
ConcurrentMap<GroupKey, StoredGroupEntry> pendingGroupRequests = getPendingGroupKeyTable(deviceId);
for (Group group : pendingGroupRequests.values()) {
GroupDescription tmp = new DefaultGroupDescription(group.deviceId(), group.type(), group.buckets(), group.appCookie(), group.givenGroupId(), group.appId());
storeGroupDescriptionInternal(tmp);
}
getPendingGroupKeyTable(deviceId).clear();
} else {
if (deviceAuditStatus.getOrDefault(deviceId, false)) {
log.debug("deviceInitialAuditCompleted: Clearing AUDIT " + "status for device {}", deviceId);
deviceAuditStatus.put(deviceId, false);
}
}
}
}
use of org.onosproject.net.group.DefaultGroupDescription 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));
}
}
Aggregations