HBASE-18291 Regenerate thrift2 python examples Change thrift python example to version 0.9.3 Update instructions in DemoClient.py
Change-Id: I5d2c2698c7f1c848b2c8bfaa761a6e1376811be3 Signed-off-by: tedyu <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/9b9fd708 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/9b9fd708 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/9b9fd708 Branch: refs/heads/branch-2 Commit: 9b9fd708b7267f00d1caf2e79fc8967b3ad0b5e4 Parents: 0f39f08 Author: Peter Somogyi <[email protected]> Authored: Mon Jul 3 15:10:58 2017 +0200 Committer: tedyu <[email protected]> Committed: Mon Jul 3 09:26:41 2017 -0700 ---------------------------------------------------------------------- .../src/main/python/thrift2/DemoClient.py | 4 +- .../thrift2/gen-py/hbase/THBaseService-remote | 127 +- .../thrift2/gen-py/hbase/THBaseService.py | 2869 +++++++++++++++--- .../python/thrift2/gen-py/hbase/constants.py | 2 +- .../main/python/thrift2/gen-py/hbase/ttypes.py | 1517 ++++++++- 5 files changed, 3916 insertions(+), 603 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/9b9fd708/hbase-examples/src/main/python/thrift2/DemoClient.py ---------------------------------------------------------------------- diff --git a/hbase-examples/src/main/python/thrift2/DemoClient.py b/hbase-examples/src/main/python/thrift2/DemoClient.py index c9811a6..63719f0 100644 --- a/hbase-examples/src/main/python/thrift2/DemoClient.py +++ b/hbase-examples/src/main/python/thrift2/DemoClient.py @@ -18,12 +18,12 @@ """ # Instructions: # 1. Run Thrift to generate the python module hbase -# thrift --gen py ../../../../../hbase-server/src/main/resources/org/apache/hadoop \ +# thrift --gen py ../../../../../hbase-thrift/src/main/resources/org/apache/hadoop \ # /hbase/thrift2/hbase.thrift # 2. Create a directory of your choosing that contains: # a. This file (DemoClient.py). # b. The directory gen-py/hbase (generated by instruction step 1). -# 3. pip install thrift==0.9.0 +# 3. pip install thrift==0.9.3 # 4. Create a table call "example", with a family called "family1" using the hbase shell. # 5. Start the hbase thrift2 server # bin/hbase thrift2 start http://git-wip-us.apache.org/repos/asf/hbase/blob/9b9fd708/hbase-examples/src/main/python/thrift2/gen-py/hbase/THBaseService-remote ---------------------------------------------------------------------- diff --git a/hbase-examples/src/main/python/thrift2/gen-py/hbase/THBaseService-remote b/hbase-examples/src/main/python/thrift2/gen-py/hbase/THBaseService-remote index 8d3eeb9..2b80916 100755 --- a/hbase-examples/src/main/python/thrift2/gen-py/hbase/THBaseService-remote +++ b/hbase-examples/src/main/python/thrift2/gen-py/hbase/THBaseService-remote @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Autogenerated by Thrift Compiler (0.9.0) +# Autogenerated by Thrift Compiler (0.9.3) # # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING # @@ -12,31 +12,39 @@ import pprint from urlparse import urlparse from thrift.transport import TTransport from thrift.transport import TSocket +from thrift.transport import TSSLSocket from thrift.transport import THttpClient from thrift.protocol import TBinaryProtocol -import THBaseService -from ttypes import * +from hbase import THBaseService +from hbase.ttypes import * if len(sys.argv) <= 1 or sys.argv[1] == '--help': - print '' - print 'Usage: ' + sys.argv[0] + ' [-h host[:port]] [-u url] [-f[ramed]] function [arg1 [arg2...]]' - print '' - print 'Functions:' - print ' bool exists(string table, TGet get)' - print ' TResult get(string table, TGet get)' - print ' getMultiple(string table, gets)' - print ' void put(string table, TPut put)' - print ' bool checkAndPut(string table, string row, string family, string qualifier, string value, TPut put)' - print ' void putMultiple(string table, puts)' - print ' void deleteSingle(string table, TDelete deleteSingle)' - print ' deleteMultiple(string table, deletes)' - print ' bool checkAndDelete(string table, string row, string family, string qualifier, string value, TDelete deleteSingle)' - print ' TResult increment(string table, TIncrement increment)' - print ' i32 openScanner(string table, TScan scan)' - print ' getScannerRows(i32 scannerId, i32 numRows)' - print ' void closeScanner(i32 scannerId)' - print '' + print('') + print('Usage: ' + sys.argv[0] + ' [-h host[:port]] [-u url] [-f[ramed]] [-s[sl]] function [arg1 [arg2...]]') + print('') + print('Functions:') + print(' bool exists(string table, TGet tget)') + print(' existsAll(string table, tgets)') + print(' TResult get(string table, TGet tget)') + print(' getMultiple(string table, tgets)') + print(' void put(string table, TPut tput)') + print(' bool checkAndPut(string table, string row, string family, string qualifier, string value, TPut tput)') + print(' void putMultiple(string table, tputs)') + print(' void deleteSingle(string table, TDelete tdelete)') + print(' deleteMultiple(string table, tdeletes)') + print(' bool checkAndDelete(string table, string row, string family, string qualifier, string value, TDelete tdelete)') + print(' TResult increment(string table, TIncrement tincrement)') + print(' TResult append(string table, TAppend tappend)') + print(' i32 openScanner(string table, TScan tscan)') + print(' getScannerRows(i32 scannerId, i32 numRows)') + print(' void closeScanner(i32 scannerId)') + print(' void mutateRow(string table, TRowMutations trowMutations)') + print(' getScannerResults(string table, TScan tscan, i32 numRows)') + print(' THRegionLocation getRegionLocation(string table, string row, bool reload)') + print(' getAllRegionLocations(string table)') + print(' bool checkAndMutate(string table, string row, string family, string qualifier, TCompareOp compareOp, string value, TRowMutations rowMutations)') + print('') sys.exit(0) pp = pprint.PrettyPrinter(indent = 2) @@ -44,6 +52,7 @@ host = 'localhost' port = 9090 uri = '' framed = False +ssl = False http = False argi = 1 @@ -72,13 +81,17 @@ if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed': framed = True argi += 1 +if sys.argv[argi] == '-s' or sys.argv[argi] == '-ssl': + ssl = True + argi += 1 + cmd = sys.argv[argi] args = sys.argv[argi+1:] if http: transport = THttpClient.THttpClient(host, port, uri) else: - socket = TSocket.TSocket(host, port) + socket = TSSLSocket.TSSLSocket(host, port, validate=False) if ssl else TSocket.TSocket(host, port) if framed: transport = TTransport.TFramedTransport(socket) else: @@ -89,84 +102,126 @@ transport.open() if cmd == 'exists': if len(args) != 2: - print 'exists requires 2 args' + print('exists requires 2 args') sys.exit(1) pp.pprint(client.exists(args[0],eval(args[1]),)) +elif cmd == 'existsAll': + if len(args) != 2: + print('existsAll requires 2 args') + sys.exit(1) + pp.pprint(client.existsAll(args[0],eval(args[1]),)) + elif cmd == 'get': if len(args) != 2: - print 'get requires 2 args' + print('get requires 2 args') sys.exit(1) pp.pprint(client.get(args[0],eval(args[1]),)) elif cmd == 'getMultiple': if len(args) != 2: - print 'getMultiple requires 2 args' + print('getMultiple requires 2 args') sys.exit(1) pp.pprint(client.getMultiple(args[0],eval(args[1]),)) elif cmd == 'put': if len(args) != 2: - print 'put requires 2 args' + print('put requires 2 args') sys.exit(1) pp.pprint(client.put(args[0],eval(args[1]),)) elif cmd == 'checkAndPut': if len(args) != 6: - print 'checkAndPut requires 6 args' + print('checkAndPut requires 6 args') sys.exit(1) pp.pprint(client.checkAndPut(args[0],args[1],args[2],args[3],args[4],eval(args[5]),)) elif cmd == 'putMultiple': if len(args) != 2: - print 'putMultiple requires 2 args' + print('putMultiple requires 2 args') sys.exit(1) pp.pprint(client.putMultiple(args[0],eval(args[1]),)) elif cmd == 'deleteSingle': if len(args) != 2: - print 'deleteSingle requires 2 args' + print('deleteSingle requires 2 args') sys.exit(1) pp.pprint(client.deleteSingle(args[0],eval(args[1]),)) elif cmd == 'deleteMultiple': if len(args) != 2: - print 'deleteMultiple requires 2 args' + print('deleteMultiple requires 2 args') sys.exit(1) pp.pprint(client.deleteMultiple(args[0],eval(args[1]),)) elif cmd == 'checkAndDelete': if len(args) != 6: - print 'checkAndDelete requires 6 args' + print('checkAndDelete requires 6 args') sys.exit(1) pp.pprint(client.checkAndDelete(args[0],args[1],args[2],args[3],args[4],eval(args[5]),)) elif cmd == 'increment': if len(args) != 2: - print 'increment requires 2 args' + print('increment requires 2 args') sys.exit(1) pp.pprint(client.increment(args[0],eval(args[1]),)) +elif cmd == 'append': + if len(args) != 2: + print('append requires 2 args') + sys.exit(1) + pp.pprint(client.append(args[0],eval(args[1]),)) + elif cmd == 'openScanner': if len(args) != 2: - print 'openScanner requires 2 args' + print('openScanner requires 2 args') sys.exit(1) pp.pprint(client.openScanner(args[0],eval(args[1]),)) elif cmd == 'getScannerRows': if len(args) != 2: - print 'getScannerRows requires 2 args' + print('getScannerRows requires 2 args') sys.exit(1) pp.pprint(client.getScannerRows(eval(args[0]),eval(args[1]),)) elif cmd == 'closeScanner': if len(args) != 1: - print 'closeScanner requires 1 args' + print('closeScanner requires 1 args') sys.exit(1) pp.pprint(client.closeScanner(eval(args[0]),)) +elif cmd == 'mutateRow': + if len(args) != 2: + print('mutateRow requires 2 args') + sys.exit(1) + pp.pprint(client.mutateRow(args[0],eval(args[1]),)) + +elif cmd == 'getScannerResults': + if len(args) != 3: + print('getScannerResults requires 3 args') + sys.exit(1) + pp.pprint(client.getScannerResults(args[0],eval(args[1]),eval(args[2]),)) + +elif cmd == 'getRegionLocation': + if len(args) != 3: + print('getRegionLocation requires 3 args') + sys.exit(1) + pp.pprint(client.getRegionLocation(args[0],args[1],eval(args[2]),)) + +elif cmd == 'getAllRegionLocations': + if len(args) != 1: + print('getAllRegionLocations requires 1 args') + sys.exit(1) + pp.pprint(client.getAllRegionLocations(args[0],)) + +elif cmd == 'checkAndMutate': + if len(args) != 7: + print('checkAndMutate requires 7 args') + sys.exit(1) + pp.pprint(client.checkAndMutate(args[0],args[1],args[2],args[3],eval(args[4]),args[5],eval(args[6]),)) + else: - print 'Unrecognized method %s' % cmd + print('Unrecognized method %s' % cmd) sys.exit(1) transport.close()
