use of org.openkilda.messaging.command.CommandMessage in project open-kilda by telstra.
the class FlowServiceImpl method rerouteFlow.
/**
* {@inheritDoc}
*/
@Override
public FlowPathPayload rerouteFlow(String flowId, String correlationId) {
Flow flow = new Flow();
flow.setFlowId(flowId);
FlowRerouteRequest data = new FlowRerouteRequest(flow, FlowOperation.UPDATE);
CommandMessage command = new CommandMessage(data, System.currentTimeMillis(), correlationId, Destination.WFM);
messageConsumer.clear();
messageProducer.send(topic, command);
Message message = (Message) messageConsumer.poll(correlationId);
logger.debug("Got response {}", message);
FlowPathResponse response = (FlowPathResponse) validateInfoMessage(command, message, correlationId);
return Converter.buildFlowPathPayloadByFlowPath(flowId, response.getPayload());
}
use of org.openkilda.messaging.command.CommandMessage in project open-kilda by telstra.
the class FlowServiceImpl method deleteFlows.
/**
* {@inheritDoc}
*/
@Override
public List<FlowPayload> deleteFlows(final String correlationId) {
LOGGER.debug("\n\nDELETE ALL FLOWS: ENTER {}={}\n", CORRELATION_ID, correlationId);
ArrayList<FlowPayload> result = new ArrayList<>();
// TODO: Need a getFlowIDs .. since that is all we need
List<FlowPayload> flows = this.getFlows(correlationId + "-GET");
messageConsumer.clear();
// Send all the requests first
ArrayList<CommandMessage> requests = new ArrayList<>();
for (int i = 0; i < flows.size(); i++) {
String cid = correlationId + "-" + i;
FlowPayload flow = flows.get(i);
requests.add(_sendDeleteFlow(flow.getId(), cid));
}
// Now wait for the responses.
for (int i = 0; i < flows.size(); i++) {
String cid = correlationId + "-" + i;
result.add(_deleteFlowRespone(cid, requests.get(i)));
}
LOGGER.debug("\n\nDELETE ALL FLOWS: EXIT {}={}\n", CORRELATION_ID, correlationId);
return result;
}
use of org.openkilda.messaging.command.CommandMessage in project open-kilda by telstra.
the class HealthCheckImpl method getHealthCheck.
/**
* The health-check info bean.
*
* @return the FlowModel instance
*/
@Override
public HealthCheck getHealthCheck(String correlationId) {
healthCheckMessageConsumer.clear();
messageProducer.send(topic, new CommandMessage(NORTHBOUND_REQUESTER, System.currentTimeMillis(), correlationId, null));
Map<String, String> status = healthCheckMessageConsumer.poll(correlationId);
Arrays.stream(ServiceType.values()).forEach(service -> status.putIfAbsent(service.getId(), Utils.HEALTH_CHECK_NON_OPERATIONAL_STATUS));
HealthCheck healthCheck = new HealthCheck(serviceName, serviceVersion, serviceDescription, status);
logger.info("Health-Check Status: {}", healthCheck);
return healthCheck;
}
use of org.openkilda.messaging.command.CommandMessage in project open-kilda by telstra.
the class SwitchServiceImpl method deleteRules.
@Override
public List<Long> deleteRules(String switchId, DeleteRulesAction deleteAction, Long cookie, String correlationId) {
LOGGER.debug("Delete switch rules request received");
// TODO: remove messageConsumer.clear() as a part of NB cleanup (clear isn't required)
messageConsumer.clear();
SwitchRulesDeleteRequest data = new SwitchRulesDeleteRequest(switchId, deleteAction, cookie);
CommandMessage request = new CommandWithReplyToMessage(data, System.currentTimeMillis(), correlationId, Destination.CONTROLLER, northboundTopic);
messageProducer.send(floodlightTopic, request);
Message message = messageConsumer.poll(correlationId);
SwitchRulesResponse response = (SwitchRulesResponse) validateInfoMessage(request, message, correlationId);
return response.getRuleIds();
}
use of org.openkilda.messaging.command.CommandMessage in project open-kilda by telstra.
the class SwitchServiceImpl method connectMode.
@Override
public ConnectModeRequest.Mode connectMode(ConnectModeRequest.Mode mode, String correlationId) {
LOGGER.debug("Set/Get switch connect mode request received: mode = {}", mode);
ConnectModeRequest data = new ConnectModeRequest(mode);
CommandMessage request = new CommandWithReplyToMessage(data, System.currentTimeMillis(), correlationId, Destination.CONTROLLER, northboundTopic);
messageProducer.send(floodlightTopic, request);
Message message = messageConsumer.poll(correlationId);
ConnectModeResponse response = (ConnectModeResponse) validateInfoMessage(request, message, correlationId);
return response.getMode();
}
Aggregations