use of org.onosproject.net.Path in project onos by opennetworkinglab.
the class OpticalPathProvisioner method setupConnectivity.
/*
* Request packet-layer connectivity between specified ports,
* over packet-optical multi-layer infrastructure.
*
* Functionality-wise this is effectively submitting Packet-Optical
* multi-layer P2P Intent.
*
* It computes multi-layer path meeting specified constraint,
* and calls setupPath.
*/
@Override
public OpticalConnectivityId setupConnectivity(ConnectPoint ingress, ConnectPoint egress, Bandwidth bandwidth, Duration latency) {
checkNotNull(ingress);
checkNotNull(egress);
log.info("setupConnectivity({}, {}, {}, {})", ingress, egress, bandwidth, latency);
Bandwidth bw = (bandwidth == null) ? NO_BW_REQUIREMENT : bandwidth;
Stream<Path> paths = topologyService.getKShortestPaths(topologyService.currentTopology(), ingress.deviceId(), egress.deviceId(), new BandwidthLinkWeight(bandwidth));
// Path service calculates from node to node, we're only interested in port to port
Optional<OpticalConnectivityId> id = paths.filter(p -> p.src().equals(ingress) && p.dst().equals(egress)).limit(maxPaths).map(p -> setupPath(p, bw, latency)).filter(Objects::nonNull).findFirst();
if (id.isPresent()) {
log.info("Assigned OpticalConnectivityId: {}", id);
} else {
log.error("setupConnectivity({}, {}, {}, {}) failed.", ingress, egress, bandwidth, latency);
}
return id.orElse(null);
}
use of org.onosproject.net.Path in project onos by opennetworkinglab.
the class GnpyManager method obtainConnectivity.
@Override
public Pair<IntentId, Double> obtainConnectivity(ConnectPoint ingress, ConnectPoint egress, boolean bidirectional) {
ByteArrayOutputStream connectivityRequest = createGnpyRequest(ingress, egress, bidirectional);
String response = gnpyHttpUtil.post(null, "/gnpy-experimental", new ByteArrayInputStream(connectivityRequest.toByteArray()), MediaType.APPLICATION_JSON_TYPE, String.class);
ObjectMapper om = new ObjectMapper();
final ObjectReader reader = om.reader();
JsonNode jsonNode;
try {
jsonNode = reader.readTree(response);
if (jsonNode == null) {
log.error("JsonNode is null for response {}", response);
return null;
}
log.info("Response {}", response);
String bestPath;
try {
bestPath = getBestOsnrPathKey(jsonNode);
} catch (IllegalStateException e) {
log.error("Exception while contacting GNPy", e);
return null;
}
OchSignal ochSignal = createOchSignal(jsonNode);
Map<DeviceId, Double> deviceAtoBPowerMap = new HashMap<>();
Map<DeviceId, Double> deviceBtoAPowerMap = new HashMap<>();
// TODO this list is currently only populated in the forward direction
List<DeviceId> deviceIds = getDeviceAndPopulatePowerMap(jsonNode, deviceAtoBPowerMap, deviceBtoAPowerMap, bestPath);
Path suggestedPath = createSuggestedPath(deviceIds);
log.info("Suggested path {}", suggestedPath);
Intent intent = createOpticalIntent(ingress, egress, deviceService, null, appId, bidirectional, ochSignal, suggestedPath);
intentsPowerMap.put(intent.id(), new GnpyPowerInfo(deviceAtoBPowerMap, deviceBtoAPowerMap, getLaunchPower(jsonNode), suggestedPath.links(), ingress, egress, ochSignal));
intentService.submit(intent);
return Pair.of(intent.id(), getOsnr(jsonNode, bestPath));
} catch (IOException e) {
log.error("Exception while reading response {}", response, e);
return null;
}
}
use of org.onosproject.net.Path in project onos by opennetworkinglab.
the class GnpyManagerTest method testCreateSuggestedPath.
@Test
public void testCreateSuggestedPath() throws IOException {
Map<DeviceId, Double> deviceAtoBPowerMap = new HashMap<>();
Map<DeviceId, Double> deviceBtoAPowerMap = new HashMap<>();
List<DeviceId> deviceIds = manager.getDeviceAndPopulatePowerMap(reply, deviceAtoBPowerMap, deviceBtoAPowerMap, "second");
Path path = manager.createSuggestedPath(deviceIds);
assertTrue(path.links().contains(tx1rdm1Link));
assertTrue(path.links().contains(rmd1ln1Link));
assertTrue(path.links().contains(ln1ln2Link));
assertTrue(path.links().contains(ln2rdm2Link));
assertTrue(path.links().contains(tx2rmd2Link));
assertEquals(path.src(), tx2);
assertEquals(path.dst(), tx1);
}
use of org.onosproject.net.Path in project onos by opennetworkinglab.
the class ReactiveForwarding method fixBlackhole.
private void fixBlackhole(ConnectPoint egress) {
Set<FlowEntry> rules = getFlowRulesFrom(egress);
Set<SrcDstPair> pairs = findSrcDstPairs(rules);
Map<DeviceId, Set<Path>> srcPaths = new HashMap<>();
for (SrcDstPair sd : pairs) {
// get the edge deviceID for the src host
Host srcHost = hostService.getHost(HostId.hostId(sd.src));
Host dstHost = hostService.getHost(HostId.hostId(sd.dst));
if (srcHost != null && dstHost != null) {
DeviceId srcId = srcHost.location().deviceId();
DeviceId dstId = dstHost.location().deviceId();
log.trace("SRC ID is {}, DST ID is {}", srcId, dstId);
cleanFlowRules(sd, egress.deviceId());
Set<Path> shortestPaths = srcPaths.get(srcId);
if (shortestPaths == null) {
shortestPaths = topologyService.getPaths(topologyService.currentTopology(), egress.deviceId(), srcId);
srcPaths.put(srcId, shortestPaths);
}
backTrackBadNodes(shortestPaths, dstId, sd);
}
}
}
use of org.onosproject.net.Path in project onos by opennetworkinglab.
the class OpticalConnectivityIntentCompiler method findFirstAvailableLambda.
/**
* Find the first available lambda on the given path by checking all the port resources.
*
* @param path the path
* @return list of consecutive and available OChSignals
*/
private List<OchSignal> findFirstAvailableLambda(OpticalConnectivityIntent intent, Path path) {
if (intent.ochSignal().isPresent()) {
// create lambdas w.r.t. slotGanularity/slotWidth
OchSignal ochSignal = intent.ochSignal().get();
if (ochSignal.gridType() == GridType.FLEX) {
// multiplier sits in the middle of slots
int startMultiplier = ochSignal.spacingMultiplier() - (ochSignal.slotGranularity() / 2);
return IntStream.range(0, ochSignal.slotGranularity()).mapToObj(x -> OchSignal.newFlexGridSlot(startMultiplier + (2 * x))).collect(Collectors.toList());
} else if (ochSignal.gridType() == GridType.DWDM) {
int startMultiplier = (int) (1 - ochSignal.slotGranularity() + ochSignal.spacingMultiplier() * ochSignal.channelSpacing().frequency().asHz() / ChannelSpacing.CHL_6P25GHZ.frequency().asHz());
return IntStream.range(0, ochSignal.slotGranularity()).mapToObj(x -> OchSignal.newFlexGridSlot(startMultiplier + (2 * x))).collect(Collectors.toList());
}
// TODO: add support for other gridTypes
log.error("Grid type: {} not supported for user defined signal intents", ochSignal.gridType());
return Collections.emptyList();
}
Set<OchSignal> lambdas = findCommonLambdas(path);
if (lambdas.isEmpty()) {
return Collections.emptyList();
}
return findFirstLambda(lambdas, slotCount());
}
Aggregations