use of org.openkilda.messaging.command.flow.FlowRequest in project open-kilda by telstra.
the class FlowServiceImpl method updateFlow.
/**
* {@inheritDoc}
*/
@Override
public CompletableFuture<FlowResponsePayload> updateFlow(final FlowUpdatePayload request) {
logger.info("Update flow request for flow {}", request.getId());
final String correlationId = RequestCorrelationId.getId();
FlowRequest updateRequest;
try {
updateRequest = flowMapper.toFlowUpdateRequest(request);
} catch (IllegalArgumentException e) {
logger.error("Can not parse arguments: {}", e.getMessage(), e);
throw new MessageException(correlationId, System.currentTimeMillis(), ErrorType.DATA_INVALID, e.getMessage(), "Can not parse arguments of the update flow request");
}
CommandMessage command = new CommandMessage(updateRequest, System.currentTimeMillis(), correlationId, Destination.WFM);
return messagingChannel.sendAndGet(flowHsTopic, command).thenApply(FlowResponse.class::cast).thenApply(FlowResponse::getPayload).thenApply(flowMapper::toFlowResponseOutput);
}
use of org.openkilda.messaging.command.flow.FlowRequest in project open-kilda by telstra.
the class FlowMapper method toFlowCreateRequest.
/**
* Map FlowCreatePayload.
*
* @param source {@link FlowCreatePayload} instance.
* @return {@link FlowRequest} instance.
*/
public FlowRequest toFlowCreateRequest(FlowCreatePayload source) {
FlowRequest target = toFlowRequest(source).toBuilder().diverseFlowId(source.getDiverseFlowId()).type(Type.CREATE).build();
if (source.getSource().getDetectConnectedDevices() != null) {
DetectConnectedDevicesPayload srcDevs = source.getSource().getDetectConnectedDevices();
target.getDetectConnectedDevices().setSrcArp(srcDevs.isArp());
target.getDetectConnectedDevices().setSrcLldp(srcDevs.isLldp());
}
if (source.getDestination().getDetectConnectedDevices() != null) {
DetectConnectedDevicesPayload dstDevs = source.getDestination().getDetectConnectedDevices();
target.getDetectConnectedDevices().setDstArp(dstDevs.isArp());
target.getDetectConnectedDevices().setDstLldp(dstDevs.isLldp());
}
return target;
}
use of org.openkilda.messaging.command.flow.FlowRequest in project open-kilda by telstra.
the class FlowServiceImpl method createFlow.
/**
* {@inheritDoc}
*/
@Override
public CompletableFuture<FlowResponsePayload> createFlow(FlowCreatePayload request) {
logger.info("Create flow: {}", request);
final String correlationId = RequestCorrelationId.getId();
FlowRequest flowRequest;
try {
flowRequest = flowMapper.toFlowCreateRequest(request);
} catch (IllegalArgumentException e) {
logger.error("Can not parse arguments: {}", e.getMessage(), e);
throw new MessageException(correlationId, System.currentTimeMillis(), ErrorType.DATA_INVALID, e.getMessage(), "Can not parse arguments of the create flow request");
}
CommandMessage command = new CommandMessage(flowRequest, System.currentTimeMillis(), correlationId, Destination.WFM);
return messagingChannel.sendAndGet(flowHsTopic, command).thenApply(FlowResponse.class::cast).thenApply(FlowResponse::getPayload).thenApply(flowMapper::toFlowResponseOutput);
}
use of org.openkilda.messaging.command.flow.FlowRequest in project open-kilda by telstra.
the class FlowUpdateHubBolt method onRequest.
@Override
protected void onRequest(Tuple input) throws PipelineException {
currentKey = input.getStringByField(MessageKafkaTranslator.FIELD_ID_KEY);
Object payload = input.getValueByField(FIELD_ID_PAYLOAD);
try {
if (payload instanceof FlowRequest) {
FlowRequest flowRequest = (FlowRequest) payload;
service.handleUpdateRequest(currentKey, pullContext(input), flowRequest);
} else if (payload instanceof CreateFlowLoopRequest) {
CreateFlowLoopRequest flowLoopRequest = (CreateFlowLoopRequest) payload;
service.handleCreateFlowLoopRequest(currentKey, pullContext(input), flowLoopRequest);
} else if (payload instanceof DeleteFlowLoopRequest) {
DeleteFlowLoopRequest flowLoopRequest = (DeleteFlowLoopRequest) payload;
service.handleDeleteFlowLoopRequest(currentKey, pullContext(input), flowLoopRequest);
} else {
unhandledInput(input);
}
} catch (DuplicateKeyException e) {
log.error("Failed to handle a request with key {}. {}", currentKey, e.getMessage());
}
}
use of org.openkilda.messaging.command.flow.FlowRequest in project open-kilda by telstra.
the class FlowCreateServiceTest method shouldCreateFlowWithTransitSwitches.
@Test
public void shouldCreateFlowWithTransitSwitches() throws Exception {
FlowRequest request = makeRequest().flowId("test_successful_flow_id").build();
preparePathComputation(request.getFlowId(), make3SwitchesPathPair());
testHappyPath(request, "successful_flow_create");
}
Aggregations