本文整理汇总了Java中org.onosproject.net.flow.instructions.Instructions.GroupInstruction方法的典型用法代码示例。如果您正苦于以下问题:Java Instructions.GroupInstruction方法的具体用法?Java Instructions.GroupInstruction怎么用?Java Instructions.GroupInstruction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.onosproject.net.flow.instructions.Instructions
的用法示例。
在下文中一共展示了Instructions.GroupInstruction方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildActions
import org.onosproject.net.flow.instructions.Instructions; //导入方法依赖的package包/类
private List<OFAction> buildActions(TrafficTreatment treatment) {
if (treatment == null) {
return Collections.emptyList();
}
List<OFAction> actions = new LinkedList<>();
for (Instruction i : treatment.allInstructions()) {
switch (i.type()) {
case L0MODIFICATION:
actions.add(buildL0Modification(i));
break;
case L2MODIFICATION:
actions.add(buildL2Modification(i));
break;
case L3MODIFICATION:
actions.add(buildL3Modification(i));
break;
case OUTPUT:
Instructions.OutputInstruction out =
(Instructions.OutputInstruction) i;
OFActionOutput.Builder action = factory.actions().buildOutput()
.setPort(OFPort.of((int) out.port().toLong()));
if (out.port().equals(PortNumber.CONTROLLER)) {
action.setMaxLen(OFPCML_NO_BUFFER);
}
actions.add(action.build());
break;
case GROUP:
Instructions.GroupInstruction grp =
(Instructions.GroupInstruction) i;
OFActionGroup.Builder actgrp = factory.actions().buildGroup()
.setGroup(OFGroup.of(grp.groupId().id()));
actions.add(actgrp.build());
break;
case EXTENSION:
Instructions.ExtensionInstructionWrapper wrapper =
(Instructions.ExtensionInstructionWrapper) i;
actions.add(buildExtensionAction(
wrapper.extensionInstruction(), wrapper.deviceId()));
break;
default:
log.warn("Instruction type {} not yet implemented.", i.type());
}
}
return actions;
}
示例2: encode
import org.onosproject.net.flow.instructions.Instructions; //导入方法依赖的package包/类
/**
* Encodes the given instruction into JSON.
*
* @return JSON object node representing the instruction
*/
public ObjectNode encode() {
final ObjectNode result = context.mapper().createObjectNode()
.put(InstructionCodec.TYPE, instruction.type().toString());
switch (instruction.type()) {
case OUTPUT:
final Instructions.OutputInstruction outputInstruction =
(Instructions.OutputInstruction) instruction;
result.put(InstructionCodec.PORT, outputInstruction.port().toString());
break;
case NOACTION:
break;
case GROUP:
final Instructions.GroupInstruction groupInstruction =
(Instructions.GroupInstruction) instruction;
result.put(InstructionCodec.GROUP_ID, groupInstruction.groupId().toString());
break;
case METER:
final Instructions.MeterInstruction meterInstruction =
(Instructions.MeterInstruction) instruction;
result.put(InstructionCodec.METER_ID, meterInstruction.meterId().toString());
break;
case TABLE:
final Instructions.TableTypeTransition tableTransitionInstruction =
(Instructions.TableTypeTransition) instruction;
result.put(InstructionCodec.TABLE_ID, tableTransitionInstruction.tableId().toString());
break;
case QUEUE:
final Instructions.SetQueueInstruction setQueueInstruction =
(Instructions.SetQueueInstruction) instruction;
result.put(InstructionCodec.QUEUE_ID, setQueueInstruction.queueId());
result.put(InstructionCodec.PORT, setQueueInstruction.port().toString());
break;
case L0MODIFICATION:
encodeL0(result);
break;
case L1MODIFICATION:
encodeL1(result);
break;
case L2MODIFICATION:
encodeL2(result);
break;
case L3MODIFICATION:
encodeL3(result);
break;
case L4MODIFICATION:
encodeL4(result);
break;
case EXTENSION:
encodeExtension(result);
break;
default:
log.info("Cannot convert instruction type of {}", instruction.type());
break;
}
return result;
}