Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor plugin shutdown #8

Merged

Conversation

colinsurprenant
Copy link
Contributor

refactor for the new shutdown semantic.

note that the specs were not refactored as a whole be new specs were added, using the new style, based on the udp input specs. some TODOs have been commented to note some duplicate code and DRYing that we could do in a followup issue/PR.

end

def stop
super
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed anymore, right?

while !stop?
set_client_socket(TCPSocket.new(@host, @port))

if @ssl_enable
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you considered extracting this block into a separate method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could I guess, and a lot of code could be better refactored here too. tried to keep it to minimal.

@andrewvc
Copy link
Contributor

Are these specs passing for you @colinsurprenant ? I'm currently seeing them hang indefinitely.

The code looks alright otherwise.

@colinsurprenant
Copy link
Contributor Author

is it running agaist the lastest core code base? I've run the tests in a loop to catch potential timing issues and it always passed... weird.


# close all sockets and make sure there is not more pending threads
sockets.each{|socket| socket.close}
it "should receive events been generated" do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This spec is where it hangs for me

@andrewvc
Copy link
Contributor

@colinsurprenant It hangs for me here https://github.com/logstash-plugins/logstash-input-tcp/pull/8/files#r40319932

This is running of 2.0.0.snapshot2. Is there another ref I should be basing this off of?

@andrewvc
Copy link
Contributor

Running with --debug I get it repeating the INFLIGHT EVENTS REPORT message

Accepted connection {:client=>"127.0.0.1:62233", :server=>"0.0.0.0:48607", :level=>:debug, :file=>"logstash/inputs/tcp.rb", :line=>"177", :method=>"block in server_connection_thread"}
config LogStash::Codecs::Line/@charset = "UTF-8" {:level=>:debug, :file=>"logstash/config/mixin.rb", :line=>"111", :method=>"block in config_init"}
stopping {:plugin=><LogStash::Inputs::Tcp port=>48607, debug=>false, codec=><LogStash::Codecs::Line charset=>"UTF-8">, host=>"0.0.0.0", data_timeout=>-1, mode=>"server", ssl_enable=>false, ssl_verify=>false, ssl_key_passphrase=><password>>, :level=>:debug, :file=>"logstash/inputs/base.rb", :line=>"115", :method=>"do_stop"}
["INFLIGHT_EVENTS_REPORT", "2015-09-24T08:45:33-05:00", {"input_to_filter"=>0, "filter_to_output"=>0, "outputs"=>[]}] {:level=>:warn, :file=>"logstash/util/reporter.rb", :line=>"26", :method=>"report"}
["INFLIGHT_EVENTS_REPORT", "2015-09-24T08:45:33-05:00", {"input_to_filter"=>0, "filter_to_output"=>0, "outputs"=>[]}] {:level=>:warn, :file=>"logstash/util/reporter.rb", :line=>"26", :method=>"report"}

That's where it hangs

@andrewvc
Copy link
Contributor

@colinsurprenant AHA. I was running the specs against JRuby 9.0.0.0 . It worked when I switched to 1.7.20 .

In that case LGTM, but that does not bode well for the future. Any ideas why?

@colinsurprenant
Copy link
Contributor Author

@andrewvc lots have changed IO wise in 9k, we'll have to investigate. Note that we should certainly test against 9k and report problems in JRuby if we find them. OTOH 9k is definitely not mature enough to consider it for a release soon.

@jsvd
Copy link
Member

jsvd commented Sep 24, 2015

LGTM, tests passed, tested manually server/client without ssl, everything worked.

comments, fixes and close

new specs styles

spec helper for input

revert data_timeout

comment rescue nil
@colinsurprenant
Copy link
Contributor Author

squashed, merging.

@colinsurprenant colinsurprenant merged commit 957848d into logstash-plugins:master Sep 26, 2015
@colinsurprenant colinsurprenant changed the title [WIP] refactor plugin shutdown refactor plugin shutdown Sep 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants