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();
}
}
}
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);
}
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);
}
}
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;
}
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());
}
Aggregations