本文整理汇总了Java中org.onosproject.net.intent.PathIntent类的典型用法代码示例。如果您正苦于以下问题:Java PathIntent类的具体用法?Java PathIntent怎么用?Java PathIntent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PathIntent类属于org.onosproject.net.intent包,在下文中一共展示了PathIntent类的33个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: isIntentRelevant
点赞 3
import org.onosproject.net.intent.PathIntent; //导入依赖的package包/类
private boolean isIntentRelevant(OpticalConnectivityIntent opticalIntent,
Iterable<Intent> intents) {
Link ccSrc = getFirstLink(opticalIntent.getSrc(), false);
Link ccDst = getFirstLink(opticalIntent.getDst(), true);
if (ccSrc == null || ccDst == null) {
return false;
}
for (Intent intent : intents) {
List<Intent> installables = intentService.getInstallableIntents(intent.key());
for (Intent installable : installables) {
if (installable instanceof PathIntent) {
List<Link> links = ((PathIntent) installable).path().links();
if (links.size() == 3) {
Link tunnel = links.get(1);
if (Objects.equals(tunnel.src(), ccSrc.src()) &&
Objects.equals(tunnel.dst(), ccDst.dst())) {
return true;
}
}
}
}
}
return false;
}
开发者ID:shlee89,
项目名称:athena,
代码行数:26,
代码来源:TopoIntentFilter.java
示例2: setUp
点赞 3
import org.onosproject.net.intent.PathIntent; //导入依赖的package包/类
@Before
public void setUp() {
processor = createMock(IntentProcessor.class);
version = createMock(Timestamp.class);
idGenerator = new MockIdGenerator();
Intent.bindIdGenerator(idGenerator);
// Intent creation should be placed after binding an ID generator
input = PointToPointIntent.builder()
.appId(appId)
.selector(selector)
.treatment(treatment)
.ingressPoint(cp1)
.egressPoint(cp3)
.build();
compiled = PathIntent.builder()
.appId(appId)
.selector(selector)
.treatment(treatment)
.path(path)
.build();
}
开发者ID:shlee89,
项目名称:athena,
代码行数:25,
代码来源:CompilingTest.java
示例3: classifyLinkTraffic
点赞 3
import org.onosproject.net.intent.PathIntent; //导入依赖的package包/类
private Map<LinkKey, BiLink> classifyLinkTraffic(TrafficClass... trafficClasses) {
Map<LinkKey, BiLink> biLinks = new HashMap<>();
for (TrafficClass trafficClass : trafficClasses) {
for (Intent intent : trafficClass.intents) {
boolean isOptical = intent instanceof OpticalConnectivityIntent;
List<Intent> installables = intentService.getInstallableIntents(intent.key());
if (installables != null) {
for (Intent installable : installables) {
String type = isOptical ? trafficClass.type + " optical" : trafficClass.type;
if (installable instanceof PathIntent) {
classifyLinks(type, biLinks, trafficClass.showTraffic,
((PathIntent) installable).path().links());
} else if (installable instanceof LinkCollectionIntent) {
classifyLinks(type, biLinks, trafficClass.showTraffic,
((LinkCollectionIntent) installable).links());
} else if (installable instanceof OpticalPathIntent) {
classifyLinks(type, biLinks, trafficClass.showTraffic,
((OpticalPathIntent) installable).path().links());
}
}
}
}
}
return biLinks;
}
开发者ID:ravikumaran2015,
项目名称:ravikumaran201504,
代码行数:26,
代码来源:TopologyViewMessages.java
示例4: isIntentRelevantToDevice
点赞 3
import org.onosproject.net.intent.PathIntent; //导入依赖的package包/类
private boolean isIntentRelevantToDevice(List<Intent> installables, Device device) {
if (installables != null) {
for (Intent installable : installables) {
if (installable instanceof PathIntent) {
PathIntent pathIntent = (PathIntent) installable;
if (pathContainsDevice(pathIntent.path().links(), device.id())) {
return true;
}
} else if (installable instanceof LinkCollectionIntent) {
LinkCollectionIntent linksIntent = (LinkCollectionIntent) installable;
if (pathContainsDevice(linksIntent.links(), device.id())) {
return true;
}
}
}
}
return false;
}
开发者ID:ravikumaran2015,
项目名称:ravikumaran201504,
代码行数:19,
代码来源:TopologyViewIntentFilter.java
示例5: isIntentRelevant
点赞 3
import org.onosproject.net.intent.PathIntent; //导入依赖的package包/类
private boolean isIntentRelevant(OpticalConnectivityIntent opticalIntent,
Iterable<Intent> intents) {
Link ccSrc = getFirstLink(opticalIntent.getSrc(), false);
Link ccDst = getFirstLink(opticalIntent.getDst(), true);
for (Intent intent : intents) {
List<Intent> installables = intentService.getInstallableIntents(intent.key());
for (Intent installable : installables) {
if (installable instanceof PathIntent) {
List<Link> links = ((PathIntent) installable).path().links();
if (links.size() == 3) {
Link tunnel = links.get(1);
if (tunnel.src().equals(ccSrc.src()) &&
tunnel.dst().equals(ccDst.dst())) {
return true;
}
}
}
}
}
return false;
}
开发者ID:ravikumaran2015,
项目名称:ravikumaran201504,
代码行数:23,
代码来源:TopologyViewIntentFilter.java
示例6: compile
点赞 3
import org.onosproject.net.intent.PathIntent; //导入依赖的package包/类
@Override
public List<Intent> compile(PathIntent intent, List<Intent> installable,
Set<LinkResourceAllocations> resources) {
// Note: right now recompile is not considered
// TODO: implement recompile behavior
List<Link> links = intent.path().links();
List<FlowRule> rules = new ArrayList<>(links.size() - 1);
for (int i = 0; i < links.size() - 1; i++) {
ConnectPoint ingress = links.get(i).dst();
ConnectPoint egress = links.get(i + 1).src();
FlowRule rule = createFlowRule(intent.selector(), intent.treatment(), ingress, egress, isLast(links, i));
rules.add(rule);
}
return Arrays.asList(new FlowRuleIntent(appId, null, rules, intent.resources()));
}
开发者ID:ravikumaran2015,
项目名称:ravikumaran201504,
代码行数:19,
代码来源:PathIntentCompiler.java
示例7: setUp
点赞 3
import org.onosproject.net.intent.PathIntent; //导入依赖的package包/类
/**
* Configures objects used in all the test cases.
*/
@Before
public void setUp() {
sut = new PathIntentCompiler();
coreService = createMock(CoreService.class);
expect(coreService.registerApplication("org.onosproject.net.intent"))
.andReturn(appId);
sut.coreService = coreService;
Intent.bindIdGenerator(idGenerator);
intent = PathIntent.builder()
.appId(APP_ID)
.selector(selector)
.treatment(treatment)
.path(new DefaultPath(pid, links, hops))
.build();
intentExtensionService = createMock(IntentExtensionService.class);
intentExtensionService.registerCompiler(PathIntent.class, sut);
intentExtensionService.unregisterCompiler(PathIntent.class);
sut.intentManager = intentExtensionService;
replay(coreService, intentExtensionService);
}
开发者ID:ravikumaran2015,
项目名称:ravikumaran201504,
代码行数:27,
代码来源:PathIntentCompilerTest.java
示例8: compile
点赞 3
import org.onosproject.net.intent.PathIntent; //导入依赖的package包/类
@Override
public List<Intent> compile(OpticalPathIntent intent, List<Intent> installable) {
log.debug("Compiling optical path intent between {} and {}", intent.src(), intent.dst());
// Create rules for forward and reverse path
List<FlowRule> rules = createRules(intent);
if (intent.isBidirectional()) {
rules.addAll(createReverseRules(intent));
}
return Collections.singletonList(
new FlowRuleIntent(appId,
intent.key(),
rules,
intent.resources(),
PathIntent.ProtectionType.PRIMARY,
intent.resourceGroup()
)
);
}
开发者ID:opennetworkinglab,
项目名称:onos,
代码行数:21,
代码来源:OpticalPathIntentCompiler.java
示例9: createFlowRule
点赞 3
import org.onosproject.net.intent.PathIntent; //导入依赖的package包/类
private FlowRuleIntent createFlowRule(OpticalCircuitIntent higherIntent,
OpticalConnectivityIntent lowerIntent, Set<TributarySlot> slots) {
// Create optical circuit intent
List<FlowRule> rules = new LinkedList<>();
// at the source: ODUCLT port mapping to OCH port
rules.add(connectPorts(higherIntent.getSrc(), lowerIntent.getSrc(), higherIntent.priority(), slots));
// at the destination: OCH port mapping to ODUCLT port
rules.add(connectPorts(lowerIntent.getDst(), higherIntent.getDst(), higherIntent.priority(), slots));
// Create flow rules for reverse path
if (higherIntent.isBidirectional()) {
// at the destination: OCH port mapping to ODUCLT port
rules.add(connectPorts(lowerIntent.getSrc(), higherIntent.getSrc(), higherIntent.priority(), slots));
// at the source: ODUCLT port mapping to OCH port
rules.add(connectPorts(higherIntent.getDst(), lowerIntent.getDst(), higherIntent.priority(), slots));
}
return new FlowRuleIntent(appId, higherIntent.key(), rules,
higherIntent.resources(),
PathIntent.ProtectionType.PRIMARY,
higherIntent.resourceGroup());
}
开发者ID:opennetworkinglab,
项目名称:onos,
代码行数:23,
代码来源:OpticalCircuitIntentCompiler.java
示例10: compile
点赞 3
import org.onosproject.net.intent.PathIntent; //导入依赖的package包/类
@Override
public List<Intent> compile(PathIntent intent, List<Intent> installable) {
List<FlowRule> rules = new LinkedList<>();
List<DeviceId> devices = new LinkedList<>();
compile(this, intent, rules, devices);
return ImmutableList.of(new FlowRuleIntent(appId,
intent.key(),
rules,
intent.resources(),
intent.type(),
intent.resourceGroup()
));
}
开发者ID:opennetworkinglab,
项目名称:onos,
代码行数:17,
代码来源:PathIntentCompiler.java
示例11: createUnprotectedIntent
点赞 3
import org.onosproject.net.intent.PathIntent; //导入依赖的package包/类
/**
* Creates an unprotected intent.
* @param ingressPoint the ingress connect point
* @param egressPoint the egress connect point
* @param intent the original intent
* @return the compilation result
* @deprecated 1.10.0
*/
@Deprecated
private List<Intent> createUnprotectedIntent(ConnectPoint ingressPoint,
ConnectPoint egressPoint,
PointToPointIntent intent) {
List<Link> links = new ArrayList<>();
Path path = getPathOrException(intent, ingressPoint.deviceId(),
egressPoint.deviceId());
links.add(createEdgeLink(ingressPoint, true));
links.addAll(path.links());
links.add(createEdgeLink(egressPoint, false));
return asList(createPathIntent(new DefaultPath(PID, links, path.cost(),
path.annotations()), intent,
PathIntent.ProtectionType.PRIMARY));
}
开发者ID:opennetworkinglab,
项目名称:onos,
代码行数:25,
代码来源:PointToPointIntentCompiler.java
示例12: createPathIntent
点赞 3
import org.onosproject.net.intent.PathIntent; //导入依赖的package包/类
/**
* Creates a path intent from the specified path and original
* connectivity intent.
*
* @param path path to create an intent for
* @param intent original intent
* @param type primary or backup
*/
private Intent createPathIntent(Path path,
PointToPointIntent intent,
PathIntent.ProtectionType type) {
return PathIntent.builder()
.appId(intent.appId())
.key(intent.key())
.selector(intent.selector())
.treatment(intent.treatment())
.path(path)
.constraints(intent.constraints())
.priority(intent.priority())
.setType(type)
.resourceGroup(intent.resourceGroup())
.build();
}
开发者ID:opennetworkinglab,
项目名称:onos,
代码行数:24,
代码来源:PointToPointIntentCompiler.java
示例13: setUp
点赞 3
import org.onosproject.net.intent.PathIntent; //导入依赖的package包/类
@Before
public void setUp() {
super.setUp();
processor = createMock(IntentProcessor.class);
version = createMock(Timestamp.class);
// Intent creation should be placed after binding an ID generator
input = PointToPointIntent.builder()
.appId(appId)
.selector(selector)
.treatment(treatment)
.ingressPoint(cp1)
.egressPoint(cp3)
.build();
compiled = PathIntent.builder()
.appId(appId)
.selector(selector)
.treatment(treatment)
.path(path)
.build();
}
开发者ID:opennetworkinglab,
项目名称:onos,
代码行数:23,
代码来源:CompilingTest.java
示例14: formatDetails
点赞 2
import org.onosproject.net.intent.PathIntent; //导入依赖的package包/类
private StringBuilder formatDetails(Intent intent, StringBuilder sb) {
if (intent instanceof ConnectivityIntent) {
buildConnectivityDetails((ConnectivityIntent) intent, sb);
}
if (intent instanceof HostToHostIntent) {
buildHostToHostDetails((HostToHostIntent) intent, sb);
} else if (intent instanceof PointToPointIntent) {
buildPointToPointDetails((PointToPointIntent) intent, sb);
} else if (intent instanceof MultiPointToSinglePointIntent) {
buildMPToSPDetails((MultiPointToSinglePointIntent) intent, sb);
} else if (intent instanceof SinglePointToMultiPointIntent) {
buildSPToMPDetails((SinglePointToMultiPointIntent) intent, sb);
} else if (intent instanceof PathIntent) {
buildPathDetails((PathIntent) intent, sb);
} else if (intent instanceof LinkCollectionIntent) {
buildLinkConnectionDetails((LinkCollectionIntent) intent, sb);
}
if (sb.length() == 0) {
sb.append("(No details for this intent)");
} else {
sb.insert(0, "Details: ");
}
return sb;
}
开发者ID:shlee89,
项目名称:athena,
代码行数:32,
代码来源:IntentViewMessageHandler.java
示例15: createTrafficLinks
点赞 2
import org.onosproject.net.intent.PathIntent; //导入依赖的package包/类
private void createTrafficLinks(Highlights highlights,
TrafficLinkMap linkMap, Set<Intent> intents,
Flavor flavor, boolean showTraffic) {
for (Intent intent : intents) {
List<Intent> installables = servicesBundle.intentService()
.getInstallableIntents(intent.key());
Iterable<Link> links = null;
if (installables != null) {
for (Intent installable : installables) {
if (installable instanceof PathIntent) {
links = ((PathIntent) installable).path().links();
} else if (installable instanceof FlowRuleIntent) {
links = linkResources(installable);
} else if (installable instanceof FlowObjectiveIntent) {
links = linkResources(installable);
} else if (installable instanceof LinkCollectionIntent) {
links = ((LinkCollectionIntent) installable).links();
} else if (installable instanceof OpticalPathIntent) {
links = ((OpticalPathIntent) installable).path().links();
}
boolean isOptical = intent instanceof OpticalConnectivityIntent;
processLinks(linkMap, links, flavor, isOptical, showTraffic);
updateHighlights(highlights, links);
}
}
}
}
开发者ID:shlee89,
项目名称:athena,
代码行数:30,
代码来源:TrafficMonitor.java
示例16: isIntentRelevantToDevice
点赞 2
import org.onosproject.net.intent.PathIntent; //导入依赖的package包/类
private boolean isIntentRelevantToDevice(List<Intent> installables, Device device) {
if (installables != null) {
for (Intent installable : installables) {
if (installable instanceof PathIntent) {
PathIntent pathIntent = (PathIntent) installable;
if (pathContainsDevice(pathIntent.path().links(), device.id())) {
return true;
}
} else if (installable instanceof FlowRuleIntent) {
FlowRuleIntent flowRuleIntent = (FlowRuleIntent) installable;
if (rulesContainDevice(flowRuleIntent.flowRules(), device.id())) {
return true;
}
} else if (installable instanceof FlowObjectiveIntent) {
FlowObjectiveIntent objectiveIntent = (FlowObjectiveIntent) installable;
return objectiveIntent.devices().contains(device.id());
} else if (installable instanceof LinkCollectionIntent) {
LinkCollectionIntent linksIntent = (LinkCollectionIntent) installable;
if (pathContainsDevice(linksIntent.links(), device.id())) {
return true;
}
}
}
}
return false;
}
开发者ID:shlee89,
项目名称:athena,
代码行数:28,
代码来源:TopoIntentFilter.java
示例17: createPathIntent
点赞 2
import org.onosproject.net.intent.PathIntent; //导入依赖的package包/类
/**
* Creates a path intent from the specified path and original
* connectivity intent.
*
* @param path path to create an intent for
* @param intent original intent
*/
private Intent createPathIntent(Path path,
PointToPointIntent intent) {
return PathIntent.builder()
.appId(intent.appId())
.selector(intent.selector())
.treatment(intent.treatment())
.path(path)
.constraints(intent.constraints())
.priority(intent.priority())
.build();
}
开发者ID:shlee89,
项目名称:athena,
代码行数:19,
代码来源:PointToPointIntentCompiler.java
示例18: createPathIntent
点赞 2
import org.onosproject.net.intent.PathIntent; //导入依赖的package包/类
private Intent createPathIntent(Path path, Host src, Host dst,
HostToHostIntent intent) {
TrafficSelector selector = builder(intent.selector())
.matchEthSrc(src.mac()).matchEthDst(dst.mac()).build();
return PathIntent.builder()
.appId(intent.appId())
.selector(selector)
.treatment(intent.treatment())
.path(path)
.constraints(intent.constraints())
.priority(intent.priority())
.build();
}
开发者ID:shlee89,
项目名称:athena,
代码行数:14,
代码来源:HostToHostIntentCompiler.java
示例19: compile
点赞 2
import org.onosproject.net.intent.PathIntent; //导入依赖的package包/类
@Override
public List<Intent> compile(PathIntent intent, List<Intent> installable) {
List<Objective> objectives = new LinkedList<>();
List<DeviceId> devices = new LinkedList<>();
compile(this, intent, objectives, devices);
return ImmutableList.of(new FlowObjectiveIntent(appId, devices, objectives, intent.resources()));
}
开发者ID:shlee89,
项目名称:athena,
代码行数:10,
代码来源:PathIntentFlowObjectiveCompiler.java
示例20: assignVlanId
点赞 2
import org.onosproject.net.intent.PathIntent; //导入依赖的package包/类
private Map<LinkKey, VlanId> assignVlanId(PathCompilerCreateFlow creator, PathIntent intent) {
Set<LinkKey> linkRequest =
Sets.newHashSetWithExpectedSize(intent.path()
.links().size() - 2);
for (int i = 1; i <= intent.path().links().size() - 2; i++) {
LinkKey link = linkKey(intent.path().links().get(i));
linkRequest.add(link);
// add the inverse link. I want that the VLANID is reserved both for
// the direct and inverse link
linkRequest.add(linkKey(link.dst(), link.src()));
}
Map<LinkKey, VlanId> vlanIds = findVlanIds(creator, linkRequest);
if (vlanIds.isEmpty()) {
creator.log().warn("No VLAN IDs available");
return Collections.emptyMap();
}
//same VLANID is used for both directions
Set<Resource> resources = vlanIds.entrySet().stream()
.flatMap(x -> Stream.of(
Resources.discrete(x.getKey().src().deviceId(), x.getKey().src().port(), x.getValue())
.resource(),
Resources.discrete(x.getKey().dst().deviceId(), x.getKey().dst().port(), x.getValue())
.resource()
))
.collect(Collectors.toSet());
List<ResourceAllocation> allocations =
creator.resourceService().allocate(intent.id(), ImmutableList.copyOf(resources));
if (allocations.isEmpty()) {
return Collections.emptyMap();
}
return vlanIds;
}
开发者ID:shlee89,
项目名称:athena,
代码行数:36,
代码来源:PathCompiler.java
示例21: assignMplsLabel
点赞 2
import org.onosproject.net.intent.PathIntent; //导入依赖的package包/类
private Map<LinkKey, MplsLabel> assignMplsLabel(PathCompilerCreateFlow creator, PathIntent intent) {
Set<LinkKey> linkRequest =
Sets.newHashSetWithExpectedSize(intent.path()
.links().size() - 2);
for (int i = 1; i <= intent.path().links().size() - 2; i++) {
LinkKey link = linkKey(intent.path().links().get(i));
linkRequest.add(link);
// add the inverse link. I want that the VLANID is reserved both for
// the direct and inverse link
linkRequest.add(linkKey(link.dst(), link.src()));
}
Map<LinkKey, MplsLabel> labels = findMplsLabels(creator, linkRequest);
if (labels.isEmpty()) {
throw new IntentCompilationException("No available MPLS Label");
}
// for short term solution: same label is used for both directions
// TODO: introduce the concept of Tx and Rx resources of a port
Set<Resource> resources = labels.entrySet().stream()
.flatMap(x -> Stream.of(
Resources.discrete(x.getKey().src().deviceId(), x.getKey().src().port(), x.getValue())
.resource(),
Resources.discrete(x.getKey().dst().deviceId(), x.getKey().dst().port(), x.getValue())
.resource()
))
.collect(Collectors.toSet());
List<ResourceAllocation> allocations =
creator.resourceService().allocate(intent.id(), ImmutableList.copyOf(resources));
if (allocations.isEmpty()) {
return Collections.emptyMap();
}
return labels;
}
开发者ID:shlee89,
项目名称:athena,
代码行数:36,
代码来源:PathCompiler.java
示例22: compile
点赞 2
import org.onosproject.net.intent.PathIntent; //导入依赖的package包/类
/**
* Compiles an intent down to flows.
*
* @param creator how to create the flows
* @param intent intent to process
* @param flows list of generated flows
* @param devices list of devices that correspond to the flows
*/
public void compile(PathCompilerCreateFlow<T> creator,
PathIntent intent,
List<T> flows,
List<DeviceId> devices) {
// Note: right now recompile is not considered
// TODO: implement recompile behavior
List<Link> links = intent.path().links();
Optional<EncapsulationConstraint> encapConstraint = intent.constraints().stream()
.filter(constraint -> constraint instanceof EncapsulationConstraint)
.map(x -> (EncapsulationConstraint) x).findAny();
//if no encapsulation or is involved only a single switch use the default behaviour
if (!encapConstraint.isPresent() || links.size() == 1) {
for (int i = 0; i < links.size() - 1; i++) {
ConnectPoint ingress = links.get(i).dst();
ConnectPoint egress = links.get(i + 1).src();
creator.createFlow(intent.selector(), intent.treatment(),
ingress, egress, intent.priority(),
isLast(links, i), flows, devices);
}
}
encapConstraint.map(EncapsulationConstraint::encapType)
.map(type -> {
switch (type) {
case VLAN:
manageVlanEncap(creator, flows, devices, intent);
break;
case MPLS:
manageMplsEncap(creator, flows, devices, intent);
break;
default:
// Nothing to do
}
return 0;
});
}
开发者ID:shlee89,
项目名称:athena,
代码行数:47,
代码来源:PathCompiler.java
示例23: testForwardPathCompilation
点赞 2
import org.onosproject.net.intent.PathIntent; //导入依赖的package包/类
/**
* Tests a pair of devices in an 8 hop path, forward direction.
*/
@Test
public void testForwardPathCompilation() {
PointToPointIntent intent = makeIntent("d1", "d8");
String[] hops = {"d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8"};
PointToPointIntentCompiler compiler = makeCompiler(hops);
List<Intent> result = compiler.compile(intent, null);
assertThat(result, is(Matchers.notNullValue()));
assertThat(result, hasSize(1));
Intent forwardResultIntent = result.get(0);
assertThat(forwardResultIntent instanceof PathIntent, is(true));
if (forwardResultIntent instanceof PathIntent) {
PathIntent forwardPathIntent = (PathIntent) forwardResultIntent;
// 7 links for the hops, plus one default lnk on ingress and egress
assertThat(forwardPathIntent.path().links(), hasSize(hops.length + 1));
assertThat(forwardPathIntent.path().links(), linksHasPath("d1", "d2"));
assertThat(forwardPathIntent.path().links(), linksHasPath("d2", "d3"));
assertThat(forwardPathIntent.path().links(), linksHasPath("d3", "d4"));
assertThat(forwardPathIntent.path().links(), linksHasPath("d4", "d5"));
assertThat(forwardPathIntent.path().links(), linksHasPath("d5", "d6"));
assertThat(forwardPathIntent.path().links(), linksHasPath("d6", "d7"));
assertThat(forwardPathIntent.path().links(), linksHasPath("d7", "d8"));
}
}
开发者ID:shlee89,
项目名称:athena,
代码行数:31,
代码来源:PointToPointIntentCompilerTest.java
示例24: testReversePathCompilation
点赞 2
import org.onosproject.net.intent.PathIntent; //导入依赖的package包/类
/**
* Tests a pair of devices in an 8 hop path, forward direction.
*/
@Test
public void testReversePathCompilation() {
PointToPointIntent intent = makeIntent("d8", "d1");
String[] hops = {"d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8"};
PointToPointIntentCompiler compiler = makeCompiler(hops);
List<Intent> result = compiler.compile(intent, null);
assertThat(result, is(Matchers.notNullValue()));
assertThat(result, hasSize(1));
Intent reverseResultIntent = result.get(0);
assertThat(reverseResultIntent instanceof PathIntent, is(true));
if (reverseResultIntent instanceof PathIntent) {
PathIntent reversePathIntent = (PathIntent) reverseResultIntent;
assertThat(reversePathIntent.path().links(), hasSize(hops.length + 1));
assertThat(reversePathIntent.path().links(), linksHasPath("d2", "d1"));
assertThat(reversePathIntent.path().links(), linksHasPath("d3", "d2"));
assertThat(reversePathIntent.path().links(), linksHasPath("d4", "d3"));
assertThat(reversePathIntent.path().links(), linksHasPath("d5", "d4"));
assertThat(reversePathIntent.path().links(), linksHasPath("d6", "d5"));
assertThat(reversePathIntent.path().links(), linksHasPath("d7", "d6"));
assertThat(reversePathIntent.path().links(), linksHasPath("d8", "d7"));
}
}
开发者ID:shlee89,
项目名称:athena,
代码行数:30,
代码来源:PointToPointIntentCompilerTest.java
示例25: testSameSwitchDifferentPortsIntentCompilation
点赞 2
import org.onosproject.net.intent.PathIntent; //导入依赖的package包/类
/**
* Tests compilation of the intent which designates two different ports on the same switch.
*/
@Test
public void testSameSwitchDifferentPortsIntentCompilation() {
ConnectPoint src = new ConnectPoint(deviceId("1"), portNumber(1));
ConnectPoint dst = new ConnectPoint(deviceId("1"), portNumber(2));
PointToPointIntent intent = PointToPointIntent.builder()
.appId(APP_ID)
.selector(selector)
.treatment(treatment)
.ingressPoint(src)
.egressPoint(dst)
.build();
String[] hops = {"1"};
PointToPointIntentCompiler sut = makeCompiler(hops);
List<Intent> compiled = sut.compile(intent, null);
assertThat(compiled, hasSize(1));
assertThat(compiled.get(0), is(instanceOf(PathIntent.class)));
Path path = ((PathIntent) compiled.get(0)).path();
assertThat(path.links(), hasSize(2));
Link firstLink = path.links().get(0);
assertThat(firstLink, is(createEdgeLink(src, true)));
Link secondLink = path.links().get(1);
assertThat(secondLink, is(createEdgeLink(dst, false)));
}
开发者ID:shlee89,
项目名称:athena,
代码行数:31,
代码来源:PointToPointIntentCompilerTest.java
示例26: formatDetails
点赞 2
import org.onosproject.net.intent.PathIntent; //导入依赖的package包/类
private String formatDetails(Intent intent) {
if (intent instanceof ConnectivityIntent) {
buildConnectivityDetails((ConnectivityIntent) intent);
}
if (intent instanceof HostToHostIntent) {
buildHostToHostDetails((HostToHostIntent) intent);
} else if (intent instanceof PointToPointIntent) {
buildPointToPointDetails((PointToPointIntent) intent);
} else if (intent instanceof MultiPointToSinglePointIntent) {
buildMPToSPDetails((MultiPointToSinglePointIntent) intent);
} else if (intent instanceof SinglePointToMultiPointIntent) {
buildSPToMPDetails((SinglePointToMultiPointIntent) intent);
} else if (intent instanceof PathIntent) {
buildPathDetails((PathIntent) intent);
} else if (intent instanceof LinkCollectionIntent) {
buildLinkConnectionDetails((LinkCollectionIntent) intent);
}
if (details.length() == 0) {
details.append("(No details for this intent)");
} else {
details.insert(0, "Details: ");
}
return details.toString();
}
开发者ID:ravikumaran2015,
项目名称:ravikumaran201504,
代码行数:32,
代码来源:IntentViewMessageHandler.java
示例27: testForwardPathCompilation
点赞 2
import org.onosproject.net.intent.PathIntent; //导入依赖的package包/类
/**
* Tests a pair of devices in an 8 hop path, forward direction.
*/
@Test
public void testForwardPathCompilation() {
PointToPointIntent intent = makeIntent("d1", "d8");
String[] hops = {"d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8"};
PointToPointIntentCompiler compiler = makeCompiler(hops);
List<Intent> result = compiler.compile(intent, null, null);
assertThat(result, is(Matchers.notNullValue()));
assertThat(result, hasSize(1));
Intent forwardResultIntent = result.get(0);
assertThat(forwardResultIntent instanceof PathIntent, is(true));
if (forwardResultIntent instanceof PathIntent) {
PathIntent forwardPathIntent = (PathIntent) forwardResultIntent;
// 7 links for the hops, plus one default lnk on ingress and egress
assertThat(forwardPathIntent.path().links(), hasSize(hops.length + 1));
assertThat(forwardPathIntent.path().links(), linksHasPath("d1", "d2"));
assertThat(forwardPathIntent.path().links(), linksHasPath("d2", "d3"));
assertThat(forwardPathIntent.path().links(), linksHasPath("d3", "d4"));
assertThat(forwardPathIntent.path().links(), linksHasPath("d4", "d5"));
assertThat(forwardPathIntent.path().links(), linksHasPath("d5", "d6"));
assertThat(forwardPathIntent.path().links(), linksHasPath("d6", "d7"));
assertThat(forwardPathIntent.path().links(), linksHasPath("d7", "d8"));
}
}
开发者ID:ravikumaran2015,
项目名称:ravikumaran201504,
代码行数:31,
代码来源:PointToPointIntentCompilerTest.java
示例28: testReversePathCompilation
点赞 2
import org.onosproject.net.intent.PathIntent; //导入依赖的package包/类
/**
* Tests a pair of devices in an 8 hop path, forward direction.
*/
@Test
public void testReversePathCompilation() {
PointToPointIntent intent = makeIntent("d8", "d1");
String[] hops = {"d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8"};
PointToPointIntentCompiler compiler = makeCompiler(hops);
List<Intent> result = compiler.compile(intent, null, null);
assertThat(result, is(Matchers.notNullValue()));
assertThat(result, hasSize(1));
Intent reverseResultIntent = result.get(0);
assertThat(reverseResultIntent instanceof PathIntent, is(true));
if (reverseResultIntent instanceof PathIntent) {
PathIntent reversePathIntent = (PathIntent) reverseResultIntent;
assertThat(reversePathIntent.path().links(), hasSize(hops.length + 1));
assertThat(reversePathIntent.path().links(), linksHasPath("d2", "d1"));
assertThat(reversePathIntent.path().links(), linksHasPath("d3", "d2"));
assertThat(reversePathIntent.path().links(), linksHasPath("d4", "d3"));
assertThat(reversePathIntent.path().links(), linksHasPath("d5", "d4"));
assertThat(reversePathIntent.path().links(), linksHasPath("d6", "d5"));
assertThat(reversePathIntent.path().links(), linksHasPath("d7", "d6"));
assertThat(reversePathIntent.path().links(), linksHasPath("d8", "d7"));
}
}
开发者ID:ravikumaran2015,
项目名称:ravikumaran201504,
代码行数:30,
代码来源:PointToPointIntentCompilerTest.java
示例29: testSameSwitchDifferentPortsIntentCompilation
点赞 2
import org.onosproject.net.intent.PathIntent; //导入依赖的package包/类
/**
* Tests compilation of the intent which designates two different ports on the same switch.
*/
@Test
public void testSameSwitchDifferentPortsIntentCompilation() {
ConnectPoint src = new ConnectPoint(deviceId("1"), portNumber(1));
ConnectPoint dst = new ConnectPoint(deviceId("1"), portNumber(2));
PointToPointIntent intent = PointToPointIntent.builder()
.appId(APP_ID)
.selector(selector)
.treatment(treatment)
.ingressPoint(src)
.egressPoint(dst)
.build();
String[] hops = {"1"};
PointToPointIntentCompiler sut = makeCompiler(hops);
List<Intent> compiled = sut.compile(intent, null, null);
assertThat(compiled, hasSize(1));
assertThat(compiled.get(0), is(instanceOf(PathIntent.class)));
Path path = ((PathIntent) compiled.get(0)).path();
assertThat(path.links(), hasSize(2));
Link firstLink = path.links().get(0);
assertThat(firstLink, is(createEdgeLink(src, true)));
Link secondLink = path.links().get(1);
assertThat(secondLink, is(createEdgeLink(dst, false)));
}
开发者ID:ravikumaran2015,
项目名称:ravikumaran201504,
代码行数:31,
代码来源:PointToPointIntentCompilerTest.java
示例30: isIntentRelevantToLink
点赞 2
import org.onosproject.net.intent.PathIntent; //导入依赖的package包/类
private boolean isIntentRelevantToLink(List<Intent> installables, Link link) {
Link reverseLink = linkService.getLink(link.dst(), link.src());
if (installables != null) {
for (Intent installable : installables) {
if (installable instanceof PathIntent) {
PathIntent pathIntent = (PathIntent) installable;
return pathIntent.path().links().contains(link) ||
pathIntent.path().links().contains(reverseLink);
} else if (installable instanceof FlowRuleIntent) {
FlowRuleIntent flowRuleIntent = (FlowRuleIntent) installable;
return flowRuleIntent.resources().contains(link) ||
flowRuleIntent.resources().contains(reverseLink);
} else if (installable instanceof FlowObjectiveIntent) {
FlowObjectiveIntent objectiveIntent = (FlowObjectiveIntent) installable;
return objectiveIntent.resources().contains(link) ||
objectiveIntent.resources().contains(reverseLink);
} else if (installable instanceof LinkCollectionIntent) {
LinkCollectionIntent linksIntent = (LinkCollectionIntent) installable;
return linksIntent.links().contains(link) ||
linksIntent.links().contains(reverseLink);
}
}
}
return false;
}
开发者ID:opennetworkinglab,
项目名称:onos,
代码行数:31,
代码来源:TopoIntentFilter.java
示例31: createZeroHopIntent
点赞 2
import org.onosproject.net.intent.PathIntent; //导入依赖的package包/类
private List<Intent> createZeroHopIntent(ConnectPoint ingressPoint,
ConnectPoint egressPoint,
PointToPointIntent intent) {
List<Link> links = asList(createEdgeLink(ingressPoint, true), createEdgeLink(egressPoint, false));
return asList(createPathIntent(new DefaultPath(PID, links, DEFAULT_COST),
intent, PathIntent.ProtectionType.PRIMARY));
}
开发者ID:opennetworkinglab,
项目名称:onos,
代码行数:8,
代码来源:PointToPointIntentCompiler.java
示例32: setPathsToRemove
点赞 2
import org.onosproject.net.intent.PathIntent; //导入依赖的package包/类
/**
* Sets instance variables erasePrimary and eraseBackup. If erasePrimary,
* the primary path is no longer viable and related intents will be deleted.
* If eraseBackup, the backup path is no longer viable and related intents
* will be deleted.
*
* @param intent intent whose resources are found to be disabled/inactive:
* if intent is part of primary path, primary path set for removal;
* if intent is part of backup path, backup path set for removal;
* if bad intent is of type failover, the ingress point is down,
* and both paths are rendered inactive.
* @return true if both primary and backup paths are to be removed
*/
private boolean setPathsToRemove(Intent intent) {
if (intent instanceof FlowRuleIntent) {
FlowRuleIntent frIntent = (FlowRuleIntent) intent;
PathIntent.ProtectionType type = frIntent.type();
if (type == PathIntent.ProtectionType.PRIMARY || type == PathIntent.ProtectionType.FAILOVER) {
erasePrimary = true;
}
if (type == PathIntent.ProtectionType.BACKUP || type == PathIntent.ProtectionType.FAILOVER) {
eraseBackup = true;
}
}
return erasePrimary && eraseBackup;
}
开发者ID:opennetworkinglab,
项目名称:onos,
代码行数:27,
代码来源:PointToPointIntentCompiler.java
示例33: removeAndUpdateIntents
点赞 2
import org.onosproject.net.intent.PathIntent; //导入依赖的package包/类
/**
* Removes intents from installables list, depending on the values
* of instance variables erasePrimary and eraseBackup. Flow rule intents
* that contain the manufactured fast failover flow rules are never deleted.
* The contents are simply modified as necessary. If cleanUpIntents size
* is greater than 1 (failover intent), then one whole path from previous
* installables must be still viable.
*
* @param cleanUpIntents list of installable intents
*/
private void removeAndUpdateIntents(List<Intent> cleanUpIntents,
PointToPointIntent pointIntent) {
ListIterator<Intent> iterator = cleanUpIntents.listIterator();
while (iterator.hasNext()) {
Intent cIntent = iterator.next();
if (cIntent instanceof FlowRuleIntent) {
FlowRuleIntent fIntent = (FlowRuleIntent) cIntent;
if (fIntent.type() == PathIntent.ProtectionType.PRIMARY && erasePrimary) {
// remove primary path's flow rule intents
iterator.remove();
} else if (fIntent.type() == PathIntent.ProtectionType.BACKUP && eraseBackup) {
//remove backup path's flow rule intents
iterator.remove();
} else if (fIntent.type() == PathIntent.ProtectionType.BACKUP && erasePrimary) {
// promote backup path's flow rule intents to primary
iterator.set(new FlowRuleIntent(fIntent, PathIntent.ProtectionType.PRIMARY));
}
}
}
// remove buckets whose watchports are disabled if the failover group exists
Group group = groupService.getGroup(pointIntent.filteredIngressPoint().connectPoint().deviceId(),
makeGroupKey(pointIntent.id()));
if (group != null) {
updateFailoverGroup(pointIntent);
}
}
开发者ID:opennetworkinglab,
项目名称:onos,
代码行数:37,
代码来源:PointToPointIntentCompiler.java