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

SocketManager: Use new feature to select path automatically #4092

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fluentd.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Gem::Specification.new do |gem|
gem.add_runtime_dependency("msgpack", [">= 1.3.1", "< 2.0.0"])
gem.add_runtime_dependency("yajl-ruby", ["~> 1.0"])
gem.add_runtime_dependency("cool.io", [">= 1.4.5", "< 2.0.0"])
gem.add_runtime_dependency("serverengine", [">= 2.3.0", "< 3.0.0"])
gem.add_runtime_dependency("serverengine", [">= 2.3.2", "< 3.0.0"])
gem.add_runtime_dependency("http_parser.rb", [">= 0.5.1", "< 0.9.0"])
gem.add_runtime_dependency("sigdump", ["~> 0.2.2"])
gem.add_runtime_dependency("tzinfo", [">= 1.0", "< 3.0"])
Expand Down
10 changes: 4 additions & 6 deletions lib/fluent/supervisor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@ def before_run
if config[:disable_shared_socket]
$log.info "shared socket for multiple workers is disabled"
else
socket_manager_path = ServerEngine::SocketManager::Server.generate_path
ServerEngine::SocketManager::Server.open(socket_manager_path)
ENV['SERVERENGINE_SOCKETMANAGER_PATH'] = socket_manager_path.to_s
server = ServerEngine::SocketManager::Server.open
ENV['SERVERENGINE_SOCKETMANAGER_PATH'] = server.path.to_s
end
end

Expand Down Expand Up @@ -801,9 +800,8 @@ def configure(supervisor: false)
private

def create_socket_manager
socket_manager_path = ServerEngine::SocketManager::Server.generate_path
ServerEngine::SocketManager::Server.open(socket_manager_path)
ENV['SERVERENGINE_SOCKETMANAGER_PATH'] = socket_manager_path.to_s
server = ServerEngine::SocketManager::Server.open
ENV['SERVERENGINE_SOCKETMANAGER_PATH'] = server.path.to_s
end

def show_plugin_config
Expand Down
14 changes: 10 additions & 4 deletions lib/fluent/test/driver/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

require 'fluent/config'
require 'fluent/config/element'
require 'fluent/env'
require 'fluent/log'
require 'fluent/clock'

Expand Down Expand Up @@ -102,11 +103,16 @@ def run(timeout: nil, start: true, shutdown: true, &block)

def instance_start
if @instance.respond_to?(:server_wait_until_start)
@socket_manager_path = ServerEngine::SocketManager::Server.generate_path
if @socket_manager_path.is_a?(String) && File.exist?(@socket_manager_path)
FileUtils.rm_f @socket_manager_path
if Fluent.windows?
@socket_manager_server = ServerEngine::SocketManager::Server.open
@socket_manager_path = @socket_manager_server.path
else
@socket_manager_path = ServerEngine::SocketManager::Server.generate_path
if @socket_manager_path.is_a?(String) && File.exist?(@socket_manager_path)
FileUtils.rm_f @socket_manager_path
end
@socket_manager_server = ServerEngine::SocketManager::Server.open(@socket_manager_path)
end
@socket_manager_server = ServerEngine::SocketManager::Server.open(@socket_manager_path)
ENV['SERVERENGINE_SOCKETMANAGER_PATH'] = @socket_manager_path.to_s
end

Expand Down
14 changes: 6 additions & 8 deletions lib/fluent/test/startup_shutdown.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,23 @@ module Fluent
module Test
module StartupShutdown
def startup
socket_manager_path = ServerEngine::SocketManager::Server.generate_path
@server = ServerEngine::SocketManager::Server.open(socket_manager_path)
ENV['SERVERENGINE_SOCKETMANAGER_PATH'] = socket_manager_path.to_s
@server = ServerEngine::SocketManager::Server.open
ENV['SERVERENGINE_SOCKETMANAGER_PATH'] = @server.path.to_s
end

def shutdown
@server.close
end

def self.setup
@socket_manager_path = ServerEngine::SocketManager::Server.generate_path
@server = ServerEngine::SocketManager::Server.open(@socket_manager_path)
ENV['SERVERENGINE_SOCKETMANAGER_PATH'] = @socket_manager_path.to_s
@server = ServerEngine::SocketManager::Server.open
ENV['SERVERENGINE_SOCKETMANAGER_PATH'] = @server.path.to_s
end

def self.teardown
@server.close
# on Windows, socket_manager_path is a TCP port number
FileUtils.rm_f @socket_manager_path unless Fluent.windows?
# on Windows, the path is a TCP port number
FileUtils.rm_f @server.path unless Fluent.windows?
end
end
end
Expand Down
5 changes: 2 additions & 3 deletions test/plugin/test_in_http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
class HttpInputTest < Test::Unit::TestCase
class << self
def startup
socket_manager_path = ServerEngine::SocketManager::Server.generate_path
@server = ServerEngine::SocketManager::Server.open(socket_manager_path)
ENV['SERVERENGINE_SOCKETMANAGER_PATH'] = socket_manager_path.to_s
@server = ServerEngine::SocketManager::Server.open
ENV['SERVERENGINE_SOCKETMANAGER_PATH'] = @server.path.to_s
end

def shutdown
Expand Down
13 changes: 9 additions & 4 deletions test/plugin_helper/test_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@ class Dummy < Fluent::Plugin::TestBase

setup do
@port = unused_port
@socket_manager_path = ServerEngine::SocketManager::Server.generate_path
if @socket_manager_path.is_a?(String) && File.exist?(@socket_manager_path)
FileUtils.rm_f @socket_manager_path
if Fluent.windows?
@socket_manager_server = ServerEngine::SocketManager::Server.open
@socket_manager_path = @socket_manager_server.path
else
@socket_manager_path = ServerEngine::SocketManager::Server.generate_path
if @socket_manager_path.is_a?(String) && File.exist?(@socket_manager_path)
FileUtils.rm_f @socket_manager_path
end
@socket_manager_server = ServerEngine::SocketManager::Server.open(@socket_manager_path)
end
@socket_manager_server = ServerEngine::SocketManager::Server.open(@socket_manager_path)
ENV['SERVERENGINE_SOCKETMANAGER_PATH'] = @socket_manager_path.to_s

@d = Dummy.new
Expand Down