use of org.onosproject.net.flowobjective.ObjectiveContext in project onos by opennetworkinglab.
the class VirtualNetworkFlowObjectiveManagerTest method nextObjective.
/**
* Tests adding a next objective.
*/
@Test
public void nextObjective() {
TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
NextObjective nextObjective = DefaultNextObjective.builder().withId(service1.allocateNextId()).fromApp(NetTestTools.APP_ID).addTreatment(treatment).withType(NextObjective.Type.BROADCAST).makePermanent().add(new ObjectiveContext() {
@Override
public void onSuccess(Objective objective) {
assertEquals("1 next map entry expected", 1, service1.getNextMappings().size());
assertEquals("0 next map entry expected", 0, service2.getNextMappings().size());
}
});
service1.next(VDID1, nextObjective);
}
use of org.onosproject.net.flowobjective.ObjectiveContext in project onos by opennetworkinglab.
the class InOrderFlowObjectiveManagerTest method forwardTimeout.
@Test
public void forwardTimeout() {
final AtomicInteger counter = new AtomicInteger(0);
ForwardingObjective fwdTimeout = buildFwdObjective(S1, NID2).add(new ObjectiveContext() {
@Override
public void onError(Objective objective, ObjectiveError error) {
if (Objects.equals(ObjectiveError.INSTALLATIONTIMEOUT, error)) {
counter.incrementAndGet();
}
}
});
List<ForwardingObjective> expectFwdObjsTimeout = Lists.newCopyOnWriteArrayList(Lists.newArrayList(fwdTimeout, FWD1, FWD2));
// Reduce timeout so the unit test doesn't have to wait many seconds
internalSetup(TIMEOUT_THRESH);
expect(mgr.flowObjectiveStore.getNextGroup(NID1)).andReturn(NGRP1).times(1);
expect(mgr.flowObjectiveStore.getNextGroup(NID2)).andReturn(NGRP2).times(2);
replay(mgr.flowObjectiveStore);
// Force this objective to time out
offset = mgr.objectiveTimeoutMs * 3;
expectFwdObjsTimeout.forEach(fwdObj -> mgr.forward(DEV1, fwdObj));
// Wait for the pipeline operation to complete
int expectedTime = (bound + offset) * 3;
assertAfter(expectedTime, expectedTime * 5, () -> assertEquals(expectFwdObjsTimeout.size(), actualObjs.size()));
assertAfter(expectedTime, expectedTime * 5, () -> assertTrue(counter.get() != 0));
assertTrue(actualObjs.indexOf(fwdTimeout) < actualObjs.indexOf(FWD1));
verify(mgr.flowObjectiveStore);
}
use of org.onosproject.net.flowobjective.ObjectiveContext in project onos by opennetworkinglab.
the class VirtualNetworkPacketManager method pushRule.
/**
* Pushes packet intercept flow rules to the device.
*
* @param device the device to push the rules to
* @param request the packet request
*/
private void pushRule(Device device, PacketRequest request) {
if (!device.type().equals(Device.Type.VIRTUAL)) {
return;
}
ForwardingObjective forwarding = createBuilder(request).add(new ObjectiveContext() {
@Override
public void onError(Objective objective, ObjectiveError error) {
log.warn("Failed to install packet request {} to {}: {}", request, device.id(), error);
}
});
objectiveService.forward(device.id(), forwarding);
}
use of org.onosproject.net.flowobjective.ObjectiveContext in project onos by opennetworkinglab.
the class PacketManager method removeRule.
/**
* Removes packet intercept flow rules from the device.
*
* @param device the device to remove the rules deom
* @param request the packet request
*/
private void removeRule(Device device, PacketRequest request) {
if (!device.type().equals(Device.Type.SWITCH)) {
return;
}
ForwardingObjective forwarding = createBuilder(request).remove(new ObjectiveContext() {
@Override
public void onError(Objective objective, ObjectiveError error) {
log.warn("Failed to withdraw packet request {} from {}: {}", request, device.id(), error);
}
});
objectiveService.forward(device.id(), forwarding);
}
use of org.onosproject.net.flowobjective.ObjectiveContext in project onos by opennetworkinglab.
the class PacketManager method pushRule.
/**
* Pushes packet intercept flow rules to the device.
*
* @param device the device to push the rules to
* @param request the packet request
*/
private void pushRule(Device device, PacketRequest request) {
if (!device.type().equals(Device.Type.SWITCH)) {
return;
}
if (!deviceService.isAvailable(device.id())) {
return;
}
ForwardingObjective forwarding = createBuilder(request).add(new ObjectiveContext() {
@Override
public void onError(Objective objective, ObjectiveError error) {
log.warn("Failed to install packet request {} to {}: {}", request, device.id(), error);
}
});
objectiveService.forward(device.id(), forwarding);
}
Aggregations