use of org.onosproject.core.GroupId in project onos by opennetworkinglab.
the class DistributedGroupStore method synchronizeGroupStoreEntries.
private void synchronizeGroupStoreEntries() {
Map<GroupStoreKeyMapKey, StoredGroupEntry> groupEntryMap = groupStoreEntriesByKey.asJavaMap();
for (Entry<GroupStoreKeyMapKey, StoredGroupEntry> entry : groupEntryMap.entrySet()) {
StoredGroupEntry value = entry.getValue();
ConcurrentMap<GroupId, StoredGroupEntry> groupIdTable = getGroupIdTable(value.deviceId());
groupIdTable.put(value.id(), value);
}
}
use of org.onosproject.core.GroupId in project onos by opennetworkinglab.
the class DistributedGroupStore method getFreeGroupIdValue.
private int getFreeGroupIdValue(DeviceId deviceId) {
int freeId = groupIdGen.incrementAndGet();
while (true) {
Group existing = getGroup(deviceId, new GroupId(freeId));
if (existing == null) {
existing = (extraneousGroupEntriesById.get(deviceId) != null) ? extraneousGroupEntriesById.get(deviceId).get(new GroupId(freeId)) : null;
}
if (existing != null) {
freeId = groupIdGen.incrementAndGet();
} else {
break;
}
}
log.debug("getFreeGroupIdValue: Next Free ID is {}", freeId);
return freeId;
}
use of org.onosproject.core.GroupId in project onos by opennetworkinglab.
the class TunnelCreateCommand method doExecute.
@Override
protected void doExecute() {
TunnelProvider service = get(TunnelProvider.class);
ProviderId producerName = new ProviderId("default", "org.onosproject.provider.tunnel.default");
TunnelEndPoint srcPoint = null;
TunnelEndPoint dstPoint = null;
Tunnel.Type trueType = null;
if ("MPLS".equals(type)) {
trueType = Tunnel.Type.MPLS;
srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src));
dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst));
} else if ("VLAN".equals(type)) {
trueType = Tunnel.Type.VLAN;
String[] srcArray = src.split("/");
String[] dstArray = dst.split("/");
srcPoint = new DefaultOpticalTunnelEndPoint(producerName, Optional.of(DeviceId.deviceId(srcArray[0])), Optional.of(PortNumber.portNumber(srcArray[1])), null, null, OpticalLogicId.logicId(0), true);
dstPoint = new DefaultOpticalTunnelEndPoint(producerName, Optional.of(DeviceId.deviceId(dstArray[0])), Optional.of(PortNumber.portNumber(dstArray[1])), null, null, OpticalLogicId.logicId(0), true);
} else if ("VXLAN".equals(type)) {
trueType = Tunnel.Type.VXLAN;
srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src));
dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst));
} else if ("GRE".equals(type)) {
trueType = Tunnel.Type.GRE;
srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src));
dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst));
} else if ("ODUK".equals(type)) {
trueType = Tunnel.Type.ODUK;
String[] srcArray = src.split("/");
String[] dstArray = dst.split("/");
srcPoint = new DefaultOpticalTunnelEndPoint(producerName, Optional.of(DeviceId.deviceId(srcArray[0])), Optional.of(PortNumber.portNumber(srcArray[1])), null, OpticalTunnelEndPoint.Type.LAMBDA, OpticalLogicId.logicId(0), true);
dstPoint = new DefaultOpticalTunnelEndPoint(producerName, Optional.of(DeviceId.deviceId(dstArray[0])), Optional.of(PortNumber.portNumber(dstArray[1])), null, OpticalTunnelEndPoint.Type.LAMBDA, OpticalLogicId.logicId(0), true);
} else if ("OCH".equals(type)) {
trueType = Tunnel.Type.OCH;
String[] srcArray = src.split("/");
String[] dstArray = dst.split("/");
srcPoint = new DefaultOpticalTunnelEndPoint(producerName, Optional.of(DeviceId.deviceId(srcArray[0])), Optional.of(PortNumber.portNumber(srcArray[1])), null, OpticalTunnelEndPoint.Type.TIMESLOT, OpticalLogicId.logicId(0), true);
dstPoint = new DefaultOpticalTunnelEndPoint(producerName, Optional.of(DeviceId.deviceId(dstArray[0])), Optional.of(PortNumber.portNumber(dstArray[1])), null, OpticalTunnelEndPoint.Type.TIMESLOT, OpticalLogicId.logicId(0), true);
} else {
print("Illegal tunnel type. Please input MPLS, VLAN, VXLAN, GRE, ODUK or OCH.");
return;
}
SparseAnnotations annotations = DefaultAnnotations.builder().set("bandwidth", bandwidth == null || "".equals(bandwidth) ? "0" : bandwidth).build();
TunnelDescription tunnel = new DefaultTunnelDescription(null, srcPoint, dstPoint, trueType, new GroupId(Integer.parseInt(groupId)), producerName, TunnelName.tunnelName(tunnelName), null, annotations);
TunnelId tunnelId = service.tunnelAdded(tunnel);
if (tunnelId == null) {
error("Create tunnel failed.");
return;
}
print(FMT, tunnelId.id());
}
use of org.onosproject.core.GroupId in project onos by opennetworkinglab.
the class VirtualNetworkGroupManagerTest method testAuditWithExtraneousMissingGroups.
// Test AUDIT process with extraneous groups and missing groups
private void testAuditWithExtraneousMissingGroups(NetworkId networkId, DeviceId deviceId) {
VirtualNetworkGroupManager groupManager;
VirtualGroupProviderService providerService;
if (networkId.id() == 1) {
groupManager = groupManager1;
providerService = providerService1;
} else {
groupManager = groupManager2;
providerService = providerService2;
}
PortNumber[] ports1 = { PortNumber.portNumber(31), PortNumber.portNumber(32) };
PortNumber[] ports2 = { PortNumber.portNumber(41), PortNumber.portNumber(42) };
GroupId gId1 = new GroupId(1);
Group group1 = createSouthboundGroupEntry(gId1, Arrays.asList(ports1), 0, deviceId);
GroupId gId2 = new GroupId(2);
Group group2 = createSouthboundGroupEntry(gId2, Arrays.asList(ports2), 0, deviceId);
List<Group> groupEntries = Arrays.asList(group1, group2);
providerService.pushGroupMetrics(deviceId, groupEntries);
GroupKey key = new DefaultGroupKey("group1BeforeAudit".getBytes());
Group createdGroup = groupManager.getGroup(deviceId, key);
List<GroupOperation> expectedGroupOps = Arrays.asList(GroupOperation.createDeleteGroupOperation(gId1, Group.Type.SELECT), GroupOperation.createDeleteGroupOperation(gId2, Group.Type.SELECT), GroupOperation.createAddGroupOperation(createdGroup.id(), Group.Type.SELECT, createdGroup.buckets()));
if (deviceId.equals(VDID1)) {
provider.validate(networkId, deviceId, expectedGroupOps);
}
}
use of org.onosproject.core.GroupId in project onos by opennetworkinglab.
the class SimpleVirtualGroupStore method addOrUpdateExtraneousGroupEntry.
@Override
public void addOrUpdateExtraneousGroupEntry(NetworkId networkId, Group group) {
ConcurrentMap<GroupId, Group> extraneousIdTable = getExtraneousGroupIdTable(networkId, group.deviceId());
extraneousIdTable.put(group.id(), group);
// Check the reference counter
if (group.referenceCount() == 0) {
notifyDelegate(networkId, new GroupEvent(GroupEvent.Type.GROUP_REMOVE_REQUESTED, group));
}
}
Aggregations