Class: HbaseRestIface::Client
- Inherits:
-
Object
- Object
- HbaseRestIface::Client
- Includes:
- HTTParty
- Defined in:
- lib/active_record/connection_adapters/hbase/client.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, val) ⇒ Object
- #abandon_results! ⇒ Object
- #affected_rows ⇒ Object
- #async_result ⇒ Object
- #charset_name=(o) ⇒ Object
- #close ⇒ Object
- #connect ⇒ Object
- #connect_timeout=(o) ⇒ Object
- #default_file=(o) ⇒ Object
- #default_group=(o) ⇒ Object
- #encoding ⇒ Object
- #escape(string) ⇒ Object
- #info ⇒ Object
- #init_command=(o) ⇒ Object
-
#initialize(ops) ⇒ Client
constructor
A new instance of Client.
- #initialize_ext ⇒ Object
- #last_id ⇒ Object
- #local_infile=(o) ⇒ Object
- #more_results? ⇒ Boolean
- #next_result ⇒ Object
- #ping ⇒ Object
- #query(sql) ⇒ Object
- #query_info_string ⇒ Object
- #query_options ⇒ Object
- #read_timeout=(o) ⇒ Object
- #reconnect= ⇒ Object
- #secure_auth=(o) ⇒ Object
- #secure_request(route, body = nil) ⇒ Object
- #select_db ⇒ Object
- #server_info ⇒ Object
- #simple_request(route, query = nil) ⇒ Object
- #socket ⇒ Object
- #ssl_set ⇒ Object
- #store_result ⇒ Object
- #thread_id ⇒ Object
- #warning_count ⇒ Object
- #write_timeout=(o) ⇒ Object
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_rows ⇒ Object
123 124 125 |
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 123 def affected_rows nil end |
#async_result ⇒ Object
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 |
#close ⇒ Object
91 92 93 |
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 91 def close nil end |
#connect ⇒ Object
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 |
#encoding ⇒ Object
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 |
#info ⇒ Object
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_ext ⇒ Object
203 204 205 |
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 203 def initialize_ext nil end |
#last_id ⇒ Object
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
135 136 137 |
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 135 def more_results? nil end |
#next_result ⇒ Object
139 140 141 |
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 139 def next_result nil end |
#ping ⇒ Object
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.}") } nil end end |
#query_info_string ⇒ Object
155 156 157 |
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 155 def query_info_string nil end |
#query_options ⇒ Object
87 88 89 |
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 87 def @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_db ⇒ Object
131 132 133 |
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 131 def select_db nil end |
#server_info ⇒ Object
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 |
#socket ⇒ Object
111 112 113 |
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 111 def socket nil end |
#ssl_set ⇒ Object
199 200 201 |
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 199 def ssl_set nil end |
#store_result ⇒ Object
143 144 145 |
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 143 def store_result nil end |
#thread_id ⇒ Object
127 128 129 |
# File 'lib/active_record/connection_adapters/hbase/client.rb', line 127 def thread_id nil end |
#warning_count ⇒ Object
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 |