Class: Fluent::FlumeInput
- Inherits:
-
Input
- Object
- Input
- Fluent::FlumeInput
- Defined in:
- lib/fluent/plugin/in_flume.rb
Defined Under Namespace
Classes: FluentFlumeHandler
Instance Method Summary collapse
- #configure(conf) ⇒ Object
-
#initialize ⇒ FlumeInput
constructor
A new instance of FlumeInput.
- #run ⇒ Object
- #shutdown ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize ⇒ FlumeInput
37 38 39 40 41 42 43 44 45 |
# File 'lib/fluent/plugin/in_flume.rb', line 37 def initialize require 'thrift' $:.unshift File.join(File.dirname(__FILE__), 'thrift') require 'flume_types' require 'flume_constants' require 'thrift_flume_event_server' super end |
Instance Method Details
#configure(conf) ⇒ Object
47 48 49 |
# File 'lib/fluent/plugin/in_flume.rb', line 47 def configure(conf) super end |
#run ⇒ Object
104 105 106 107 108 109 110 |
# File 'lib/fluent/plugin/in_flume.rb', line 104 def run log.debug "starting server: #{@server}" @server.serve rescue log.error "unexpected error", :error=>$!.to_s log.error_backtrace end |
#shutdown ⇒ Object
99 100 101 102 |
# File 'lib/fluent/plugin/in_flume.rb', line 99 def shutdown @transport.close unless @transport.closed? #@thread.join end |
#start ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/fluent/plugin/in_flume.rb', line 51 def start log.debug "listening flume on #{@bind}:#{@port}" handler = FluentFlumeHandler.new handler.tag_field = @tag_field handler.default_tag = @default_tag handler.add_prefix = @add_prefix handler.msg_format = @msg_format handler.log = log processor = ThriftFlumeEventServer::Processor.new handler @transport = Thrift::ServerSocket.new @bind, @port unless @is_framed transport_factory = Thrift::BufferedTransportFactory.new else raise ConfigError, "in_flume: unsupported is_framed '#{@is_framed}'" end unless ['text', 'json'].include? @msg_format raise 'Unknown format: msg_format=#{@msg_format}' end # 2011/09/29 Kazuki Ohta <[email protected]> # This section is a workaround to set strict_read and strict_write option. # Ruby-Thrift 0.7 set them both 'true' in default, but Flume protocol set # them both 'false'. protocol_factory = Thrift::BinaryProtocolFactory.new protocol_factory.instance_eval {|obj| def get_protocol(trans) # override return Thrift::BinaryProtocol.new(trans, strict_read=false, strict_write=false) end } case @server_type when 'simple' @server = Thrift::SimpleServer.new processor, @transport, transport_factory, protocol_factory when 'threaded' @server = Thrift::ThreadedServer.new processor, @transport, transport_factory, protocol_factory when 'thread_pool' @server = Thrift::ThreadPoolServer.new processor, @transport, transport_factory, protocol_factory else raise ConfigError, "in_flume: unsupported server_type '#{@server_type}'" end @thread = Thread.new(&method(:run)) end |