use of org.openkilda.messaging.command.flow.FlowRequest in project open-kilda by telstra.
the class FlowMapperTest method testFlowCreatePayloadToFlowRequest.
@Test
public void testFlowCreatePayloadToFlowRequest() {
FlowRequest flowRequest = flowMapper.toFlowCreateRequest(FLOW_CREATE_PAYLOAD);
assertEquals(FLOW_CREATE_PAYLOAD.getDiverseFlowId(), flowRequest.getDiverseFlowId());
assertEquals(Type.CREATE, flowRequest.getType());
assertFlowDtos(FLOW_CREATE_PAYLOAD, flowRequest);
}
use of org.openkilda.messaging.command.flow.FlowRequest in project open-kilda by telstra.
the class FlowMapperTest method testFlowUpdatePayloadToFlowRequest.
@Test
public void testFlowUpdatePayloadToFlowRequest() {
FlowRequest flowRequest = flowMapper.toFlowUpdateRequest(FLOW_UPDATE_PAYLOAD);
assertEquals(FLOW_UPDATE_PAYLOAD.getDiverseFlowId(), flowRequest.getDiverseFlowId());
assertEquals(Type.UPDATE, flowRequest.getType());
assertFlowDtos(FLOW_UPDATE_PAYLOAD, flowRequest);
}
use of org.openkilda.messaging.command.flow.FlowRequest in project open-kilda by telstra.
the class FlowServiceImpl method createFlow.
@Override
public CompletableFuture<FlowResponseV2> createFlow(FlowRequestV2 request) {
logger.info("Processing flow creation: {}", 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::toFlowResponseV2);
}
use of org.openkilda.messaging.command.flow.FlowRequest in project open-kilda by telstra.
the class FlowServiceImpl method updateFlow.
@Override
public CompletableFuture<FlowResponseV2> updateFlow(FlowRequestV2 request) {
logger.info("Processing flow update: {}", request);
final String correlationId = RequestCorrelationId.getId();
FlowRequest updateRequest;
try {
updateRequest = flowMapper.toFlowRequest(request).toBuilder().type(Type.UPDATE).build();
} 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::toFlowResponseV2);
}
use of org.openkilda.messaging.command.flow.FlowRequest in project open-kilda by telstra.
the class FlowMapper method toFlowUpdateRequest.
/**
* Map FlowUpdatePayload.
*
* @param source {@link FlowUpdatePayload} instance.
* @return {@link FlowRequest} instance.
*/
public FlowRequest toFlowUpdateRequest(FlowUpdatePayload source) {
FlowRequest target = toFlowRequest(source).toBuilder().diverseFlowId(source.getDiverseFlowId()).type(Type.UPDATE).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;
}
Aggregations