mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 14:47:19 -04:00
reduce overhead of create_pipeline if config is known
This commit is contained in:
parent
60c04c2bdc
commit
c8e8bc4b3b
2 changed files with 14 additions and 10 deletions
|
@ -165,12 +165,15 @@ class LogStash::Agent
|
|||
@collect_metric
|
||||
end
|
||||
|
||||
def create_pipeline(settings)
|
||||
begin
|
||||
config = fetch_config(settings)
|
||||
rescue => e
|
||||
@logger.error("failed to fetch pipeline configuration", :message => e.message)
|
||||
return
|
||||
def create_pipeline(settings, config=nil)
|
||||
|
||||
if config.nil?
|
||||
begin
|
||||
config = fetch_config(settings)
|
||||
rescue => e
|
||||
@logger.error("failed to fetch pipeline configuration", :message => e.message)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
begin
|
||||
|
@ -189,13 +192,14 @@ class LogStash::Agent
|
|||
# wrapped in @upgrade_mutex in the parent call `reload_state!`
|
||||
def reload_pipeline!(id)
|
||||
old_pipeline = @pipelines[id]
|
||||
if old_pipeline.config_str == fetch_config(old_pipeline.original_settings)
|
||||
new_config = fetch_config(old_pipeline.original_settings)
|
||||
if old_pipeline.config_str == new_config
|
||||
@logger.debug("no configuration change for pipeline",
|
||||
:pipeline => id, :config => old_pipeline.config_str)
|
||||
:pipeline => id, :config => new_config)
|
||||
return
|
||||
end
|
||||
|
||||
new_pipeline = create_pipeline(old_pipeline.original_settings)
|
||||
new_pipeline = create_pipeline(old_pipeline.original_settings, new_config)
|
||||
return if new_pipeline.nil?
|
||||
|
||||
if new_pipeline.non_reloadable_plugins.any?
|
||||
|
|
|
@ -179,7 +179,7 @@ describe LogStash::Agent do
|
|||
|
||||
context "when fetching a new state" do
|
||||
it "upgrades the state" do
|
||||
expect(subject).to receive(:fetch_config).twice.and_return(second_pipeline_config)
|
||||
expect(subject).to receive(:fetch_config).and_return(second_pipeline_config)
|
||||
expect(subject).to receive(:upgrade_pipeline).with(pipeline_id, kind_of(LogStash::Pipeline))
|
||||
subject.send(:reload_state!)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue