Search in sources :

Example 31 with Flow

use of org.openkilda.messaging.model.Flow in project open-kilda by telstra.

the class CacheWarmingService method getFlowCommands.

public List<CommandData> getFlowCommands(String switchId) {
    List<CommandData> result = new ArrayList<>();
    predefinedFlows.stream().filter(flow -> switchId.equals(flow.getLeft().getSourceSwitch())).forEach(pair -> {
        CommandData command = getFlowCommandIfNeeded(pair.getLeft());
        if (Objects.nonNull(command)) {
            result.add(command);
        }
    });
    return result;
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) CommandData(org.openkilda.messaging.command.CommandData) Flow(org.openkilda.messaging.model.Flow) IslInfoData(org.openkilda.messaging.info.event.IslInfoData) ImmutablePair(org.openkilda.messaging.model.ImmutablePair) PortInfoData(org.openkilda.messaging.info.event.PortInfoData) FlowCache(org.openkilda.pce.cache.FlowCache) PathNode(org.openkilda.messaging.info.event.PathNode) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) Objects(java.util.Objects) List(java.util.List) Logger(org.apache.logging.log4j.Logger) MutablePair(org.apache.commons.lang3.tuple.MutablePair) FlowCreateRequest(org.openkilda.messaging.command.flow.FlowCreateRequest) PortChangeType(org.openkilda.messaging.info.event.PortChangeType) NetworkCache(org.openkilda.pce.cache.NetworkCache) FlowState(org.openkilda.messaging.payload.flow.FlowState) LogManager(org.apache.logging.log4j.LogManager) ArrayList(java.util.ArrayList) CommandData(org.openkilda.messaging.command.CommandData)

Example 32 with Flow

use of org.openkilda.messaging.model.Flow in project open-kilda by telstra.

the class CrudBolt method handlePathRequest.

private void handlePathRequest(String flowId, CommandMessage message, Tuple tuple) throws IOException {
    ImmutablePair<Flow, Flow> flow = flowCache.getFlow(flowId);
    logger.info("Path flow: {}", flow);
    Values northbound = new Values(new InfoMessage(new FlowPathResponse(flow.left.getFlowPath()), message.getTimestamp(), message.getCorrelationId(), Destination.NORTHBOUND));
    outputCollector.emit(StreamType.RESPONSE.toString(), tuple, northbound);
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) Values(org.apache.storm.tuple.Values) Flow(org.openkilda.messaging.model.Flow)

Example 33 with Flow

use of org.openkilda.messaging.model.Flow in project open-kilda by telstra.

the class CrudBolt method handlePushRequest.

private void handlePushRequest(String flowId, InfoMessage message, Tuple tuple) throws IOException {
    logger.info("PUSH flow: {} :: {}", flowId, message);
    FlowInfoData fid = (FlowInfoData) message.getData();
    ImmutablePair<Flow, Flow> flow = fid.getPayload();
    flowCache.pushFlow(flow);
    Values northbound = new Values(new InfoMessage(new FlowStatusResponse(new FlowIdStatusPayload(flowId, FlowState.UP)), message.getTimestamp(), message.getCorrelationId(), Destination.NORTHBOUND));
    outputCollector.emit(StreamType.RESPONSE.toString(), tuple, northbound);
}
Also used : FlowIdStatusPayload(org.openkilda.messaging.payload.flow.FlowIdStatusPayload) InfoMessage(org.openkilda.messaging.info.InfoMessage) Values(org.apache.storm.tuple.Values) Flow(org.openkilda.messaging.model.Flow)

Example 34 with Flow

use of org.openkilda.messaging.model.Flow in project open-kilda by telstra.

the class CrudBolt method handleReadRequest.

private void handleReadRequest(String flowId, CommandMessage message, Tuple tuple) {
    ImmutablePair<Flow, Flow> flow = flowCache.getFlow(flowId);
    logger.info("Got flow: {}", flow);
    Values northbound = new Values(new InfoMessage(new FlowResponse(buildFlowResponse(flow)), message.getTimestamp(), message.getCorrelationId(), Destination.NORTHBOUND));
    outputCollector.emit(StreamType.RESPONSE.toString(), tuple, northbound);
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) Values(org.apache.storm.tuple.Values) Flow(org.openkilda.messaging.model.Flow)

Example 35 with Flow

use of org.openkilda.messaging.model.Flow in project open-kilda by telstra.

the class CrudBolt method buildFlowResponse.

/**
 * Builds response flow.
 *
 * @param flow cache flow
 * @return response flow model
 */
private Flow buildFlowResponse(ImmutablePair<Flow, Flow> flow) {
    Flow response = new Flow(flow.left);
    response.setCookie(response.getCookie() & ResourceCache.FLOW_COOKIE_VALUE_MASK);
    return response;
}
Also used : Flow(org.openkilda.messaging.model.Flow)

Aggregations

Flow (org.openkilda.messaging.model.Flow)54 InfoMessage (org.openkilda.messaging.info.InfoMessage)23 Values (org.apache.storm.tuple.Values)14 PathInfoData (org.openkilda.messaging.info.event.PathInfoData)14 InstallOneSwitchFlow (org.openkilda.messaging.command.flow.InstallOneSwitchFlow)13 RemoveFlow (org.openkilda.messaging.command.flow.RemoveFlow)13 Test (org.junit.Test)12 CommandMessage (org.openkilda.messaging.command.CommandMessage)8 ImmutablePair (org.openkilda.messaging.model.ImmutablePair)8 AbstractStormTest (org.openkilda.wfm.AbstractStormTest)8 FlowResponse (org.openkilda.messaging.info.flow.FlowResponse)6 Then (cucumber.api.java.en.Then)5 FlowIdStatusPayload (org.openkilda.messaging.payload.flow.FlowIdStatusPayload)5 UnroutablePathException (org.openkilda.pce.provider.UnroutablePathException)5 Driver (org.neo4j.driver.v1.Driver)4 MessageException (org.openkilda.messaging.error.MessageException)4 FlowPayload (org.openkilda.messaging.payload.flow.FlowPayload)4 And (cucumber.api.java.en.And)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3