logstash-core 6.3.2-java → 6.4.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. checksums.yaml +4 -4
  2. data/lib/logstash/agent.rb +10 -6
  3. data/lib/logstash/api/modules/logging.rb +4 -0
  4. data/lib/logstash/api/service.rb +0 -1
  5. data/lib/logstash/bootstrap_check/default_config.rb +0 -2
  6. data/lib/logstash/bootstrap_check/persisted_queue_config.rb +0 -1
  7. data/lib/logstash/codecs/base.rb +2 -4
  8. data/lib/logstash/compiler.rb +2 -3
  9. data/lib/logstash/compiler/lscl.rb +0 -1
  10. data/lib/logstash/config/config_ast.rb +0 -1
  11. data/lib/logstash/config/cpu_core_strategy.rb +0 -1
  12. data/lib/logstash/config/defaults.rb +0 -1
  13. data/lib/logstash/config/file.rb +0 -2
  14. data/lib/logstash/config/mixin.rb +4 -7
  15. data/lib/logstash/config/modules_common.rb +0 -2
  16. data/lib/logstash/config/source/local.rb +1 -3
  17. data/lib/logstash/config/source/modules.rb +0 -2
  18. data/lib/logstash/config/source/multi_local.rb +0 -1
  19. data/lib/logstash/config/source_loader.rb +1 -2
  20. data/lib/logstash/dependency_report.rb +19 -6
  21. data/lib/logstash/elasticsearch_client.rb +0 -2
  22. data/lib/logstash/environment.rb +3 -2
  23. data/lib/logstash/errors.rb +1 -15
  24. data/lib/logstash/event.rb +0 -1
  25. data/lib/logstash/event_dispatcher.rb +1 -40
  26. data/lib/logstash/execution_context.rb +2 -19
  27. data/lib/logstash/filters/base.rb +0 -2
  28. data/lib/logstash/inputs/base.rb +2 -4
  29. data/lib/logstash/inputs/threadable.rb +2 -3
  30. data/lib/logstash/instrument/collector.rb +0 -2
  31. data/lib/logstash/instrument/metric.rb +1 -105
  32. data/lib/logstash/instrument/namespaced_metric.rb +1 -58
  33. data/lib/logstash/instrument/namespaced_null_metric.rb +1 -58
  34. data/lib/logstash/instrument/null_metric.rb +2 -71
  35. data/lib/logstash/instrument/periodic_poller/base.rb +0 -1
  36. data/lib/logstash/instrument/periodic_poller/cgroup.rb +0 -1
  37. data/lib/logstash/java_pipeline.rb +33 -222
  38. data/lib/logstash/json.rb +0 -1
  39. data/lib/logstash/logging.rb +0 -2
  40. data/lib/logstash/logging/logger.rb +1 -159
  41. data/lib/logstash/modules/cli_parser.rb +0 -4
  42. data/lib/logstash/modules/elasticsearch_config.rb +0 -3
  43. data/lib/logstash/modules/elasticsearch_importer.rb +0 -3
  44. data/lib/logstash/modules/elasticsearch_resource.rb +0 -1
  45. data/lib/logstash/modules/file_reader.rb +0 -2
  46. data/lib/logstash/modules/kibana_base.rb +0 -1
  47. data/lib/logstash/modules/kibana_client.rb +0 -2
  48. data/lib/logstash/modules/kibana_config.rb +0 -3
  49. data/lib/logstash/modules/kibana_dashboards.rb +0 -2
  50. data/lib/logstash/modules/kibana_importer.rb +0 -3
  51. data/lib/logstash/modules/kibana_resource.rb +0 -1
  52. data/lib/logstash/modules/kibana_settings.rb +0 -2
  53. data/lib/logstash/modules/logstash_config.rb +0 -1
  54. data/lib/logstash/modules/resource_base.rb +0 -1
  55. data/lib/logstash/modules/scaffold.rb +0 -3
  56. data/lib/logstash/modules/settings_merger.rb +0 -2
  57. data/lib/logstash/namespace.rb +2 -15
  58. data/lib/logstash/outputs/base.rb +3 -5
  59. data/lib/logstash/patches/clamp.rb +6 -0
  60. data/lib/logstash/pipeline.rb +38 -180
  61. data/lib/logstash/pipeline_action/create.rb +0 -2
  62. data/lib/logstash/pipeline_action/reload.rb +1 -4
  63. data/lib/logstash/pipeline_action/stop.rb +0 -2
  64. data/lib/logstash/pipeline_reporter.rb +2 -108
  65. data/lib/logstash/plugin.rb +4 -7
  66. data/lib/logstash/plugins/hooks_registry.rb +1 -63
  67. data/lib/logstash/plugins/registry.rb +3 -2
  68. data/lib/logstash/runner.rb +6 -7
  69. data/lib/logstash/settings.rb +4 -5
  70. data/lib/logstash/shutdown_watcher.rb +0 -119
  71. data/lib/logstash/universal_plugin.rb +1 -13
  72. data/lib/logstash/util.rb +0 -1
  73. data/lib/logstash/util/buftok.rb +1 -139
  74. data/lib/logstash/util/byte_value.rb +2 -3
  75. data/lib/logstash/util/charset.rb +0 -1
  76. data/lib/logstash/util/cloud_setting_auth.rb +0 -1
  77. data/lib/logstash/util/cloud_setting_id.rb +20 -8
  78. data/lib/logstash/util/dead_letter_queue_manager.rb +2 -61
  79. data/lib/logstash/util/decorators.rb +0 -1
  80. data/lib/logstash/util/loggable.rb +1 -31
  81. data/lib/logstash/util/modules_setting_array.rb +2 -2
  82. data/lib/logstash/util/password.rb +0 -1
  83. data/lib/logstash/util/plugin_version.rb +0 -1
  84. data/lib/logstash/util/safe_uri.rb +7 -8
  85. data/lib/logstash/util/secretstore.rb +1 -38
  86. data/lib/logstash/util/substitution_variables.rb +4 -5
  87. data/lib/logstash/util/worker_threads_default_printer.rb +0 -1
  88. data/locales/en.yml +28 -1
  89. data/spec/logstash/config/mixin_spec.rb +4 -4
  90. data/spec/logstash/converge_result_spec.rb +0 -1
  91. data/spec/logstash/event_dispatcher_spec.rb +0 -2
  92. data/spec/logstash/event_spec.rb +22 -26
  93. data/spec/logstash/execution_context_spec.rb +0 -2
  94. data/spec/logstash/filter_delegator_spec.rb +12 -28
  95. data/spec/logstash/inputs/base_spec.rb +4 -5
  96. data/spec/logstash/instrument/metric_spec.rb +0 -1
  97. data/spec/logstash/instrument/namespaced_metric_spec.rb +0 -2
  98. data/spec/logstash/instrument/namespaced_null_metric_spec.rb +1 -3
  99. data/spec/logstash/instrument/null_metric_spec.rb +1 -4
  100. data/spec/logstash/instrument/periodic_poller/base_spec.rb +0 -1
  101. data/spec/logstash/instrument/periodic_poller/os_spec.rb +0 -1
  102. data/spec/logstash/instrument/wrapped_write_client_spec.rb +0 -1
  103. data/spec/logstash/java_filter_delegator_spec.rb +0 -3
  104. data/spec/logstash/java_integration_spec.rb +0 -1
  105. data/spec/logstash/java_pipeline_spec.rb +1 -4
  106. data/spec/logstash/modules/cli_parser_spec.rb +1 -3
  107. data/spec/logstash/modules/scaffold_spec.rb +0 -1
  108. data/spec/logstash/outputs/base_spec.rb +9 -10
  109. data/spec/logstash/pipeline_action/create_spec.rb +2 -3
  110. data/spec/logstash/pipeline_action/reload_spec.rb +1 -2
  111. data/spec/logstash/pipeline_action/stop_spec.rb +0 -1
  112. data/spec/logstash/pipeline_dlq_commit_spec.rb +0 -6
  113. data/spec/logstash/pipeline_reporter_spec.rb +18 -4
  114. data/spec/logstash/pipeline_spec.rb +2 -6
  115. data/spec/logstash/plugin_spec.rb +1 -2
  116. data/spec/logstash/plugins/hooks_registry_spec.rb +0 -2
  117. data/spec/logstash/queue_factory_spec.rb +0 -1
  118. data/spec/logstash/runner_spec.rb +16 -9
  119. data/spec/logstash/settings/modules_spec.rb +3 -3
  120. data/spec/logstash/shutdown_watcher_spec.rb +0 -27
  121. data/spec/logstash/state_resolver_spec.rb +0 -1
  122. data/spec/logstash/util/buftok_spec.rb +0 -1
  123. data/spec/logstash/util/cloud_setting_id_spec.rb +55 -2
  124. data/spec/logstash/util/secretstore_spec.rb +10 -10
  125. data/spec/logstash/util/wrapped_synchronous_queue_spec.rb +2 -2
  126. data/versions-gem-copy.yml +2 -2
  127. metadata +2 -16
  128. data/lib/logstash/bootstrap_check/bad_java.rb +0 -16
  129. data/lib/logstash/bootstrap_check/bad_ruby.rb +0 -12
  130. data/lib/logstash/converge_result.rb +0 -103
  131. data/lib/logstash/instrument/global_metrics.rb +0 -13
  132. data/lib/logstash/instrument/snapshot.rb +0 -15
  133. data/lib/logstash/java_integration.rb +0 -116
  134. data/lib/logstash/logging/json.rb +0 -21
  135. data/lib/logstash/plugins/plugin_factory.rb +0 -107
  136. data/lib/logstash/queue_factory.rb +0 -34
  137. data/lib/logstash/util/retryable.rb +0 -40
  138. data/spec/logstash/output_delegator_spec.rb +0 -201
  139. data/spec/logstash/timestamp_spec.rb +0 -45
