Merge branch 'master' of github.com:elastic/logstash

This commit is contained in:
guyboertje 2015-09-04 08:26:07 +01:00
commit 972302c494
9 changed files with 51 additions and 66 deletions

View file

@ -18,11 +18,6 @@ Logstash has the following flags. You can use the `--help` flag to display this
-w, --filterworkers COUNT
Sets the number of filter workers to run (default: 1)
--watchdog-timeout TIMEOUT
Set watchdog timeout value in seconds. Default is 10. This timeout is used to detect
stuck filters; stuck filters usually symptoms of bugs. When a filter takes longer than
TIMEOUT seconds, it will cause Logstash to abort.
-l, --log FILE
Log to a given path. Default is to log to stdout

View file

@ -20,8 +20,6 @@ default. If no output is specified, 'stdout { debug => true }}' is
default. </dd>
<dt> -w, --filterworkers COUNT </dt>
<dd> Run COUNT filter workers (default: 1) </dd>
<dt> --watchdog-timeout TIMEOUT </dt>
<dd> Set watchdog timeout value in seconds. Default is 10.</dd>
<dt> -l, --log FILE </dt>
<dd> Log to a given path. Default is to log to stdout </dd>
<dt> --verbose </dt>

View file

@ -23,10 +23,6 @@ class LogStash::Agent < Clamp::Command
I18n.t("logstash.agent.flag.filterworkers"),
:attribute_name => :filter_workers, :default => 1, &:to_i
option "--watchdog-timeout", "SECONDS",
I18n.t("logstash.agent.flag.watchdog-timeout"),
:default => 10, &:to_f
option ["-l", "--log"], "FILE",
I18n.t("logstash.agent.flag.log"),
:attribute_name => :log_file

View file

@ -78,6 +78,22 @@ module java::util::Collection
self.removeAll([o]) ? o : block_given? ? yield : nil
end
def compact
duped = Java::JavaUtil::ArrayList.new(self)
duped.compact!
duped
end
def compact!
size_before = self.size
self.removeAll(java::util::Collections.singleton(nil))
if size_before == self.size
nil
else
self
end
end
# support the Ruby intersection method on Java Collection
def &(other)
# transform self into a LinkedHashSet to remove duplicates and preserve order as defined by the Ruby Array intersection contract

View file

@ -97,18 +97,6 @@ class LogStash::Plugin
return "#{self.class.name}: #{@params}"
end
protected
def update_watchdog(state)
Thread.current[:watchdog] = Time.now
Thread.current[:watchdog_state] = state
end
protected
def clear_watchdog
Thread.current[:watchdog] = nil
Thread.current[:watchdog_state] = nil
end
public
def inspect
if !@params.nil?

View file

@ -1,37 +0,0 @@
# encoding: utf-8
require "logstash/namespace"
require "logstash/logging"
class LogStash::ThreadWatchdog
attr_accessor :logger
attr_accessor :threads
class TimeoutError < StandardError; end
public
def initialize(threads, watchdog_timeout=10)
@threads = threads
@watchdog_timeout = watchdog_timeout
end # def initialize
public
def watch
while sleep(1)
cutoff = Time.now - @watchdog_timeout
@threads.each do |t|
watchdog = t[:watchdog]
if watchdog and watchdog <= cutoff
age = Time.now - watchdog
@logger.fatal("thread watchdog timeout",
:thread => t,
:backtrace => t.backtrace,
:thread_watchdog => watchdog,
:age => age,
:cutoff => @watchdog_timeout,
:state => t[:watchdog_state])
raise TimeoutError, "watchdog timeout"
end
end
end
end # def watch
end # class LogStash::ThreadWatchdog

View file

@ -153,12 +153,6 @@ en:
Check configuration for valid syntax and then exit.
filterworkers: |+
Sets the number of filter workers to run.
watchdog-timeout: |+
Set the filter watchdog timeout (in seconds).
This timeout is used to detect stuck filters;
stuck filters usually symptoms of bugs.
When a filter takes longer than TIMEOUT
seconds, it will cause logstash to abort.
log: |+
Write logstash internal logs to the given
file. Without this flag, logstash will emit

View file

@ -29,6 +29,11 @@ namespace "test" do
exit(Spec::Core::Runner.run(["--fail-fast", Rake::FileList["spec/**/*_spec.rb"]]))
end
desc "run core specs on a single file"
task "core-single-file", [:specfile] => ["setup"] do |t,args|
exit(RSpec::Core::Runner.run([Rake::FileList[args.specfile]]))
end
desc "run all installed plugins specs"
task "plugins" => ["setup"] do
# grab all spec files using the live plugins gem specs. this allows correclty also running the specs

View file

@ -211,6 +211,36 @@ describe "Java integration" do
end
end
end
context "when compacting" do
context "#compact with nils" do
let(:initial_array) { [1,2,3,nil,nil,6] }
it "should remove nil values from a copy" do
expect(subject.compact).to eq([1,2,3,6])
expect(subject).to eq([1,2,3,nil,nil,6])
end
end
context "#compact! with nils" do
let(:initial_array) { [1,2,3,nil,nil,6] }
it "should remove nil values" do
expect(subject.compact!).to eq([1,2,3,6])
expect(subject).to eq([1,2,3,6])
end
it "should return the original" do
expect(subject.compact!.object_id).to eq(subject.object_id)
end
end
context "#compact! without nils" do
let(:initial_array) { [1,2,3,6] }
it "should return nil" do
expect(subject.compact!).to be nil
expect(subject).to eq([1,2,3,6])
end
end
end
end
context "Enumerable implementation" do