Java Code Examples for org.onosproject.net.flow.DefaultTrafficSelector#emptySelector()
The following examples show how to use
org.onosproject.net.flow.DefaultTrafficSelector#emptySelector() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VirtualNetworkFlowObjectiveManagerTest.java From onos with Apache License 2.0 | 6 votes |
/** * Tests adding a forwarding objective. */ @Test public void forwardingObjective() { TrafficSelector selector = DefaultTrafficSelector.emptySelector(); TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment(); ForwardingObjective forward = DefaultForwardingObjective.builder() .fromApp(NetTestTools.APP_ID) .withFlag(ForwardingObjective.Flag.SPECIFIC) .withSelector(selector) .withTreatment(treatment) .makePermanent() .add(new ObjectiveContext() { @Override public void onSuccess(Objective objective) { assertEquals("1 flowrule entry expected", 1, flowRuleStore.getFlowRuleCount(vnet1.id())); assertEquals("0 flowrule entry expected", 0, flowRuleStore.getFlowRuleCount(vnet2.id())); } }); service1.forward(VDID1, forward); }
Example 2
Source File: DemoInstaller.java From onos with Apache License 2.0 | 6 votes |
@Override public void run() { TrafficSelector selector = DefaultTrafficSelector.emptySelector(); TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment(); List<Constraint> constraint = Lists.newArrayList(); List<Host> hosts = Lists.newArrayList(hostService.getHosts()); while (!hosts.isEmpty()) { Host src = hosts.remove(0); for (Host dst : hosts) { HostToHostIntent intent = HostToHostIntent.builder() .appId(appId) .one(src.id()) .two(dst.id()) .selector(selector) .treatment(treatment) .constraints(constraint) .build(); existingIntents.add(intent); intentService.submit(intent); } } }
Example 3
Source File: FlowObjectiveManagerTest.java From onos with Apache License 2.0 | 6 votes |
/** * Tests adding a forwarding objective. */ @Test public void forwardingObjective() { TrafficSelector selector = DefaultTrafficSelector.emptySelector(); TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment(); ForwardingObjective forward = DefaultForwardingObjective.builder() .fromApp(NetTestTools.APP_ID) .withFlag(ForwardingObjective.Flag.SPECIFIC) .withSelector(selector) .withTreatment(treatment) .makePermanent() .add(); manager.forward(id1, forward); TestTools.assertAfter(RETRY_MS, () -> assertThat(forwardingObjectives, hasSize(1))); assertThat(forwardingObjectives, hasItem("of:d1")); assertThat(filteringObjectives, hasSize(0)); assertThat(nextObjectives, hasSize(0)); }
Example 4
Source File: AbstractIntentInstallerTest.java From onos with Apache License 2.0 | 6 votes |
/** * Creates point to point Intent for test. * * @return the point to point Intent */ public PointToPointIntent createP2PIntent() { PointToPointIntent intent; TrafficSelector selector = DefaultTrafficSelector.emptySelector(); TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment(); FilteredConnectPoint ingress = new FilteredConnectPoint(CP1); FilteredConnectPoint egress = new FilteredConnectPoint(CP2); intent = PointToPointIntent.builder() .selector(selector) .treatment(treatment) .filteredIngressPoint(ingress) .filteredEgressPoint(egress) .appId(APP_ID) .build(); return intent; }
Example 5
Source File: AbstractIntentInstallerTest.java From onos with Apache License 2.0 | 6 votes |
/** * Creates point to point Intent for testing non-disruptive reallocation. * * @return the point to point Intent */ public PointToPointIntent createP2PIntentNonDisruptive() { PointToPointIntent intent; TrafficSelector selector = DefaultTrafficSelector.emptySelector(); TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment(); FilteredConnectPoint ingress = new FilteredConnectPoint(CP1); FilteredConnectPoint egress = new FilteredConnectPoint(CP4_1); List<Constraint> constraints = ImmutableList.of(nonDisruptive()); intent = PointToPointIntent.builder() .selector(selector) .treatment(treatment) .filteredIngressPoint(ingress) .filteredEgressPoint(egress) .constraints(constraints) .appId(APP_ID) .build(); return intent; }
Example 6
Source File: ForwardingObjectiveTranslator.java From onos with Apache License 2.0 | 5 votes |
private void defaultIpv4Route(ForwardingObjective obj, ObjectiveTranslation.Builder resultBuilder) throws FabricPipelinerException { ForwardingObjective defaultObj = obj.copy() .withPriority(0) .add(); final TrafficSelector selector = DefaultTrafficSelector.emptySelector(); resultBuilder.addFlowRule(flowRule( defaultObj, FabricConstants.FABRIC_INGRESS_FORWARDING_ROUTING_V4, selector)); }
Example 7
Source File: VirtualNetworkPacketManagerTest.java From onos with Apache License 2.0 | 5 votes |
/** * Tests the addition and removal of packet requests for a device. * * @throws TestUtils.TestUtilsException */ @Test public void requestAndCancelPacketsForDeviceTest() throws TestUtils.TestUtilsException { TestFlowObjectiveService testFlowObjectiveService = new TestFlowObjectiveService(); TestUtils.setField(packetManager1, "objectiveService", testFlowObjectiveService); TrafficSelector ts = DefaultTrafficSelector.emptySelector(); Optional<DeviceId> optionalDeviceId = Optional.of(VDID3); // add first request packetManager1.requestPackets(ts, CONTROL, appId, optionalDeviceId); assertEquals("1 packet expected", 1, packetManager1.getRequests().size()); testFlowObjectiveService.validateObjectiveForDevice(VDID3, ts, CONTROL, ADD); // add same request as first packetManager1.requestPackets(ts, CONTROL, appId, optionalDeviceId); assertEquals("1 packet expected", 1, packetManager1.getRequests().size()); testFlowObjectiveService.validateObjectiveForDevice(VDID3, ts, CONTROL, ADD); // add second request packetManager1.requestPackets(ts, REACTIVE, appId, optionalDeviceId); assertEquals("2 packets expected", 2, packetManager1.getRequests().size()); testFlowObjectiveService.validateObjectiveForDevice(VDID3, ts, REACTIVE, ADD); // cancel second request packetManager1.cancelPackets(ts, REACTIVE, appId, optionalDeviceId); assertEquals("1 packet expected", 1, packetManager1.getRequests().size()); testFlowObjectiveService.validateObjectiveForDevice(VDID3, ts, REACTIVE, REMOVE); // cancel second request again packetManager1.cancelPackets(ts, REACTIVE, appId, optionalDeviceId); assertEquals("1 packet expected", 1, packetManager1.getRequests().size()); testFlowObjectiveService.validateObjectiveForDevice(VDID3, ts, REACTIVE, REMOVE); // cancel first request packetManager1.cancelPackets(ts, CONTROL, appId, optionalDeviceId); assertEquals("0 packet expected", 0, packetManager1.getRequests().size()); testFlowObjectiveService.validateObjectiveForDevice(VDID3, ts, CONTROL, REMOVE); }
Example 8
Source File: VirtualNetworkPacketManagerTest.java From onos with Apache License 2.0 | 5 votes |
/** * Tests the addition and removal of packet requests for all devices in a virtual * network. * * @throws TestUtils.TestUtilsException */ @Test public void requestAndCancelPacketsForVnetTest() throws TestUtils.TestUtilsException { TestFlowObjectiveService testFlowObjectiveService = new TestFlowObjectiveService(); TestUtils.setField(packetManager1, "objectiveService", testFlowObjectiveService); TrafficSelector ts = DefaultTrafficSelector.emptySelector(); Set<VirtualDevice> vnet1Devices = manager.getVirtualDevices(vnet1.id()); // add first request packetManager1.requestPackets(ts, CONTROL, appId); assertEquals("1 packet expected", 1, packetManager1.getRequests().size()); testFlowObjectiveService.validateObjectives(vnet1Devices, ts, CONTROL, ADD); // add same request as first packetManager1.requestPackets(ts, CONTROL, appId); assertEquals("1 packet expected", 1, packetManager1.getRequests().size()); testFlowObjectiveService.validateObjectives(vnet1Devices, ts, CONTROL, ADD); // add second request packetManager1.requestPackets(ts, REACTIVE, appId); assertEquals("2 packets expected", 2, packetManager1.getRequests().size()); testFlowObjectiveService.validateObjectives(vnet1Devices, ts, REACTIVE, ADD); // cancel second request packetManager1.cancelPackets(ts, REACTIVE, appId); assertEquals("1 packet expected", 1, packetManager1.getRequests().size()); testFlowObjectiveService.validateObjectives(vnet1Devices, ts, REACTIVE, REMOVE); // cancel second request again packetManager1.cancelPackets(ts, REACTIVE, appId); assertEquals("1 packet expected", 1, packetManager1.getRequests().size()); testFlowObjectiveService.validateObjectives(vnet1Devices, ts, REACTIVE, REMOVE); // cancel first request packetManager1.cancelPackets(ts, CONTROL, appId); assertEquals("0 packet expected", 0, packetManager1.getRequests().size()); testFlowObjectiveService.validateObjectives(vnet1Devices, ts, CONTROL, REMOVE); }
Example 9
Source File: FlowObjectiveManagerTest.java From onos with Apache License 2.0 | 5 votes |
/** * Tests receipt of a device up event. * * @throws TestUtilsException if lookup of a field fails */ @Test public void deviceUpEvent() throws TestUtilsException { TrafficSelector selector = DefaultTrafficSelector.emptySelector(); TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment(); DeviceEvent event = new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, d2); DeviceListener listener = TestUtils.getField(manager, "deviceListener"); assertThat(listener, notNullValue()); listener.event(event); ForwardingObjective forward = DefaultForwardingObjective.builder() .fromApp(NetTestTools.APP_ID) .withFlag(ForwardingObjective.Flag.SPECIFIC) .withSelector(selector) .withTreatment(treatment) .makePermanent() .add(); manager.forward(id2, forward); // new device should have an objective now TestTools.assertAfter(RETRY_MS, () -> assertThat(forwardingObjectives, hasSize(1))); assertThat(forwardingObjectives, hasItem("of:d2")); assertThat(filteringObjectives, hasSize(0)); assertThat(nextObjectives, hasSize(0)); }
Example 10
Source File: FlowObjectiveManagerTest.java From onos with Apache License 2.0 | 4 votes |
/** * Tests adding a pending forwarding objective. * * @throws TestUtilsException if lookup of a field fails */ @Test public void pendingForwardingObjective() throws TestUtilsException { TrafficSelector selector = DefaultTrafficSelector.emptySelector(); TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment(); ForwardingObjective forward4 = DefaultForwardingObjective.builder() .fromApp(NetTestTools.APP_ID) .withFlag(ForwardingObjective.Flag.SPECIFIC) .withSelector(selector) .withTreatment(treatment) .makePermanent() .nextStep(4) .add(); ForwardingObjective forward5 = DefaultForwardingObjective.builder() .fromApp(NetTestTools.APP_ID) .withFlag(ForwardingObjective.Flag.SPECIFIC) .withSelector(selector) .withTreatment(treatment) .makePermanent() .nextStep(5) .add(); // multiple pending forwards should be combined manager.forward(id1, forward4); manager.forward(id1, forward4); manager.forward(id1, forward5); // 1 should be complete, 1 pending TestTools.assertAfter(RETRY_MS, () -> assertThat(forwardingObjectives, hasSize(1))); assertThat(forwardingObjectives, hasItem("of:d1")); assertThat(filteringObjectives, hasSize(0)); assertThat(nextObjectives, hasSize(0)); // Now send events to trigger the objective still in the queue ObjectiveEvent event1 = new ObjectiveEvent(ObjectiveEvent.Type.ADD, 4); FlowObjectiveStoreDelegate delegate = TestUtils.getField(manager, "delegate"); delegate.notify(event1); // all should be processed now TestTools.assertAfter(RETRY_MS, () -> assertThat(forwardingObjectives, hasSize(2))); assertThat(forwardingObjectives, hasItem("of:d1")); assertThat(filteringObjectives, hasSize(0)); assertThat(nextObjectives, hasSize(0)); }
Example 11
Source File: FilteredConnectPoint.java From onos with Apache License 2.0 | 2 votes |
/** * Creates filtered connect point with default traffic selector. * * @param connectPoint connect point */ public FilteredConnectPoint(ConnectPoint connectPoint) { this.connectPoint = connectPoint; this.trafficSelector = DefaultTrafficSelector.emptySelector(); }
Example 12
Source File: NetTestTools.java From onos with Apache License 2.0 | 2 votes |
/** * Builds an empty selector. * * @return the selector */ public static TrafficSelector emptySelector() { return DefaultTrafficSelector.emptySelector(); }