@@ -2,8 +2,6 @@
2
2
  require "logstash/pipeline_action/base"
3
3
  require "logstash/pipeline"
4
4
  require "logstash/java_pipeline"
5
- require "logstash/converge_result"
6
- require "logstash/util/loggable"
7
5
 
8
6
  module LogStash module PipelineAction
9
7
  class Create < Base
@@ -2,9 +2,6 @@
2
2
  require "logstash/pipeline_action/base"
3
3
  require "logstash/pipeline_action/create"
4
4
  require "logstash/pipeline_action/stop"
5
- require "logstash/errors"
6
- require "logstash/util/loggable"
7
- require "logstash/converge_result"
8
5
 
9
6
  module LogStash module PipelineAction
10
7
  class Reload < Base
@@ -33,7 +30,7 @@ module LogStash module PipelineAction
33
30
  begin
34
31
  pipeline_validator =
35
32
  if @pipeline_config.settings.get_value("pipeline.java_execution")
36
- LogStash::JavaBasePipeline.new(@pipeline_config)
33
+ LogStash::JavaBasePipeline.new(@pipeline_config, nil, logger, nil)
37
34
  else
38
35
  LogStash::BasePipeline.new(@pipeline_config)
39
36
  end
@@ -1,7 +1,5 @@
1
1
  # encoding: utf-8
