Search in sources :

Example 1 with UpdateSwitchUnderMaintenanceRequest

use of org.openkilda.messaging.nbtopology.request.UpdateSwitchUnderMaintenanceRequest in project open-kilda by telstra.

the class SwitchServiceImpl method updateSwitchUnderMaintenance.

/**
 * {@inheritDoc}
 */
@Override
public CompletableFuture<SwitchDto> updateSwitchUnderMaintenance(SwitchId switchId, UnderMaintenanceDto underMaintenanceDto) {
    String correlationId = RequestCorrelationId.getId();
    logger.debug("Update under maintenance flag for switch request processing");
    UpdateSwitchUnderMaintenanceRequest data = new UpdateSwitchUnderMaintenanceRequest(switchId, underMaintenanceDto.isUnderMaintenance(), underMaintenanceDto.isEvacuate());
    CommandMessage request = new CommandMessage(data, System.currentTimeMillis(), correlationId);
    return messagingChannel.sendAndGetChunked(nbworkerTopic, request).thenApply(messages -> messages.stream().map(GetSwitchResponse.class::cast).map(GetSwitchResponse::getPayload).map(switchMapper::toSwitchDto).collect(Collectors.toList()).get(0));
}
Also used : GetSwitchResponse(org.openkilda.messaging.nbtopology.response.GetSwitchResponse) UpdateSwitchUnderMaintenanceRequest(org.openkilda.messaging.nbtopology.request.UpdateSwitchUnderMaintenanceRequest) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Aggregations

CommandMessage (org.openkilda.messaging.command.CommandMessage)1 UpdateSwitchUnderMaintenanceRequest (org.openkilda.messaging.nbtopology.request.UpdateSwitchUnderMaintenanceRequest)1 GetSwitchResponse (org.openkilda.messaging.nbtopology.response.GetSwitchResponse)1