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


Java DefaultNextObjective类代码示例

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


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

示例1: createPeerGroup

import org.onosproject.net.flowobjective.DefaultNextObjective; //导入依赖的package包/类
private int createPeerGroup(MacAddress srcMac, MacAddress dstMac,
        VlanId vlanId, DeviceId deviceId, PortNumber port) {
    int nextId = flowObjectiveService.allocateNextId();
    NextObjective.Builder nextObjBuilder = DefaultNextObjective.builder()
            .withId(nextId)
            .withType(NextObjective.Type.SIMPLE)
            .fromApp(appId);

    TrafficTreatment.Builder ttBuilder = DefaultTrafficTreatment.builder();
    ttBuilder.setEthSrc(srcMac);
    ttBuilder.setEthDst(dstMac);
    ttBuilder.setOutput(port);
    nextObjBuilder.addTreatment(ttBuilder.build());

    TrafficSelector.Builder metabuilder = DefaultTrafficSelector.builder();
    VlanId matchVlanId = (vlanId.equals(VlanId.NONE)) ?
            VlanId.vlanId(SingleSwitchFibInstaller.ASSIGNED_VLAN) :
            vlanId;
    metabuilder.matchVlanId(matchVlanId);
    nextObjBuilder.withMeta(metabuilder.build());

    flowObjectiveService.next(deviceId, nextObjBuilder.add());
    return nextId;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:ControlPlaneRedirectManager.java

示例2: modifyNextObjective

import org.onosproject.net.flowobjective.DefaultNextObjective; //导入依赖的package包/类
/**
 * Setup expectations on flowObjectiveService.next for NextObjective.
 *
 **/
private int modifyNextObjective(DeviceId deviceId, PortNumber portNumber, VlanId vlanId, boolean popVlan,
        boolean modifyFlag) {
    NextObjective.Builder nextObjBuilder = DefaultNextObjective.builder().withId(1)
            .withType(NextObjective.Type.SIMPLE).fromApp(APPID);

    TrafficTreatment.Builder ttBuilder = DefaultTrafficTreatment.builder();
    if (popVlan) {
        ttBuilder.popVlan();
    }
    ttBuilder.setOutput(portNumber);

    TrafficSelector.Builder metabuilder = DefaultTrafficSelector.builder();
    metabuilder.matchVlanId(vlanId);

    nextObjBuilder.withMeta(metabuilder.build());
    nextObjBuilder.addTreatment(ttBuilder.build());
    if (modifyFlag) {
        flowObjectiveService.next(deviceId, nextObjBuilder.add());
        expectLastCall().once();
    } else {
        flowObjectiveService.next(deviceId, nextObjBuilder.remove());
        expectLastCall().once();
    }
    return 1;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:30,代码来源:ControlPlaneRedirectManagerTest.java

示例3: createGroupFromPort

import org.onosproject.net.flowobjective.DefaultNextObjective; //导入依赖的package包/类
/**
 * Create simple next objective for a single port. The treatments can include
 * all outgoing actions that need to happen on the packet.
 *
 * @param portNum  the outgoing port on the device
 * @param treatment the actions to apply on the packets (should include outport)
 * @param meta optional data to pass to the driver
 */
public void createGroupFromPort(PortNumber portNum, TrafficTreatment treatment,
                                TrafficSelector meta) {
    int nextId = flowObjectiveService.allocateNextId();
    PortNextObjectiveStoreKey key = new PortNextObjectiveStoreKey(
                                            deviceId, portNum, treatment);

    NextObjective.Builder nextObjBuilder = DefaultNextObjective
            .builder().withId(nextId)
            .withType(NextObjective.Type.SIMPLE)
            .addTreatment(treatment)
            .fromApp(appId)
            .withMeta(meta);

    NextObjective nextObj = nextObjBuilder.add();
    flowObjectiveService.next(deviceId, nextObj);
    log.debug("createGroupFromPort: Submited next objective {} in device {} "
            + "for port {}", nextId, deviceId, portNum);

    portNextObjStore.put(key, nextId);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:29,代码来源:DefaultGroupHandler.java

示例4: nextObjective

import org.onosproject.net.flowobjective.DefaultNextObjective; //导入依赖的package包/类
/**
 * Tests adding a next objective.
 */
@Test
public void nextObjective() {
    TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
    NextObjective next =
            DefaultNextObjective.builder()
                    .withId(manager.allocateNextId())
                    .addTreatment(treatment)
                    .withType(NextObjective.Type.BROADCAST)
                    .fromApp(NetTestTools.APP_ID)
                    .makePermanent()
                    .add();

    manager.next(id1, next);

    TestTools.assertAfter(RETRY_MS, () ->
            assertThat(nextObjectives, hasSize(1)));

    assertThat(forwardingObjectives, hasSize(0));
    assertThat(filteringObjectives, hasSize(0));
    assertThat(nextObjectives, hasItem("of:d1"));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:FlowObjectiveManagerTest.java

示例5: testNextObjectiveEncode

import org.onosproject.net.flowobjective.DefaultNextObjective; //导入依赖的package包/类
/**
 * Tests encoding of a NextObjective object.
 */
@Test
public void testNextObjectiveEncode() {

    TrafficTreatment treatment = DefaultTrafficTreatment.builder().build();

    NextObjective nextObj = DefaultNextObjective.builder()
            .makePermanent()
            .withType(NextObjective.Type.HASHED)
            .fromApp(APP_ID)
            .withPriority(60)
            .withId(5)
            .addTreatment(treatment)
            .add();

    ObjectNode nextObjJson = nextObjectiveCodec.encode(nextObj, context);
    assertThat(nextObjJson, matchesNextObjective(nextObj));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:21,代码来源:NextObjectiveCodecTest.java

示例6: createSimpleNextObjective

import org.onosproject.net.flowobjective.DefaultNextObjective; //导入依赖的package包/类
private List<Objective> createSimpleNextObjective(ForwardingInstructions instructions,
                                                  LinkCollectionIntent intent) {
    List<Objective> objectives = Lists.newArrayList();
    ForwardingObjective forwardingObjective;
    NextObjective nextObjective;

    Integer nextId = flowObjectiveService.allocateNextId();

    forwardingObjective = buildForwardingObjective(instructions.selector(),
                                                   nextId, intent.priority());

    DefaultNextObjective.Builder nxBuilder = DefaultNextObjective.builder();
    nextObjective = nxBuilder.withId(nextId)
            .withMeta(instructions.selector())
            .addTreatment(instructions.treatment())
            .withType(NextObjective.Type.SIMPLE)
            .fromApp(appId)
            .makePermanent()
            .withPriority(intent.priority())
            .add();

    objectives.add(forwardingObjective);
    objectives.add(nextObjective);

    return objectives;
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:27,代码来源:LinkCollectionIntentObjectiveCompiler.java

示例7: modifyNextObjective

import org.onosproject.net.flowobjective.DefaultNextObjective; //导入依赖的package包/类
/**
 * Creates a next objective for forwarding to a port. Handles metadata for
 * some pipelines that require vlan information for egress port.
 *
 * @param deviceId the device on which the next objective is being created
 * @param portNumber the egress port
 * @param vlanId vlan information for egress port
 * @param popVlan if vlan tag should be popped or not
 * @param install true to create an add next objective, false to create a remove
 *            next objective
 * @return nextId of the next objective created
 */
private int modifyNextObjective(DeviceId deviceId, PortNumber portNumber,
                                VlanId vlanId, boolean popVlan, boolean install) {
    int nextId = flowObjectiveService.allocateNextId();
    NextObjective.Builder nextObjBuilder = DefaultNextObjective
            .builder().withId(nextId)
            .withType(NextObjective.Type.SIMPLE)
            .fromApp(appId);

    TrafficTreatment.Builder ttBuilder = DefaultTrafficTreatment.builder();
    if (popVlan) {
        ttBuilder.popVlan();
    }
    ttBuilder.setOutput(portNumber);

    // setup metadata to pass to nextObjective - indicate the vlan on egress
    // if needed by the switch pipeline.
    TrafficSelector.Builder metabuilder = DefaultTrafficSelector.builder();
    metabuilder.matchVlanId(vlanId);

    nextObjBuilder.withMeta(metabuilder.build());
    nextObjBuilder.addTreatment(ttBuilder.build());
    log.debug("Submitted next objective {} in device {} for port/vlan {}/{}",
            nextId, deviceId, portNumber, vlanId);
    if (install) {
         flowObjectiveService.next(deviceId, nextObjBuilder.add());
    } else {
         flowObjectiveService.next(deviceId, nextObjBuilder.remove());
    }
    return nextId;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:43,代码来源:ControlPlaneRedirectManager.java

示例8: createNextObjective

import org.onosproject.net.flowobjective.DefaultNextObjective; //导入依赖的package包/类
/**
 * Creates a next objective with the given parameters.
 *
 * @param srcMac source MAC address
 * @param dstMac destination MAC address
 * @param port port number
 * @param vlan vlan ID
 * @param add whether to create an add objective or remove objective
 * @return new next objective
 */
private NextObjective createNextObjective(MacAddress srcMac,
                                          MacAddress dstMac,
                                          PortNumber port,
                                          VlanId vlan,
                                          boolean add) {
    TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder()
            .setEthSrc(srcMac)
            .setEthDst(dstMac);
    TrafficSelector.Builder metabuilder = null;
    if (!vlan.equals(VlanId.NONE)) {
        treatment.pushVlan()
                 .setVlanId(vlan)
                 .setVlanPcp((byte) 0);
    } else {
        metabuilder = DefaultTrafficSelector.builder();
        metabuilder.matchVlanId(VlanId.vlanId(SingleSwitchFibInstaller.ASSIGNED_VLAN));
    }

    treatment.setOutput(port);
    NextObjective.Builder nextBuilder = DefaultNextObjective.builder()
            .withId(NEXT_ID)
            .addTreatment(treatment.build())
            .withType(NextObjective.Type.SIMPLE)
            .fromApp(APPID);
    if (metabuilder != null) {
        nextBuilder.withMeta(metabuilder.build());
    }

    return add ? nextBuilder.add() : nextBuilder.remove();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:41,代码来源:SingleSwitchFibInstallerTest.java

示例9: removeGroup

import org.onosproject.net.flowobjective.DefaultNextObjective; //导入依赖的package包/类
/**
 * Removes groups for the next objective ID given.
 *
 * @param objectiveId next objective ID to remove
 * @return true if succeeds, false otherwise
 */
public boolean removeGroup(int objectiveId) {

    if (nsNextObjStore.containsValue(objectiveId)) {
        NextObjective.Builder nextObjBuilder = DefaultNextObjective
                .builder().withId(objectiveId)
                .withType(NextObjective.Type.HASHED).fromApp(appId);
        ObjectiveContext context = new DefaultObjectiveContext(
                (objective) -> log.debug("RemoveGroup removes NextObj {} on {}",
                        objectiveId, deviceId),
                (objective, error) ->
                        log.warn("RemoveGroup failed to remove NextObj {} on {}: {}",
                                objectiveId, deviceId, error));
        NextObjective nextObjective = nextObjBuilder.remove(context);
        log.info("**removeGroup: Submited "
                + "next objective {} in device {}",
                objectiveId, deviceId);
        flowObjectiveService.next(deviceId, nextObjective);

        for (Map.Entry<NeighborSetNextObjectiveStoreKey, Integer> entry: nsNextObjStore.entrySet()) {
            if (entry.getValue().equals(objectiveId)) {
                nsNextObjStore.remove(entry.getKey());
                break;
            }
        }
        return true;
    }

    return false;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:36,代码来源:DefaultGroupHandler.java

示例10: createFlow

import org.onosproject.net.flowobjective.DefaultNextObjective; //导入依赖的package包/类
@Override
public void createFlow(TrafficSelector originalSelector, TrafficTreatment originalTreatment,
                                      ConnectPoint ingress, ConnectPoint egress,
                                      int priority, boolean applyTreatment,
                                      List<Objective> objectives,
                                      List<DeviceId> devices) {
    TrafficSelector selector = DefaultTrafficSelector.builder(originalSelector)
            .matchInPort(ingress.port())
            .build();

    TrafficTreatment.Builder treatmentBuilder;
    if (applyTreatment) {
        treatmentBuilder = DefaultTrafficTreatment.builder(originalTreatment);
    } else {
        treatmentBuilder = DefaultTrafficTreatment.builder();
    }

    TrafficTreatment treatment = treatmentBuilder.setOutput(egress.port()).build();

    NextObjective nextObjective = DefaultNextObjective.builder()
            .withId(flowObjectiveService.allocateNextId())
            .addTreatment(treatment)
            .withType(NextObjective.Type.SIMPLE)
            .fromApp(appId)
            .makePermanent().add();
    objectives.add(nextObjective);
    devices.add(ingress.deviceId());

    objectives.add(DefaultForwardingObjective.builder()
            .withSelector(selector)
            .nextStep(nextObjective.id())
            .withPriority(priority)
            .fromApp(appId)
            .makePermanent()
            .withFlag(ForwardingObjective.Flag.SPECIFIC)
            .add());
    devices.add(ingress.deviceId());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:39,代码来源:PathIntentFlowObjectiveCompiler.java

示例11: testSimple

import org.onosproject.net.flowobjective.DefaultNextObjective; //导入依赖的package包/类
private void testSimple(TrafficTreatment treatment) {
    NextObjective nextObjective = DefaultNextObjective.builder()
            .withId(NEXT_ID_1)
            .withPriority(PRIORITY)
            .addTreatment(treatment)
            .withType(NextObjective.Type.SIMPLE)
            .makePermanent()
            .fromApp(APP_ID)
            .add();

    PipelinerTranslationResult result = pipeliner.pipelinerNext.next(nextObjective);

    List<FlowRule> flowRulesInstalled = (List<FlowRule>) result.flowRules();
    List<GroupDescription> groupsInstalled = (List<GroupDescription>) result.groups();
    assertEquals(1, flowRulesInstalled.size());
    assertTrue(groupsInstalled.isEmpty());

    // Simple table
    PiCriterion nextIdCriterion = PiCriterion.builder()
            .matchExact(FabricConstants.HF_FABRIC_METADATA_NEXT_ID_ID, NEXT_ID_1)
            .build();
    TrafficSelector nextIdSelector = DefaultTrafficSelector.builder()
            .matchPi(nextIdCriterion)
            .build();
    FlowRule actualFlowRule = flowRulesInstalled.get(0);
    FlowRule expectedFlowRule = DefaultFlowRule.builder()
            .forDevice(DEVICE_ID)
            .fromApp(APP_ID)
            .makePermanent()
            // FIXME: currently next objective doesn't support priority, ignore this
            .withPriority(0)
            .forTable(FabricConstants.TBL_SIMPLE_ID)
            .withSelector(nextIdSelector)
            .withTreatment(treatment)
            .build();
    assertTrue(expectedFlowRule.exactMatch(actualFlowRule));
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:38,代码来源:FabricNextPipelinerTest.java

示例12: createNextObjective

import org.onosproject.net.flowobjective.DefaultNextObjective; //导入依赖的package包/类
/**
 * Creates a next objective with the given parameters.
 *
 * @param srcMac source MAC address
 * @param dstMac destination MAC address
 * @param port port number
 * @param vlan vlan ID
 * @param add whether to create an add objective or remove objective
 * @return new next objective
 */
private NextObjective createNextObjective(MacAddress srcMac,
                                          MacAddress dstMac,
                                          PortNumber port,
                                          VlanId vlan,
                                          boolean add) {
    TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder()
            .setEthSrc(srcMac)
            .setEthDst(dstMac);
    TrafficSelector.Builder metabuilder = null;
    if (!vlan.equals(VlanId.NONE)) {
        treatment.pushVlan()
                 .setVlanId(vlan)
                 .setVlanPcp((byte) 0);
    } else {
        metabuilder = DefaultTrafficSelector.builder();
        metabuilder.matchVlanId(VlanId.vlanId(FibInstaller.ASSIGNED_VLAN));
    }

    treatment.setOutput(port);
    NextObjective.Builder nextBuilder = DefaultNextObjective.builder()
            .withId(NEXT_ID)
            .addTreatment(treatment.build())
            .withType(NextObjective.Type.SIMPLE)
            .fromApp(APPID);
    if (metabuilder != null) {
        nextBuilder.withMeta(metabuilder.build());
    }

    return add ? nextBuilder.add() : nextBuilder.remove();
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:41,代码来源:FibInstallerTest.java

示例13: addToHashedNextObjective

import org.onosproject.net.flowobjective.DefaultNextObjective; //导入依赖的package包/类
/**
 * Makes a call to the FlowObjective service to add buckets to
 * a hashed group. User must ensure that all the ports & labels are meant
 * same neighbor (ie. dstMac).
 *
 * @param portLabels a collection of port & label combinations to add
 *                   to the hash group identified by the nextId
 * @param dstMac destination mac address of next-hop
 * @param nextId id for next-objective to which buckets will be added
 *
 */
private void addToHashedNextObjective(Collection<PortLabel> portLabels,
                                      MacAddress dstMac, Integer nextId) {
    // setup metadata to pass to nextObjective - indicate the vlan on egress
    // if needed by the switch pipeline. Since hashed next-hops are always to
    // other neighboring routers, there is no subnet assigned on those ports.
    TrafficSelector.Builder metabuilder = DefaultTrafficSelector.builder();
    metabuilder.matchVlanId(INTERNAL_VLAN);
    NextObjective.Builder nextObjBuilder = DefaultNextObjective.builder()
            .withId(nextId)
            .withType(NextObjective.Type.HASHED)
            .withMeta(metabuilder.build())
            .fromApp(appId);
    // Create the new buckets to be updated
    portLabels.forEach(pl -> {
        TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
        tBuilder.setOutput(pl.port)
            .setEthDst(dstMac)
            .setEthSrc(nodeMacAddr);
        if (pl.edgeLabel != DestinationSet.NO_EDGE_LABEL) {
            tBuilder.pushMpls()
                .copyTtlOut()
                .setMpls(MplsLabel.mplsLabel(pl.edgeLabel));
        }
        nextObjBuilder.addTreatment(tBuilder.build());
    });

    log.debug("addToHash in device {}: Adding Bucket with port/label {} "
            + "to nextId {}", deviceId, portLabels, nextId);

    ObjectiveContext context = new DefaultObjectiveContext(
            (objective) -> log.debug("addToHash port/label {} addedTo "
                    + "NextObj {} on {}", portLabels, nextId, deviceId),
            (objective, error) ->
                    log.warn("addToHash failed to add port/label {} to"
                            + " NextObj {} on {}: {}", portLabels,
                             nextId, deviceId, error));
    NextObjective nextObjective = nextObjBuilder.addToExisting(context);
    flowObjectiveService.next(deviceId, nextObjective);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:51,代码来源:DefaultGroupHandler.java

示例14: removeFromHashedNextObjective

import org.onosproject.net.flowobjective.DefaultNextObjective; //导入依赖的package包/类
/**
 * Makes a call to the FlowObjective service to remove buckets from
 * a hash group. User must ensure that all the ports & labels are meant
 * same neighbor (ie. dstMac).
 *
 * @param portLabels a collection of port & label combinations to remove
 *                   from the hash group identified by the nextId
 * @param dstMac destination mac address of next-hop
 * @param nextId id for next-objective from which buckets will be removed
 */
private void removeFromHashedNextObjective(Collection<PortLabel> portLabels,
                                           MacAddress dstMac, Integer nextId) {
    NextObjective.Builder nextObjBuilder = DefaultNextObjective
            .builder()
            .withType(NextObjective.Type.HASHED) //same as original
            .withId(nextId)
            .fromApp(appId);
    // Create the buckets to be removed
    portLabels.forEach(pl -> {
        TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
        tBuilder.setOutput(pl.port)
            .setEthDst(dstMac)
            .setEthSrc(nodeMacAddr);
        if (pl.edgeLabel != DestinationSet.NO_EDGE_LABEL) {
            tBuilder.pushMpls()
                .copyTtlOut()
                .setMpls(MplsLabel.mplsLabel(pl.edgeLabel));
        }
        nextObjBuilder.addTreatment(tBuilder.build());
    });
    log.debug("removeFromHash in device {}: Removing Bucket with port/label"
            + " {} from nextId {}", deviceId, portLabels, nextId);

    ObjectiveContext context = new DefaultObjectiveContext(
            (objective) -> log.debug("port/label {} removedFrom NextObj"
                    + " {} on {}", portLabels, nextId, deviceId),
            (objective, error) ->
            log.warn("port/label {} failed to removeFrom NextObj {} on "
                    + "{}: {}", portLabels, nextId, deviceId, error));
    NextObjective nextObjective = nextObjBuilder.removeFromExisting(context);
    flowObjectiveService.next(deviceId, nextObjective);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:43,代码来源:DefaultGroupHandler.java

示例15: createGroupFromPort

import org.onosproject.net.flowobjective.DefaultNextObjective; //导入依赖的package包/类
/**
 * Create simple next objective for a single port. The treatments can include
 * all outgoing actions that need to happen on the packet.
 *
 * @param portNum  the outgoing port on the device
 * @param treatment the actions to apply on the packets (should include outport)
 * @param meta optional data to pass to the driver
 */
public void createGroupFromPort(PortNumber portNum, TrafficTreatment treatment,
                                TrafficSelector meta) {
    int nextId = flowObjectiveService.allocateNextId();
    PortNextObjectiveStoreKey key = new PortNextObjectiveStoreKey(
                                            deviceId, portNum, treatment, meta);

    NextObjective.Builder nextObjBuilder = DefaultNextObjective
            .builder().withId(nextId)
            .withType(NextObjective.Type.SIMPLE)
            .addTreatment(treatment)
            .fromApp(appId)
            .withMeta(meta);

    ObjectiveContext context = new DefaultObjectiveContext(
        (objective) ->
            log.debug("createGroupFromPort installed "
                    + "NextObj {} on {}", nextId, deviceId),
        (objective, error) ->
            log.warn("createGroupFromPort failed to install"
                    + " NextObj {} on {}: {}", nextId, deviceId, error)
        );
    NextObjective nextObj = nextObjBuilder.add(context);
    flowObjectiveService.next(deviceId, nextObj);
    log.debug("createGroupFromPort: Submited next objective {} in device {} "
            + "for port {}", nextId, deviceId, portNum);

    portNextObjStore.put(key, nextId);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:37,代码来源:DefaultGroupHandler.java


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