2
2
  require "logstash/pipeline_action/base"
3
- require "logstash/shutdown_watcher"
4
- require "logstash/converge_result"
5
3
 
6
4
  module LogStash module PipelineAction
7
5
  class Stop < Base
@@ -1,108 +1,2 @@
1
- # encoding: utf-8
2
- require 'ostruct'
3
-
4
- module LogStash; class PipelineReporter
5
- attr_reader :logger, :pipeline
6
-
7
- # This is an immutable copy of the pipeline state,
8
- # It is a proxy to a hash to allow us to add methods dynamically to the hash
9
- class Snapshot
10
- def initialize(data)
11
- @data = data
12
- end
13
-
14
- def to_hash
15
- @data
16
- end
17
-
18
- def to_simple_hash
19
- {"inflight_count" => inflight_count, "stalling_thread_info" => format_threads_by_plugin}
20
- end
21
-
22
- def to_str
23
- to_simple_hash.to_s
24
- end
25
- alias_method :to_s, :to_str
26
-
27
- def method_missing(meth)
28
- @data[meth]
29
- end
30
-
31
- def format_threads_by_plugin
32
- stalled_plugins = {}
33
- stalling_threads_info.each do |thr|
34
- key = (thr.delete("plugin") || "other")
35
- stalled_plugins[key] ||= []
36
- stalled_plugins[key] << thr
37
- end
38
- stalled_plugins
39
- end
40
- end
41
-
42
- def initialize(logger, pipeline)
43
- @logger = logger
44
- @pipeline = pipeline
45
- end
46
-
47
- # The main way of accessing data from the reporter,,
48
- # this provides a (more or less) consistent snapshot of what's going on in the
49
- # pipeline with some extra decoration
50
- def snapshot
51
- Snapshot.new(self.to_hash)
52
- end
53
-
54
- def to_hash
55
- # pipeline.filter_queue_client.inflight_batches is synchronized
56
- batch_map = pipeline.filter_queue_client.inflight_batches
57
- worker_states_snap = worker_states(batch_map) # We only want to run this once
58
- inflight_count = worker_states_snap.map {|s| s[:inflight_count]}.reduce(0, :+)
59
- {
60
- :events_filtered => events_filtered,
61
- :events_consumed => events_consumed,
62
- :inflight_count => inflight_count,
63
- :worker_states => worker_states_snap,
64
- :output_info => output_info,
65
- :thread_info => pipeline.plugin_threads_info,
66
- :stalling_threads_info => pipeline.stalling_threads_info
67
- }
68
- end
69
-
70
- private
71
-
72
- def events_filtered
73
- pipeline.events_filtered.sum
74
- end
75
-
76
- def events_consumed
77
- pipeline.events_consumed.sum
78
- end
79
-
80
- def plugin_threads
81
- pipeline.plugin_threads
82
- end
83
-
84
- # Not threadsafe! ensure synchronization
85
- def worker_states(batch_map)
86
- pipeline.worker_threads.map.with_index do |thread, idx|
87
- status = thread.status || "dead"
88
- batch = batch_map[thread]
89
- inflight_count = batch ? batch.size : 0
90
- {
91
- :status => status,
92
- :alive => thread.alive?,
93
- :index => idx,
94
- :inflight_count => inflight_count
95
- }
96
- end
97
- end
98
-
99
- def output_info
100
- pipeline.outputs.map do |output_delegator|
101
- {
102
- :type => output_delegator.config_name,
103
- :id => output_delegator.id,
104
- :concurrency => output_delegator.concurrency,
105
- }
106
- end
107
- end
108
- end end
1
+ # The contents of this file have been ported to Java. It is included for for compatibility
2
+ # with plugins that directly require it.
@@ -1,9 +1,5 @@
1
1
  # encoding: utf-8
