Search in sources :

Example 66 with CommandMessage

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());
}
Also used : FlowPathResponse(org.openkilda.messaging.info.flow.FlowPathResponse) InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) CommandMessage(org.openkilda.messaging.command.CommandMessage) FlowRerouteRequest(org.openkilda.messaging.command.flow.FlowRerouteRequest) Flow(org.openkilda.messaging.model.Flow) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 67 with CommandMessage

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;
}
Also used : FlowPayload(org.openkilda.messaging.payload.flow.FlowPayload) ArrayList(java.util.ArrayList) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 68 with CommandMessage

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;
}
Also used : HealthCheck(org.openkilda.messaging.model.HealthCheck) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 69 with CommandMessage

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();
}
Also used : Message(org.openkilda.messaging.Message) CommandMessage(org.openkilda.messaging.command.CommandMessage) CommandWithReplyToMessage(org.openkilda.messaging.command.CommandWithReplyToMessage) SwitchRulesResponse(org.openkilda.messaging.info.switches.SwitchRulesResponse) SwitchRulesDeleteRequest(org.openkilda.messaging.command.switches.SwitchRulesDeleteRequest) CommandWithReplyToMessage(org.openkilda.messaging.command.CommandWithReplyToMessage) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 70 with CommandMessage

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();
}
Also used : ConnectModeRequest(org.openkilda.messaging.command.switches.ConnectModeRequest) Message(org.openkilda.messaging.Message) CommandMessage(org.openkilda.messaging.command.CommandMessage) CommandWithReplyToMessage(org.openkilda.messaging.command.CommandWithReplyToMessage) CommandWithReplyToMessage(org.openkilda.messaging.command.CommandWithReplyToMessage) CommandMessage(org.openkilda.messaging.command.CommandMessage) ConnectModeResponse(org.openkilda.messaging.info.switches.ConnectModeResponse)

Aggregations

CommandMessage (org.openkilda.messaging.command.CommandMessage)70 Message (org.openkilda.messaging.Message)36 InfoMessage (org.openkilda.messaging.info.InfoMessage)32 Test (org.junit.Test)19 ErrorMessage (org.openkilda.messaging.error.ErrorMessage)18 Values (org.apache.storm.tuple.Values)11 FlowIdStatusPayload (org.openkilda.messaging.payload.flow.FlowIdStatusPayload)11 RemoveFlow (org.openkilda.messaging.command.flow.RemoveFlow)8 Flow (org.openkilda.messaging.model.Flow)8 IOException (java.io.IOException)7 CommandData (org.openkilda.messaging.command.CommandData)7 AbstractStormTest (org.openkilda.wfm.AbstractStormTest)7 HashSet (java.util.HashSet)6 SwitchInfoData (org.openkilda.messaging.info.event.SwitchInfoData)6 CommandWithReplyToMessage (org.openkilda.messaging.command.CommandWithReplyToMessage)5 NetworkCommandData (org.openkilda.messaging.command.discovery.NetworkCommandData)5 InstallOneSwitchFlow (org.openkilda.messaging.command.flow.InstallOneSwitchFlow)5 FlowDeleteRequest (org.openkilda.messaging.command.flow.FlowDeleteRequest)4 FlowPathRequest (org.openkilda.messaging.command.flow.FlowPathRequest)4 FlowRerouteRequest (org.openkilda.messaging.command.flow.FlowRerouteRequest)4