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

Java FlowRule类代码示例

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

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



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

示例1: createFlows

import org.onosproject.net.flow.FlowRule; //导入依赖的package包/类
/**
 * Creates new flow rules. Creates and installs a new flow rules.<br>
 * Instructions description:
 * https://wiki.onosproject.org/display/ONOS/Flow+Rule+Instructions
 * <br>
 * Criteria description:
 * https://wiki.onosproject.org/display/ONOS/Flow+Rule+Criteria
 *
 * @param stream flow rules JSON
 * @return status of the request - CREATED if the JSON is correct,
 * BAD_REQUEST if the JSON is invalid
 * @onos.rsModel FlowsBatchPost
 */
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response createFlows(@QueryParam("appId") String appId, InputStream stream) {
    try {
        ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
        ArrayNode flowsArray = (ArrayNode) jsonTree.get(FLOWS);

        if (appId != null) {
            flowsArray.forEach(flowJson -> ((ObjectNode) flowJson).put("appId", appId));
        }

        List<FlowRule> rules = codec(FlowRule.class).decode(flowsArray, this);
        service.applyFlowRules(rules.toArray(new FlowRule[rules.size()]));
        rules.forEach(flowRule -> {
            ObjectNode flowNode = mapper().createObjectNode();
            flowNode.put(DEVICE_ID, flowRule.deviceId().toString())
                    .put(FLOW_ID, flowRule.id().value());
            flowsNode.add(flowNode);
        });
    } catch (IOException ex) {
        throw new IllegalArgumentException(ex);
    }
    return Response.ok(root).build();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:39,代码来源:FlowsWebResource.java


示例2: testFlowRuleBatchEntry

import org.onosproject.net.flow.FlowRule; //导入依赖的package包/类
@Test
public void testFlowRuleBatchEntry() {
    final FlowRule rule1 =
            DefaultFlowRule.builder()
                    .forDevice(DID1)
                    .withSelector(DefaultTrafficSelector.emptySelector())
                    .withTreatment(DefaultTrafficTreatment.emptyTreatment())
                    .withPriority(0)
                    .fromApp(new DefaultApplicationId(1, "1"))
                    .makeTemporary(1)
                    .build();

    final FlowRuleBatchEntry entry1 =
            new FlowRuleBatchEntry(FlowRuleBatchEntry.FlowRuleOperation.ADD, rule1);
    final FlowRuleBatchEntry entry2 =
            new FlowRuleBatchEntry(FlowRuleBatchEntry.FlowRuleOperation.ADD, rule1, 100L);

    testSerializedEquals(entry1);
    testSerializedEquals(entry2);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:21,代码来源:KryoSerializerTest.java


示例3: highestHitter

import org.onosproject.net.flow.FlowRule; //导入依赖的package包/类
@Override
public FlowRule highestHitter(ConnectPoint connectPoint) {
    checkPermission(STATISTIC_READ);

    Set<FlowEntry> hitters = statisticStore.getCurrentStatistic(connectPoint);
    if (hitters.isEmpty()) {
        return null;
    }

    FlowEntry max = hitters.iterator().next();
    for (FlowEntry entry : hitters) {
        if (entry.bytes() > max.bytes()) {
            max = entry;
        }
    }
    return max;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:StatisticManager.java


示例4: removeFromStatistics

import org.onosproject.net.flow.FlowRule; //导入依赖的package包/类
@Override
public synchronized void removeFromStatistics(FlowRule rule) {
    ConnectPoint cp = buildConnectPoint(rule);
    if (cp == null) {
        return;
    }
    InternalStatisticRepresentation rep = representations.get(cp);
    if (rep != null && rep.remove(rule)) {
        updatePublishedStats(cp, Collections.emptySet());
    }
    Set<FlowEntry> values = current.get(cp);
    if (values != null) {
        values.remove(rule);
    }
    values = previous.get(cp);
    if (values != null) {
        values.remove(rule);
    }

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


示例5: processForward

import org.onosproject.net.flow.FlowRule; //导入依赖的package包/类
private Collection<FlowRule> processForward(ForwardingObjective fwd) {

        log.debug("Processing forwarding object");

        FlowRule.Builder ruleBuilder = DefaultFlowRule.builder()
                .forDevice(deviceId)
                .withSelector(fwd.selector())
                .withTreatment(fwd.treatment())
                .withPriority(fwd.priority())
                .fromApp(fwd.appId())
                .forTable(SOFTWARE_TABLE_START);

        if (fwd.permanent()) {
            ruleBuilder.makePermanent();
        } else {
            ruleBuilder.makeTemporary(TIME_OUT);
        }

        return Collections.singletonList(ruleBuilder.build());
    }
 
开发者ID:shlee89,项目名称:athena,代码行数:21,代码来源:HpPipeline.java


示例6: processForwardingTable

import org.onosproject.net.flow.FlowRule; //导入依赖的package包/类
private void processForwardingTable(boolean install) {
    TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
    TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();

    treatment.drop();

    FlowRule flowRule = DefaultFlowRule.builder()
            .forDevice(deviceId)
            .withSelector(selector.build())
            .withTreatment(treatment.build())
            .withPriority(DROP_PRIORITY)
            .fromApp(appId)
            .makePermanent()
            .forTable(FORWARDING_TABLE)
            .build();

    applyRules(install, flowRule);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:OpenstackPipeline.java


示例7: flowMetrics

import org.onosproject.net.flow.FlowRule; //导入依赖的package包/类
@Test
public void flowMetrics() {
    FlowRule f1 = flowRule(1, 1);
    FlowRule f2 = flowRule(2, 2);
    FlowRule f3 = flowRule(3, 3);

    mgr.applyFlowRules(f1, f2, f3);

    FlowEntry fe1 = new DefaultFlowEntry(f1);
    FlowEntry fe2 = new DefaultFlowEntry(f2);

    //FlowRule updatedF1 = flowRule(f1, FlowRuleState.ADDED);
    //FlowRule updatedF2 = flowRule(f2, FlowRuleState.ADDED);

    providerService.pushFlowMetrics(DID, Lists.newArrayList(fe1, fe2));

    assertTrue("Entries should be added.",
               validateState(ImmutableMap.of(
                       f1, FlowEntryState.ADDED,
                       f2, FlowEntryState.ADDED,
                       f3, FlowEntryState.PENDING_ADD)));

    validateEvents(RULE_ADD_REQUESTED, RULE_ADD_REQUESTED, RULE_ADD_REQUESTED,
                   RULE_ADDED, RULE_ADDED);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:26,代码来源:FlowRuleManagerTest.java


示例8: processEthDstOnlyFilter

import org.onosproject.net.flow.FlowRule; //导入依赖的package包/类
protected List<FlowRule> processEthDstOnlyFilter(EthCriterion ethCriterion,
        ApplicationId applicationId, int priority) {
    TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
    TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
    selector.matchEthType(Ethernet.TYPE_IPV4);
    selector.matchEthDst(ethCriterion.mac());
    treatment.transition(TABLE_IPV4_UNICAST);
    FlowRule rule = DefaultFlowRule.builder()
            .forDevice(deviceId)
            .withSelector(selector.build())
            .withTreatment(treatment.build())
            .withPriority(priority)
            .fromApp(applicationId)
            .makePermanent()
            .forTable(TABLE_TMAC).build();
    return ImmutableList.<FlowRule>builder().add(rule).build();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:SpringOpenTTP.java


示例9: populateTableMissEntry

import org.onosproject.net.flow.FlowRule; //导入依赖的package包/类
protected void populateTableMissEntry(int tableToAdd,
                                      boolean toControllerNow,
                                      boolean toControllerWrite,
                                      boolean toTable, int tableToSend) {
    TrafficSelector selector = DefaultTrafficSelector.builder().build();
    TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();

    if (toControllerNow) {
        tBuilder.setOutput(PortNumber.CONTROLLER);
    }

    if (toControllerWrite) {
        tBuilder.deferred().setOutput(PortNumber.CONTROLLER);
    }

    if (toTable) {
        tBuilder.transition(tableToSend);
    }

    FlowRule flow = DefaultFlowRule.builder().forDevice(deviceId)
            .withSelector(selector).withTreatment(tBuilder.build())
            .withPriority(0).fromApp(appId).makePermanent()
            .forTable(tableToAdd).build();

    flowRuleService.applyFlowRules(flow);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:27,代码来源:SpringOpenTTP.java


示例10: removeFlowStatistic

import org.onosproject.net.flow.FlowRule; //导入依赖的package包/类
@Override
public synchronized void removeFlowStatistic(FlowRule rule) {
    ConnectPoint cp = buildConnectPoint(rule);
    if (cp == null) {
        return;
    }

    // remove this rule if present from current map
    current.computeIfPresent(cp, (c, e) -> {
        e.remove(rule);
        return e;
    });

    // remove this on if present from previous map
    previous.computeIfPresent(cp, (c, e) -> {
        e.remove(rule);
        return e;
    });
}
 
开发者ID:shlee89,项目名称:athena,代码行数:20,代码来源:DistributedFlowStatisticStore.java


示例11: executeBatch

import org.onosproject.net.flow.FlowRule; //导入依赖的package包/类
@Override
public void executeBatch(FlowRuleBatchOperation batch) {
    ImmutableList.Builder<FlowRule> toAdd = ImmutableList.builder();
    ImmutableList.Builder<FlowRule> toRemove = ImmutableList.builder();
    for (FlowRuleBatchEntry fbe : batch.getOperations()) {
        if (fbe.operator() == ADD || fbe.operator() == MODIFY) {
            toAdd.add(fbe.target());
        } else if (fbe.operator() == REMOVE) {
            toRemove.add(fbe.target());
        }
    }

    ImmutableList<FlowRule> rulesToAdd = toAdd.build();
    ImmutableList<FlowRule> rulesToRemove = toRemove.build();

    Collection<FlowRule> added = applyFlowRules(batch.deviceId(), rulesToAdd);
    Collection<FlowRule> removed = removeFlowRules(batch.deviceId(), rulesToRemove);

    Set<FlowRule> failedRules = Sets.union(Sets.difference(copyOf(rulesToAdd), copyOf(added)),
                                           Sets.difference(copyOf(rulesToRemove), copyOf(removed)));
    CompletedBatchOperation status =
            new CompletedBatchOperation(failedRules.isEmpty(), failedRules, batch.deviceId());
    providerService.batchOperationCompleted(batch.id(), status);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:FlowRuleDriverProvider.java


示例12: applyFlowRules

import org.onosproject.net.flow.FlowRule; //导入依赖的package包/类
@Test
public void applyFlowRules() {

    FlowRule r1 = flowRule(1, 1);
    FlowRule r2 = flowRule(2, 2);
    FlowRule r3 = flowRule(3, 3);

    assertTrue("store should be empty",
               Sets.newHashSet(service.getFlowEntries(DID)).isEmpty());
    mgr.applyFlowRules(r1, r2, r3);
    assertEquals("3 rules should exist", 3, flowCount());
    assertTrue("Entries should be pending add.",
               validateState(ImmutableMap.of(
                       r1, FlowEntryState.PENDING_ADD,
                       r2, FlowEntryState.PENDING_ADD,
                       r3, FlowEntryState.PENDING_ADD)));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:FlowRuleManagerTest.java


示例13: createFlowRule

import org.onosproject.net.flow.FlowRule; //导入依赖的package包/类
private FlowRuleIntent createFlowRule(OpticalCircuitIntent higherIntent,
                                      OpticalConnectivityIntent lowerIntent, Set<TributarySlot> slots) {
    // Create optical circuit intent
    List<FlowRule> rules = new LinkedList<>();
    // at the source: ODUCLT port mapping to OCH port
    rules.add(connectPorts(higherIntent.getSrc(), lowerIntent.getSrc(), higherIntent.priority(), slots));
    // at the destination: OCH port mapping to ODUCLT port
    rules.add(connectPorts(lowerIntent.getDst(), higherIntent.getDst(), higherIntent.priority(), slots));

    // Create flow rules for reverse path
    if (higherIntent.isBidirectional()) {
       // at the destination: OCH port mapping to ODUCLT port
        rules.add(connectPorts(lowerIntent.getSrc(), higherIntent.getSrc(), higherIntent.priority(), slots));
        // at the source: ODUCLT port mapping to OCH port
        rules.add(connectPorts(higherIntent.getDst(), lowerIntent.getDst(), higherIntent.priority(), slots));
    }

    return new FlowRuleIntent(appId, rules, higherIntent.resources());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:20,代码来源:OpticalCircuitIntentCompiler.java


示例14: processTableMissGoTo

import org.onosproject.net.flow.FlowRule; //导入依赖的package包/类
protected void processTableMissGoTo(boolean install, int table, int goTo, String description) {
    TrafficSelector.Builder selector = DefaultTrafficSelector.builder();

    TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
    treatment.transition(goTo);

    FlowRule rule = DefaultFlowRule.builder()
            .forDevice(deviceId)
            .withSelector(selector.build())
            .withTreatment(treatment.build())
            .withPriority(DROP_PRIORITY)
            .fromApp(appId)
            .makePermanent()
            .forTable(table).build();

    processFlowRule(install, rule, description);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:AbstractCorsaPipeline.java


示例15: cleanAllFlowRules

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


示例16: processMacTable

import org.onosproject.net.flow.FlowRule; //导入依赖的package包/类
private void processMacTable(boolean install) {
    TrafficSelector.Builder selector;
    TrafficTreatment.Builder treatment;

    // Bcast rule
    selector = DefaultTrafficSelector.builder();
    treatment = DefaultTrafficTreatment.builder();

    selector.matchEthDst(MacAddress.BROADCAST);
    treatment.transition(VLAN_MPLS_TABLE);

    FlowRule rule = DefaultFlowRule.builder()
            .forDevice(deviceId)
            .withSelector(selector.build())
            .withTreatment(treatment.build())
            .withPriority(CONTROLLER_PRIORITY)
            .fromApp(appId)
            .makePermanent()
            .forTable(MAC_TABLE).build();
    processFlowRule(true, rule, "Provisioned mac table transition");

    //Drop rule
    processTableMissDrop(true, MAC_TABLE, "Provisioned mac table drop action");

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


示例17: processTaggedPackets

import org.onosproject.net.flow.FlowRule; //导入依赖的package包/类
protected void processTaggedPackets(boolean install) {
    TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
    selector.matchVlanId(VlanId.ANY);

    TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
    treatment.transition(VLAN_MAC_XLATE_TABLE);

    FlowRule rule = DefaultFlowRule.builder()
            .forDevice(deviceId)
            .withSelector(selector.build())
            .withTreatment(treatment.build())
            .withPriority(CONTROLLER_PRIORITY)
            .fromApp(appId)
            .makePermanent()
            .forTable(VLAN_CHECK_TABLE).build();
    processFlowRule(install, rule, "Provisioned vlan table tagged packets");
}
 
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:CorsaPipelineV3.java


示例18: processLocalTable

import org.onosproject.net.flow.FlowRule; //导入依赖的package包/类
private void processLocalTable(boolean install) {
    int table = LOCAL_TABLE;
    /* Default action */
    processTableMissDrop(install, table, "Provisioned local table drop");

    /* Send all protocols to controller */
    TrafficSelector.Builder selector = DefaultTrafficSelector.builder();

    TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
    treatment.punt();

    FlowRule rule = DefaultFlowRule.builder()
            .forDevice(deviceId)
            .withSelector(selector.build())
            .withTreatment(treatment.build())
            .withPriority(CONTROLLER_PRIORITY)
            .fromApp(appId)
            .makePermanent()
            .forTable(table).build();
    processFlowRule(install, rule, "Provisioned ether type table to controller");
}
 
开发者ID:shlee89,项目名称:athena,代码行数:22,代码来源:CorsaPipelineV3.java


示例19: processRouterPacket

import org.onosproject.net.flow.FlowRule; //导入依赖的package包/类
private void processRouterPacket(boolean install) {

        deviceService.getPorts(deviceId).forEach(port -> {
            if (!port.number().isLogical()) {
                TrafficSelector.Builder selector = DefaultTrafficSelector.builder()
                        .matchVlanId(VlanId.vlanId(NATIVE_VLAN))
                        .matchInPort(port.number());

                TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder()
                        .setVlanPcp((byte) 0)
                        .setQueue(0)
                        .meter(defaultMeterId)
                        .transition(L3_IF_MAC_DA_TABLE);

                FlowRule rule = DefaultFlowRule.builder()
                        .forDevice(deviceId)
                        .withSelector(selector.build())
                        .withTreatment(treatment.build())
                        .withPriority(CONTROLLER_PRIORITY)
                        .fromApp(appId)
                        .makePermanent()
                        .forTable(VLAN_CIRCUIT_TABLE).build();
                processFlowRule(install, rule, "Provisioned vlan circuit table");
            }
        });
    }
 
开发者ID:shlee89,项目名称:athena,代码行数:27,代码来源:CorsaPipelineV39.java


示例20: processL3IFMacDATable

import org.onosproject.net.flow.FlowRule; //导入依赖的package包/类
@Override
protected void processL3IFMacDATable(boolean install) {
    int table = L3_IF_MAC_DA_TABLE;

    //Default action
    processTableMissDrop(install, table, "Provisioned l3 table drop");

    TrafficSelector.Builder selector = DefaultTrafficSelector.builder();

    TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder()
            .transition(ETHER_TABLE);

    FlowRule rule = DefaultFlowRule.builder()
            .forDevice(deviceId)
            .withSelector(selector.build())
            .withTreatment(treatment.build())
            .withPriority(1)
            .fromApp(appId)
            .makePermanent()
            .forTable(table).build();
    processFlowRule(install, rule, "Provisioned l3 table");
}
 
开发者ID:shlee89,项目名称:athena,代码行数:23,代码来源:CorsaPipelineV39.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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