2
- require "logstash/namespace"
3
- require "logstash/logging"
4
2
  require "logstash/config/mixin"
5
- require "logstash/instrument/null_metric"
6
- require "logstash/util/dead_letter_queue_manager"
7
3
  require "concurrent"
8
4
  require "securerandom"
9
5
 
@@ -21,9 +17,9 @@ class LogStash::Plugin
21
17
  # for a specific plugin.
22
18
  config :enable_metric, :validate => :boolean, :default => true
23
19
 
24
- # Add a unique `ID` to the plugin configuration. If no ID is specified, Logstash will generate one.
25
- # It is strongly recommended to set this ID in your configuration. This is particularly useful
26
- # when you have two or more plugins of the same type, for example, if you have 2 grok filters.
20
+ # Add a unique `ID` to the plugin configuration. If no ID is specified, Logstash will generate one.
21
+ # It is strongly recommended to set this ID in your configuration. This is particularly useful
22
+ # when you have two or more plugins of the same type, for example, if you have 2 grok filters.
27
23
  # Adding a named ID in this case will help in monitoring Logstash when using the monitoring APIs.
28
24
  #
29
25
  # [source,ruby]
@@ -137,6 +133,7 @@ class LogStash::Plugin
137
133
  # Should I remove this now and make sure the pipeline invoke the Registry or I should wait for 6.0
