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


Java Instructions类代码示例

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


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


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