Class: HbaseRestIface::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/active_record/connection_adapters/hbase/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(ops) ⇒ Client

Returns a new instance of Client.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 9

def initialize(ops)
  ops ||= {}
  ops[:host] ||= 'localhost'
  ops[:port] ||= '9191'
  
  @ops = ops
  @query_options = {}
  @info = { :version => '1' }
  
  connect
end

Instance Method Details

#[](key) ⇒ Object



21
22
23
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 21

def [](key)
  @ops[key]
end

#[]=(key, val) ⇒ Object



24
25
26
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 24

def []=(key,val)
  @ops[key]=val
end

#abandon_results!Object



95
96
97
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 95

def abandon_results!
  nil
end

#affected_rowsObject



123
124
125
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 123

def affected_rows
  nil
end

#async_resultObject



115
116
117
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 115

def async_result
  nil
end

#charset_name=(o) ⇒ Object



179
180
181
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 179

def charset_name=(o)
  nil
end

#closeObject



91
92
93
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 91

def close
  nil
end

#connectObject



41
42
43
44
45
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 41

def connect
  self.class.base_uri "#{@ops[:host]}:#{@ops[:port]}"
  #File.open('/tmp/thing.txt', 'a') { |file| file.write("\n\n!!!connect\n#{@ops[:host]}:#{@ops[:port]}") }
  ping
end

#connect_timeout=(o) ⇒ Object



163
164
165
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 163

def connect_timeout=(o)
  nil
end

#default_file=(o) ⇒ Object



187
188
189
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 187

def default_file=(o)
  nil
end

#default_group=(o) ⇒ Object



191
192
193
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 191

def default_group=(o)
  nil
end

#encodingObject



159
160
161
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 159

def encoding
  nil
end

#escape(string) ⇒ Object



99
100
101
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 99

def escape(string)
  string
end

#infoObject



83
84
85
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 83

def info
  @info
end

#init_command=(o) ⇒ Object



195
196
197
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 195

def init_command=(o)
  nil
end

#initialize_extObject



203
204
205
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 203

def initialize_ext
  nil
end

#last_idObject



119
120
121
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 119

def last_id
  nil
end

#local_infile=(o) ⇒ Object



175
176
177
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 175

def local_infile=(o)
  nil
end

#more_results?Boolean

Returns:

  • (Boolean)


135
136
137
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 135

def more_results?
  nil
end

#next_resultObject



139
140
141
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 139

def next_result
  nil
end

#pingObject



47
48
49
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 47

def ping
  simple_request("/ping")[0]
end

#query(sql) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 28

def query(sql)
  File.open('/tmp/thing.txt', 'a') { |file| file.write("\n!!query\n#{sql}") }
  query_object = HipsterSqlToHbase.parse_hash(sql)
  File.open('/tmp/thing.txt', 'a') { |file| file.write("\n#{query_object.inspect}") }
  begin
    result = secure_request("/exec", { body: {query: MessagePack.pack(query_object)} })
    Hbase::Result.new(result) unless result.nil?
  rescue Exception => e
    File.open('/tmp/thing.txt', 'a') { |file| file.write("\n\n!!!error\n#{e.message}") }
    nil
  end
end

#query_info_stringObject



155
156
157
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 155

def query_info_string
  nil
end

#query_optionsObject



87
88
89
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 87

def query_options
  @query_options
end

#read_timeout=(o) ⇒ Object



167
168
169
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 167

def read_timeout=(o)
  nil
end

#reconnect=Object



147
148
149
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 147

def reconnect=
  nil
end

#secure_auth=(o) ⇒ Object



183
184
185
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 183

def secure_auth=(o)
  nil
end

#secure_request(route, body = nil) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 67

def secure_request(route, body=nil)
  if body.nil?
    response = self.class.post(route)
  else
    response = self.class.post(route, body)
  end
  
  if response.code.to_s =~ /2\d\d/
    MessagePack.unpack(response.body)
  else
    error = Nokogiri::HTML(response.body)
    #binding.pry
    raise error.css("title")[0].text
  end
end

#select_dbObject



131
132
133
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 131

def select_db
  nil
end

#server_infoObject



107
108
109
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 107

def server_info
  nil
end

#simple_request(route, query = nil) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 51

def simple_request(route, query=nil)
  if query.nil?
    response = self.class.get(route)
  else
    response = self.class.get(route, query)
  end
  
  if response.code.to_s =~ /2\d\d/
    MessagePack.unpack(response.body)
  else
    error = Nokogiri::HTML(response.body)
    #binding.pry
    raise error.css("title")[0].text
  end
end

#socketObject



111
112
113
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 111

def socket
  nil
end

#ssl_setObject



199
200
201
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 199

def ssl_set
  nil
end

#store_resultObject



143
144
145
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 143

def store_result
  nil
end

#thread_idObject



127
128
129
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 127

def thread_id
  nil
end

#warning_countObject



151
152
153
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 151

def warning_count
  nil
end

#write_timeout=(o) ⇒ Object



171
172
173
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 171

def write_timeout=(o)
  nil
end