Module: Priam::Core::Get

Defined in:
lib/priam/core/get.rb

Class Method Summary collapse

Class Method Details

.get_column(client, column_family, super_column, key, options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/priam/core/get.rb', line 3

def self.get_column(client, column_family, super_column, key, options={})
  raise_exception_flag = options[:raise_exception_flag]
  retry_max_count = options[:retry_max_count] || 0
  weight_second = options[:weight_second] || 1
  
  retry_count = 0
  begin
    if super_column
      record = client.get(column_family, super_column, key)
    else
      record = client.get(column_family, key)
    end
  rescue Exception => e
    if retry_max_count <= retry_count then
      if raise_exception_flag then
        raise e
      else
        backtrace = e.backtrace.map{|s| "  #{s}"}.join("\n")
        Priam.logger.warn(" #{e.message}(#{e.class.name}): #{backtrace}")
        return {}
      end
    else
      retry_count += 1
      Priam.logger.warn(" #{e.message}(#{e.class.name})")
      Priam.logger.info(" retry(#{retry_count})")
      sleep(weight_second) if weight_second
      retry
    end
  end
  return record
end