本文整理汇总了Java中org.onosproject.net.intent.MplsIntent类的典型用法代码示例。如果您正苦于以下问题:Java MplsIntent类的具体用法?Java MplsIntent怎么用?Java MplsIntent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MplsIntent类属于org.onosproject.net.intent包,在下文中一共展示了MplsIntent类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.onosproject.net.intent.MplsIntent; //导入依赖的package包/类
@Override
protected void execute() {
IntentService service = get(IntentService.class);
ConnectPoint ingress = ConnectPoint.deviceConnectPoint(ingressDeviceString);
Optional<MplsLabel> ingressLabel = Optional.empty();
if (!ingressLabelString.isEmpty()) {
ingressLabel = Optional
.ofNullable(MplsLabel.mplsLabel(parseInt(ingressLabelString)));
}
ConnectPoint egress = ConnectPoint.deviceConnectPoint(egressDeviceString);
Optional<MplsLabel> egressLabel = Optional.empty();
if (!egressLabelString.isEmpty()) {
egressLabel = Optional
.ofNullable(MplsLabel.mplsLabel(parseInt(egressLabelString)));
}
TrafficSelector selector = buildTrafficSelector();
TrafficTreatment treatment = buildTrafficTreatment();
List<Constraint> constraints = buildConstraints();
MplsIntent intent = MplsIntent.builder()
.appId(appId())
.selector(selector)
.treatment(treatment)
.ingressPoint(ingress)
.ingressLabel(ingressLabel)
.egressPoint(egress)
.egressLabel(egressLabel)
.constraints(constraints)
.priority(priority())
.build();
service.submit(intent);
}
示例2: createPathIntent
import org.onosproject.net.intent.MplsIntent; //导入依赖的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,
MplsIntent intent) {
return MplsPathIntent.builder()
.appId(intent.appId())
.selector(intent.selector())
.treatment(intent.treatment())
.path(path)
.ingressLabel(intent.ingressLabel())
.egressLabel(intent.egressLabel())
.constraints(intent.constraints())
.priority(intent.priority())
.build();
}
示例3: makeIntent
import org.onosproject.net.intent.MplsIntent; //导入依赖的package包/类
/**
* Creates a PointToPoint intent based on ingress and egress device Ids.
*
* @param ingressIdString string for id of ingress device
* @param egressIdString string for id of egress device
* @return PointToPointIntent for the two devices
*/
private MplsIntent makeIntent(String ingressIdString, Optional<MplsLabel> ingressLabel,
String egressIdString, Optional<MplsLabel> egressLabel) {
return MplsIntent.builder()
.appId(APPID)
.selector(selector)
.treatment(treatment)
.ingressPoint(connectPoint(ingressIdString, 1))
.ingressLabel(ingressLabel)
.egressPoint(connectPoint(egressIdString, 1))
.egressLabel(egressLabel).build();
}
示例4: testForwardPathCompilation
import org.onosproject.net.intent.MplsIntent; //导入依赖的package包/类
/**
* Tests a pair of devices in an 8 hop path, forward direction.
*/
@Test
public void testForwardPathCompilation() {
Optional<MplsLabel> ingressLabel = Optional.of(MplsLabel.mplsLabel(10));
Optional<MplsLabel> egressLabel = Optional.of(MplsLabel.mplsLabel(20));
MplsIntent intent = makeIntent("d1", ingressLabel, "d8", egressLabel);
assertThat(intent, is(notNullValue()));
String[] hops = {"d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8"};
MplsIntentCompiler compiler = makeCompiler(hops);
assertThat(compiler, is(notNullValue()));
List<Intent> result = compiler.compile(intent, null);
assertThat(result, is(Matchers.notNullValue()));
assertThat(result, hasSize(1));
Intent forwardResultIntent = result.get(0);
assertThat(forwardResultIntent instanceof MplsPathIntent, is(true));
// if statement suppresses static analysis warnings about unchecked cast
if (forwardResultIntent instanceof MplsPathIntent) {
MplsPathIntent forwardPathIntent = (MplsPathIntent) 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"));
assertEquals(forwardPathIntent.egressLabel(), egressLabel);
assertEquals(forwardPathIntent.ingressLabel(), ingressLabel);
}
}
示例5: testReversePathCompilation
import org.onosproject.net.intent.MplsIntent; //导入依赖的package包/类
/**
* Tests a pair of devices in an 8 hop path, forward direction.
*/
@Test
public void testReversePathCompilation() {
Optional<MplsLabel> ingressLabel = Optional.of(MplsLabel.mplsLabel(10));
Optional<MplsLabel> egressLabel = Optional.of(MplsLabel.mplsLabel(20));
MplsIntent intent = makeIntent("d8", ingressLabel, "d1", egressLabel);
assertThat(intent, is(notNullValue()));
String[] hops = {"d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8"};
MplsIntentCompiler compiler = makeCompiler(hops);
assertThat(compiler, is(notNullValue()));
List<Intent> result = compiler.compile(intent, null);
assertThat(result, is(Matchers.notNullValue()));
assertThat(result, hasSize(1));
Intent reverseResultIntent = result.get(0);
assertThat(reverseResultIntent instanceof MplsPathIntent, is(true));
// if statement suppresses static analysis warnings about unchecked cast
if (reverseResultIntent instanceof MplsPathIntent) {
MplsPathIntent reversePathIntent = (MplsPathIntent) 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"));
assertEquals(reversePathIntent.egressLabel(), egressLabel);
assertEquals(reversePathIntent.ingressLabel(), ingressLabel);
}
}
示例6: testSameSwitchDifferentPortsIntentCompilation
import org.onosproject.net.intent.MplsIntent; //导入依赖的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));
MplsIntent intent = MplsIntent.builder()
.appId(APP_ID)
.selector(selector)
.treatment(treatment)
.ingressPoint(src)
.ingressLabel(Optional.empty())
.egressPoint(dst)
.egressLabel(Optional.empty())
.build();
String[] hops = {"1"};
MplsIntentCompiler sut = makeCompiler(hops);
List<Intent> compiled = sut.compile(intent, null);
assertThat(compiled, hasSize(1));
assertThat(compiled.get(0), is(instanceOf(MplsPathIntent.class)));
Path path = ((MplsPathIntent) 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)));
}
示例7: testForwardPathCompilation
import org.onosproject.net.intent.MplsIntent; //导入依赖的package包/类
/**
* Tests a pair of devices in an 8 hop path, forward direction.
*/
@Test
public void testForwardPathCompilation() {
Optional<MplsLabel> ingressLabel = Optional.of(MplsLabel.mplsLabel(10));
Optional<MplsLabel> egressLabel = Optional.of(MplsLabel.mplsLabel(20));
MplsIntent intent = makeIntent("d1", ingressLabel, "d8", egressLabel);
assertThat(intent, is(notNullValue()));
String[] hops = {"d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8"};
MplsIntentCompiler compiler = makeCompiler(hops);
assertThat(compiler, is(notNullValue()));
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 MplsPathIntent, is(true));
// if statement suppresses static analysis warnings about unchecked cast
if (forwardResultIntent instanceof MplsPathIntent) {
MplsPathIntent forwardPathIntent = (MplsPathIntent) 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"));
assertEquals(forwardPathIntent.egressLabel(), egressLabel);
assertEquals(forwardPathIntent.ingressLabel(), ingressLabel);
}
}
示例8: testReversePathCompilation
import org.onosproject.net.intent.MplsIntent; //导入依赖的package包/类
/**
* Tests a pair of devices in an 8 hop path, forward direction.
*/
@Test
public void testReversePathCompilation() {
Optional<MplsLabel> ingressLabel = Optional.of(MplsLabel.mplsLabel(10));
Optional<MplsLabel> egressLabel = Optional.of(MplsLabel.mplsLabel(20));
MplsIntent intent = makeIntent("d8", ingressLabel, "d1", egressLabel);
assertThat(intent, is(notNullValue()));
String[] hops = {"d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8"};
MplsIntentCompiler compiler = makeCompiler(hops);
assertThat(compiler, is(notNullValue()));
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 MplsPathIntent, is(true));
// if statement suppresses static analysis warnings about unchecked cast
if (reverseResultIntent instanceof MplsPathIntent) {
MplsPathIntent reversePathIntent = (MplsPathIntent) 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"));
assertEquals(reversePathIntent.egressLabel(), egressLabel);
assertEquals(reversePathIntent.ingressLabel(), ingressLabel);
}
}
示例9: testSameSwitchDifferentPortsIntentCompilation
import org.onosproject.net.intent.MplsIntent; //导入依赖的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));
MplsIntent intent = MplsIntent.builder()
.appId(APP_ID)
.selector(selector)
.treatment(treatment)
.ingressPoint(src)
.ingressLabel(Optional.empty())
.egressPoint(dst)
.egressLabel(Optional.empty())
.build();
String[] hops = {"1"};
MplsIntentCompiler sut = makeCompiler(hops);
List<Intent> compiled = sut.compile(intent, null, null);
assertThat(compiled, hasSize(1));
assertThat(compiled.get(0), is(instanceOf(MplsPathIntent.class)));
Path path = ((MplsPathIntent) 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)));
}
示例10: activate
import org.onosproject.net.intent.MplsIntent; //导入依赖的package包/类
@Activate
public void activate() {
intentManager.registerCompiler(MplsIntent.class, this);
}
示例11: deactivate
import org.onosproject.net.intent.MplsIntent; //导入依赖的package包/类
@Deactivate
public void deactivate() {
intentManager.unregisterCompiler(MplsIntent.class);
}
示例12: execute
import org.onosproject.net.intent.MplsIntent; //导入依赖的package包/类
@Override
protected void execute() {
IntentService service = get(IntentService.class);
DeviceId ingressDeviceId = deviceId(getDeviceId(ingressDeviceString));
PortNumber ingressPortNumber = portNumber(getPortNumber(ingressDeviceString));
ConnectPoint ingress = new ConnectPoint(ingressDeviceId,
ingressPortNumber);
Optional<MplsLabel> ingressLabel = Optional.empty();
if (!ingressLabelString.isEmpty()) {
ingressLabel = Optional
.ofNullable(MplsLabel.mplsLabel(parseInt(ingressLabelString)));
}
DeviceId egressDeviceId = deviceId(getDeviceId(egressDeviceString));
PortNumber egressPortNumber = portNumber(getPortNumber(egressDeviceString));
ConnectPoint egress = new ConnectPoint(egressDeviceId, egressPortNumber);
Optional<MplsLabel> egressLabel = Optional.empty();
if (!ingressLabelString.isEmpty()) {
egressLabel = Optional
.ofNullable(MplsLabel.mplsLabel(parseInt(egressLabelString)));
}
TrafficSelector selector = buildTrafficSelector();
TrafficTreatment treatment = buildTrafficTreatment();
List<Constraint> constraints = buildConstraints();
MplsIntent intent = MplsIntent.builder()
.appId(appId())
.selector(selector)
.treatment(treatment)
.ingressPoint(ingress)
.ingressLabel(ingressLabel)
.egressPoint(egress)
.egressLabel(egressLabel)
.constraints(constraints)
.priority(priority())
.build();
service.submit(intent);
}