Class: Wukong::Store::ChhChunkedFlatFileStore

Inherits:
FlatFileStore show all
Defined in:
lib/wukong/store/chh_chunked_flat_file_store.rb

Instance Attribute Summary collapse

Attributes inherited from FlatFileStore

#filemode, #filename

Instance Method Summary collapse

Methods inherited from FlatFileStore

#<<, #close, #each, #file, #flush, #mkdir!, #save, #size, #skip!

Methods inherited from Base

#each_as, #log_line

Constructor Details

#initialize(options = {}) ⇒ ChhChunkedFlatFileStore

Note that filemode is inherited from flat_file



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/wukong/store/chh_chunked_flat_file_store.rb', line 12

def initialize options={}
  # super wants a :filename in the options or it will fail. We need to get the initial filename
  # set up before we call super, so we need all of the parts of the pattern set up.
  self.rootdir          = options[:rootdir] || Settings[:chunk_file_rootdir]
  self.handle           = options[:handle]
  pattern               = options[:pattern] || Settings[:chunk_file_pattern]
  self.filename_pattern = FilenamePattern.new(pattern, :handle => handle, :rootdir => self.rootdir)
  options[:filename]    = filename_pattern.make()

  super options

  self.mkdir!
end

Instance Attribute Details

#filename_patternObject

Returns the value of attribute filename_pattern.



4
5
6
# File 'lib/wukong/store/chh_chunked_flat_file_store.rb', line 4

def filename_pattern
  @filename_pattern
end

#handleObject

Returns the value of attribute handle.



4
5
6
# File 'lib/wukong/store/chh_chunked_flat_file_store.rb', line 4

def handle
  @handle
end

#rootdirObject

Returns the value of attribute rootdir.



4
5
6
# File 'lib/wukong/store/chh_chunked_flat_file_store.rb', line 4

def rootdir
  @rootdir
end

Instance Method Details

#new_chunkObject



26
27
28
29
30
31
32
33
# File 'lib/wukong/store/chh_chunked_flat_file_store.rb', line 26

def new_chunk
  new_filename = filename_pattern.make()
  Log.info "Rotating chunked file #{filename} into #{new_filename}"
  self.flush
  self.close
  @filename = new_filename
  self.mkdir!
end