diff options
author | Wouter Bolsterlee <uws@xs4all.nl> | 2012-07-10 00:41:34 +0200 |
---|---|---|
committer | Wouter Bolsterlee <uws@xs4all.nl> | 2012-07-10 00:41:34 +0200 |
commit | 6dcd4863bc106922da47c811e2fc351487f68166 (patch) | |
tree | 55e2ac92ebc02e2a708aa5a4a728bb8c003b5ae5 | |
parent | 0e7805a0ff8ca25a3eff357a360ca9161caae53b (diff) | |
download | happybase-6dcd4863bc106922da47c811e2fc351487f68166.tar.gz |
Initial support for framed Thrift transports
See issue #6.
Add initial support for TFramedTransport in addition to
TBufferedTransport. This means HappyBase can connect to the different
Thrift server implementations in HBase 0.94.x. This is required for the
nonblocking, threadedselector, and hsha implementation. The threadpool
implementation requires TBufferedTransport.
This change is not exposed in the API yet.
-rw-r--r-- | happybase/api.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/happybase/api.py b/happybase/api.py index 5236f3f..d256abb 100644 --- a/happybase/api.py +++ b/happybase/api.py @@ -12,7 +12,7 @@ from operator import attrgetter from struct import Struct from thrift.transport.TSocket import TSocket -from thrift.transport.TTransport import TBufferedTransport +from thrift.transport.TTransport import TBufferedTransport, TFramedTransport from thrift.protocol import TBinaryProtocol from .hbase import Hbase @@ -93,7 +93,12 @@ class Connection(object): self.table_prefix = table_prefix self.table_prefix_separator = table_prefix_separator - self.transport = TBufferedTransport(TSocket(self.host, self.port)) + socket = TSocket(self.host, self.port) + framed_transport = False # TODO: make parameter, add docs + if framed_transport: + self.transport = TFramedTransport(socket) + else: + self.transport = TBufferedTransport(socket) protocol = TBinaryProtocol.TBinaryProtocolAccelerated(self.transport) self.client = Hbase.Client(protocol) if autoconnect: |