Search in sources :

Example 1 with PipelineException

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

the class ControllerToSpeakerProxyBolt method pullKafkaKey.

private String pullKafkaKey() {
    String result;
    Tuple tuple = getCurrentTuple();
    try {
        result = pullValue(tuple, KafkaRecordTranslator.FIELD_ID_KEY, String.class);
    } catch (PipelineException e) {
        log.error("Unable to read kafka-key from tuple {}: {}", formatTuplePayload(tuple), e);
        return null;
    }
    return result;
}
Also used : PipelineException(org.openkilda.wfm.error.PipelineException) Tuple(org.apache.storm.tuple.Tuple)

Example 2 with PipelineException

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

the class FailReporter method report.

private void report(Tuple input, String flowId, FlowObserver flowObserver, State state) throws PipelineException {
    String logMessage = String.format("{FLOW-PING} Flow %s become %s", flowId, state);
    if (state != State.OPERATIONAL) {
        String cookies = flowObserver.getFlowTreadsInState(state).stream().map(cookie -> String.format("0x%016x", cookie)).collect(Collectors.joining(", "));
        if (!cookies.isEmpty()) {
            logMessage += String.format("(%s)", cookies);
        }
    }
    log.info(logMessage);
    Values output = new Values(new PingReport(flowId, state), pullContext(input));
    getOutput().emit(input, output);
}
Also used : OutputFieldsDeclarer(org.apache.storm.topology.OutputFieldsDeclarer) PingObserver(org.openkilda.wfm.topology.ping.model.PingObserver) Iterator(java.util.Iterator) PingReport(org.openkilda.messaging.model.PingReport) HashMap(java.util.HashMap) Fields(org.apache.storm.tuple.Fields) FlowObserver(org.openkilda.wfm.topology.ping.model.FlowObserver) Collectors(java.util.stream.Collectors) State(org.openkilda.messaging.model.PingReport.State) TimeUnit(java.util.concurrent.TimeUnit) Values(org.apache.storm.tuple.Values) Tuple(org.apache.storm.tuple.Tuple) Flow(org.openkilda.model.Flow) PipelineException(org.openkilda.wfm.error.PipelineException) PingContext(org.openkilda.wfm.topology.ping.model.PingContext) Entry(java.util.Map.Entry) Values(org.apache.storm.tuple.Values) PingReport(org.openkilda.messaging.model.PingReport)

Example 3 with PipelineException

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

the class FlowFetcher method init.

@Override
@PersistenceContextRequired(requiresNew = true)
public void init() {
    super.init();
    flowRepository = persistenceManager.getRepositoryFactory().createFlowRepository();
    yFlowRepository = persistenceManager.getRepositoryFactory().createYFlowRepository();
    flowResourcesManager = new FlowResourcesManager(persistenceManager, flowResourcesConfig);
    try {
        refreshHeap(null, false);
    } catch (PipelineException e) {
        log.error("Failed to init periodic ping cache");
    }
}
Also used : PipelineException(org.openkilda.wfm.error.PipelineException) FlowResourcesManager(org.openkilda.wfm.share.flow.resources.FlowResourcesManager) PersistenceContextRequired(org.openkilda.persistence.context.PersistenceContextRequired)

Example 4 with PipelineException

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

the class FlowFetcher method refreshHeap.

