Class: LogStash::Outputs::HDFS::DFSOutputStreamWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/outputs/hdfs.rb

Constant Summary collapse

FLUSH_METHOD =

hadoop 2.x uses hflush

:flush

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#activeObject

Returns the value of attribute active.



191
192
193
# File 'lib/logstash/outputs/hdfs.rb', line 191

def active
  @active
end

Instance Method Details

#closeObject



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

#flushObject



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