use of org.openkilda.wfm.CommandContext in project open-kilda by telstra.
the class FlowCreateServiceTest method testHappyPath.
private Flow testHappyPath(FlowRequest flowRequest, String key) throws DuplicateKeyException {
FlowCreateService service = makeService();
service.handleRequest(key, new CommandContext(), flowRequest);
Flow inProgress = verifyFlowStatus(flowRequest.getFlowId(), FlowStatus.IN_PROGRESS);
verifyFlowPathStatus(inProgress.getForwardPath(), FlowPathStatus.IN_PROGRESS, "forward");
verifyFlowPathStatus(inProgress.getReversePath(), FlowPathStatus.IN_PROGRESS, "reverse");
verifyNorthboundSuccessResponse(carrier);
FlowSegmentRequest request;
while ((request = requests.poll()) != null) {
try {
if (request.isVerifyRequest()) {
service.handleAsyncResponse(key, buildResponseOnVerifyRequest(request));
} else {
handleResponse(service, key, request);
}
} catch (UnknownKeyException ex) {
// skip
}
}
Flow result = verifyFlowStatus(flowRequest.getFlowId(), FlowStatus.UP);
verifyFlowPathStatus(result.getForwardPath(), FlowPathStatus.ACTIVE, "forward");
verifyFlowPathStatus(result.getReversePath(), FlowPathStatus.ACTIVE, "reverse");
return result;
}
use of org.openkilda.wfm.CommandContext in project open-kilda by telstra.
the class LinkOperationsBolt method updateLinkUnderMaintenanceFlag.
private List<IslInfoData> updateLinkUnderMaintenanceFlag(UpdateLinkUnderMaintenanceRequest request) {
SwitchId srcSwitch = request.getSource().getDatapath();
Integer srcPort = request.getSource().getPortNumber();
SwitchId dstSwitch = request.getDestination().getDatapath();
Integer dstPort = request.getDestination().getPortNumber();
boolean underMaintenance = request.isUnderMaintenance();
boolean evacuate = request.isEvacuate();
List<Isl> isl;
try {
isl = linkOperationsService.updateLinkUnderMaintenanceFlag(srcSwitch, srcPort, dstSwitch, dstPort, underMaintenance);
if (underMaintenance && evacuate) {
Set<IslEndpoint> affectedIslEndpoints = new HashSet<>();
affectedIslEndpoints.add(new IslEndpoint(srcSwitch, srcPort));
affectedIslEndpoints.add(new IslEndpoint(dstSwitch, dstPort));
String reason = format("evacuated due to link maintenance %s_%d - %s_%d", srcSwitch, srcPort, dstSwitch, dstPort);
Collection<FlowPath> targetPaths = flowOperationsService.getFlowPathsForLink(srcSwitch, srcPort, dstSwitch, dstPort);
for (FlowRerouteRequest reroute : flowOperationsService.makeRerouteRequests(targetPaths, affectedIslEndpoints, reason)) {
CommandContext forkedContext = getCommandContext().fork(reroute.getFlowId());
getOutput().emit(StreamType.REROUTE.toString(), getCurrentTuple(), new Values(reroute, forkedContext.getCorrelationId()));
}
}
} catch (IslNotFoundException e) {
throw new MessageException(ErrorType.NOT_FOUND, e.getMessage(), "ISL was not found.");
}
return isl.stream().map(IslMapper.INSTANCE::map).collect(Collectors.toList());
}
use of org.openkilda.wfm.CommandContext in project open-kilda by telstra.
the class NetworkPersistedStateImportHandler method switchAddWithHistory.
/**
* Emit new history fact about switch.
* @param historyFacts entity
*/
public void switchAddWithHistory(HistoryFacts historyFacts) {
SwitchHistoryCommand command = new SwitchHistoryCommand(historyFacts);
SwitchId switchId = command.getDatapath();
CommandContext context = getCommandContext().fork(switchId.toOtsdFormat());
getOutput().emit(new Values(switchId, command, context));
}
use of org.openkilda.wfm.CommandContext in project open-kilda by telstra.
the class DecisionMakerHandler method makeDefaultTuple.
// Private
private Values makeDefaultTuple(PortCommand command) {
Endpoint endpoint = command.getEndpoint();
CommandContext context = forkContext("DM", endpoint.toString());
return new Values(endpoint.getDatapath(), endpoint.getPortNumber(), command, context);
}
use of org.openkilda.wfm.CommandContext in project open-kilda by telstra.
the class SwitchHandler method makePortTuple.
private Values makePortTuple(PortCommand command) {
Endpoint endpoint = command.getEndpoint();
CommandContext context = forkContext(endpoint.toString());
return new Values(endpoint.getDatapath(), endpoint.getPortNumber(), command, context);
}
Aggregations