use of org.openkilda.bluegreen.LifecycleEvent in project open-kilda by telstra.
the class ControllerToSpeakerProxyBoltTest method injectLifecycleEventUpdate.
private void injectLifecycleEventUpdate(Signal signal) {
LifecycleEvent event = LifecycleEvent.builder().signal(signal).build();
Tuple input = new TupleImpl(generalTopologyContext, new Values(event, new CommandContext()), ZOOKEEPER_SPOUT, STREAM_SPOUT_DEFAULT);
subject.execute(input);
verify(outputCollector).ack(eq(input));
}
use of org.openkilda.bluegreen.LifecycleEvent in project open-kilda by telstra.
the class SpeakerToNetworkProxyBoltTest method injectLifecycleEventUpdate.
private void injectLifecycleEventUpdate(Signal signal) {
LifecycleEvent event = LifecycleEvent.builder().signal(signal).build();
Tuple input = new TupleImpl(generalTopologyContext, new Values(event, new CommandContext()), ZOOKEEPER_SPOUT, STREAM_SPOUT_DEFAULT);
subject.execute(input);
verify(outputCollector).ack(eq(input));
}
use of org.openkilda.bluegreen.LifecycleEvent in project open-kilda by telstra.
the class DatapointParseBolt method execute.
@Override
public void execute(Tuple tuple) {
if (ZooKeeperSpout.SPOUT_ID.equals(tuple.getSourceComponent())) {
LifecycleEvent event = (LifecycleEvent) tuple.getValueByField(FIELD_ID_LIFECYCLE_EVENT);
if (event != null && shouldHandleLifeCycleEvent(event.getSignal())) {
handleLifeCycleEvent(tuple, event);
}
collector.ack(tuple);
} else if (active) {
InfoData data = (InfoData) tuple.getValueByField(MessageKafkaTranslator.FIELD_ID_PAYLOAD);
LOGGER.debug("Processing datapoint: {}", data);
try {
List<Datapoint> datapoints;
Object payload = tuple.getValueByField(MessageKafkaTranslator.FIELD_ID_PAYLOAD);
if (payload instanceof Datapoint) {
LOGGER.debug("Processing datapoint: {}", payload);
datapoints = Collections.singletonList((Datapoint) payload);
} else if (payload instanceof DatapointEntries) {
LOGGER.debug("Processing datapoints: {}", payload);
datapoints = ((DatapointEntries) payload).getDatapointEntries();
} else {
LOGGER.error("Unhandled input tuple from {} with data {}", getClass().getName(), payload);
return;
}
for (Datapoint datapoint : datapoints) {
collector.emit(asList(datapoint.simpleHashCode(), datapoint));
}
} catch (Exception e) {
LOGGER.error("Failed process data: {}", data, e);
} finally {
collector.ack(tuple);
}
} else {
LOGGER.debug("DatapointParseBolt is inactive");
collector.ack(tuple);
}
}
use of org.openkilda.bluegreen.LifecycleEvent in project open-kilda by telstra.
the class AbstractBolt method dispatch.
protected void dispatch(Tuple input) throws Exception {
if (input.getSourceComponent().equals(lifeCycleEventSourceComponent)) {
LifecycleEvent event = (LifecycleEvent) input.getValueByField(FIELD_ID_LIFECYCLE_EVENT);
log.info("Received lifecycle event {}", event);
if (shouldHandleLifeCycleEvent(event.getSignal())) {
handleLifeCycleEvent(event);
}
} else {
if (meterRegistry != null) {
MeterRegistryHolder.setRegistry(meterRegistry);
}
try {
handleInput(input);
} finally {
MeterRegistryHolder.removeRegistry();
if (meterRegistry != null && meterOutputStream != null) {
log.debug("Pushing MeterRegistry data to {} stream", meterOutputStream);
meterRegistry.pushMeters(getOutput(), meterOutputStream);
}
}
}
}
use of org.openkilda.bluegreen.LifecycleEvent in project open-kilda by telstra.
the class ZooKeeperBolt method handleInput.
@Override
protected void handleInput(Tuple input) throws Exception {
if (!zkWriter.isConnectedAndValidated()) {
if (isZooKeeperConnectTimeoutPassed()) {
zkWriter.safeRefreshConnection();
zooKeeperConnectionTimestamp = Instant.now();
}
}
try {
LifecycleEvent event = (LifecycleEvent) input.getValueByField(FIELD_ID_STATE);
if (event != null) {
log.info("Handling lifecycle event {} for component {} with id {} from {}", event, serviceName, id, input.getSourceComponent());
zkStateTracker.processLifecycleEvent(event);
} else {
log.error("Received null value as a lifecycle-event");
}
} catch (Exception e) {
log.error("Failed to process event: {}", e.getMessage(), e);
}
}
Aggregations