本文整理汇总了Java中org.onosproject.net.flow.instructions.Instructions.createOutput方法的典型用法代码示例。如果您正苦于以下问题:Java Instructions.createOutput方法的具体用法?Java Instructions.createOutput怎么用?Java Instructions.createOutput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.onosproject.net.flow.instructions.Instructions
的用法示例。
在下文中一共展示了Instructions.createOutput方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testTrafficTreatmentEncode
import org.onosproject.net.flow.instructions.Instructions; //导入方法依赖的package包/类
/**
* Tests encoding of a traffic treatment object.
*/
@Test
public void testTrafficTreatmentEncode() {
Instruction output = Instructions.createOutput(PortNumber.portNumber(0));
Instruction modL2Src = Instructions.modL2Src(MacAddress.valueOf("11:22:33:44:55:66"));
Instruction modL2Dst = Instructions.modL2Dst(MacAddress.valueOf("44:55:66:77:88:99"));
MeterId meterId = MeterId.meterId(0);
Instruction meter = Instructions.meterTraffic(meterId);
Instruction transition = Instructions.transition(1);
TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
TrafficTreatment treatment = tBuilder
.add(output)
.add(modL2Src)
.add(modL2Dst)
.add(meter)
.add(transition)
.build();
ObjectNode treatmentJson = trafficTreatmentCodec.encode(treatment, context);
assertThat(treatmentJson, TrafficTreatmentJsonMatcher.matchesTrafficTreatment(treatment));
}
示例2: decode
import org.onosproject.net.flow.instructions.Instructions; //导入方法依赖的package包/类
/**
* Decodes the JSON into an instruction object.
*
* @return Criterion object
* @throws IllegalArgumentException if the JSON is invalid
*/
public Instruction decode() {
String type = json.get(InstructionCodec.TYPE).asText();
if (type.equals(Instruction.Type.OUTPUT.name())) {
return Instructions.createOutput(getPortNumber(json));
} else if (type.equals(Instruction.Type.NOACTION.name())) {
return Instructions.createNoAction();
} else if (type.equals(Instruction.Type.TABLE.name())) {
return Instructions.transition(nullIsIllegal(json.get(InstructionCodec.TABLE_ID)
.asInt(), InstructionCodec.TABLE_ID + InstructionCodec.MISSING_MEMBER_MESSAGE));
} else if (type.equals(Instruction.Type.GROUP.name())) {
GroupId groupId = new DefaultGroupId(nullIsIllegal(json.get(InstructionCodec.GROUP_ID)
.asInt(), InstructionCodec.GROUP_ID + InstructionCodec.MISSING_MEMBER_MESSAGE));
return Instructions.createGroup(groupId);
} else if (type.equals(Instruction.Type.METER.name())) {
MeterId meterId = MeterId.meterId(nullIsIllegal(json.get(InstructionCodec.METER_ID)
.asLong(), InstructionCodec.METER_ID + InstructionCodec.MISSING_MEMBER_MESSAGE));
return Instructions.meterTraffic(meterId);
} else if (type.equals(Instruction.Type.QUEUE.name())) {
long queueId = nullIsIllegal(json.get(InstructionCodec.QUEUE_ID)
.asLong(), InstructionCodec.QUEUE_ID + InstructionCodec.MISSING_MEMBER_MESSAGE);
return Instructions.setQueue(queueId, getPortNumber(json));
} else if (type.equals(Instruction.Type.L0MODIFICATION.name())) {
return decodeL0();
} else if (type.equals(Instruction.Type.L1MODIFICATION.name())) {
return decodeL1();
} else if (type.equals(Instruction.Type.L2MODIFICATION.name())) {
return decodeL2();
} else if (type.equals(Instruction.Type.L3MODIFICATION.name())) {
return decodeL3();
} else if (type.equals(Instruction.Type.L4MODIFICATION.name())) {
return decodeL4();
} else if (type.equals(Instruction.Type.EXTENSION.name())) {
return decodeExtension();
}
throw new IllegalArgumentException("Instruction type "
+ type + " is not supported");
}
示例3: outputInstructionTest
import org.onosproject.net.flow.instructions.Instructions; //导入方法依赖的package包/类
/**
* Tests the encoding of output instructions.
*/
@Test
public void outputInstructionTest() {
final Instructions.OutputInstruction instruction =
Instructions.createOutput(PortNumber.portNumber(22));
final ObjectNode instructionJson =
instructionCodec.encode(instruction, context);
assertThat(instructionJson, matchesInstruction(instruction));
}
示例4: testFlowRuleEncode
import org.onosproject.net.flow.instructions.Instructions; //导入方法依赖的package包/类
/**
* Checks that a simple rule encodes properly.
*/
@Test
public void testFlowRuleEncode() {
DeviceId deviceId = DeviceId.deviceId("of:000000000000000a");
Instruction output = Instructions.createOutput(PortNumber.portNumber(0));
Instruction modL2Src = Instructions.modL2Src(MacAddress.valueOf("11:22:33:44:55:66"));
Instruction modL2Dst = Instructions.modL2Dst(MacAddress.valueOf("44:55:66:77:88:99"));
TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
TrafficTreatment treatment = tBuilder
.add(output)
.add(modL2Src)
.add(modL2Dst)
.build();
Criterion inPort = Criteria.matchInPort(PortNumber.portNumber(0));
Criterion ethSrc = Criteria.matchEthSrc(MacAddress.valueOf("11:22:33:44:55:66"));
Criterion ethDst = Criteria.matchEthDst(MacAddress.valueOf("44:55:66:77:88:99"));
Criterion ethType = Criteria.matchEthType(Ethernet.TYPE_IPV4);
TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder();
TrafficSelector selector = sBuilder
.add(inPort)
.add(ethSrc)
.add(ethDst)
.add(ethType)
.build();
FlowRule permFlowRule = DefaultFlowRule.builder()
.withCookie(1)
.forTable(1)
.withPriority(1)
.makePermanent()
.withTreatment(treatment)
.withSelector(selector)
.forDevice(deviceId).build();
FlowRule tempFlowRule = DefaultFlowRule.builder()
.withCookie(1)
.forTable(1)
.withPriority(1)
.makeTemporary(1000)
.withTreatment(treatment)
.withSelector(selector)
.forDevice(deviceId).build();
ObjectNode permFlowRuleJson = flowRuleCodec.encode(permFlowRule, context);
ObjectNode tempFlowRuleJson = flowRuleCodec.encode(tempFlowRule, context);
assertThat(permFlowRuleJson, FlowRuleJsonMatcher.matchesFlowRule(permFlowRule));
assertThat(tempFlowRuleJson, FlowRuleJsonMatcher.matchesFlowRule(tempFlowRule));
}