当前位置: 首页>>代码示例>>Java>>正文


Java Instructions.ExtensionInstructionWrapper方法代码示例

本文整理汇总了Java中org.onosproject.net.flow.instructions.Instructions.ExtensionInstructionWrapper方法的典型用法代码示例。如果您正苦于以下问题:Java Instructions.ExtensionInstructionWrapper方法的具体用法?Java Instructions.ExtensionInstructionWrapper怎么用?Java Instructions.ExtensionInstructionWrapper使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.onosproject.net.flow.instructions.Instructions的用法示例。


在下文中一共展示了Instructions.ExtensionInstructionWrapper方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: encodeExtension

import org.onosproject.net.flow.instructions.Instructions; //导入方法依赖的package包/类
/**
 * Encodes a extension instruction.
 *
 * @param result json node that the instruction attributes are added to
 */
private void encodeExtension(ObjectNode result) {
    final Instructions.ExtensionInstructionWrapper extensionInstruction =
            (Instructions.ExtensionInstructionWrapper) instruction;

    DeviceId deviceId = extensionInstruction.deviceId();

    ServiceDirectory serviceDirectory = new DefaultServiceDirectory();
    DeviceService deviceService = serviceDirectory.get(DeviceService.class);
    Device device = deviceService.getDevice(deviceId);

    if (device.is(ExtensionTreatmentCodec.class)) {
        ExtensionTreatmentCodec treatmentCodec = device.as(ExtensionTreatmentCodec.class);
        ObjectNode node = treatmentCodec.encode(extensionInstruction.extensionInstruction(), context);
        result.set(InstructionCodec.EXTENSION, node);
    } else {
        log.warn("There is no codec to encode extension for device {}", deviceId.toString());
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:EncodeInstructionCodecHelper.java

示例2: read

import org.onosproject.net.flow.instructions.Instructions; //导入方法依赖的package包/类
@Override
public Instructions.ExtensionInstructionWrapper read(Kryo kryo, Input input,
                                                     Class<Instructions.ExtensionInstructionWrapper> type) {
    ExtensionTreatmentType exType = (ExtensionTreatmentType) kryo.readClassAndObject(input);
    DeviceId deviceId = (DeviceId) kryo.readClassAndObject(input);

    DriverService driverService = DefaultServiceDirectory.getService(DriverService.class);
    DriverHandler handler = new DefaultDriverHandler(
            new DefaultDriverData(driverService.getDriver(deviceId), deviceId));

    ExtensionTreatmentResolver resolver = handler.behaviour(ExtensionTreatmentResolver.class);
    ExtensionTreatment instruction = resolver.getExtensionInstruction(exType);

    byte[] bytes = (byte[]) kryo.readClassAndObject(input);

    instruction.deserialize(bytes);

    return Instructions.extension(instruction, deviceId);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:20,代码来源:ExtensionInstructionSerializer.java

示例3: getActionFromExtension

import org.onosproject.net.flow.instructions.Instructions; //导入方法依赖的package包/类
private Bmv2Action getActionFromExtension(Instructions.ExtensionInstructionWrapper inst)
        throws Bmv2FlowRuleTranslatorException {

    ExtensionTreatment extTreatment = inst.extensionInstruction();

    if (extTreatment.type() == ExtensionTreatmentTypes.BMV2_ACTION.type()) {
        if (extTreatment instanceof Bmv2ExtensionTreatment) {
            return ((Bmv2ExtensionTreatment) extTreatment).action();
        } else {
            throw new Bmv2FlowRuleTranslatorException("Unable to decode treatment extension: " + extTreatment);
        }
    } else {
        throw new Bmv2FlowRuleTranslatorException("Unsupported treatment extension type: " + extTreatment.type());
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:16,代码来源:Bmv2FlowRuleTranslatorImpl.java

示例4: 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;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:48,代码来源:GroupModBuilder.java

示例5: write

import org.onosproject.net.flow.instructions.Instructions; //导入方法依赖的package包/类
@Override
public void write(Kryo kryo, Output output, Instructions.ExtensionInstructionWrapper object) {
    kryo.writeClassAndObject(output, object.extensionInstruction().type());
    kryo.writeClassAndObject(output, object.deviceId());
    kryo.writeClassAndObject(output, object.extensionInstruction().serialize());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:7,代码来源:ExtensionInstructionSerializer.java


注:本文中的org.onosproject.net.flow.instructions.Instructions.ExtensionInstructionWrapper方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。