138
134
  # Its not really part of the public api but its used by the tests a lot to mock the plugins.
139
135
  def self.lookup(type, name)
136
+ require "logstash/plugins/registry"
140
137
  LogStash::PLUGIN_REGISTRY.lookup_pipeline_plugin(type, name)
141
138
  end
142
139
  end # class LogStash::Plugin
@@ -1,63 +1 @@
1
- # encoding: utf-8
2
- module LogStash module Plugins
3
- # This calls allow logstash to expose the endpoints for listeners
4
- class HooksRegistry
5
- java_import "java.util.concurrent.ConcurrentHashMap"
6
- java_import "java.util.concurrent.CopyOnWriteArrayList"
7
-
8
- def initialize
9
- @registered_emitters = ConcurrentHashMap.new
10
- @registered_hooks = ConcurrentHashMap.new
11
- end
12
-
13
- def register_emitter(emitter_scope, dispatcher)
14
- @registered_emitters.put(emitter_scope, dispatcher)
15
- sync_hooks
16
- end
17
-
18
- def remove_emitter(emitter_scope)
19
- @registered_emitters.remove(emitter_scope)
20
- end
21
-
22
- def register_hooks(emitter_scope, callback)
23
- callbacks = @registered_hooks.computeIfAbsent(emitter_scope) do
24
- CopyOnWriteArrayList.new
25
- end
26
-
27
- callbacks.add(callback)
28
- sync_hooks
29
- end
30
-
31
- def emitters_count
32
- @registered_emitters.size
33
- end
34
-
35
- def hooks_count(emitter_scope = nil)
36
- if emitter_scope.nil?
37
- @registered_hooks.elements().collect(&:size).reduce(0, :+)
38
- else
39
- callbacks = @registered_hooks.get(emitter_scope)
40
- callbacks.nil? ? 0 : @registered_hooks.get(emitter_scope).size
41
- end
42
- end
43
-
44
- def registered_hook?(emitter_scope, klass)
45
- callbacks = @registered_hooks[emitter_scope]
46
- return false if callbacks.nil?
47
- callbacks.collect(&:class).include?(klass)
48
- end
49
-
50
- private
51
- def sync_hooks
52
- @registered_emitters.each do |emitter, dispatcher|
53
- listeners = @registered_hooks.get(emitter)
54
-
55
- unless listeners.nil?
56
- listeners.each do |listener|
57
- dispatcher.add_listener(listener)
58
- end
59
- end
60
- end
61
- end
62
- end
63
- end end
1
+ # encoding: utf-8
@@ -1,9 +1,10 @@
1
1
  # encoding: utf-8
2
2
  require "rubygems/package"
3
- require "logstash/util/loggable"
4
3
  require "logstash/plugin"
5
- require "logstash/plugins/hooks_registry"
6
4
  require "logstash/modules/scaffold"
5
+ require "logstash/codecs/base"
6
+ require "logstash/filters/base"
7
+ require "logstash/outputs/base"
7
8
 
8
9
  module LogStash module Plugins
9
10
  class Registry
@@ -18,7 +18,6 @@ end
18
18
  require "clamp"
19
19
  require "net/http"
20
20
 
21
- require "logstash/namespace"
22
21
  require "logstash-core/logstash-core"
23
22
  require "logstash/environment"
24
23
  require "logstash/modules/cli_parser"
@@ -28,15 +27,12 @@ LogStash::Environment.load_locale!
28
27
 