private void refreshHeap(Tuple input, boolean emitCacheExpiry) throws PipelineException {
    log.debug("Handle periodic ping request");
    Set<FlowWithTransitEncapsulation> flowsWithTransitEncapsulation = flowRepository.findWithPeriodicPingsEnabled().stream().peek(flowRepository::detach).map(this::getFlowWithTransitEncapsulation).flatMap(o -> o.isPresent() ? Stream.of(o.get()) : Stream.empty()).collect(Collectors.toSet());
    if (emitCacheExpiry) {
        final CommandContext commandContext = pullContext(input);
        emitCacheExpire(input, commandContext, flowsWithTransitEncapsulation);
    }
    flowsSet = flowsWithTransitEncapsulation;
    lastPeriodicPingCacheRefresh = System.currentTimeMillis();
}
Also used : OutputFieldsDeclarer(org.apache.storm.topology.OutputFieldsDeclarer) YFlowPingResponse(org.openkilda.messaging.info.flow.YFlowPingResponse) FlowTransitEncapsulation(org.openkilda.model.FlowTransitEncapsulation) FlowResourcesConfig(org.openkilda.wfm.share.flow.resources.FlowResourcesConfig) Value(lombok.Value) ArrayList(java.util.ArrayList) Values(org.apache.storm.tuple.Values) Tuple(org.apache.storm.tuple.Tuple) FlowPingRequest(org.openkilda.messaging.command.flow.FlowPingRequest) Flow(org.openkilda.model.Flow) OutputCollector(org.apache.storm.task.OutputCollector) PipelineException(org.openkilda.wfm.error.PipelineException) Kinds(org.openkilda.wfm.topology.ping.model.PingContext.Kinds) YFlow(org.openkilda.model.YFlow) FlowRepository(org.openkilda.persistence.repositories.FlowRepository) PersistenceManager(org.openkilda.persistence.PersistenceManager) Utils(org.openkilda.messaging.Utils) YSubFlow(org.openkilda.model.YSubFlow) PersistenceContextRequired(org.openkilda.persistence.context.PersistenceContextRequired) PeriodicPingCommand(org.openkilda.messaging.command.flow.PeriodicPingCommand) Set(java.util.Set) CommandContext(org.openkilda.wfm.CommandContext) Fields(org.apache.storm.tuple.Fields) FlowPingResponse(org.openkilda.messaging.info.flow.FlowPingResponse) EqualsAndHashCode(lombok.EqualsAndHashCode) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) YFlowRepository(org.openkilda.persistence.repositories.YFlowRepository) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) YFlowPingRequest(org.openkilda.messaging.command.flow.YFlowPingRequest) Stream(java.util.stream.Stream) GroupId(org.openkilda.wfm.topology.ping.model.GroupId) PingContext(org.openkilda.wfm.topology.ping.model.PingContext) FlowResourcesManager(org.openkilda.wfm.share.flow.resources.FlowResourcesManager) Optional(java.util.Optional) AllArgsConstructor(lombok.AllArgsConstructor) CommandContext(org.openkilda.wfm.CommandContext)

Example 5 with PipelineException

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

the class AbstractBolt method setupCommandContext.

protected CommandContext setupCommandContext() {
    Tuple input = getCurrentTuple();
    CommandContext context;
    try {
        context = pullContext(input);
    } catch (PipelineException e) {
        context = new CommandContext().fork("trace-fail");
        log.warn("The command context is missing in input tuple received by {} on stream {}:{}, execution context" + " can't  be traced. Create new command context for possible tracking of following" + " processing [{}].", getClass().getName(), input.getSourceComponent(), input.getSourceStreamId(), formatTuplePayload(input), e);
    }
    return context;
}
Also used : PipelineException(org.openkilda.wfm.error.PipelineException) Tuple(org.apache.storm.tuple.Tuple)

Aggregations

PipelineException (org.openkilda.wfm.error.PipelineException)7 Tuple (org.apache.storm.tuple.Tuple)5 TimeUnit (java.util.concurrent.TimeUnit)2 Collectors (java.util.stream.Collectors)2 OutputFieldsDeclarer (org.apache.storm.topology.OutputFieldsDeclarer)2 Fields (org.apache.storm.tuple.Fields)2 Values (org.apache.storm.tuple.Values)2 Flow (org.openkilda.model.Flow)2 PersistenceContextRequired (org.openkilda.persistence.context.PersistenceContextRequired)2 FlowResourcesManager (org.openkilda.wfm.share.flow.resources.FlowResourcesManager)2 PingContext (org.openkilda.wfm.topology.ping.model.PingContext)2 String.format (java.lang.String.format)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Entry (java.util.Map.Entry)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Stream (java.util.stream.Stream)1