ImpalaHiveServer2Service-remote 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 ' TStatus ResetCatalog()'
  24. print ''
  25. sys.exit(0)
  26. pp = pprint.PrettyPrinter(indent = 2)
  27. host = 'localhost'
  28. port = 9090
  29. uri = ''
  30. framed = False
  31. http = False
  32. argi = 1
  33. if sys.argv[argi] == '-h':
  34. parts = sys.argv[argi+1].split(':')
  35. host = parts[0]
  36. if len(parts) > 1:
  37. port = int(parts[1])
  38. argi += 2
  39. if sys.argv[argi] == '-u':
  40. url = urlparse(sys.argv[argi+1])
  41. parts = url[1].split(':')
  42. host = parts[0]
  43. if len(parts) > 1:
  44. port = int(parts[1])
  45. else:
  46. port = 80
  47. uri = url[2]
  48. if url[4]:
  49. uri += '?%s' % url[4]
  50. http = True
  51. argi += 2
  52. if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed':
  53. framed = True
  54. argi += 1
  55. cmd = sys.argv[argi]
  56. args = sys.argv[argi+1:]
  57. if http:
  58. transport = THttpClient.THttpClient(host, port, uri)
  59. else:
  60. socket = TSocket.TSocket(host, port)
  61. if framed:
  62. transport = TTransport.TFramedTransport(socket)
  63. else:
  64. transport = TTransport.TBufferedTransport(socket)
  65. protocol = TBinaryProtocol.TBinaryProtocol(transport)
  66. client = ImpalaHiveServer2Service.Client(protocol)
  67. transport.open()
  68. if cmd == 'ResetCatalog':
  69. if len(args) != 0:
  70. print 'ResetCatalog requires 0 args'
  71. sys.exit(1)
  72. pp.pprint(client.ResetCatalog())
  73. else:
  74. print 'Unrecognized method %s' % cmd
  75. sys.exit(1)
  76. transport.close()