use of org.openkilda.messaging.payload.flow.FlowIdStatusPayload in project open-kilda by telstra.
the class KafkaMessageConsumer method receive.
/**
* Receives messages from WorkFlowManager queue.
*
* @param record the message object instance
*/
@KafkaListener(topics = "kilda-test")
public void receive(final String record) {
logger.debug("message received: {}", record);
try {
Message message = MAPPER.readValue(record, Message.class);
if (message.getDestination() == null || Destination.TOPOLOGY_ENGINE.equals(message.getDestination())) {
if (message instanceof CommandMessage) {
CommandData data = ((CommandMessage) message).getData();
if (data instanceof FlowCreateRequest) {
FlowPayload payload = ((FlowCreateRequest) data).getPayload();
logger.debug("FlowCreateRequest: {}", payload);
Set<CommandMessage> commands = flowService.createFlow(payload, message.getCorrelationId());
for (CommandMessage response : commands) {
kafkaMessageProducer.send(topic, response);
}
logger.debug("Response send, {}={}", CORRELATION_ID, message.getCorrelationId());
} else if (data instanceof FlowDeleteRequest) {
FlowIdStatusPayload payload = ((FlowDeleteRequest) data).getPayload();
logger.debug("FlowDeleteRequest: {}", payload);
Set<CommandMessage> commands = flowService.deleteFlow(payload, message.getCorrelationId());
for (CommandMessage response : commands) {
kafkaMessageProducer.send(topic, response);
}
logger.debug("Response send, {}={}", CORRELATION_ID, message.getCorrelationId());
} else if (data instanceof FlowUpdateRequest) {
FlowPayload payload = ((FlowUpdateRequest) data).getPayload();
logger.debug("FlowUpdateRequest: {}", payload);
Set<CommandMessage> commands = flowService.updateFlow(payload, message.getCorrelationId());
for (CommandMessage response : commands) {
kafkaMessageProducer.send(topic, response);
}
logger.debug("Response send, {}={}", CORRELATION_ID, message.getCorrelationId());
} else if (data instanceof FlowGetRequest) {
FlowIdStatusPayload payload = ((FlowGetRequest) data).getPayload();
logger.debug("FlowGetRequest: {}", payload);
InfoMessage response = flowService.getFlow(payload, message.getCorrelationId());
kafkaMessageProducer.send(topic, response);
logger.debug("Response send, {}={}", CORRELATION_ID, message.getCorrelationId());
} else if (data instanceof FlowsGetRequest) {
FlowIdStatusPayload payload = ((FlowsGetRequest) data).getPayload();
logger.debug("FlowsGetRequest: {}", payload);
InfoMessage response = flowService.getFlows(payload, message.getCorrelationId());
kafkaMessageProducer.send(topic, response);
logger.debug("Response send, {}={}", CORRELATION_ID, message.getCorrelationId());
} else if (data instanceof FlowPathRequest) {
FlowIdStatusPayload payload = ((FlowPathRequest) data).getPayload();
logger.debug("FlowPathRequest: {}", payload);
InfoMessage response = flowService.pathFlow(payload, message.getCorrelationId());
kafkaMessageProducer.send(topic, response);
logger.debug("Response send, {}={}", CORRELATION_ID, message.getCorrelationId());
} else {
logger.error("Unexpected command message data type: {}", data);
}
} else if (message instanceof InfoMessage) {
InfoData data = ((InfoMessage) message).getData();
if (data instanceof SwitchInfoData) {
SwitchInfoData payload = (SwitchInfoData) data;
switch(payload.getState()) {
case ADDED:
switchService.add(payload);
break;
case ACTIVATED:
switchService.activate(payload);
break;
case DEACTIVATED:
switchService.deactivate(payload);
break;
case REMOVED:
switchService.remove(payload);
break;
case CHANGED:
default:
break;
}
} else if (data instanceof IslInfoData) {
IslInfoData payload = (IslInfoData) data;
islService.discoverLink(payload);
} else {
logger.debug("Unexpected info message data type: {}", data);
}
}
} else {
logger.debug("Skip message: {}", message);
}
} catch (IOException exception) {
logger.error("Could not deserialize message: {}", record, exception);
}
}
use of org.openkilda.messaging.payload.flow.FlowIdStatusPayload in project open-kilda by telstra.
the class FlowCrudSteps method eachFlowIsInUPState.
@And("^each flow is in UP state$")
public void eachFlowIsInUPState() {
for (FlowPayload flow : flows) {
FlowIdStatusPayload status = Failsafe.with(retryPolicy.abortIf(p -> p != null && FlowState.UP == ((FlowIdStatusPayload) p).getStatus())).get(() -> northboundService.getFlowStatus(flow.getId()));
assertNotNull(status);
assertThat(format("The flow status for '%s' can't be retrived.", flow.getId()), status, hasProperty("id", equalTo(flow.getId())));
assertThat(format("The flow '%s' has wrong status.", flow.getId()), status, hasProperty("status", equalTo(FlowState.UP)));
}
}
use of org.openkilda.messaging.payload.flow.FlowIdStatusPayload in project open-kilda by telstra.
the class FlowIgnoreBandwidthTest method flowIgnoreBandwidthBetweenSwitchesWithBandwidthIsCreated.
@When("^flow ignore bandwidth between ([0-9a-f]{2}(?::[0-9a-f]{2}){7}) and ([0-9a-f]{2}(?::[0-9a-f]{2}){7}) with (\\d+) bandwidth is created$")
public void flowIgnoreBandwidthBetweenSwitchesWithBandwidthIsCreated(String source, String dest, int bandwidth) throws InterruptedException {
String flowId = FlowUtils.getFlowName("flowId");
FlowEndpointPayload sourcePoint = new FlowEndpointPayload(source, 1, 0);
FlowEndpointPayload destPoint = new FlowEndpointPayload(dest, 2, 0);
FlowPayload requestPayload = new FlowPayload(flowId, sourcePoint, destPoint, bandwidth, true, "Flow that ignore ISL bandwidth", null);
System.out.println(String.format("==> Send flow CREATE request (%s <--> %s)", source, dest));
FlowPayload response = FlowUtils.putFlow(requestPayload);
Assert.assertNotNull(response);
response.setLastUpdated(null);
System.out.println(String.format("==> Wait till flow become \"UP\" (%s <--> %s)", source, dest));
FlowIdStatusPayload status = FlowUtils.waitFlowStatus(flowId, FlowState.UP);
assertNotNull(status);
assertEquals(FlowState.UP, status.getStatus());
saveCreatedFlowId(source, dest, flowId);
}
use of org.openkilda.messaging.payload.flow.FlowIdStatusPayload in project open-kilda by telstra.
the class NorthboundRunTest method checkFlowStatus.
@Then("^status of flow (.*) could be read$")
public void checkFlowStatus(final String flowId) throws Exception {
String flowName = FlowUtils.getFlowName(flowId);
FlowIdStatusPayload payload = FlowUtils.waitFlowStatus(flowName, expectedFlowStatus);
assertNotNull(payload);
assertEquals(flowName, payload.getId());
assertEquals(expectedFlowStatus, payload.getStatus());
}
use of org.openkilda.messaging.payload.flow.FlowIdStatusPayload in project open-kilda by telstra.
the class StormTopologyLCM method networkTopologyInTheSameState.
/**
* Just check that flow is here and it in UP state
*/
@Then("^network topology in the same state$")
public void networkTopologyInTheSameState() throws Throwable {
FlowIdStatusPayload flowStatus = null;
for (int i = 0; i < 6; ++i) {
flowStatus = FlowUtils.getFlowStatus(flowId);
if (flowStatus != null && FlowState.UP == flowStatus.getStatus()) {
break;
}
TimeUnit.SECONDS.sleep(10);
}
assertNotNull(flowStatus);
assertEquals(FlowState.UP, flowStatus.getStatus());
}
Aggregations