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
Returns a new instance of FlumeInput.
33 34 35 36 37 38 39 40 41 |
# File 'lib/fluent/plugin/in_flume.rb', line 33 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
43 44 45 |
# File 'lib/fluent/plugin/in_flume.rb', line 43 def configure(conf) super end |
#run ⇒ Object
99 100 101 102 103 104 105 |
# File 'lib/fluent/plugin/in_flume.rb', line 99 def run $log.debug "starting server: #{@server}" @server.serve rescue $log.error "unexpected error", :error=>$!.to_s $log.error_backtrace end |
#shutdown ⇒ Object
94 95 96 97 |
# File 'lib/fluent/plugin/in_flume.rb', line 94 def shutdown @transport.close unless @transport.closed? # TODO #@thread.join # TODO end |
#start ⇒ Object
47 48 49 50 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 |
# File 'lib/fluent/plugin/in_flume.rb', line 47 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. = @message_format 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? @message_format raise 'Unknown format: message_format=#{@message_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 |