Class: HBase::Client
- Inherits:
-
Object
- Object
- HBase::Client
- Includes:
- Operation::MetaOperation, Operation::RowOperation, Operation::ScannerOperation, Operation::TableOperation
- Defined in:
- lib/hbase/client.rb
Constant Summary
Constants included from Operation::RowOperation
Operation::RowOperation::Converter
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #delete(path, options = {}) ⇒ Object
- #delete_response(path, options = {}) ⇒ Object
- #get(path, options = {}) ⇒ Object
- #get_response(path, options = {}) ⇒ Object
-
#initialize(url = "http://localhost:8080", opts = {}) ⇒ Client
constructor
A new instance of Client.
- #post(path, data = nil, options = {}) ⇒ Object
- #post_response(path, data = nil, options = {}) ⇒ Object
- #put(path, data = nil, options = {}) ⇒ Object
- #put_response(path, data = nil, options = {}) ⇒ Object
Methods included from Operation::ScannerOperation
#close_scanner, #get_rows, #open_scanner
Methods included from Operation::RowOperation
#create_row, #delete_row, #row_timestamps, #show_row
Methods included from Operation::TableOperation
#alter_table, #create_table, #delete_table, #destroy_table, #disable_table, #enable_table, #show_table, #table_regions
Methods included from Operation::MetaOperation
#cluster_version, #list_tables, #version
Constructor Details
#initialize(url = "http://localhost:8080", opts = {}) ⇒ Client
Returns a new instance of Client.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/hbase/client.rb', line 16 def initialize(url = "http://localhost:8080", opts = {}) @url = URI.parse(url) unless @url.kind_of? URI::HTTP raise "invalid http url: #{url}" end # Not actually opening the connection yet, just setting up the persistent connection. if opts[:proxy] proxy_address, proxy_port = opts[:proxy].split(':') @connection = Net::HTTP.Proxy(proxy_address, proxy_port).new(@url.host, @url.port) else @connection = Net::HTTP.new(@url.host, @url.port) end @connection.read_timeout = opts[:timeout] if opts[:timeout] end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
14 15 16 |
# File 'lib/hbase/client.rb', line 14 def connection @connection end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
14 15 16 |
# File 'lib/hbase/client.rb', line 14 def url @url end |
Instance Method Details
#delete(path, options = {}) ⇒ Object
48 49 50 |
# File 'lib/hbase/client.rb', line 48 def delete(path, = {}) safe_request { @connection.delete(@url.path + path, ) } end |
#delete_response(path, options = {}) ⇒ Object
52 53 54 |
# File 'lib/hbase/client.rb', line 52 def delete_response(path, = {}) safe_response { @connection.delete(@url.path + path, ) } end |
#get(path, options = {}) ⇒ Object
32 33 34 |
# File 'lib/hbase/client.rb', line 32 def get(path, = {}) safe_request { @connection.get(@url.path + path, {"Accept" => "application/json"}.merge()) } end |
#get_response(path, options = {}) ⇒ Object
36 37 38 |
# File 'lib/hbase/client.rb', line 36 def get_response(path, = {}) safe_response { @connection.get(@url.path + path, {"Accept" => "application/json"}.merge()) } end |
#post(path, data = nil, options = {}) ⇒ Object
40 41 42 |
# File 'lib/hbase/client.rb', line 40 def post(path, data = nil, = {}) safe_request { @connection.post(@url.path + path, data, {'Content-Type' => 'text/xml'}.merge()) } end |
#post_response(path, data = nil, options = {}) ⇒ Object
44 45 46 |
# File 'lib/hbase/client.rb', line 44 def post_response(path, data = nil, = {}) safe_response { @connection.post(@url.path + path, data, {'Content-Type' => 'text/xml'}.merge()) } end |
#put(path, data = nil, options = {}) ⇒ Object
56 57 58 |
# File 'lib/hbase/client.rb', line 56 def put(path, data = nil, = {}) safe_request { @connection.put(@url.path + path, data, {'Content-Type' => 'text/xml'}.merge()) } end |
#put_response(path, data = nil, options = {}) ⇒ Object
60 61 62 |
# File 'lib/hbase/client.rb', line 60 def put_response(path, data = nil, = {}) safe_response { @connection.put(@url.path + path, data, {'Content-Type' => 'text/xml'}.merge()) } end |