MINOR: Remove redundant methods and method calls from both Queue implementations

Fixes #8647
This commit is contained in:
Armin 2017-11-13 12:12:06 +01:00 committed by Armin Braun
parent 0b8a0bdbdd
commit 289290109d
2 changed files with 12 additions and 40 deletions

View file

@ -149,10 +149,6 @@ module LogStash; module Util
end
end
def current_inflight_batch
@inflight_batches.fetch(Thread.current, [])
end
# create a new empty batch
# @return [ReadBatch] a new empty read batch
def new_batch
@ -171,36 +167,26 @@ module LogStash; module Util
end
def start_metrics(batch)
thread = Thread.current
@mutex.lock
begin
set_current_thread_inflight_batch(batch)
@inflight_batches[thread] = batch
ensure
@mutex.unlock
end
start_clock
end
def set_current_thread_inflight_batch(batch)
@inflight_batches[Thread.current] = batch
@inflight_clocks[thread] = java.lang.System.nano_time
end
def close_batch(batch)
thread = Thread.current
@mutex.lock
begin
batch.close
@inflight_batches.delete(Thread.current)
@inflight_batches.delete(thread)
ensure
@mutex.unlock
end
stop_clock(batch)
end
def start_clock
@inflight_clocks[Thread.current] = java.lang.System.nano_time
end
def stop_clock(batch)
start_time = @inflight_clocks.get_and_set(Thread.current, nil)
start_time = @inflight_clocks.get_and_set(thread, nil)
unless start_time.nil?
if batch.size > 0
# only stop (which also records) the metrics if the batch is non-empty.

View file

@ -80,10 +80,6 @@ module LogStash; module Util
yield(@inflight_batches)
end
def current_inflight_batch
@inflight_batches.fetch(Thread.current, [])
end
# create a new empty batch
# @return [ReadBatch] a new empty read batch
def new_batch
@ -97,25 +93,15 @@ module LogStash; module Util
end
def start_metrics(batch)
set_current_thread_inflight_batch(batch)
start_clock
end
def set_current_thread_inflight_batch(batch)
@inflight_batches[Thread.current] = batch
thread = Thread.current
@inflight_batches[thread] = batch
@inflight_clocks[thread] = java.lang.System.nano_time
end
def close_batch(batch)
@inflight_batches.delete(Thread.current)
stop_clock(batch)
end
def start_clock
@inflight_clocks[Thread.current] = java.lang.System.nano_time
end
def stop_clock(batch)
start_time = @inflight_clocks.get_and_set(Thread.current, nil)
thread = Thread.current
@inflight_batches.delete(thread)
start_time = @inflight_clocks.get_and_set(thread, nil)
unless start_time.nil?
if batch.size > 0
# only stop (which also records) the metrics if the batch is non-empty.