29
28
  require "logstash/agent"
30
29
  require "logstash/config/defaults"
31
- require "logstash/shutdown_watcher"
32
30
  require "logstash/patches/clamp"
33
31
  require "logstash/settings"
34
32
  require "logstash/version"
35
33
  require 'logstash/plugins'
36
34
  require "logstash/modules/util"
37
35
  require "logstash/bootstrap_check/default_config"
38
- require "logstash/bootstrap_check/bad_java"
39
- require "logstash/bootstrap_check/bad_ruby"
40
36
  require "logstash/bootstrap_check/persisted_queue_config"
41
37
  require "set"
42
38
 
@@ -50,8 +46,6 @@ class LogStash::Runner < Clamp::StrictCommand
50
46
  # Ordered list of check to run before starting logstash
51
47
  # theses checks can be changed by a plugin loaded into memory.
52
48
  DEFAULT_BOOTSTRAP_CHECKS = [
53
- LogStash::BootstrapCheck::BadRuby,
54
- LogStash::BootstrapCheck::BadJava,
55
49
  LogStash::BootstrapCheck::DefaultConfig,
56
50
  LogStash::BootstrapCheck::PersistedQueueConfig
57
51
  ]
@@ -74,6 +68,11 @@ class LogStash::Runner < Clamp::StrictCommand
74
68
  :default => LogStash::SETTINGS.get_default("config.string"),
75
69
  :attribute_name => "config.string"
76
70
 
71
+ option ["--field-reference-parser"], "MODE",
72
+ I18n.t("logstash.runner.flag.field-reference-parser"),
73
+ :attribute_name => "config.field_reference.parser",
74
+ :default => LogStash::SETTINGS.get_default("config.field_reference.parser")
75
+
77
76
  # Module settings
78
77
  option ["--modules"], "MODULES",
79
78
  I18n.t("logstash.runner.flag.modules"),
@@ -281,7 +280,7 @@ class LogStash::Runner < Clamp::StrictCommand
281
280
 
282
281
  return start_shell(setting("interactive"), binding) if setting("interactive")
283
282
 
284
- module_parser = LogStash::Modules::CLIParser.new(@modules_list, @modules_variable_list)
283
+ module_parser = LogStash::Modules::CLIParser.new(setting("modules_list"), setting("modules_variable_list"))
285
284
  # Now populate Setting for modules.list with our parsed array.
286
285
  @settings.set("modules.cli", module_parser.output)
287
286
 
@@ -1,5 +1,4 @@
1
1
  # encoding: utf-8
2
- require "logstash/util/loggable"
3
2
  require "fileutils"
4
3
  require "logstash/util/byte_value"
5
4
  require "logstash/util/substitution_variables"
@@ -10,7 +9,7 @@ module LogStash
10
9
 
11
10
  include LogStash::Util::SubstitutionVariables
12
11
  include LogStash::Util::Loggable
13
-
12
+
14
13
  def initialize
15
14
  @settings = {}
16
15
  # Theses settings were loaded from the yaml file
@@ -119,7 +118,7 @@ module LogStash
119
118
  self.merge(deep_replace(flatten_hash(settings)), true)
120
119
  self
121
120
  end
122
-
121
+
123
122
  def post_process
124
123
  if @post_process_callbacks
125
124
  @post_process_callbacks.each do |callback|
@@ -127,7 +126,7 @@ module LogStash
127
126
  end
128
127
  end
129
128
  end
130
-
129
+
131
130
  def on_post_process(&block)
132
131
  @post_process_callbacks ||= []
133
132
  @post_process_callbacks << block
@@ -439,7 +438,7 @@ module LogStash
439
438
  def initialize(name, default=nil, strict=false)
440
439
  super(name, ::String, default, strict)
441
440
  end
442
-
441
+
443
442
  def validate(path)
444
443
  super(path)
445
444
 
@@ -1,120 +1 @@
1
1
  # encoding: utf-8
