Search in sources :

Example 71 with CommandContext

use of org.openkilda.wfm.CommandContext in project open-kilda by telstra.

the class ZooKeeperSpout method nextTuple.

@Override
public void nextTuple() {
    Signal signal = signals.poll();
    if (signal != null) {
        LifecycleEvent event = LifecycleEvent.builder().signal(signal).uuid(UUID.randomUUID()).messageId(messageId++).build();
        log.info("Component {} with id {} received signal {} from zookeeper. Sending event {}", serviceName, id, signal, event);
        collector.emit(new Values(event, new CommandContext()), messageId);
    } else {
        org.apache.storm.utils.Utils.sleep(1L);
    }
    if (!watchDog.isConnectedAndValidated()) {
        if (isZooKeeperConnectTimeoutPassed()) {
            log.info("Service {} with run_id {} tries to reconnect to ZooKeeper {}", serviceName, id, connectionString);
            watchDog.safeRefreshConnection();
            zooKeeperConnectionTimestamp = Instant.now();
        }
    }
}
Also used : Signal(org.openkilda.bluegreen.Signal) CommandContext(org.openkilda.wfm.CommandContext) Values(org.apache.storm.tuple.Values) LifecycleEvent(org.openkilda.bluegreen.LifecycleEvent)

Example 72 with CommandContext

use of org.openkilda.wfm.CommandContext in project open-kilda by telstra.

the class KafkaRecordTranslator method apply.

// FIXME(surabujin): keep payload at index 0 because some code grab it in following way: `tuple.getString(0)`
// public static final Fields FIELDS = new Fields(FIELD_ID_PAYLOAD, FIELD_ID_KEY);
@Override
public List<Object> apply(ConsumerRecord<K, V> record) {
    D payload = decodePayload(record.value());
    CommandContext context = makeContext(record, payload);
    return makeTuple(record, payload, context);
}
Also used : CommandContext(org.openkilda.wfm.CommandContext)

Example 73 with CommandContext

use of org.openkilda.wfm.CommandContext in project open-kilda by telstra.

the class YFlowUpdateHubBolt method onRequest.

@Override
protected void onRequest(Tuple input) throws PipelineException {
    currentKey = pullKey(input);
    CommandData payload = pullValue(input, FIELD_ID_PAYLOAD, CommandData.class);
    try {
        if (payload instanceof YFlowRequest) {
            yflowUpdateService.handleRequest(currentKey, pullContext(input), (YFlowRequest) payload);
        } else if (payload instanceof YFlowPartialUpdateRequest) {
            yflowUpdateService.handlePartialUpdateRequest(currentKey, pullContext(input), (YFlowPartialUpdateRequest) payload);
        } else {
            unhandledInput(input);
        }
    } catch (DuplicateKeyException e) {
        log.error("Failed to handle a request with key {}. {}", currentKey, e.getMessage());
    } catch (FlowProcessingException e) {
        ErrorData errorData = new ErrorData(e.getErrorType(), "Y-flow update error", e.getMessage());
        CommandContext commandContext = getCommandContext();
        ErrorMessage errorMessage = new ErrorMessage(errorData, commandContext.getCreateTime(), commandContext.getCorrelationId());
        sendNorthboundResponse(errorMessage);
    }
}
Also used : CommandContext(org.openkilda.wfm.CommandContext) FlowProcessingException(org.openkilda.wfm.topology.flowhs.exception.FlowProcessingException) YFlowPartialUpdateRequest(org.openkilda.messaging.command.yflow.YFlowPartialUpdateRequest) CommandData(org.openkilda.messaging.command.CommandData) ErrorMessage(org.openkilda.messaging.error.ErrorMessage) ErrorData(org.openkilda.messaging.error.ErrorData) YFlowRequest(org.openkilda.messaging.command.yflow.YFlowRequest) DuplicateKeyException(org.openkilda.wfm.topology.flowhs.exception.DuplicateKeyException)

Example 74 with CommandContext

use of org.openkilda.wfm.CommandContext in project open-kilda by telstra.

the class ControllerToSpeakerProxyBoltTest method injectDiscoveryRequest.

