use of org.openkilda.wfm.CommandContext in project open-kilda by telstra.
the class PingProducer method emit.
private void emit(Tuple input, PingContext pingContext) throws PipelineException {
CommandContext commandContext = pullContext(input);
Values output = new Values(pingContext, commandContext);
getOutput().emit(input, output);
}
use of org.openkilda.wfm.CommandContext in project open-kilda by telstra.
the class WorkerBoltTest method multipleRequestsArePossible.
@Test
public void multipleRequestsArePossible() {
String key = "key";
String payload = "payload";
Tuple request = new TupleImpl(topologyContext, new Values(key, payload, new CommandContext()), HUB_TASK_ID, Utils.DEFAULT_STREAM_ID);
worker.execute(request);
worker.emitHubResponse = false;
reset(output);
Tuple response = new TupleImpl(topologyContext, new Values(key, payload, new CommandContext()), SPOUT_TASK_ID, Utils.DEFAULT_STREAM_ID);
worker.execute(response);
verify(output).ack(response);
verifyNoMoreInteractions(output);
reset(output);
worker.emitHubResponse = true;
worker.execute(response);
// cancel timeout
verify(output).emit(eq(CoordinatorBolt.INCOME_STREAM), eq(response), Mockito.any());
// hub response
verify(output).emitDirect(eq(HUB_TASK_ID), eq(WORKER_TO_HUB_STREAM_ID), eq(response), Mockito.any());
verify(output).ack(response);
verifyNoMoreInteractions(output);
}
use of org.openkilda.wfm.CommandContext in project open-kilda by telstra.
the class LoggerContextInitializer method aroundAdvice.
/**
* Wraps "execute" method of storm bolts to inject/cleanup fields in logger MDC.
*/
@Around("execution(* org.apache.storm.topology.IRichBolt+.execute(org.apache.storm.tuple.Tuple)) && args(input)" + "|| execution(* org.apache.storm.topology.IStatefulBolt+.execute(org.apache.storm.tuple.Tuple)) " + "&& args(input)")
public Object aroundAdvice(ProceedingJoinPoint joinPoint, Tuple input) throws Throwable {
CommandContext context = extract(input).orElseGet(() -> {
LOGGER.debug("CorrelationId was not sent or can't be extracted for tuple {}", input);
return new CommandContext(DEFAULT_CORRELATION_ID);
});
Map<String, String> fields = prepareFields(context);
fields.put(TOPOLOGY_NAME, stormId);
Map<String, String> current = inject(fields);
try {
return joinPoint.proceed(joinPoint.getArgs());
} finally {
revert(current);
}
}
use of org.openkilda.wfm.CommandContext in project open-kilda by telstra.
the class CoordinatorSpout method nextTuple.
@Override
public void nextTuple() {
if (emit) {
collector.emit(new Values(System.currentTimeMillis(), new CommandContext()), messageId++);
emit = false;
} else {
org.apache.storm.utils.Utils.sleep(1L);
}
}
use of org.openkilda.wfm.CommandContext in project open-kilda by telstra.
the class SpeakerToNetworkProxyBoltTest method verifySpeakerToConsumerTupleConsistency.
@Test
public void verifySpeakerToConsumerTupleConsistency() throws Exception {
injectLifecycleEventUpdate(START_SIGNAL);
ArgumentCaptor<Values> outputCaptor = ArgumentCaptor.forClass(Values.class);
verify(outputCollector).emit(anyString(), any(Tuple.class), outputCaptor.capture());
Values output = outputCaptor.getValue();
assertEquals(START_SIGNAL, ((LifecycleEvent) output.get(0)).getSignal());
InfoMessage discoveryConfirmation = new InfoMessage(new DiscoPacketSendingConfirmation(new NetworkEndpoint(switchAlpha, 1), 1L), 3L, "discovery-confirmation", REGION_ONE);
Tuple tuple = new TupleImpl(generalTopologyContext, new Values(switchAlpha.toString(), discoveryConfirmation, new CommandContext(discoveryConfirmation)), TASK_ID_SPOUT, STREAM_SPOUT_DEFAULT);
subject.execute(tuple);
ArgumentCaptor<Values> discoReplyValuesCaptor = ArgumentCaptor.forClass(Values.class);
verify(outputCollector).emit(eq(SpeakerToNetworkProxyBolt.STREAM_ALIVE_EVIDENCE_ID), eq(tuple), discoReplyValuesCaptor.capture());
assertEquals(REGION_ONE, discoReplyValuesCaptor.getValue().get(0));
assertEquals(discoveryConfirmation.getTimestamp(), discoReplyValuesCaptor.getValue().get(1));
ArgumentCaptor<Values> topoDiscoCaptor = ArgumentCaptor.forClass(Values.class);
verify(outputCollector).emit(eq(tuple), topoDiscoCaptor.capture());
assertEquals(switchAlpha.toString(), topoDiscoCaptor.getValue().get(0));
assertEquals(discoveryConfirmation, topoDiscoCaptor.getValue().get(1));
}
Aggregations