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.



188
189
190
# File 'lib/logstash/outputs/hdfs.rb', line 188

def initialize(output_stream)
  @output_stream = output_stream
end

Instance Attribute Details

#activeObject

Returns the value of attribute active.



187
188
189
# File 'lib/logstash/outputs/hdfs.rb', line 187

def active
  @active
end

Instance Method Details

#closeObject



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

def close
  @output_stream.close
rescue IOException => e
  logger.error("Failed to close file", :exception => e)
end

#flushObject



196
197
198
199
200
201
202
203
204
205
# File 'lib/logstash/outputs/hdfs.rb', line 196

def flush
  if FLUSH_METHOD == :hflush
    @output_stream.hflush
  else
    @output_stream.flush
    @output_stream.sync
  end
rescue

end

#write(str) ⇒ Object



206
207
208
209
210
# File 'lib/logstash/outputs/hdfs.rb', line 206

def write(str)
  bytes = str.to_java_bytes
  @output_stream.write(bytes, 0, bytes.length)
  @active = true
end