2
- require "concurrent/atomic/atomic_fixnum"
3
- require "concurrent/atomic/atomic_boolean"
4
-
5
- module LogStash
6
- class ShutdownWatcher
7
- include LogStash::Util::Loggable
8
-
9
- CHECK_EVERY = 1 # second
10
- REPORT_EVERY = 5 # checks
11
- ABORT_AFTER = 3 # stalled reports
12
-
13
- attr_reader :cycle_period, :report_every, :abort_threshold
14
-
15
- def initialize(pipeline, cycle_period=CHECK_EVERY, report_every=REPORT_EVERY, abort_threshold=ABORT_AFTER)
16
- @pipeline = pipeline
17
- @cycle_period = cycle_period
18
- @report_every = report_every
19
- @abort_threshold = abort_threshold
20
- @reports = []
21
- @attempts_count = Concurrent::AtomicFixnum.new(0)
22
- @running = Concurrent::AtomicBoolean.new(false)
23
- end
24
-
25
- def self.unsafe_shutdown=(boolean)
26
- @unsafe_shutdown = boolean
27
- end
28
-
29
- def self.unsafe_shutdown?
30
- @unsafe_shutdown
31
- end
32
-
33
- def self.start(pipeline, cycle_period=CHECK_EVERY, report_every=REPORT_EVERY, abort_threshold=ABORT_AFTER)
34
- controller = self.new(pipeline, cycle_period, report_every, abort_threshold)
35
- Thread.new(controller) { |controller| controller.start }
36
- end
37
-
38
- def logger
39
- self.class.logger
40
- end
41
-
42
- def attempts_count
43
- @attempts_count.value
44
- end
45
-
46
- def stop!
47
- @running.make_false
48
- end
49
-
50
- def stopped?
51
- @running.false?
52
- end
53
-
54
- def start
55
- sleep(@cycle_period)
56
- cycle_number = 0
57
- stalled_count = 0
58
- running!
59
- Stud.interval(@cycle_period) do
60
- @attempts_count.increment
61
- break if stopped?
62
- break unless @pipeline.thread.alive?
63
- @reports << pipeline_report_snapshot
64
- @reports.delete_at(0) if @reports.size > @report_every # expire old report
65
- if cycle_number == (@report_every - 1) # it's report time!
66
- logger.warn(@reports.last.to_s)
67
-
68
- if shutdown_stalled?
69
- logger.error("The shutdown process appears to be stalled due to busy or blocked plugins. Check the logs for more information.") if stalled_count == 0
70
- stalled_count += 1
71
-
72
- if self.class.unsafe_shutdown? && @abort_threshold == stalled_count
73
- logger.fatal("Forcefully quitting logstash..")
74
- force_exit()
75
- break
76
- end
77
- else
78
- stalled_count = 0
79
- end
80
- end
81
- cycle_number = (cycle_number + 1) % @report_every
82
- end
83
- ensure
84
- stop!
85
- end
86
-
87
- def pipeline_report_snapshot
88
- @pipeline.reporter.snapshot
89
- end
90
-
91
- # A pipeline shutdown is stalled if
92
- # * at least REPORT_EVERY reports have been created
93
- # * the inflight event count is in monotonically increasing
94
- # * there are worker threads running which aren't blocked on SizedQueue pop/push
95
- # * the stalled thread list is constant in the previous REPORT_EVERY reports
96
- def shutdown_stalled?
97
- return false unless @reports.size == @report_every #
98
- # is stalled if inflight count is either constant or increasing
99
- stalled_event_count = @reports.each_cons(2).all? do |prev_report, next_report|
100
- prev_report.inflight_count <= next_report.inflight_count
101
- end
102
- if stalled_event_count
103
- @reports.each_cons(2).all? do |prev_report, next_report|
104
- prev_report.stalling_threads == next_report.stalling_threads
105
- end
106
- else
107
- false
108
- end
109
- end
110
-
111
- def force_exit
112
- exit(-1)
113
- end
114
-
115
- private
116
- def running!
117
- @running.make_true
118
- end
119
- end
120
- end