mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-21 12:22:18 +02:00
Handle exception when compiling fails
- Change arguments of the constructor of PathNotFoundException - Change the catched exception in Compiling.execute() Change-Id: I3b639ffd585900c2a6dd99aeeb313bf20c6104f4
This commit is contained in:
parent
37a24a887a
commit
877ec2c51f
@ -47,14 +47,9 @@ class Compiling implements IntentUpdate {
|
|||||||
List<Intent> installables = (current != null) ? current.installables() : null;
|
List<Intent> installables = (current != null) ? current.installables() : null;
|
||||||
pending.setInstallables(intentManager.compileIntent(pending.intent(), installables));
|
pending.setInstallables(intentManager.compileIntent(pending.intent(), installables));
|
||||||
return Optional.of(new InstallCoordinating(intentManager, pending, current));
|
return Optional.of(new InstallCoordinating(intentManager, pending, current));
|
||||||
} catch (PathNotFoundException e) {
|
|
||||||
log.debug("Path not found for intent {}", pending.intent());
|
|
||||||
// TODO: revisit to implement failure handling
|
|
||||||
return Optional.of(new CompilingFailed(pending)); //FIXME failed state transition
|
|
||||||
} catch (IntentException e) {
|
} catch (IntentException e) {
|
||||||
log.warn("Unable to compile intent {} due to:", pending.intent().id(), e);
|
log.debug("Unable to compile intent {} due to: {}", pending.intent(), e);
|
||||||
// TODO: revisit to implement failure handling
|
return Optional.of(new CompilingFailed(pending));
|
||||||
return Optional.of(new CompilingFailed(pending)); //FIXME failed state transition
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ public abstract class ConnectivityIntentCompiler<T extends ConnectivityIntent>
|
|||||||
}
|
}
|
||||||
}).toList();
|
}).toList();
|
||||||
if (filtered.isEmpty()) {
|
if (filtered.isEmpty()) {
|
||||||
throw new PathNotFoundException("No packet path from " + one + " to " + two);
|
throw new PathNotFoundException(one, two);
|
||||||
}
|
}
|
||||||
// TODO: let's be more intelligent about this eventually
|
// TODO: let's be more intelligent about this eventually
|
||||||
return filtered.iterator().next();
|
return filtered.iterator().next();
|
||||||
|
@ -101,7 +101,7 @@ public class MultiPointToSinglePointIntentCompiler
|
|||||||
private Path getPath(ConnectPoint one, ConnectPoint two) {
|
private Path getPath(ConnectPoint one, ConnectPoint two) {
|
||||||
Set<Path> paths = pathService.getPaths(one.deviceId(), two.deviceId());
|
Set<Path> paths = pathService.getPaths(one.deviceId(), two.deviceId());
|
||||||
if (paths.isEmpty()) {
|
if (paths.isEmpty()) {
|
||||||
throw new PathNotFoundException("No path from " + one + " to " + two);
|
throw new PathNotFoundException(one.elementId(), two.elementId());
|
||||||
}
|
}
|
||||||
// TODO: let's be more intelligent about this eventually
|
// TODO: let's be more intelligent about this eventually
|
||||||
return paths.iterator().next();
|
return paths.iterator().next();
|
||||||
|
@ -89,8 +89,7 @@ public class OpticalConnectivityIntentCompiler implements IntentCompiler<Optical
|
|||||||
Set<Path> paths = topologyService.getPaths(topology, start.deviceId(),
|
Set<Path> paths = topologyService.getPaths(topology, start.deviceId(),
|
||||||
end.deviceId(), weight);
|
end.deviceId(), weight);
|
||||||
if (paths.isEmpty()) {
|
if (paths.isEmpty()) {
|
||||||
throw new PathNotFoundException("No Optical path found from " +
|
throw new PathNotFoundException(start.elementId(), end.elementId());
|
||||||
start + " to " + end);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: let's be more intelligent about this eventually
|
// TODO: let's be more intelligent about this eventually
|
||||||
|
@ -15,23 +15,32 @@
|
|||||||
*/
|
*/
|
||||||
package org.onosproject.net.intent.impl;
|
package org.onosproject.net.intent.impl;
|
||||||
|
|
||||||
|
import com.google.common.base.MoreObjects;
|
||||||
|
import org.onosproject.net.ElementId;
|
||||||
import org.onosproject.net.intent.IntentException;
|
import org.onosproject.net.intent.IntentException;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An exception thrown when a path is not found.
|
* An exception thrown when a path is not found.
|
||||||
*/
|
*/
|
||||||
public class PathNotFoundException extends IntentException {
|
public class PathNotFoundException extends IntentException {
|
||||||
private static final long serialVersionUID = -2087045731049914733L;
|
private static final long serialVersionUID = -2087045731049914733L;
|
||||||
|
|
||||||
public PathNotFoundException() {
|
private final ElementId source;
|
||||||
super();
|
private final ElementId destination;
|
||||||
|
|
||||||
|
public PathNotFoundException(ElementId source, ElementId destination) {
|
||||||
|
super(String.format("No path from %s to %s", source, destination));
|
||||||
|
this.source = checkNotNull(source);
|
||||||
|
this.destination = checkNotNull(destination);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PathNotFoundException(String message) {
|
@Override
|
||||||
super(message);
|
public String toString() {
|
||||||
}
|
return MoreObjects.toStringHelper(this)
|
||||||
|
.add("source", source)
|
||||||
public PathNotFoundException(String message, Throwable cause) {
|
.add("destination", destination)
|
||||||
super(message, cause);
|
.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ public class PathConstraintCalculationTest extends AbstractIntentTest {
|
|||||||
fail("Point to Point compilation with insufficient bandwidth does "
|
fail("Point to Point compilation with insufficient bandwidth does "
|
||||||
+ "not throw exception.");
|
+ "not throw exception.");
|
||||||
} catch (PathNotFoundException noPath) {
|
} catch (PathNotFoundException noPath) {
|
||||||
assertThat(noPath.getMessage(), containsString("No packet path"));
|
assertThat(noPath.getMessage(), containsString("No path"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,7 +173,7 @@ public class PathConstraintCalculationTest extends AbstractIntentTest {
|
|||||||
fail("Point to Point compilation with no available lambda does "
|
fail("Point to Point compilation with no available lambda does "
|
||||||
+ "not throw exception.");
|
+ "not throw exception.");
|
||||||
} catch (PathNotFoundException noPath) {
|
} catch (PathNotFoundException noPath) {
|
||||||
assertThat(noPath.getMessage(), containsString("No packet path"));
|
assertThat(noPath.getMessage(), containsString("No path"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user