• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Instructions类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



Instructions类属于org.onosproject.net.flow.instructions包,在下文中一共展示了Instructions类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: processNextTreatment

import org.onosproject.net.flow.instructions.Instructions; //导入依赖的package包/类
@Override
protected TrafficTreatment processNextTreatment(TrafficTreatment treatment) {
    TrafficTreatment.Builder tb = DefaultTrafficTreatment.builder();
    tb.add(Instructions.popVlan());
    treatment.immediate().stream()
            .filter(i -> {
                switch (i.type()) {
                    case L2MODIFICATION:
                        L2ModificationInstruction l2i = (L2ModificationInstruction) i;
                        if (l2i.subtype() == VLAN_ID ||
                                l2i.subtype() == VLAN_POP ||
                                l2i.subtype() == VLAN_POP ||
                                l2i.subtype() == ETH_DST ||
                                l2i.subtype() == ETH_SRC) {
                            return true;
                        }
                    case OUTPUT:
                        return true;
                    default:
                        return false;
                }
            }).forEach(i -> tb.add(i));
    return tb.build();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:CorsaPipelineV39.java


示例2: getFlowRulesFrom

import org.onosproject.net.flow.instructions.Instructions; //导入依赖的package包/类
private Set<FlowEntry> getFlowRulesFrom(ConnectPoint egress) {
    ImmutableSet.Builder<FlowEntry> builder = ImmutableSet.builder();
    flowRuleService.getFlowEntries(egress.deviceId()).forEach(r -> {
        if (r.appId() == appId.id()) {
            r.treatment().allInstructions().forEach(i -> {
                if (i.type() == Instruction.Type.OUTPUT) {
                    if (((Instructions.OutputInstruction) i).port().equals(egress.port())) {
                        builder.add(r);
                    }
                }
            });
        }
    });

    return builder.build();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:17,代码来源:ReactiveForwarding.java


示例3: programLocalIn

import org.onosproject.net.flow.instructions.Instructions; //导入依赖的package包/类
@Override
public void programLocalIn(DeviceId deviceId,
                           SegmentationId segmentationId, PortNumber inPort,
                           MacAddress srcMac, ApplicationId appid,
                           Objective.Operation type) {
    TrafficSelector selector = DefaultTrafficSelector.builder()
            .matchInPort(inPort).matchEthSrc(srcMac).build();
    TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
    treatment.add(Instructions
            .modTunnelId(Long.parseLong(segmentationId.toString())));
    ForwardingObjective.Builder objective = DefaultForwardingObjective
            .builder().withTreatment(treatment.build())
            .withSelector(selector).fromApp(appId).makePermanent()
            .withFlag(Flag.SPECIFIC).withPriority(L2_CLASSIFIER_PRIORITY);
    if (type.equals(Objective.Operation.ADD)) {
        log.debug("programLocalIn-->ADD");
        flowObjectiveService.forward(deviceId, objective.add());
    } else {
        log.debug("programLocalIn-->REMOVE");
        flowObjectiveService.forward(deviceId, objective.remove());
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:23,代码来源:ClassifierServiceImpl.java


示例4: programExportPortArpClassifierRules

import org.onosproject.net.flow.instructions.Instructions; //导入依赖的package包/类
@Override
public void programExportPortArpClassifierRules(Port exportPort,
                                                DeviceId deviceId,
                                                Operation type) {
    TrafficSelector selector = DefaultTrafficSelector.builder()
            .matchEthType(EtherType.ARP.ethType().toShort())
            .matchInPort(exportPort.number()).build();
    TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
    treatment.add(Instructions.createOutput(PortNumber.CONTROLLER));
    ForwardingObjective.Builder objective = DefaultForwardingObjective
            .builder().withTreatment(treatment.build())
            .withSelector(selector).fromApp(appId).withFlag(Flag.SPECIFIC)
            .withPriority(L3_CLASSIFIER_PRIORITY);
    if (type.equals(Objective.Operation.ADD)) {
        flowObjectiveService.forward(deviceId, objective.add());
    } else {
        flowObjectiveService.forward(deviceId, objective.remove());
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:20,代码来源:ClassifierServiceImpl.java


示例5: programRouteRules

import org.onosproject.net.flow.instructions.Instructions; //导入依赖的package包/类
@Override
public void programRouteRules(DeviceId deviceId, SegmentationId l3Vni,
                              IpAddress dstVmIP, SegmentationId dstVni,
                              MacAddress dstVmGwMac, MacAddress dstVmMac,
                              Operation type) {
    TrafficSelector selector = DefaultTrafficSelector.builder()
            .matchEthType(IP_TYPE)
            .matchTunnelId(Long.parseLong(l3Vni.segmentationId()))
            .matchIPDst(IpPrefix.valueOf(dstVmIP, PREFIX_LENGTH)).build();
    TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
    treatment.setEthSrc(dstVmGwMac)
            .setEthDst(dstVmMac)
            .add(Instructions.modTunnelId(Long.parseLong(dstVni
                         .segmentationId())));
    ForwardingObjective.Builder objective = DefaultForwardingObjective
            .builder().withTreatment(treatment.build())
            .withSelector(selector).fromApp(appId).withFlag(Flag.SPECIFIC)
            .withPriority(L3FWD_PRIORITY);
    if (type.equals(Objective.Operation.ADD)) {
        log.debug("RouteRules-->ADD");
        flowObjectiveService.forward(deviceId, objective.add());
    } else {
        log.debug("RouteRules-->REMOVE");
        flowObjectiveService.forward(deviceId, objective.remove());
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:27,代码来源:L3ForwardServiceImpl.java


示例6: programSnatSameSegmentUploadControllerRules

import org.onosproject.net.flow.instructions.Instructions; //导入依赖的package包/类
@Override
public void programSnatSameSegmentUploadControllerRules(DeviceId deviceId,
                                                        SegmentationId matchVni,
                                                        IpAddress srcIP,
                                                        IpAddress dstIP,
                                                        IpPrefix prefix,
                                                        Operation type) {

    TrafficSelector selector = DefaultTrafficSelector.builder()
            .matchEthType(Ethernet.TYPE_IPV4)
            .matchTunnelId(Long.parseLong(matchVni.segmentationId()))
            .matchIPSrc(IpPrefix.valueOf(srcIP, PREFIC_LENGTH))
            .matchIPDst(IpPrefix.valueOf(dstIP, prefix.prefixLength()))
            .build();
    TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
    treatment.add(Instructions.createOutput(PortNumber.CONTROLLER));
    ForwardingObjective.Builder objective = DefaultForwardingObjective
            .builder().withTreatment(treatment.build())
            .withSelector(selector).fromApp(appId).withFlag(Flag.SPECIFIC)
            .withPriority(SNAT_SAME_SEG_CON_PRIORITY);
    if (type.equals(Objective.Operation.ADD)) {
        flowObjectiveService.forward(deviceId, objective.add());
    } else {
        flowObjectiveService.forward(deviceId, objective.remove());
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:27,代码来源:SnatServiceImpl.java


示例7: nextBatch

import org.onosproject.net.flow.instructions.Instructions; //导入依赖的package包/类
private List<FlowRule> nextBatch(int size) {
    List<FlowRule> rules = Lists.newArrayList();
    for (int i = 0; i < size; ++i) {
        Device device = devices.next();
        long srcMac = macIndex.incrementAndGet();
        long dstMac = srcMac + 1;
        TrafficSelector selector = DefaultTrafficSelector.builder()
                .matchEthSrc(MacAddress.valueOf(srcMac))
                .matchEthDst(MacAddress.valueOf(dstMac))
                .matchInPort(PortNumber.portNumber(2))
                .build();
        TrafficTreatment treatment = DefaultTrafficTreatment.builder()
                .add(Instructions.createOutput(PortNumber.portNumber(3))).build();
        FlowRule rule = new DefaultFlowRule(device.id(),
                selector,
                treatment,
                100,
                appId,
                50000,
                true,
                null);
        rules.add(rule);
    }
    return rules;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:26,代码来源:FlowPerfApp.java


示例8: DefaultTrafficTreatment

import org.onosproject.net.flow.instructions.Instructions; //导入依赖的package包/类
/**
 * Creates a new traffic treatment from the specified list of instructions.
 *
 * @param deferred deferred instructions
 * @param immediate immediate instructions
 * @param table table transition instruction
 * @param clear instruction to clear the deferred actions list
 */
private DefaultTrafficTreatment(List<Instruction> deferred,
                               List<Instruction> immediate,
                               Instructions.TableTypeTransition table,
                               boolean clear,
                               Instructions.MetadataInstruction meta,
                               Instructions.MeterInstruction meter) {
    this.immediate = ImmutableList.copyOf(checkNotNull(immediate));
    this.deferred = ImmutableList.copyOf(checkNotNull(deferred));
    this.all = new ImmutableList.Builder<Instruction>()
            .addAll(immediate)
            .addAll(deferred)
            .build();
    this.table = table;
    this.meta = meta;
    this.hasClear = clear;
    this.meter = meter;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:26,代码来源:DefaultTrafficTreatment.java


示例9: 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


示例10: 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


示例11: decodeL1

import org.onosproject.net.flow.instructions.Instructions; //导入依赖的package包/类
/**
 * Decodes a Layer 1 instruction.
 *
 * @return instruction object decoded from the JSON
 * @throws IllegalArgumentException if the JSON is invalid
 */
private Instruction decodeL1() {
    String subType = json.get(InstructionCodec.SUBTYPE).asText();
    if (subType.equals(L1ModificationInstruction.L1SubType.ODU_SIGID.name())) {
        int tributaryPortNumber = nullIsIllegal(json.get(InstructionCodec.TRIBUTARY_PORT_NUMBER),
                InstructionCodec.TRIBUTARY_PORT_NUMBER + InstructionCodec.MISSING_MEMBER_MESSAGE).asInt();
        int tributarySlotLen = nullIsIllegal(json.get(InstructionCodec.TRIBUTARY_SLOT_LEN),
                InstructionCodec.TRIBUTARY_SLOT_LEN + InstructionCodec.MISSING_MEMBER_MESSAGE).asInt();
        byte[] tributarySlotBitmap = null;
        tributarySlotBitmap = HexString.fromHexString(
                nullIsIllegal(json.get(InstructionCodec.TRIBUTARY_SLOT_BITMAP),
                InstructionCodec.TRIBUTARY_SLOT_BITMAP + InstructionCodec.MISSING_MEMBER_MESSAGE).asText());
        return Instructions.modL1OduSignalId(OduSignalId.oduSignalId(tributaryPortNumber, tributarySlotLen,
                tributarySlotBitmap));
    }
    throw new IllegalArgumentException("L1 Instruction subtype "
            + subType + " is not supported");
}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:DecodeInstructionCodecHelper.java


示例12: decodeExtension

import org.onosproject.net.flow.instructions.Instructions; //导入依赖的package包/类
/**
 * Decodes a extension instruction.
 *
 * @return extension treatment
 */
private Instruction decodeExtension() {
    ObjectNode node = (ObjectNode) json.get(InstructionCodec.EXTENSION);
    if (node != null) {
        DeviceId deviceId = getDeviceId();

        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);
            ExtensionTreatment treatment = treatmentCodec.decode(node, null);
            return Instructions.extension(treatment, deviceId);
        } else {
            log.warn("There is no codec to decode extension for device {}", deviceId.toString());
        }
    }
    return null;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:DecodeInstructionCodecHelper.java


示例13: codecSimpleFlowTest

import org.onosproject.net.flow.instructions.Instructions; //导入依赖的package包/类
/**
 * Checks that a simple rule decodes properly.
 *
 * @throws IOException if the resource cannot be processed
 */
@Test
public void codecSimpleFlowTest() throws IOException {
    FlowRule rule = getRule("simple-flow.json");

    checkCommonData(rule);

    assertThat(rule.selector().criteria().size(), is(1));
    Criterion criterion1 = rule.selector().criteria().iterator().next();
    assertThat(criterion1.type(), is(Criterion.Type.ETH_TYPE));
    assertThat(((EthTypeCriterion) criterion1).ethType(), is(new EthType(2054)));

    assertThat(rule.treatment().allInstructions().size(), is(1));
    Instruction instruction1 = rule.treatment().allInstructions().get(0);
    assertThat(instruction1.type(), is(Instruction.Type.OUTPUT));
    assertThat(((Instructions.OutputInstruction) instruction1).port(), is(PortNumber.CONTROLLER));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:22,代码来源:FlowRuleCodecTest.java


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


示例15: getOutput

import org.onosproject.net.flow.instructions.Instructions; //导入依赖的package包/类
private PortNumber getOutput(FlowRule rule) {
    for (Instruction i : rule.treatment().allInstructions()) {
        if (i.type() == Instruction.Type.OUTPUT) {
            Instructions.OutputInstruction out = (Instructions.OutputInstruction) i;
            return out.port();
        }
    }
    return null;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:10,代码来源:DistributedFlowStatisticStore.java


示例16: provisionEapol

import org.onosproject.net.flow.instructions.Instructions; //导入依赖的package包/类
private void provisionEapol(FilteringObjective filter,
                            EthTypeCriterion ethType,
                            Instructions.OutputInstruction output) {

    TrafficSelector selector = buildSelector(filter.key(), ethType);
    TrafficTreatment treatment = buildTreatment(output);
    buildAndApplyRule(filter, selector, treatment);

}
 
开发者ID:shlee89,项目名称:athena,代码行数:10,代码来源:OltPipeline.java


示例17: provisionIgmp

import org.onosproject.net.flow.instructions.Instructions; //导入依赖的package包/类
private void provisionIgmp(FilteringObjective filter, EthTypeCriterion ethType,
                           IPProtocolCriterion ipProto,
                           Instructions.OutputInstruction output) {
    TrafficSelector selector = buildSelector(filter.key(), ethType, ipProto);
    TrafficTreatment treatment = buildTreatment(output);
    buildAndApplyRule(filter, selector, treatment);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:8,代码来源:OltPipeline.java


示例18: 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


示例19: ofFlowStatsRequestFlowSend

import org.onosproject.net.flow.instructions.Instructions; //导入依赖的package包/类
private void ofFlowStatsRequestFlowSend(FlowEntry fe) {
    // set find match
    Match match = FlowModBuilder.builder(fe, sw.factory(), Optional.empty(),
            Optional.of(driverService)).buildMatch();
    // set find tableId
    TableId tableId = TableId.of(fe.tableId());
    // set output port
    Instruction ins = fe.treatment().allInstructions().stream()
            .filter(i -> (i.type() == Instruction.Type.OUTPUT))
            .findFirst()
            .orElse(null);
    OFPort ofPort = OFPort.NO_MASK;
    if (ins != null) {
        Instructions.OutputInstruction out = (Instructions.OutputInstruction) ins;
        ofPort = OFPort.of((int) ((out.port().toLong())));
    }

    OFFlowStatsRequest request = sw.factory().buildFlowStatsRequest()
            .setMatch(match)
            .setTableId(tableId)
            .setOutPort(ofPort)
            .build();

    synchronized (this) {
        if (getFlowMissingXid() != NO_FLOW_MISSING_XID) {
            log.debug("ofFlowStatsRequestFlowSend: previous FlowStatsRequestAll does not be processed yet,"
                            + " set no flow missing xid anyway, for {}",
                    sw.getStringId());
            setFlowMissingXid(NO_FLOW_MISSING_XID);
        }

        sw.sendMsg(request);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:35,代码来源:NewAdaptiveFlowStatsCollector.java


示例20: genFlow

import org.onosproject.net.flow.instructions.Instructions; //导入依赖的package包/类
public FlowRule genFlow(String d, long inPort, long outPort) {
    DeviceId device = DeviceId.deviceId(d);
    TrafficSelector ts = DefaultTrafficSelector.builder().matchInPort(PortNumber.portNumber(inPort)).build();
    TrafficTreatment tt = DefaultTrafficTreatment.builder()
            .add(Instructions.createOutput(PortNumber.portNumber(outPort))).build();
    return new DefaultFlowRule(device, ts, tt, 1, new DefaultApplicationId(5000, "of"),
                               50000, true, FlowRuleExtPayLoad.flowRuleExtPayLoad(new byte[5]));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:9,代码来源:FlowAnalyzerTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java NotifyNeighborBlockEvent类代码示例发布时间:2022-05-23
下一篇:
Java Art类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap