Class: HBase::Client

Constant Summary

Constants included from Operation::RowOperation

Operation::RowOperation::Converter

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#list_tables

Constructor Details

#initialize(url = "http://localhost:60010/api", opts = {}) ⇒ Client

Returns a new instance of Client.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/hbase/client.rb', line 16

def initialize(url = "http://localhost:60010/api", opts = {})
  @url = URI.parse(url)
  unless @url.kind_of? URI::HTTP
    raise "invalid http url: #{url}"
  end

  unless @url.path =~ /^\/api/
    @url.path += (@url.path[-1] == '/' ? "api" : "/api")
  end

  # Not actually opening the connection yet, just setting up the persistent connection.
  @connection = Net::HTTP.new(@url.host, @url.port)
  @connection.read_timeout = opts[:timeout] if opts[:timeout]
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



14
15
16
# File 'lib/hbase/client.rb', line 14

def connection
  @connection
end

#urlObject (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) ⇒ Object



39
40
41
# File 'lib/hbase/client.rb', line 39

def delete(path)
  safe_request { @connection.delete(@url.path + path) }
end

#get(path) ⇒ Object



31
32
33
# File 'lib/hbase/client.rb', line 31

def get(path)
  safe_request { @connection.get(@url.path + path) }
end

#post(path, data = nil) ⇒ Object



35
36
37
# File 'lib/hbase/client.rb', line 35

def post(path, data = nil)
  safe_request { @connection.post(@url.path + path, data, {'Content-Type' => 'text/xml'}) }
end

#put(path, data = nil) ⇒ Object



43
44
45
# File 'lib/hbase/client.rb', line 43

def put(path, data = nil)
  safe_request { @connection.put(@url.path + path, data, {'Content-Type' => 'text/xml'}) }
end