def __init__(self): transport = TSocket.TSocket('localhost', 9090) transport = TTransport.TBufferedTransport(transport) protocol = TBinaryProtocol.TBinaryProtocol(transport) self.__client = Client(protocol) transport.open()
def make_connection(self): self.socket = TSocket.TSocket(self.config.hbase_host, self.config.hbase_port) self.socket.setTimeout(self.config.hbase_timeout) self.transport = TTransport.TBufferedTransport(self.socket) self.protocol = TBinaryProtocol.TBinaryProtocol(self.transport) self.client = Client(self.protocol) self.transport.open()
def __init__(self, ip='localhost', port=9090, timeout=10): transport = TSocket.TSocket(ip, int(port)) transport.setTimeout(timeout * 1000) transport = TTransport.TBufferedTransport(transport) protocol = TBinaryProtocol.TBinaryProtocol(transport) self.__client = Client(protocol) transport.open()
def demo_client(host, port, is_framed_transport): # Make socket socket = TSocket.TSocket(host, port) # Make transport if is_framed_transport: transport = TTransport.TFramedTransport(socket) else: transport = TTransport.TBufferedTransport(socket) # Wrap in a protocol protocol = TBinaryProtocol.TBinaryProtocol(transport) # Create a client to use the protocol encoder client = Client(protocol) # Connect! transport.open() # Check Thrift Server Type serverType = client.getThriftServerType() if serverType != TThriftServerType.ONE: raise Exception( "Mismatch between client and server, server type is %s" % serverType) t = "demo_table" # # Scan all tables, look for the demo table and delete it. # print "scanning tables..." for table in client.getTableNames(): print " found: %s" % (table) if table == t: if client.isTableEnabled(table): print " disabling table: %s" % (t) client.disableTable(table) print " deleting table: %s" % (t) client.deleteTable(table) columns = [] col = ColumnDescriptor() col.name = 'entry:' col.maxVersions = 10 columns.append(col) col = ColumnDescriptor() col.name = 'unused:' columns.append(col) try: print "creating table: %s" % (t) client.createTable(t, columns) except AlreadyExists, ae: print "WARN: " + ae.message
for k in sorted(entry.columns): print k + " => " + entry.columns[k].value, print # Make socket transport = TSocket.TSocket('localhost', 9090) # Buffering is critical. Raw sockets are very slow transport = TTransport.TBufferedTransport(transport) # Wrap in a protocol protocol = TBinaryProtocol.TBinaryProtocol(transport) # Create a client to use the protocol encoder client = Client(protocol) # Connect! transport.open() t = "demo_table" # # Scan all tables, look for the demo table and delete it. # print "scanning tables..." for table in client.getTableNames(): print " found: %s" % (table) if table == t: if client.isTableEnabled(table): print " disabling table: %s" % (t)