use of org.onosproject.portloadbalancer.api.PortLoadBalancerData in project onos by opennetworkinglab.
the class PortLoadBalancerManager method onErrorHandler.
private void onErrorHandler(NextObjective nextObjective, PortLoadBalancerId portLoadBalancerId) {
// There was a failure
PortLoadBalancerData portLoadBalancerData = new PortLoadBalancerData(portLoadBalancerId);
// send FAILED event;
switch(nextObjective.op()) {
case ADD:
// If ADD is failing apps do not know the next id; let's update the store
portLoadBalancerNextStore.remove(portLoadBalancerId);
portLoadBalancerResStore.remove(portLoadBalancerId);
portLoadBalancerStore.remove(portLoadBalancerId);
post(new PortLoadBalancerEvent(PortLoadBalancerEvent.Type.FAILED, portLoadBalancerData, portLoadBalancerData));
break;
case ADD_TO_EXISTING:
// If ADD_TO_EXISTING is failing let's remove the failed ports
Collection<PortNumber> addedPorts = nextObjective.next().stream().flatMap(t -> t.allInstructions().stream()).filter(i -> i.type() == Instruction.Type.OUTPUT).map(i -> ((Instructions.OutputInstruction) i).port()).collect(Collectors.toList());
portLoadBalancerStore.compute(portLoadBalancerId, (key, value) -> {
if (value != null && value.ports() != null && !value.ports().isEmpty()) {
value.ports().removeAll(addedPorts);
}
return value;
});
portLoadBalancerData.setNextId(nextObjective.id());
post(new PortLoadBalancerEvent(PortLoadBalancerEvent.Type.FAILED, portLoadBalancerData, portLoadBalancerData));
break;
case REMOVE_FROM_EXISTING:
// If REMOVE_TO_EXISTING is failing let's re-add the failed ports
Collection<PortNumber> removedPorts = nextObjective.next().stream().flatMap(t -> t.allInstructions().stream()).filter(i -> i.type() == Instruction.Type.OUTPUT).map(i -> ((Instructions.OutputInstruction) i).port()).collect(Collectors.toList());
portLoadBalancerStore.compute(portLoadBalancerId, (key, value) -> {
if (value != null && value.ports() != null) {
value.ports().addAll(removedPorts);
}
return value;
});
portLoadBalancerData.setNextId(nextObjective.id());
post(new PortLoadBalancerEvent(PortLoadBalancerEvent.Type.FAILED, portLoadBalancerData, portLoadBalancerData));
break;
case VERIFY:
case REMOVE:
// If ADD/REMOVE_TO_EXISTING, REMOVE and VERIFY are failing let's send
// also the info about the next id
portLoadBalancerData.setNextId(nextObjective.id());
post(new PortLoadBalancerEvent(PortLoadBalancerEvent.Type.FAILED, portLoadBalancerData, portLoadBalancerData));
break;
default:
break;
}
}
use of org.onosproject.portloadbalancer.api.PortLoadBalancerData in project onos by opennetworkinglab.
the class PortLoadBalancerManager method onSuccessHandler.
private void onSuccessHandler(NextObjective nextObjective, PortLoadBalancerId portLoadBalancerId) {
// Operation done
PortLoadBalancerData oldPortLoadBalancerData = new PortLoadBalancerData(portLoadBalancerId);
PortLoadBalancerData newPortLoadBalancerData = new PortLoadBalancerData(portLoadBalancerId);
// Other operations will not lead to a generation of an event
switch(nextObjective.op()) {
case ADD:
newPortLoadBalancerData.setNextId(nextObjective.id());
post(new PortLoadBalancerEvent(PortLoadBalancerEvent.Type.INSTALLED, newPortLoadBalancerData, oldPortLoadBalancerData));
break;
case REMOVE:
oldPortLoadBalancerData.setNextId(nextObjective.id());
post(new PortLoadBalancerEvent(PortLoadBalancerEvent.Type.UNINSTALLED, newPortLoadBalancerData, oldPortLoadBalancerData));
break;
default:
break;
}
}
Aggregations