Class: MassiveRecord::Adapters::Thrift::Connection
- Inherits:
-
Object
- Object
- MassiveRecord::Adapters::Thrift::Connection
show all
- Defined in:
- lib/massive_record/adapters/thrift/connection.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(opts = {}) ⇒ Connection
Returns a new instance of Connection.
8
9
10
11
12
|
# File 'lib/massive_record/adapters/thrift/connection.rb', line 8
def initialize(opts = {})
@timeout = 4000
@host = opts[:host]
@port = opts[:port] || 9090
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
Wrapp HBase API to be able to catch errors and try reconnect
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/massive_record/adapters/thrift/connection.rb', line 54
def method_missing(method, *args)
begin
open if not @client
client.send(method, *args) if @client
rescue IOError
@client = nil
open
client.send(method, *args) if @client
rescue ::Thrift::TransportException
@transport = nil
@client = nil
open
client.send(method, *args) if @client
end
end
|
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
6
7
8
|
# File 'lib/massive_record/adapters/thrift/connection.rb', line 6
def host
@host
end
|
#port ⇒ Object
Returns the value of attribute port.
6
7
8
|
# File 'lib/massive_record/adapters/thrift/connection.rb', line 6
def port
@port
end
|
#timeout ⇒ Object
Returns the value of attribute timeout.
6
7
8
|
# File 'lib/massive_record/adapters/thrift/connection.rb', line 6
def timeout
@timeout
end
|
Instance Method Details
#client ⇒ Object
34
35
36
|
# File 'lib/massive_record/adapters/thrift/connection.rb', line 34
def client
@client
end
|
#close ⇒ Object
30
31
32
|
# File 'lib/massive_record/adapters/thrift/connection.rb', line 30
def close
@transport.close.nil?
end
|
#load_table(table_name) ⇒ Object
49
50
51
|
# File 'lib/massive_record/adapters/thrift/connection.rb', line 49
def load_table(table_name)
MassiveRecord::Wrapper::Table.new(self, table_name)
end
|
#open? ⇒ Boolean
38
39
40
|
# File 'lib/massive_record/adapters/thrift/connection.rb', line 38
def open?
@transport.try("open?")
end
|
#tables ⇒ Object
42
43
44
45
46
47
|
# File 'lib/massive_record/adapters/thrift/connection.rb', line 42
def tables
collection = MassiveRecord::Wrapper::TablesCollection.new
collection.connection = self
getTableNames().each{|table_name| collection.push(table_name)}
collection
end
|
#transport ⇒ Object
14
15
16
|
# File 'lib/massive_record/adapters/thrift/connection.rb', line 14
def transport
@transport ||= ::Thrift::BufferedTransport.new(::Thrift::Socket.new(@host, @port, @timeout))
end
|