Sha256: 65af6754602ec921fa61085d5de0e9965938b0c1e3d171c58003806ece82b7ca

Contents?: true

Size: 1.4 KB

Versions: 7

Compression:

Stored size: 1.4 KB

Contents

# encoding: utf-8
require "logstash/pipeline_action/base"
require "logstash/pipeline_action/create"
require "logstash/pipeline_action/stop"
require "logstash/errors"
require "logstash/util/loggable"
require "logstash/converge_result"

module LogStash module PipelineAction
  class Reload < Base
    include LogStash::Util::Loggable

    def initialize(pipeline_config, metric)
      @pipeline_config = pipeline_config
      @metric = metric
    end

    def pipeline_id
      @pipeline_config.pipeline_id
    end

    def execute(agent, pipelines)
      old_pipeline = pipelines[pipeline_id]

      if !old_pipeline.reloadable?
        return LogStash::ConvergeResult::FailedAction.new("Cannot reload pipeline, because the existing pipeline is not reloadable")
      end

      begin
        pipeline_validator = LogStash::BasePipeline.new(@pipeline_config)
      rescue => e
        return LogStash::ConvergeResult::FailedAction.from_exception(e)
      end

      if !pipeline_validator.reloadable?
        return LogStash::ConvergeResult::FailedAction.new("Cannot reload pipeline, because the new pipeline is not reloadable")
      end

      logger.info("Reloading pipeline", "pipeline.id" => pipeline_id)
      status = Stop.new(pipeline_id).execute(agent, pipelines)

      if status
        return Create.new(@pipeline_config, @metric).execute(agent, pipelines)
      else
        return status
      end
    end
  end
end end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
logstash-core-6.0.1-java lib/logstash/pipeline_action/reload.rb
logstash-core-6.0.0-java lib/logstash/pipeline_action/reload.rb
logstash-core-6.0.0.rc2-java lib/logstash/pipeline_action/reload.rb
logstash-core-6.0.0.rc1-java lib/logstash/pipeline_action/reload.rb
logstash-core-6.0.0.beta2-java lib/logstash/pipeline_action/reload.rb
logstash-core-6.0.0.beta1-java lib/logstash/pipeline_action/reload.rb
logstash-core-6.0.0.alpha2-java lib/logstash/pipeline_action/reload.rb