-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTSasl.py
More file actions
25 lines (19 loc) · 686 Bytes
/
TSasl.py
File metadata and controls
25 lines (19 loc) · 686 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TCompactProtocol
from hbase import Hbase
import socket
# Initialize TSocket and TTransport
hostname = socket.gethostname()
t_socket = TSocket.TSocket(hostname, 9090)
transport=TTransport.TSaslClientTransport(t_socket,host=hostname,service='hbase',mechanism='GSSAPI')
# Initialize TCompactProtocol with TTransport
protocol = TCompactProtocol.TCompactProtocol(transport)
# Create HBase client
client = Hbase.Client(protocol)
# Open connection and retrieve list of HBase tables
transport.open()
tables = client.getTableNames()
print(tables)
# Close connection
transport.close()