private CommandMessage injectDiscoveryRequest(SwitchId switchId) {
    CommandMessage discoCommand = new CommandMessage(new DiscoverIslCommandData(switchId, 1, 1L), 3L, "discovery-confirmation");
    Tuple input = new TupleImpl(generalTopologyContext, new Values(switchId.toString(), discoCommand, new CommandContext(discoCommand)), TASK_ID_SPOUT, STREAM_SPOUT_DEFAULT);
    subject.execute(input);
    verify(outputCollector).ack(eq(input));
    return discoCommand;
}
Also used : DiscoverIslCommandData(org.openkilda.messaging.command.discovery.DiscoverIslCommandData) CommandContext(org.openkilda.wfm.CommandContext) Values(org.apache.storm.tuple.Values) TupleImpl(org.apache.storm.tuple.TupleImpl) Tuple(org.apache.storm.tuple.Tuple) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 75 with CommandContext

use of org.openkilda.wfm.CommandContext in project open-kilda by telstra.

the class YFlowRerouteServiceTest method shouldFailOnTimeoutDuringMeterInstallation.

@Test
public void shouldFailOnTimeoutDuringMeterInstallation() throws UnroutableFlowException, RecoverableException, DuplicateKeyException, UnknownKeyException {
    // given
    YFlowRequest createYFlowRequest = createYFlow();
    YFlowRerouteRequest request = new YFlowRerouteRequest(createYFlowRequest.getYFlowId(), "reason");
    preparePathComputationForReroute("test_flow_1", buildFirstSubFlowPathPairWithNewTransit());
    preparePathComputationForReroute("test_flow_2", buildSecondSubFlowPathPairWithNewTransit());
    prepareYPointComputation(SWITCH_SHARED, SWITCH_FIRST_EP, SWITCH_SECOND_EP, SWITCH_NEW_TRANSIT);
    YFlowRerouteService service = makeYFlowRerouteService(0);
    // when
    service.handleRequest(request.getYFlowId(), new CommandContext(), request);
    verifyYFlowStatus(request.getYFlowId(), FlowStatus.IN_PROGRESS);
    // and
    handleSpeakerCommandsAndTimeoutInstall(service, request.getYFlowId());
    // then
    verifyNorthboundSuccessResponse(yFlowRerouteHubCarrier, YFlowRerouteResponse.class);
    verifyYFlowStatus(request.getYFlowId(), FlowStatus.UP);
    verifyAffinity(request.getYFlowId());
    verify(yFlowRerouteHubCarrier).sendYFlowRerouteResultStatus(eq(createYFlowRequest.getYFlowId()), eq(new RerouteError("Timeout event has been received")), anyString());
}
Also used : CommandContext(org.openkilda.wfm.CommandContext) YFlowRerouteRequest(org.openkilda.messaging.command.yflow.YFlowRerouteRequest) RerouteError(org.openkilda.messaging.info.reroute.error.RerouteError) YFlowRequest(org.openkilda.messaging.command.yflow.YFlowRequest) Test(org.junit.Test) AbstractYFlowTest(org.openkilda.wfm.topology.flowhs.service.AbstractYFlowTest)

Aggregations

CommandContext (org.openkilda.wfm.CommandContext)95 Test (org.junit.Test)28 Values (org.apache.storm.tuple.Values)27 FlowSegmentRequest (org.openkilda.floodlight.api.request.FlowSegmentRequest)15 Flow (org.openkilda.model.Flow)15 AbstractYFlowTest (org.openkilda.wfm.topology.flowhs.service.AbstractYFlowTest)14 Tuple (org.apache.storm.tuple.Tuple)12 SwitchId (org.openkilda.model.SwitchId)11 YFlow (org.openkilda.model.YFlow)11 BaseSpeakerCommandsRequest (org.openkilda.floodlight.api.request.rulemanager.BaseSpeakerCommandsRequest)9 SpeakerResponse (org.openkilda.floodlight.api.response.SpeakerResponse)9 YFlowRequest (org.openkilda.messaging.command.yflow.YFlowRequest)9 InfoMessage (org.openkilda.messaging.info.InfoMessage)9 TupleImpl (org.apache.storm.tuple.TupleImpl)8 FlowPath (org.openkilda.model.FlowPath)8 ArrayList (java.util.ArrayList)7 FlowRerouteRequest (org.openkilda.messaging.command.flow.FlowRerouteRequest)7 FlowProcessingException (org.openkilda.wfm.topology.flowhs.exception.FlowProcessingException)7 UnknownKeyException (org.openkilda.wfm.topology.flowhs.exception.UnknownKeyException)7 List (java.util.List)6