Skip to content

Commit

Permalink
Initial support for framed Thrift transports
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wbolster committed Jul 9, 2012
1 parent 0e7805a commit 6dcd486
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions happybase/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
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
Expand Down Expand Up @@ -93,7 +93,12 @@ def __init__(self, host=DEFAULT_HOST, port=DEFAULT_PORT, autoconnect=True,
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:
Expand Down

0 comments on commit 6dcd486

Please sign in to comment.