Class: LogStash::Outputs::HDFS::DFSOutputStreamWrapper
- Inherits:
-
Object
- Object
- LogStash::Outputs::HDFS::DFSOutputStreamWrapper
- Defined in:
- lib/logstash/outputs/hdfs.rb
Constant Summary collapse
- FLUSH_METHOD =
hadoop 2.x uses hflush
:flush
Instance Attribute Summary collapse
-
#active ⇒ Object
Returns the value of attribute active.
Instance Method Summary collapse
- #close ⇒ Object
- #flush ⇒ Object
-
#initialize(output_stream) ⇒ DFSOutputStreamWrapper
constructor
A new instance of DFSOutputStreamWrapper.
- #write(str) ⇒ Object
Constructor Details
#initialize(output_stream) ⇒ DFSOutputStreamWrapper
Returns a new instance of DFSOutputStreamWrapper.
192 193 194 |
# File 'lib/logstash/outputs/hdfs.rb', line 192 def initialize(output_stream) @output_stream = output_stream end |
Instance Attribute Details
#active ⇒ Object
Returns the value of attribute active.
191 192 193 |
# File 'lib/logstash/outputs/hdfs.rb', line 191 def active @active end |
Instance Method Details
#close ⇒ Object
195 196 197 198 199 |
# File 'lib/logstash/outputs/hdfs.rb', line 195 def close @output_stream.close rescue IOException => e logger.error("Failed to close file", :exception => e) end |
#flush ⇒ Object
200 201 202 203 204 205 206 207 208 209 |
# File 'lib/logstash/outputs/hdfs.rb', line 200 def flush if FLUSH_METHOD == :hflush @output_stream.hflush else @output_stream.flush @output_stream.sync end rescue end |
#write(str) ⇒ Object
210 211 212 213 214 |
# File 'lib/logstash/outputs/hdfs.rb', line 210 def write(str) bytes = str.to_java_bytes @output_stream.write(bytes, 0, bytes.length) @active = true end |