ImpalaHiveServer2Service-remote 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #!/usr/bin/env python
  2. #
  3. # Autogenerated by Thrift Compiler (0.9.0)
  4. #
  5. # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  6. #
  7. # options string: py:new_style
  8. #
  9. import sys
  10. import pprint
  11. from urlparse import urlparse
  12. from thrift.transport import TTransport
  13. from thrift.transport import TSocket
  14. from thrift.transport import THttpClient
  15. from thrift.protocol import TBinaryProtocol
  16. import ImpalaHiveServer2Service
  17. from ttypes import *
  18. if len(sys.argv) <= 1 or sys.argv[1] == '--help':
  19. print ''
  20. print 'Usage: ' + sys.argv[0] + ' [-h host[:port]] [-u url] [-f[ramed]] function [arg1 [arg2...]]'
  21. print ''
  22. print 'Functions:'
  23. print ' TResetCatalogResp ResetCatalog()'
  24. print ' TResetTableResp ResetTable(TResetTableReq request)'
  25. print ''
  26. sys.exit(0)
  27. pp = pprint.PrettyPrinter(indent = 2)
  28. host = 'localhost'
  29. port = 9090
  30. uri = ''
  31. framed = False
  32. http = False
  33. argi = 1
  34. if sys.argv[argi] == '-h':
  35. parts = sys.argv[argi+1].split(':')
  36. host = parts[0]
  37. if len(parts) > 1:
  38. port = int(parts[1])
  39. argi += 2
  40. if sys.argv[argi] == '-u':
  41. url = urlparse(sys.argv[argi+1])
  42. parts = url[1].split(':')
  43. host = parts[0]
  44. if len(parts) > 1:
  45. port = int(parts[1])
  46. else:
  47. port = 80
  48. uri = url[2]
  49. if url[4]:
  50. uri += '?%s' % url[4]
  51. http = True
  52. argi += 2
  53. if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed':
  54. framed = True
  55. argi += 1
  56. cmd = sys.argv[argi]
  57. args = sys.argv[argi+1:]
  58. if http:
  59. transport = THttpClient.THttpClient(host, port, uri)
  60. else:
  61. socket = TSocket.TSocket(host, port)
  62. if framed:
  63. transport = TTransport.TFramedTransport(socket)
  64. else:
  65. transport = TTransport.TBufferedTransport(socket)
  66. protocol = TBinaryProtocol.TBinaryProtocol(transport)
  67. client = ImpalaHiveServer2Service.Client(protocol)
  68. transport.open()
  69. if cmd == 'ResetCatalog':
  70. if len(args) != 0:
  71. print 'ResetCatalog requires 0 args'
  72. sys.exit(1)
  73. pp.pprint(client.ResetCatalog())
  74. elif cmd == 'ResetTable':
  75. if len(args) != 1:
  76. print 'ResetTable requires 1 args'
  77. sys.exit(1)
  78. pp.pprint(client.ResetTable(eval(args[0]),))
  79. else:
  80. print 'Unrecognized method %s' % cmd
  81. sys.exit(1)
  82. transport.close()