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

Java Instruction类代码示例

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

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



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

示例1: format

import org.onosproject.net.flow.instructions.Instruction; //导入依赖的package包/类
@Override
public String format(Object value) {
    FlowEntry flow = (FlowEntry) value;
    List<Instruction> instructions = flow.treatment().allInstructions();

    if (instructions.isEmpty()
            && flow.treatment().metered() == null
            && flow.treatment().tableTransition() == null) {
        return "(No traffic treatment instructions for this flow)";
    }
    StringBuilder sb = new StringBuilder("Treatment Instructions: ");
    for (Instruction i : instructions) {
        sb.append(i).append(COMMA);
    }
    if (flow.treatment().metered() != null) {
        sb.append(flow.treatment().metered().toString()).append(COMMA);
    }
    if (flow.treatment().tableTransition() != null) {
        sb.append(flow.treatment().tableTransition().toString()).append(COMMA);
    }
    removeTrailingComma(sb);

    return sb.toString();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:FlowViewMessageHandler.java


示例2: buildConnectivityDetails

import org.onosproject.net.flow.instructions.Instruction; //导入依赖的package包/类
private void buildConnectivityDetails(ConnectivityIntent intent,
                                      StringBuilder sb) {
    Set<Criterion> criteria = intent.selector().criteria();
    List<Instruction> instructions = intent.treatment().allInstructions();
    List<Constraint> constraints = intent.constraints();

    if (!criteria.isEmpty()) {
        sb.append("Selector: ").append(criteria);
    }
    if (!instructions.isEmpty()) {
        sb.append("Treatment: ").append(instructions);
    }
    if (constraints != null && !constraints.isEmpty()) {
        sb.append("Constraints: ").append(constraints);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:17,代码来源:IntentViewMessageHandler.java


示例3: findVlanOps

import org.onosproject.net.flow.instructions.Instruction; //导入依赖的package包/类
private List<Pair<Instruction, Instruction>> findVlanOps(List<Instruction> instructions,
                                                         L2ModificationInstruction.L2SubType type) {

    List<Instruction> vlanPushs = findL2Instructions(
            type,
            instructions);
    List<Instruction> vlanSets = findL2Instructions(
            L2ModificationInstruction.L2SubType.VLAN_ID,
            instructions);

    if (vlanPushs.size() != vlanSets.size()) {
        return null;
    }

    List<Pair<Instruction, Instruction>> pairs = Lists.newArrayList();

    for (int i = 0; i < vlanPushs.size(); i++) {
        pairs.add(new ImmutablePair<>(vlanPushs.get(i), vlanSets.get(i)));
    }
    return pairs;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:22,代码来源:OltPipeline.java


示例4: sendPacket

import org.onosproject.net.flow.instructions.Instruction; //导入依赖的package包/类
private void sendPacket(Ethernet eth) {
    List<Instruction> ins = treatmentBuilder().build().allInstructions();
    OFPort p = null;
    //TODO: support arbitrary list of treatments must be supported in ofPacketContext
    for (Instruction i : ins) {
        if (i.type() == Type.OUTPUT) {
            p = buildPort(((OutputInstruction) i).port());
            break; //for now...
        }
    }
    if (eth == null) {
        ofPktCtx.build(p);
    } else {
        ofPktCtx.build(eth, p);
    }
    ofPktCtx.send();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:OpenFlowCorePacketContext.java


示例5: getInstructionType

import org.onosproject.net.flow.instructions.Instruction; //导入依赖的package包/类
/**
 * converts string of instruction type to Instruction type enum.
 *
 * @param instType string representing the instruction type
 * @return Instruction.Type
 */
private Instruction.Type getInstructionType(String instType) {
    String instTypeUC = instType.toUpperCase();

    if (instTypeUC.equals("OUTPUT")) {
        return Instruction.Type.OUTPUT;
    } else if (instTypeUC.equals("GROUP")) {
        return Instruction.Type.GROUP;
    } else if (instTypeUC.equals("L0MODIFICATION")) {
        return Instruction.Type.L0MODIFICATION;
    } else if (instTypeUC.equals("L2MODIFICATION")) {
        return Instruction.Type.L2MODIFICATION;
    } else if (instTypeUC.equals("TABLE")) {
        return Instruction.Type.TABLE;
    } else if (instTypeUC.equals("L3MODIFICATION")) {
        return Instruction.Type.L3MODIFICATION;
    } else if (instTypeUC.equals("METADATA")) {
        return Instruction.Type.METADATA;
    } else {
         return null; // instruction type error
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:28,代码来源:GetFlowStatistics.java


示例6: getFlowRulesFrom

import org.onosproject.net.flow.instructions.Instruction; //导入依赖的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


示例7: cleanAllFlowRules

import org.onosproject.net.flow.instructions.Instruction; //导入依赖的package包/类
private void cleanAllFlowRules() {
    Iterable<Device> deviceList = deviceService.getAvailableDevices();

    for (Device d : deviceList) {
        DeviceId id = d.id();
        log.trace("Searching for flow rules to remove from: " + id);
        for (FlowEntry r : flowRuleService.getFlowEntries(id)) {
            boolean match = false;
            for (Instruction i : r.treatment().allInstructions()) {
                if (i.type() == Instruction.Type.OUTPUT) {
                    OutputInstruction oi = (OutputInstruction) i;
                    // if the flow has matching src and dst
                    for (Criterion cr : r.selector().criteria()) {
                        if (cr.type() == Criterion.Type.ETH_DST || cr.type() == Criterion.Type.ETH_SRC) {
                                    match = true;
                        }
                    }
                }
            }
            if (match) {
                log.trace("Removed flow rule from device: " + id);
                flowRuleService.removeFlowRules((FlowRule) r);
            }
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:27,代码来源:SimpleLoadBalancer.java


示例8: DefaultTrafficTreatment

import org.onosproject.net.flow.instructions.Instruction; //导入依赖的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: equals

import org.onosproject.net.flow.instructions.Instruction; //导入依赖的package包/类
@Override
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }
    if (obj instanceof DefaultGroupBucket) {
        DefaultGroupBucket that = (DefaultGroupBucket) obj;
        List<Instruction> myInstructions = this.treatment.allInstructions();
        List<Instruction> theirInstructions = that.treatment.allInstructions();

        return Objects.equals(type, that.type) &&
               myInstructions.containsAll(theirInstructions) &&
               theirInstructions.containsAll(myInstructions);
    }
    return false;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:17,代码来源:DefaultGroupBucket.java


示例10: loadAllByType

import org.onosproject.net.flow.instructions.Instruction; //导入依赖的package包/类
@Override
public Map<ConnectPoint, List<TypedFlowEntryWithLoad>> loadAllByType(Device device,
                                                              TypedStoredFlowEntry.FlowLiveType liveType,
                                                              Instruction.Type instType) {
    checkPermission(STATISTIC_READ);

    Map<ConnectPoint, List<TypedFlowEntryWithLoad>> allLoad = new TreeMap<>(CONNECT_POINT_COMPARATOR);

    if (device == null) {
        return allLoad;
    }

    List<Port> ports = new ArrayList<>(deviceService.getPorts(device.id()));

    for (Port port : ports) {
        ConnectPoint cp = new ConnectPoint(device.id(), port.number());
        List<TypedFlowEntryWithLoad> tfel = loadAllPortInternal(cp, liveType, instType);
        allLoad.put(cp, tfel);
    }

    return allLoad;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:23,代码来源:FlowStatisticManager.java


示例11: loadTopnByType

import org.onosproject.net.flow.instructions.Instruction; //导入依赖的package包/类
@Override
public Map<ConnectPoint, List<TypedFlowEntryWithLoad>> loadTopnByType(Device device,
                                                               TypedStoredFlowEntry.FlowLiveType liveType,
                                                               Instruction.Type instType,
                                                               int topn) {
    checkPermission(STATISTIC_READ);

    Map<ConnectPoint, List<TypedFlowEntryWithLoad>> allLoad = new TreeMap<>(CONNECT_POINT_COMPARATOR);

    if (device == null) {
        return allLoad;
    }

    List<Port> ports = new ArrayList<>(deviceService.getPorts(device.id()));

    for (Port port : ports) {
        ConnectPoint cp = new ConnectPoint(device.id(), port.number());
        List<TypedFlowEntryWithLoad> tfel = loadTopnPortInternal(cp, liveType, instType, topn);
        allLoad.put(cp, tfel);
    }

    return allLoad;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:FlowStatisticManager.java


示例12: typedFlowEntryLoadByInstInternal

import org.onosproject.net.flow.instructions.Instruction; //导入依赖的package包/类
private List<TypedFlowEntryWithLoad> typedFlowEntryLoadByInstInternal(ConnectPoint cp,
                                                                  Map<FlowRule, TypedStoredFlowEntry> currentMap,
                                                                  Map<FlowRule, TypedStoredFlowEntry> previousMap,
                                                                  boolean isAllInstType,
                                                                  Instruction.Type instType,
                                                                  int liveTypePollInterval) {
    List<TypedFlowEntryWithLoad> fel = new ArrayList<>();

    for (TypedStoredFlowEntry tfe : currentMap.values()) {
        if (isAllInstType ||
                tfe.treatment().allInstructions().stream().
                        filter(i -> i.type() == instType).
                        findAny().isPresent()) {
            long currentBytes = tfe.bytes();
            long previousBytes = previousMap.getOrDefault(tfe, new DefaultTypedFlowEntry((FlowRule) tfe)).bytes();
            Load fLoad = new DefaultLoad(currentBytes, previousBytes, liveTypePollInterval);
            fel.add(new TypedFlowEntryWithLoad(cp, tfe, fLoad));
        }
    }

    return fel;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:23,代码来源:FlowStatisticManager.java


示例13: decodeL1

import org.onosproject.net.flow.instructions.Instruction; //导入依赖的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


示例14: decodeExtension

import org.onosproject.net.flow.instructions.Instruction; //导入依赖的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


示例15: codecSimpleFlowTest

import org.onosproject.net.flow.instructions.Instruction; //导入依赖的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


示例16: testTrafficTreatmentEncode

import org.onosproject.net.flow.instructions.Instruction; //导入依赖的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


示例17: getEgressFlows

import org.onosproject.net.flow.instructions.Instruction; //导入依赖的package包/类
private int getEgressFlows(Link link, List<FlowEntry> entries) {
    int count = 0;
    PortNumber out = link.src().port();
    for (FlowEntry entry : entries) {
        TrafficTreatment treatment = entry.treatment();
        for (Instruction instruction : treatment.allInstructions()) {
            if (instruction.type() == Instruction.Type.OUTPUT &&
                    ((OutputInstruction) instruction).port().equals(out)) {
                count++;
            }
        }
    }
    return count;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:15,代码来源:TrafficMonitor.java


示例18: getNextMappings

import org.onosproject.net.flow.instructions.Instruction; //导入依赖的package包/类
@Override
public List<String> getNextMappings(NextGroup nextGroup) {
    List<String> mappings = new ArrayList<>();
    List<Deque<GroupKey>> gkeys = appKryo.deserialize(nextGroup.data());
    for (Deque<GroupKey> gkd : gkeys) {
        Group lastGroup = null;
        StringBuffer gchain = new StringBuffer();
        for (GroupKey gk : gkd) {
            Group g = groupService.getGroup(deviceId, gk);
            if (g == null) {
                gchain.append("  NoGrp").append(" -->");
                continue;
            }
            gchain.append("  0x").append(Integer.toHexString(g.id().id()))
                .append(" -->");
            lastGroup = g;
        }
        // add port information for last group in group-chain
        List<Instruction> lastGroupIns = new ArrayList<Instruction>();
        if (lastGroup != null) {
            lastGroupIns = lastGroup.buckets().buckets().get(0)
                                .treatment().allInstructions();
        }
        for (Instruction i: lastGroupIns) {
            if (i instanceof OutputInstruction) {
                gchain.append(" port:").append(((OutputInstruction) i).port());
            }
        }
        mappings.add(gchain.toString());
    }
    return mappings;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:33,代码来源:Ofdpa2Pipeline.java


示例19: readVlanFromTreatment

import org.onosproject.net.flow.instructions.Instruction; //导入依赖的package包/类
private static VlanId readVlanFromTreatment(TrafficTreatment treatment) {
    if (treatment == null) {
        return null;
    }
    for (Instruction i : treatment.allInstructions()) {
        if (i instanceof ModVlanIdInstruction) {
            return ((ModVlanIdInstruction) i).vlanId();
        }
    }
    return null;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:12,代码来源:Ofdpa2Pipeline.java


示例20: fetchOutput

import org.onosproject.net.flow.instructions.Instruction; //导入依赖的package包/类
private Instruction fetchOutput(ForwardingObjective fwd, String direction) {
    Instruction output = fwd.treatment().allInstructions().stream()
            .filter(i -> i.type() == Instruction.Type.OUTPUT)
            .findFirst().orElse(null);

    if (output == null) {
        log.error("OLT {} rule has no output", direction);
        fail(fwd, ObjectiveError.BADPARAMS);
        return null;
    }
    return output;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:13,代码来源:OltPipeline.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java EclipseStarter类代码示例发布时间:2022-05-23
下一篇:
Java InMemoryLookupTable类代码示例发布时间: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