浏览代码

Merge branch 'HUE-219'

Aaron T. Myers 16 年之前
父节点
当前提交
74eac4370b
共有 100 个文件被更改,包括 9120 次插入2409 次删除
  1. 3 3
      Makefile
  2. 2 0
      README.rst
  3. 1 1
      apps/beeswax/beeswax_server.sh
  4. 8 2
      apps/beeswax/gen-py/beeswaxd/BeeswaxService-remote
  5. 77 25
      apps/beeswax/gen-py/beeswaxd/BeeswaxService.py
  6. 43 39
      apps/beeswax/gen-py/beeswaxd/ttypes.py
  7. 8 2
      apps/beeswax/gen-py/fb303/FacebookService-remote
  8. 82 12
      apps/beeswax/gen-py/fb303/FacebookService.py
  9. 1 1
      apps/beeswax/gen-py/fb303/ttypes.py
  10. 8 2
      apps/beeswax/gen-py/hive_metastore/ThriftHiveMetastore-remote
  11. 139 3
      apps/beeswax/gen-py/hive_metastore/ThriftHiveMetastore.py
  12. 0 13
      apps/beeswax/gen-py/hive_metastore/constants.py
  13. 62 2
      apps/beeswax/gen-py/hive_metastore/ttypes.py
  14. 二进制
      apps/beeswax/hive/lib/commons-cli-1.2.jar
  15. 二进制
      apps/beeswax/hive/lib/commons-codec-1.4.jar
  16. 二进制
      apps/beeswax/hive/lib/hive-cli-0.5.0.jar
  17. 二进制
      apps/beeswax/hive/lib/hive-common-0.5.0.jar
  18. 二进制
      apps/beeswax/hive/lib/hive-default-xml-0.5.0.jar
  19. 二进制
      apps/beeswax/hive/lib/hive-exec-0.5.0.jar
  20. 二进制
      apps/beeswax/hive/lib/hive-jdbc-0.5.0.jar
  21. 二进制
      apps/beeswax/hive/lib/hive-metastore-0.5.0.jar
  22. 二进制
      apps/beeswax/hive/lib/hive-serde-0.5.0.jar
  23. 二进制
      apps/beeswax/hive/lib/hive-service-0.5.0.jar
  24. 二进制
      apps/beeswax/hive/lib/hive-shims-0.5.0.jar
  25. 二进制
      apps/beeswax/hive/lib/hive_contrib.jar
  26. 二进制
      apps/beeswax/hive/lib/junit-4.5.jar
  27. 二进制
      apps/beeswax/hive/lib/libfb303.jar
  28. 二进制
      apps/beeswax/hive/lib/libthrift.jar
  29. 二进制
      apps/beeswax/hive/lib/slf4j-api-1.6.1.jar
  30. 二进制
      apps/beeswax/hive/lib/slf4j-log4j12-1.6.1.jar
  31. 162 44
      apps/beeswax/java/gen-java/com/cloudera/beeswax/api/BeeswaxException.java
  32. 601 64
      apps/beeswax/java/gen-java/com/cloudera/beeswax/api/BeeswaxService.java
  33. 161 43
      apps/beeswax/java/gen-java/com/cloudera/beeswax/api/ConfigVariable.java
  34. 0 313
      apps/beeswax/java/gen-java/com/cloudera/beeswax/api/FileResource.java
  35. 0 31
      apps/beeswax/java/gen-java/com/cloudera/beeswax/api/FileResourceType.java
  36. 0 307
      apps/beeswax/java/gen-java/com/cloudera/beeswax/api/Function.java
  37. 165 162
      apps/beeswax/java/gen-java/com/cloudera/beeswax/api/Query.java
  38. 122 32
      apps/beeswax/java/gen-java/com/cloudera/beeswax/api/QueryExplanation.java
  39. 142 38
      apps/beeswax/java/gen-java/com/cloudera/beeswax/api/QueryHandle.java
  40. 103 24
      apps/beeswax/java/gen-java/com/cloudera/beeswax/api/QueryNotFoundException.java
  41. 42 26
      apps/beeswax/java/gen-java/com/cloudera/beeswax/api/QueryState.java
  42. 0 31
      apps/beeswax/java/gen-java/com/cloudera/beeswax/api/QueryType.java
  43. 244 93
      apps/beeswax/java/gen-java/com/cloudera/beeswax/api/Results.java
  44. 192 48
      apps/beeswax/java/gen-java/com/cloudera/beeswax/api/ResultsMetadata.java
  45. 0 307
      apps/beeswax/java/gen-java/com/cloudera/beeswax/api/Setting.java
  46. 0 399
      apps/beeswax/java/gen-java/com/cloudera/beeswax/api/WrongQueryTypeException.java
  47. 117 55
      apps/beeswax/java/src/com/cloudera/beeswax/BeeswaxServiceImpl.java
  48. 4 2
      apps/beeswax/java/src/com/cloudera/beeswax/Server.java
  49. 46 0
      apps/beeswax/regenerate_thrift.sh
  50. 0 2
      apps/beeswax/src/beeswax/management/commands/beeswax_install_examples.py
  51. 2 1
      apps/beeswax/src/beeswax/management/commands/beeswax_server.py
  52. 5 2
      apps/beeswax/src/beeswax/test_base.py
  53. 7 2
      apps/beeswax/src/beeswax/tests.py
  54. 2 3
      apps/beeswax/src/beeswax/views.py
  55. 0 1
      apps/beeswax/thrift/beeswax.thrift
  56. 1 0
      apps/filebrowser/src/filebrowser/views.py
  57. 0 1
      apps/filebrowser/src/filebrowser/views_test.py
  58. 1 1
      apps/jobbrowser/src/jobbrowser/models.py
  59. 18 18
      apps/jobbrowser/src/jobbrowser/tests.py
  60. 8 2
      apps/jobsub/gen-py/jobsubd/JobSubmissionService-remote
  61. 15 18
      apps/jobsub/gen-py/jobsubd/JobSubmissionService.py
  62. 1 16
      apps/jobsub/gen-py/jobsubd/__init__.py
  63. 2 16
      apps/jobsub/gen-py/jobsubd/constants.py
  64. 33 23
      apps/jobsub/gen-py/jobsubd/ttypes.py
  65. 4 0
      apps/jobsub/regenerate_thrift.sh
  66. 1 1
      apps/jobsub/src/jobsub/java/build.xml
  67. 2 2
      apps/jobsub/src/jobsub/java/src/META-INF/aop-ajc.xml
  68. 0 35
      apps/jobsub/src/jobsub/java/src/com/cloudera/jobsub/JobClientTrace.aj
  69. 0 59
      apps/jobsub/src/jobsub/java/src/com/cloudera/jobsub/UgiFixer.aj
  70. 60 0
      apps/jobsub/src/jobsub/java/src/org/apache/hadoop/security/JobClientTrace.aj
  71. 2 2
      apps/jobsub/src/jobsub/java/src/org/apache/hadoop/security/JobClientTracer.java
  72. 97 0
      apps/jobsub/src/jobsub/java/src/org/apache/hadoop/security/UgiFixer.aj
  73. 9 5
      apps/jobsub/src/jobsub/management/commands/jobsub_setup.py
  74. 22 2
      apps/jobsub/src/jobsub/server.py
  75. 7 4
      apps/jobsub/src/jobsub/tests.py
  76. 1 0
      desktop/core/ext-py/sasl-0.1.1/MANIFEST.in
  77. 10 0
      desktop/core/ext-py/sasl-0.1.1/PKG-INFO
  78. 1 0
      desktop/core/ext-py/sasl-0.1.1/sasl/__init__.py
  79. 383 0
      desktop/core/ext-py/sasl-0.1.1/sasl/saslwrapper.cpp
  80. 146 0
      desktop/core/ext-py/sasl-0.1.1/sasl/saslwrapper.h
  81. 103 0
      desktop/core/ext-py/sasl-0.1.1/sasl/saslwrapper.py
  82. 5068 0
      desktop/core/ext-py/sasl-0.1.1/sasl/saslwrapper_wrap.cxx
  83. 5 0
      desktop/core/ext-py/sasl-0.1.1/setup.cfg
  84. 25 0
      desktop/core/ext-py/sasl-0.1.1/setup.py
  85. 4 0
      desktop/core/regenerate_thrift.sh
  86. 3 1
      desktop/core/setup.py
  87. 53 0
      desktop/core/src/desktop/conf.py
  88. 49 0
      desktop/core/src/desktop/kt_renewer.py
  89. 8 2
      desktop/core/src/desktop/lib/gen-py/djangothrift_test_gen/TestService-remote
  90. 7 3
      desktop/core/src/desktop/lib/gen-py/djangothrift_test_gen/TestService.py
  91. 11 2
      desktop/core/src/desktop/lib/gen-py/djangothrift_test_gen/ttypes.py
  92. 156 0
      desktop/core/src/desktop/lib/thrift_sasl.py
  93. 90 33
      desktop/core/src/desktop/lib/thrift_util.py
  94. 8 10
      desktop/core/src/desktop/management/commands/kt_renewer.py
  95. 2 2
      desktop/core/src/desktop/middleware.py
  96. 4 0
      desktop/core/src/desktop/settings.py
  97. 18 2
      desktop/libs/hadoop/Makefile
  98. 8 2
      desktop/libs/hadoop/gen-py/hadoop/api/common/HadoopServiceBase-remote
  99. 33 5
      desktop/libs/hadoop/gen-py/hadoop/api/common/HadoopServiceBase.py
  100. 90 7
      desktop/libs/hadoop/gen-py/hadoop/api/common/ttypes.py

+ 3 - 3
Makefile

@@ -131,9 +131,9 @@ docs:
 
 .PHONY: crepo
 crepo: $(THIRDPARTY_JS_DIR)/manifest.json $(THIRDPARTY_JS_DIR)/*.hash
-	@echo "--- Synchronizing external dependencies with crepo"
-	@mkdir -p $(BLD_DIR)
-	@cd $(THIRDPARTY_JS_DIR) && $(CREPO) sync && \
+#	@echo "--- Synchronizing external dependencies with crepo"
+#	@mkdir -p $(BLD_DIR)
+#	@cd $(THIRDPARTY_JS_DIR) && $(CREPO) sync && \
 	  ($(CREPO) dump-refs > $(ROOT)/VERSION_DATA || true)
 # END DEV ONLY >>>>
 

+ 2 - 0
README.rst

@@ -62,6 +62,7 @@ Development Prerequisites
     Debian:
       * gcc
       * libmysqlclient-dev
+      * libsasl2-dev
       * libsqlite3-dev
       * libxml2-dev
       * libxslt-dev
@@ -69,6 +70,7 @@ Development Prerequisites
       * python-setuptools
 
     CentOS:
+      * cyrus-sasl-devel
       * gcc
       * libxml2-devel
       * libxslt-devel

+ 1 - 1
apps/beeswax/beeswax_server.sh

@@ -36,7 +36,7 @@ BEESWAX_HIVE_LIB=$BEESWAX_ROOT/hive/lib
 
 echo \$HADOOP_HOME=$HADOOP_HOME
 
-export HADOOP_CLASSPATH=$(find $BEESWAX_HIVE_LIB -name "*.jar" | tr "\n" :):$HIVE_CONF_DIR
+export HADOOP_CLASSPATH=$(find $BEESWAX_HIVE_LIB -name "*.jar" | tr "\n" :):$HIVE_CONF_DIR:$BEESWAX_ROOT/../../desktop/libs/hadoop/static-group-mapping/java-lib/static-group-mapping-1.0.jar
 echo \$HADOOP_CLASSPATH=$HADOOP_CLASSPATH
 
 # Use HADOOP_CONF_DIR to preprend to classpath, to avoid fb303 conflict,

+ 8 - 2
apps/beeswax/gen-py/beeswaxd/BeeswaxService-remote

@@ -42,20 +42,22 @@ http = False
 argi = 1
 
 if sys.argv[argi] == '-h':
-  parts = sys.argv[argi+1].split(':') 
+  parts = sys.argv[argi+1].split(':')
   host = parts[0]
   port = int(parts[1])
   argi += 2
 
 if sys.argv[argi] == '-u':
   url = urlparse(sys.argv[argi+1])
-  parts = url[1].split(':') 
+  parts = url[1].split(':')
   host = parts[0]
   if len(parts) > 1:
     port = int(parts[1])
   else:
     port = 80
   uri = url[2]
+  if url[4]:
+    uri += '?%s' % url[4]
   http = True
   argi += 2
 
@@ -132,4 +134,8 @@ elif cmd == 'get_default_configuration':
     sys.exit(1)
   pp.pprint(client.get_default_configuration(eval(args[0]),))
 
+else:
+  print 'Unrecognized method %s' % cmd
+  sys.exit(1)
+
 transport.close()

+ 77 - 25
apps/beeswax/gen-py/beeswaxd/BeeswaxService.py

@@ -8,18 +8,18 @@ from thrift.Thrift import *
 from ttypes import *
 from thrift.Thrift import TProcessor
 from thrift.transport import TTransport
-from thrift.protocol import TBinaryProtocol
+from thrift.protocol import TBinaryProtocol, TProtocol
 try:
   from thrift.protocol import fastbinary
 except:
   fastbinary = None
 
 
-class Iface:
+class Iface(object):
   def query(self, query):
     """
     Submit a query and return a handle (QueryHandle). The query runs asynchronously.
-    
+
     Parameters:
      - query
     """
@@ -28,7 +28,7 @@ class Iface:
   def explain(self, query):
     """
     Get the query plan for a query.
-    
+
     Parameters:
      - query
     """
@@ -38,7 +38,7 @@ class Iface:
     """
     Get the results of a query. This is non-blocking. Caller should check
     Results.ready to determine if the results are in yet.
-    
+
     Parameters:
      - query_id
      - start_over
@@ -48,7 +48,7 @@ class Iface:
   def get_state(self, handle):
     """
     Get the state of the query
-    
+
     Parameters:
      - handle
     """
@@ -57,7 +57,7 @@ class Iface:
   def get_results_metadata(self, handle):
     """
     Get the result metadata
-    
+
     Parameters:
      - handle
     """
@@ -66,7 +66,7 @@ class Iface:
   def echo(self, s):
     """
     Used to test connection to server.  A "noop" command.
-    
+
     Parameters:
      - s
     """
@@ -82,7 +82,7 @@ class Iface:
   def get_log(self, context):
     """
     Get the log messages related to the given context.
-    
+
     Parameters:
      - context
     """
@@ -106,7 +106,7 @@ class Client(Iface):
   def query(self, query):
     """
     Submit a query and return a handle (QueryHandle). The query runs asynchronously.
-    
+
     Parameters:
      - query
     """
@@ -140,7 +140,7 @@ class Client(Iface):
   def explain(self, query):
     """
     Get the query plan for a query.
-    
+
     Parameters:
      - query
     """
@@ -175,7 +175,7 @@ class Client(Iface):
     """
     Get the results of a query. This is non-blocking. Caller should check
     Results.ready to determine if the results are in yet.
-    
+
     Parameters:
      - query_id
      - start_over
@@ -213,7 +213,7 @@ class Client(Iface):
   def get_state(self, handle):
     """
     Get the state of the query
-    
+
     Parameters:
      - handle
     """
@@ -247,7 +247,7 @@ class Client(Iface):
   def get_results_metadata(self, handle):
     """
     Get the result metadata
-    
+
     Parameters:
      - handle
     """
@@ -281,7 +281,7 @@ class Client(Iface):
   def echo(self, s):
     """
     Used to test connection to server.  A "noop" command.
-    
+
     Parameters:
      - s
     """
@@ -342,7 +342,7 @@ class Client(Iface):
   def get_log(self, context):
     """
     Get the log messages related to the given context.
-    
+
     Parameters:
      - context
     """
@@ -600,6 +600,9 @@ class query_args(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -669,6 +672,9 @@ class query_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -726,6 +732,9 @@ class explain_args(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -795,6 +804,9 @@ class explain_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -864,6 +876,9 @@ class fetch_args(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -946,6 +961,9 @@ class fetch_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -1003,6 +1021,9 @@ class get_state_args(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -1071,6 +1092,9 @@ class get_state_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -1128,6 +1152,9 @@ class get_results_metadata_args(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -1197,6 +1224,9 @@ class get_results_metadata_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -1253,6 +1283,9 @@ class echo_args(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -1308,6 +1341,9 @@ class echo_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -1346,6 +1382,9 @@ class dump_config_args(object):
     oprot.writeStructBegin('dump_config_args')
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -1401,6 +1440,9 @@ class dump_config_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -1457,6 +1499,9 @@ class get_log_args(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -1525,6 +1570,9 @@ class get_log_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -1581,6 +1629,9 @@ class get_default_configuration_args(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -1618,11 +1669,11 @@ class get_default_configuration_result(object):
       if fid == 0:
         if ftype == TType.LIST:
           self.success = []
-          (_etype31, _size28) = iprot.readListBegin()
-          for _i32 in xrange(_size28):
-            _elem33 = ConfigVariable()
-            _elem33.read(iprot)
-            self.success.append(_elem33)
+          (_etype24, _size21) = iprot.readListBegin()
+          for _i25 in xrange(_size21):
+            _elem26 = ConfigVariable()
+            _elem26.read(iprot)
+            self.success.append(_elem26)
           iprot.readListEnd()
         else:
           iprot.skip(ftype)
@@ -1639,12 +1690,15 @@ class get_default_configuration_result(object):
     if self.success != None:
       oprot.writeFieldBegin('success', TType.LIST, 0)
       oprot.writeListBegin(TType.STRUCT, len(self.success))
-      for iter34 in self.success:
-        iter34.write(oprot)
+      for iter27 in self.success:
+        iter27.write(oprot)
       oprot.writeListEnd()
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -1656,5 +1710,3 @@ class get_default_configuration_result(object):
 
   def __ne__(self, other):
     return not (self == other)
-
-

+ 43 - 39
apps/beeswax/gen-py/beeswaxd/ttypes.py

@@ -9,7 +9,7 @@ import hive_metastore.ttypes
 
 
 from thrift.transport import TTransport
-from thrift.protocol import TBinaryProtocol
+from thrift.protocol import TBinaryProtocol, TProtocol
 try:
   from thrift.protocol import fastbinary
 except:
@@ -42,13 +42,13 @@ class QueryState(object):
     "EXCEPTION": 5,
   }
 
+
 class Query(object):
   """
   Attributes:
    - query
    - configuration
    - hadoop_user
-   - hadoop_groups
   """
 
   thrift_spec = (
@@ -57,14 +57,12 @@ class Query(object):
     None, # 2
     (3, TType.LIST, 'configuration', (TType.STRING,None), None, ), # 3
     (4, TType.STRING, 'hadoop_user', None, None, ), # 4
-    (5, TType.LIST, 'hadoop_groups', (TType.STRING,None), None, ), # 5
   )
 
-  def __init__(self, query=None, configuration=None, hadoop_user=None, hadoop_groups=None,):
+  def __init__(self, query=None, configuration=None, hadoop_user=None,):
     self.query = query
     self.configuration = configuration
     self.hadoop_user = hadoop_user
-    self.hadoop_groups = hadoop_groups
 
   def read(self, iprot):
     if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
@@ -95,16 +93,6 @@ class Query(object):
           self.hadoop_user = iprot.readString();
         else:
           iprot.skip(ftype)
-      elif fid == 5:
-        if ftype == TType.LIST:
-          self.hadoop_groups = []
-          (_etype9, _size6) = iprot.readListBegin()
-          for _i10 in xrange(_size6):
-            _elem11 = iprot.readString();
-            self.hadoop_groups.append(_elem11)
-          iprot.readListEnd()
-        else:
-          iprot.skip(ftype)
       else:
         iprot.skip(ftype)
       iprot.readFieldEnd()
@@ -122,23 +110,19 @@ class Query(object):
     if self.configuration != None:
       oprot.writeFieldBegin('configuration', TType.LIST, 3)
       oprot.writeListBegin(TType.STRING, len(self.configuration))
-      for iter12 in self.configuration:
-        oprot.writeString(iter12)
+      for iter6 in self.configuration:
+        oprot.writeString(iter6)
       oprot.writeListEnd()
       oprot.writeFieldEnd()
     if self.hadoop_user != None:
       oprot.writeFieldBegin('hadoop_user', TType.STRING, 4)
       oprot.writeString(self.hadoop_user)
       oprot.writeFieldEnd()
-    if self.hadoop_groups != None:
-      oprot.writeFieldBegin('hadoop_groups', TType.LIST, 5)
-      oprot.writeListBegin(TType.STRING, len(self.hadoop_groups))
-      for iter13 in self.hadoop_groups:
-        oprot.writeString(iter13)
-      oprot.writeListEnd()
-      oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -207,6 +191,9 @@ class QueryHandle(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -263,6 +250,9 @@ class QueryExplanation(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -318,20 +308,20 @@ class Results(object):
       elif fid == 2:
         if ftype == TType.LIST:
           self.columns = []
-          (_etype17, _size14) = iprot.readListBegin()
-          for _i18 in xrange(_size14):
-            _elem19 = iprot.readString();
-            self.columns.append(_elem19)
+          (_etype10, _size7) = iprot.readListBegin()
+          for _i11 in xrange(_size7):
+            _elem12 = iprot.readString();
+            self.columns.append(_elem12)
           iprot.readListEnd()
         else:
           iprot.skip(ftype)
       elif fid == 3:
         if ftype == TType.LIST:
           self.data = []
-          (_etype23, _size20) = iprot.readListBegin()
-          for _i24 in xrange(_size20):
-            _elem25 = iprot.readString();
-            self.data.append(_elem25)
+          (_etype16, _size13) = iprot.readListBegin()
+          for _i17 in xrange(_size13):
+            _elem18 = iprot.readString();
+            self.data.append(_elem18)
           iprot.readListEnd()
         else:
           iprot.skip(ftype)
@@ -362,15 +352,15 @@ class Results(object):
     if self.columns != None:
       oprot.writeFieldBegin('columns', TType.LIST, 2)
       oprot.writeListBegin(TType.STRING, len(self.columns))
-      for iter26 in self.columns:
-        oprot.writeString(iter26)
+      for iter19 in self.columns:
+        oprot.writeString(iter19)
       oprot.writeListEnd()
       oprot.writeFieldEnd()
     if self.data != None:
       oprot.writeFieldBegin('data', TType.LIST, 3)
       oprot.writeListBegin(TType.STRING, len(self.data))
-      for iter27 in self.data:
-        oprot.writeString(iter27)
+      for iter20 in self.data:
+        oprot.writeString(iter20)
       oprot.writeListEnd()
       oprot.writeFieldEnd()
     if self.start_row != None:
@@ -383,6 +373,9 @@ class Results(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -399,7 +392,7 @@ class ResultsMetadata(object):
   """
   Metadata information about the results.
   Applicable only for SELECT.
-  
+
   Attributes:
    - schema: The schema of the results
    - table_dir: The directory containing the results. Not applicable for partition table.
@@ -479,6 +472,9 @@ class ResultsMetadata(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -560,6 +556,9 @@ class BeeswaxException(Exception):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __str__(self):
     return repr(self)
@@ -601,6 +600,9 @@ class QueryNotFoundException(Exception):
     oprot.writeStructBegin('QueryNotFoundException')
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __str__(self):
     return repr(self)
@@ -619,7 +621,7 @@ class QueryNotFoundException(Exception):
 class ConfigVariable(object):
   """
   Represents a Hadoop-style configuration variable.
-  
+
   Attributes:
    - key
    - value
@@ -686,6 +688,9 @@ class ConfigVariable(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -697,4 +702,3 @@ class ConfigVariable(object):
 
   def __ne__(self, other):
     return not (self == other)
-

+ 8 - 2
apps/beeswax/gen-py/fb303/FacebookService-remote

@@ -46,20 +46,22 @@ http = False
 argi = 1
 
 if sys.argv[argi] == '-h':
-  parts = sys.argv[argi+1].split(':') 
+  parts = sys.argv[argi+1].split(':')
   host = parts[0]
   port = int(parts[1])
   argi += 2
 
 if sys.argv[argi] == '-u':
   url = urlparse(sys.argv[argi+1])
-  parts = url[1].split(':') 
+  parts = url[1].split(':')
   host = parts[0]
   if len(parts) > 1:
     port = int(parts[1])
   else:
     port = 80
   uri = url[2]
+  if url[4]:
+    uri += '?%s' % url[4]
   http = True
   argi += 2
 
@@ -160,4 +162,8 @@ elif cmd == 'shutdown':
     sys.exit(1)
   pp.pprint(client.shutdown())
 
+else:
+  print 'Unrecognized method %s' % cmd
+  sys.exit(1)
+
 transport.close()

+ 82 - 12
apps/beeswax/gen-py/fb303/FacebookService.py

@@ -8,14 +8,14 @@ from thrift.Thrift import *
 from ttypes import *
 from thrift.Thrift import TProcessor
 from thrift.transport import TTransport
-from thrift.protocol import TBinaryProtocol
+from thrift.protocol import TBinaryProtocol, TProtocol
 try:
   from thrift.protocol import fastbinary
 except:
   fastbinary = None
 
 
-class Iface:
+class Iface(object):
   """
   Standard base service
   """
@@ -53,7 +53,7 @@ class Iface:
   def getCounter(self, key):
     """
     Gets the value of a single counter
-    
+
     Parameters:
      - key
     """
@@ -62,7 +62,7 @@ class Iface:
   def setOption(self, key, value):
     """
     Sets an option
-    
+
     Parameters:
      - key
      - value
@@ -72,7 +72,7 @@ class Iface:
   def getOption(self, key):
     """
     Gets an option
-    
+
     Parameters:
      - key
     """
@@ -88,7 +88,7 @@ class Iface:
     """
     Returns a CPU profile over the given time interval (client and server
     must agree on the profile format).
-    
+
     Parameters:
      - profileDurationInSec
     """
@@ -267,7 +267,7 @@ class Client(Iface):
   def getCounter(self, key):
     """
     Gets the value of a single counter
-    
+
     Parameters:
      - key
     """
@@ -299,7 +299,7 @@ class Client(Iface):
   def setOption(self, key, value):
     """
     Sets an option
-    
+
     Parameters:
      - key
      - value
@@ -331,7 +331,7 @@ class Client(Iface):
   def getOption(self, key):
     """
     Gets an option
-    
+
     Parameters:
      - key
     """
@@ -392,7 +392,7 @@ class Client(Iface):
     """
     Returns a CPU profile over the given time interval (client and server
     must agree on the profile format).
-    
+
     Parameters:
      - profileDurationInSec
     """
@@ -671,6 +671,9 @@ class getName_args(object):
     oprot.writeStructBegin('getName_args')
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -726,6 +729,9 @@ class getName_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -764,6 +770,9 @@ class getVersion_args(object):
     oprot.writeStructBegin('getVersion_args')
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -819,6 +828,9 @@ class getVersion_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -857,6 +869,9 @@ class getStatus_args(object):
     oprot.writeStructBegin('getStatus_args')
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -912,6 +927,9 @@ class getStatus_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -950,6 +968,9 @@ class getStatusDetails_args(object):
     oprot.writeStructBegin('getStatusDetails_args')
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -1005,6 +1026,9 @@ class getStatusDetails_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -1043,6 +1067,9 @@ class getCounters_args(object):
     oprot.writeStructBegin('getCounters_args')
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -1108,6 +1135,9 @@ class getCounters_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -1164,6 +1194,9 @@ class getCounter_args(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -1219,6 +1252,9 @@ class getCounter_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -1287,6 +1323,9 @@ class setOption_args(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -1325,6 +1364,9 @@ class setOption_result(object):
     oprot.writeStructBegin('setOption_result')
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -1381,6 +1423,9 @@ class getOption_args(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -1436,6 +1481,9 @@ class getOption_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -1474,6 +1522,9 @@ class getOptions_args(object):
     oprot.writeStructBegin('getOptions_args')
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -1539,6 +1590,9 @@ class getOptions_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -1595,6 +1649,9 @@ class getCpuProfile_args(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -1650,6 +1707,9 @@ class getCpuProfile_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -1688,6 +1748,9 @@ class aliveSince_args(object):
     oprot.writeStructBegin('aliveSince_args')
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -1743,6 +1806,9 @@ class aliveSince_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -1781,6 +1847,9 @@ class reinitialize_args(object):
     oprot.writeStructBegin('reinitialize_args')
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -1819,6 +1888,9 @@ class shutdown_args(object):
     oprot.writeStructBegin('shutdown_args')
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -1830,5 +1902,3 @@ class shutdown_args(object):
 
   def __ne__(self, other):
     return not (self == other)
-
-

+ 1 - 1
apps/beeswax/gen-py/fb303/ttypes.py

@@ -7,7 +7,7 @@
 from thrift.Thrift import *
 
 from thrift.transport import TTransport
-from thrift.protocol import TBinaryProtocol
+from thrift.protocol import TBinaryProtocol, TProtocol
 try:
   from thrift.protocol import fastbinary
 except:

+ 8 - 2
apps/beeswax/gen-py/hive_metastore/ThriftHiveMetastore-remote

@@ -56,20 +56,22 @@ http = False
 argi = 1
 
 if sys.argv[argi] == '-h':
-  parts = sys.argv[argi+1].split(':') 
+  parts = sys.argv[argi+1].split(':')
   host = parts[0]
   port = int(parts[1])
   argi += 2
 
 if sys.argv[argi] == '-u':
   url = urlparse(sys.argv[argi+1])
-  parts = url[1].split(':') 
+  parts = url[1].split(':')
   host = parts[0]
   if len(parts) > 1:
     port = int(parts[1])
   else:
     port = 80
   uri = url[2]
+  if url[4]:
+    uri += '?%s' % url[4]
   http = True
   argi += 2
 
@@ -230,4 +232,8 @@ elif cmd == 'get_config_value':
     sys.exit(1)
   pp.pprint(client.get_config_value(args[0],args[1],))
 
+else:
+  print 'Unrecognized method %s' % cmd
+  sys.exit(1)
+
 transport.close()

+ 139 - 3
apps/beeswax/gen-py/hive_metastore/ThriftHiveMetastore.py

@@ -9,7 +9,7 @@ import fb303.FacebookService
 from ttypes import *
 from thrift.Thrift import TProcessor
 from thrift.transport import TTransport
-from thrift.protocol import TBinaryProtocol
+from thrift.protocol import TBinaryProtocol, TProtocol
 try:
   from thrift.protocol import fastbinary
 except:
@@ -1485,6 +1485,9 @@ class create_database_args(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -1566,6 +1569,9 @@ class create_database_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -1622,6 +1628,9 @@ class get_database_args(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -1704,6 +1713,9 @@ class get_database_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -1760,6 +1772,9 @@ class drop_database_args(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -1829,6 +1844,9 @@ class drop_database_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -1867,6 +1885,9 @@ class get_databases_args(object):
     oprot.writeStructBegin('get_databases_args')
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -1943,6 +1964,9 @@ class get_databases_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -1999,6 +2023,9 @@ class get_type_args(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -2068,6 +2095,9 @@ class get_type_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -2125,6 +2155,9 @@ class create_type_args(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -2219,6 +2252,9 @@ class create_type_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -2275,6 +2311,9 @@ class drop_type_args(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -2343,6 +2382,9 @@ class drop_type_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -2399,6 +2441,9 @@ class get_type_all_args(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -2478,6 +2523,9 @@ class get_type_all_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -2546,6 +2594,9 @@ class get_fields_args(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -2649,6 +2700,9 @@ class get_fields_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -2717,6 +2771,9 @@ class get_schema_args(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -2820,6 +2877,9 @@ class get_schema_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -2877,6 +2937,9 @@ class create_table_args(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -2973,6 +3036,9 @@ class create_table_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -3053,6 +3119,9 @@ class drop_table_args(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -3123,6 +3192,9 @@ class drop_table_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -3191,6 +3263,9 @@ class get_tables_args(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -3267,6 +3342,9 @@ class get_tables_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -3335,6 +3413,9 @@ class get_table_args(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -3417,6 +3498,9 @@ class get_table_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -3498,6 +3582,9 @@ class alter_table_args(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -3568,6 +3655,9 @@ class alter_table_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -3625,6 +3715,9 @@ class add_partition_args(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -3720,6 +3813,9 @@ class add_partition_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -3808,6 +3904,9 @@ class append_partition_args(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -3903,6 +4002,9 @@ class append_partition_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -4003,6 +4105,9 @@ class drop_partition_args(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -4084,6 +4189,9 @@ class drop_partition_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -4172,6 +4280,9 @@ class get_partition_args(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -4241,6 +4352,9 @@ class get_partition_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -4321,6 +4435,9 @@ class get_partitions_args(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -4411,6 +4528,9 @@ class get_partitions_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -4491,6 +4611,9 @@ class get_partition_names_args(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -4567,6 +4690,9 @@ class get_partition_names_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -4648,6 +4774,9 @@ class alter_partition_args(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -4718,6 +4847,9 @@ class alter_partition_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -4786,6 +4918,9 @@ class get_config_value_args(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -4854,6 +4989,9 @@ class get_config_value_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -4865,5 +5003,3 @@ class get_config_value_result(object):
 
   def __ne__(self, other):
     return not (self == other)
-
-

+ 0 - 13
apps/beeswax/gen-py/hive_metastore/constants.py

@@ -8,28 +8,15 @@ from thrift.Thrift import *
 from ttypes import *
 
 DDL_TIME = "transient_lastDdlTime"
-
 META_TABLE_COLUMNS = "columns"
-
 META_TABLE_COLUMN_TYPES = "columns.types"
-
 BUCKET_FIELD_NAME = "bucket_field_name"
-
 BUCKET_COUNT = "bucket_count"
-
 FIELD_TO_DIMENSION = "field_to_dimension"
-
 META_TABLE_NAME = "name"
-
 META_TABLE_DB = "db"
-
 META_TABLE_LOCATION = "location"
-
 META_TABLE_SERDE = "serde"
-
 META_TABLE_PARTITION_COLUMNS = "partition_columns"
-
 FILE_INPUT_FORMAT = "file.inputformat"
-
 FILE_OUTPUT_FORMAT = "file.outputformat"
-

+ 62 - 2
apps/beeswax/gen-py/hive_metastore/ttypes.py

@@ -9,13 +9,14 @@ import fb303.ttypes
 
 
 from thrift.transport import TTransport
-from thrift.protocol import TBinaryProtocol
+from thrift.protocol import TBinaryProtocol, TProtocol
 try:
   from thrift.protocol import fastbinary
 except:
   fastbinary = None
 
 
+
 class Version(object):
   """
   Attributes:
@@ -72,6 +73,9 @@ class Version(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -152,6 +156,9 @@ class FieldSchema(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -253,6 +260,9 @@ class Type(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -321,6 +331,9 @@ class Database(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -411,6 +424,9 @@ class SerDeInfo(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -479,6 +495,9 @@ class Order(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -680,6 +699,9 @@ class StorageDescriptor(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -852,6 +874,9 @@ class Table(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -999,6 +1024,9 @@ class Partition(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -1123,6 +1151,9 @@ class Index(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -1210,6 +1241,9 @@ class Schema(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -1266,6 +1300,9 @@ class MetaException(Exception):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __str__(self):
     return repr(self)
@@ -1325,6 +1362,9 @@ class UnknownTableException(Exception):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __str__(self):
     return repr(self)
@@ -1384,6 +1424,9 @@ class UnknownDBException(Exception):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __str__(self):
     return repr(self)
@@ -1443,6 +1486,9 @@ class AlreadyExistsException(Exception):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __str__(self):
     return repr(self)
@@ -1502,6 +1548,9 @@ class InvalidObjectException(Exception):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __str__(self):
     return repr(self)
@@ -1561,6 +1610,9 @@ class NoSuchObjectException(Exception):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __str__(self):
     return repr(self)
@@ -1620,6 +1672,9 @@ class IndexAlreadyExistsException(Exception):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __str__(self):
     return repr(self)
@@ -1679,6 +1734,9 @@ class InvalidOperationException(Exception):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __str__(self):
     return repr(self)
@@ -1738,6 +1796,9 @@ class ConfigValSecurityException(Exception):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __str__(self):
     return repr(self)
@@ -1752,4 +1813,3 @@ class ConfigValSecurityException(Exception):
 
   def __ne__(self, other):
     return not (self == other)
-

二进制
apps/beeswax/hive/lib/commons-cli-1.2.jar


二进制
apps/beeswax/hive/lib/commons-codec-1.4.jar


二进制
apps/beeswax/hive/lib/hive-cli-0.5.0.jar


二进制
apps/beeswax/hive/lib/hive-common-0.5.0.jar


二进制
apps/beeswax/hive/lib/hive-default-xml-0.5.0.jar


二进制
apps/beeswax/hive/lib/hive-exec-0.5.0.jar


二进制
apps/beeswax/hive/lib/hive-jdbc-0.5.0.jar


二进制
apps/beeswax/hive/lib/hive-metastore-0.5.0.jar


二进制
apps/beeswax/hive/lib/hive-serde-0.5.0.jar


二进制
apps/beeswax/hive/lib/hive-service-0.5.0.jar


二进制
apps/beeswax/hive/lib/hive-shims-0.5.0.jar


二进制
apps/beeswax/hive/lib/hive_contrib.jar


二进制
apps/beeswax/hive/lib/junit-4.5.jar


二进制
apps/beeswax/hive/lib/libfb303.jar


二进制
apps/beeswax/hive/lib/libthrift.jar


二进制
apps/beeswax/hive/lib/slf4j-api-1.6.1.jar


二进制
apps/beeswax/hive/lib/slf4j-log4j12-1.6.1.jar


+ 162 - 44
apps/beeswax/java/gen-java/com/cloudera/beeswax/api/BeeswaxException.java

@@ -10,42 +10,110 @@ import java.util.List;
 import java.util.ArrayList;
 import java.util.Map;
 import java.util.HashMap;
+import java.util.EnumMap;
 import java.util.Set;
 import java.util.HashSet;
+import java.util.EnumSet;
 import java.util.Collections;
-import org.apache.log4j.Logger;
+import java.util.BitSet;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.thrift.*;
+import org.apache.thrift.async.*;
 import org.apache.thrift.meta_data.*;
+import org.apache.thrift.transport.*;
 import org.apache.thrift.protocol.*;
 
-public class BeeswaxException extends Exception implements TBase, java.io.Serializable, Cloneable {
+public class BeeswaxException extends Exception implements TBase<BeeswaxException, BeeswaxException._Fields>, java.io.Serializable, Cloneable {
   private static final TStruct STRUCT_DESC = new TStruct("BeeswaxException");
+
   private static final TField MESSAGE_FIELD_DESC = new TField("message", TType.STRING, (short)1);
   private static final TField LOG_CONTEXT_FIELD_DESC = new TField("log_context", TType.STRING, (short)2);
   private static final TField HANDLE_FIELD_DESC = new TField("handle", TType.STRUCT, (short)3);
 
   public String message;
-  public static final int MESSAGE = 1;
   public String log_context;
-  public static final int LOG_CONTEXT = 2;
   public QueryHandle handle;
-  public static final int HANDLE = 3;
 
-  private final Isset __isset = new Isset();
-  private static final class Isset implements java.io.Serializable {
+  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+  public enum _Fields implements TFieldIdEnum {
+    MESSAGE((short)1, "message"),
+    LOG_CONTEXT((short)2, "log_context"),
+    HANDLE((short)3, "handle");
+
+    private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+    static {
+      for (_Fields field : EnumSet.allOf(_Fields.class)) {
+        byName.put(field.getFieldName(), field);
+      }
+    }
+
+    /**
+     * Find the _Fields constant that matches fieldId, or null if its not found.
+     */
+    public static _Fields findByThriftId(int fieldId) {
+      switch(fieldId) {
+        case 1: // MESSAGE
+          return MESSAGE;
+        case 2: // LOG_CONTEXT
+          return LOG_CONTEXT;
+        case 3: // HANDLE
+          return HANDLE;
+        default:
+          return null;
+      }
+    }
+
+    /**
+     * Find the _Fields constant that matches fieldId, throwing an exception
+     * if it is not found.
+     */
+    public static _Fields findByThriftIdOrThrow(int fieldId) {
+      _Fields fields = findByThriftId(fieldId);
+      if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+      return fields;
+    }
+
+    /**
+     * Find the _Fields constant that matches name, or null if its not found.
+     */
+    public static _Fields findByName(String name) {
+      return byName.get(name);
+    }
+
+    private final short _thriftId;
+    private final String _fieldName;
+
+    _Fields(short thriftId, String fieldName) {
+      _thriftId = thriftId;
+      _fieldName = fieldName;
+    }
+
+    public short getThriftFieldId() {
+      return _thriftId;
+    }
+
+    public String getFieldName() {
+      return _fieldName;
+    }
   }
 
-  public static final Map<Integer, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new HashMap<Integer, FieldMetaData>() {{
-    put(MESSAGE, new FieldMetaData("message", TFieldRequirementType.DEFAULT, 
-        new FieldValueMetaData(TType.STRING)));
-    put(LOG_CONTEXT, new FieldMetaData("log_context", TFieldRequirementType.DEFAULT, 
-        new FieldValueMetaData(TType.STRING)));
-    put(HANDLE, new FieldMetaData("handle", TFieldRequirementType.DEFAULT, 
-        new StructMetaData(TType.STRUCT, QueryHandle.class)));
-  }});
+  // isset id assignments
 
+  public static final Map<_Fields, FieldMetaData> metaDataMap;
   static {
+    Map<_Fields, FieldMetaData> tmpMap = new EnumMap<_Fields, FieldMetaData>(_Fields.class);
+    tmpMap.put(_Fields.MESSAGE, new FieldMetaData("message", TFieldRequirementType.DEFAULT, 
+        new FieldValueMetaData(TType.STRING)));
+    tmpMap.put(_Fields.LOG_CONTEXT, new FieldMetaData("log_context", TFieldRequirementType.DEFAULT, 
+        new FieldValueMetaData(TType.STRING        , "LogContextId")));
+    tmpMap.put(_Fields.HANDLE, new FieldMetaData("handle", TFieldRequirementType.DEFAULT, 
+        new StructMetaData(TType.STRUCT, QueryHandle.class)));
+    metaDataMap = Collections.unmodifiableMap(tmpMap);
     FieldMetaData.addStructMetaDataMap(BeeswaxException.class, metaDataMap);
   }
 
@@ -78,24 +146,31 @@ public class BeeswaxException extends Exception implements TBase, java.io.Serial
     }
   }
 
-  @Override
-  public BeeswaxException clone() {
+  public BeeswaxException deepCopy() {
     return new BeeswaxException(this);
   }
 
+  @Override
+  public void clear() {
+    this.message = null;
+    this.log_context = null;
+    this.handle = null;
+  }
+
   public String getMessage() {
     return this.message;
   }
 
-  public void setMessage(String message) {
+  public BeeswaxException setMessage(String message) {
     this.message = message;
+    return this;
   }
 
   public void unsetMessage() {
     this.message = null;
   }
 
-  // Returns true if field message is set (has been asigned a value) and false otherwise
+  /** Returns true if field message is set (has been asigned a value) and false otherwise */
   public boolean isSetMessage() {
     return this.message != null;
   }
@@ -110,15 +185,16 @@ public class BeeswaxException extends Exception implements TBase, java.io.Serial
     return this.log_context;
   }
 
-  public void setLog_context(String log_context) {
+  public BeeswaxException setLog_context(String log_context) {
     this.log_context = log_context;
+    return this;
   }
 
   public void unsetLog_context() {
     this.log_context = null;
   }
 
-  // Returns true if field log_context is set (has been asigned a value) and false otherwise
+  /** Returns true if field log_context is set (has been asigned a value) and false otherwise */
   public boolean isSetLog_context() {
     return this.log_context != null;
   }
@@ -133,15 +209,16 @@ public class BeeswaxException extends Exception implements TBase, java.io.Serial
     return this.handle;
   }
 
-  public void setHandle(QueryHandle handle) {
+  public BeeswaxException setHandle(QueryHandle handle) {
     this.handle = handle;
+    return this;
   }
 
   public void unsetHandle() {
     this.handle = null;
   }
 
-  // Returns true if field handle is set (has been asigned a value) and false otherwise
+  /** Returns true if field handle is set (has been asigned a value) and false otherwise */
   public boolean isSetHandle() {
     return this.handle != null;
   }
@@ -152,8 +229,8 @@ public class BeeswaxException extends Exception implements TBase, java.io.Serial
     }
   }
 
-  public void setFieldValue(int fieldID, Object value) {
-    switch (fieldID) {
+  public void setFieldValue(_Fields field, Object value) {
+    switch (field) {
     case MESSAGE:
       if (value == null) {
         unsetMessage();
@@ -178,13 +255,11 @@ public class BeeswaxException extends Exception implements TBase, java.io.Serial
       }
       break;
 
-    default:
-      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
     }
   }
 
-  public Object getFieldValue(int fieldID) {
-    switch (fieldID) {
+  public Object getFieldValue(_Fields field) {
+    switch (field) {
     case MESSAGE:
       return getMessage();
 
@@ -194,23 +269,25 @@ public class BeeswaxException extends Exception implements TBase, java.io.Serial
     case HANDLE:
       return getHandle();
 
-    default:
-      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
     }
+    throw new IllegalStateException();
   }
 
-  // Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise
-  public boolean isSet(int fieldID) {
-    switch (fieldID) {
+  /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
+  public boolean isSet(_Fields field) {
+    if (field == null) {
+      throw new IllegalArgumentException();
+    }
+
+    switch (field) {
     case MESSAGE:
       return isSetMessage();
     case LOG_CONTEXT:
       return isSetLog_context();
     case HANDLE:
       return isSetHandle();
-    default:
-      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
     }
+    throw new IllegalStateException();
   }
 
   @Override
@@ -278,6 +355,51 @@ public class BeeswaxException extends Exception implements TBase, java.io.Serial
     return builder.toHashCode();
   }
 
+  public int compareTo(BeeswaxException other) {
+    if (!getClass().equals(other.getClass())) {
+      return getClass().getName().compareTo(other.getClass().getName());
+    }
+
+    int lastComparison = 0;
+    BeeswaxException typedOther = (BeeswaxException)other;
+
+    lastComparison = Boolean.valueOf(isSetMessage()).compareTo(typedOther.isSetMessage());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetMessage()) {
+      lastComparison = TBaseHelper.compareTo(this.message, typedOther.message);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetLog_context()).compareTo(typedOther.isSetLog_context());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetLog_context()) {
+      lastComparison = TBaseHelper.compareTo(this.log_context, typedOther.log_context);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetHandle()).compareTo(typedOther.isSetHandle());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetHandle()) {
+      lastComparison = TBaseHelper.compareTo(this.handle, typedOther.handle);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    return 0;
+  }
+
+  public _Fields fieldForId(int fieldId) {
+    return _Fields.findByThriftId(fieldId);
+  }
+
   public void read(TProtocol iprot) throws TException {
     TField field;
     iprot.readStructBegin();
@@ -287,23 +409,22 @@ public class BeeswaxException extends Exception implements TBase, java.io.Serial
       if (field.type == TType.STOP) { 
         break;
       }
-      switch (field.id)
-      {
-        case MESSAGE:
+      switch (field.id) {
+        case 1: // MESSAGE
           if (field.type == TType.STRING) {
             this.message = iprot.readString();
           } else { 
             TProtocolUtil.skip(iprot, field.type);
           }
           break;
-        case LOG_CONTEXT:
+        case 2: // LOG_CONTEXT
           if (field.type == TType.STRING) {
             this.log_context = iprot.readString();
           } else { 
             TProtocolUtil.skip(iprot, field.type);
           }
           break;
-        case HANDLE:
+        case 3: // HANDLE
           if (field.type == TType.STRUCT) {
             this.handle = new QueryHandle();
             this.handle.read(iprot);
@@ -313,13 +434,11 @@ public class BeeswaxException extends Exception implements TBase, java.io.Serial
           break;
         default:
           TProtocolUtil.skip(iprot, field.type);
-          break;
       }
       iprot.readFieldEnd();
     }
     iprot.readStructEnd();
 
-
     // check for required fields of primitive type, which can't be checked in the validate method
     validate();
   }
@@ -381,7 +500,6 @@ public class BeeswaxException extends Exception implements TBase, java.io.Serial
 
   public void validate() throws TException {
     // check for required fields
-    // check that fields of type enum have valid values
   }
 
 }

文件差异内容过多而无法显示
+ 601 - 64
apps/beeswax/java/gen-java/com/cloudera/beeswax/api/BeeswaxService.java


+ 161 - 43
apps/beeswax/java/gen-java/com/cloudera/beeswax/api/ConfigVariable.java

@@ -10,45 +10,113 @@ import java.util.List;
 import java.util.ArrayList;
 import java.util.Map;
 import java.util.HashMap;
+import java.util.EnumMap;
 import java.util.Set;
 import java.util.HashSet;
+import java.util.EnumSet;
 import java.util.Collections;
-import org.apache.log4j.Logger;
+import java.util.BitSet;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.thrift.*;
+import org.apache.thrift.async.*;
 import org.apache.thrift.meta_data.*;
+import org.apache.thrift.transport.*;
 import org.apache.thrift.protocol.*;
 
 /**
  * Represents a Hadoop-style configuration variable.
  */
-public class ConfigVariable implements TBase, java.io.Serializable, Cloneable {
+public class ConfigVariable implements TBase<ConfigVariable, ConfigVariable._Fields>, java.io.Serializable, Cloneable {
   private static final TStruct STRUCT_DESC = new TStruct("ConfigVariable");
+
   private static final TField KEY_FIELD_DESC = new TField("key", TType.STRING, (short)1);
   private static final TField VALUE_FIELD_DESC = new TField("value", TType.STRING, (short)2);
   private static final TField DESCRIPTION_FIELD_DESC = new TField("description", TType.STRING, (short)3);
 
   public String key;
-  public static final int KEY = 1;
   public String value;
-  public static final int VALUE = 2;
   public String description;
-  public static final int DESCRIPTION = 3;
 
-  private final Isset __isset = new Isset();
-  private static final class Isset implements java.io.Serializable {
+  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+  public enum _Fields implements TFieldIdEnum {
+    KEY((short)1, "key"),
+    VALUE((short)2, "value"),
+    DESCRIPTION((short)3, "description");
+
+    private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+    static {
+      for (_Fields field : EnumSet.allOf(_Fields.class)) {
+        byName.put(field.getFieldName(), field);
+      }
+    }
+
+    /**
+     * Find the _Fields constant that matches fieldId, or null if its not found.
+     */
+    public static _Fields findByThriftId(int fieldId) {
+      switch(fieldId) {
+        case 1: // KEY
+          return KEY;
+        case 2: // VALUE
+          return VALUE;
+        case 3: // DESCRIPTION
+          return DESCRIPTION;
+        default:
+          return null;
+      }
+    }
+
+    /**
+     * Find the _Fields constant that matches fieldId, throwing an exception
+     * if it is not found.
+     */
+    public static _Fields findByThriftIdOrThrow(int fieldId) {
+      _Fields fields = findByThriftId(fieldId);
+      if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+      return fields;
+    }
+
+    /**
+     * Find the _Fields constant that matches name, or null if its not found.
+     */
+    public static _Fields findByName(String name) {
+      return byName.get(name);
+    }
+
+    private final short _thriftId;
+    private final String _fieldName;
+
+    _Fields(short thriftId, String fieldName) {
+      _thriftId = thriftId;
+      _fieldName = fieldName;
+    }
+
+    public short getThriftFieldId() {
+      return _thriftId;
+    }
+
+    public String getFieldName() {
+      return _fieldName;
+    }
   }
 
-  public static final Map<Integer, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new HashMap<Integer, FieldMetaData>() {{
-    put(KEY, new FieldMetaData("key", TFieldRequirementType.DEFAULT, 
+  // isset id assignments
+
+  public static final Map<_Fields, FieldMetaData> metaDataMap;
+  static {
+    Map<_Fields, FieldMetaData> tmpMap = new EnumMap<_Fields, FieldMetaData>(_Fields.class);
+    tmpMap.put(_Fields.KEY, new FieldMetaData("key", TFieldRequirementType.DEFAULT, 
         new FieldValueMetaData(TType.STRING)));
-    put(VALUE, new FieldMetaData("value", TFieldRequirementType.DEFAULT, 
+    tmpMap.put(_Fields.VALUE, new FieldMetaData("value", TFieldRequirementType.DEFAULT, 
         new FieldValueMetaData(TType.STRING)));
-    put(DESCRIPTION, new FieldMetaData("description", TFieldRequirementType.DEFAULT, 
+    tmpMap.put(_Fields.DESCRIPTION, new FieldMetaData("description", TFieldRequirementType.DEFAULT, 
         new FieldValueMetaData(TType.STRING)));
-  }});
-
-  static {
+    metaDataMap = Collections.unmodifiableMap(tmpMap);
     FieldMetaData.addStructMetaDataMap(ConfigVariable.class, metaDataMap);
   }
 
@@ -81,24 +149,31 @@ public class ConfigVariable implements TBase, java.io.Serializable, Cloneable {
     }
   }
 
-  @Override
-  public ConfigVariable clone() {
+  public ConfigVariable deepCopy() {
     return new ConfigVariable(this);
   }
 
+  @Override
+  public void clear() {
+    this.key = null;
+    this.value = null;
+    this.description = null;
+  }
+
   public String getKey() {
     return this.key;
   }
 
-  public void setKey(String key) {
+  public ConfigVariable setKey(String key) {
     this.key = key;
+    return this;
   }
 
   public void unsetKey() {
     this.key = null;
   }
 
-  // Returns true if field key is set (has been asigned a value) and false otherwise
+  /** Returns true if field key is set (has been asigned a value) and false otherwise */
   public boolean isSetKey() {
     return this.key != null;
   }
@@ -113,15 +188,16 @@ public class ConfigVariable implements TBase, java.io.Serializable, Cloneable {
     return this.value;
   }
 
-  public void setValue(String value) {
+  public ConfigVariable setValue(String value) {
     this.value = value;
+    return this;
   }
 
   public void unsetValue() {
     this.value = null;
   }
 
-  // Returns true if field value is set (has been asigned a value) and false otherwise
+  /** Returns true if field value is set (has been asigned a value) and false otherwise */
   public boolean isSetValue() {
     return this.value != null;
   }
@@ -136,15 +212,16 @@ public class ConfigVariable implements TBase, java.io.Serializable, Cloneable {
     return this.description;
   }
 
-  public void setDescription(String description) {
+  public ConfigVariable setDescription(String description) {
     this.description = description;
+    return this;
   }
 
   public void unsetDescription() {
     this.description = null;
   }
 
-  // Returns true if field description is set (has been asigned a value) and false otherwise
+  /** Returns true if field description is set (has been asigned a value) and false otherwise */
   public boolean isSetDescription() {
     return this.description != null;
   }
@@ -155,8 +232,8 @@ public class ConfigVariable implements TBase, java.io.Serializable, Cloneable {
     }
   }
 
-  public void setFieldValue(int fieldID, Object value) {
-    switch (fieldID) {
+  public void setFieldValue(_Fields field, Object value) {
+    switch (field) {
     case KEY:
       if (value == null) {
         unsetKey();
@@ -181,13 +258,11 @@ public class ConfigVariable implements TBase, java.io.Serializable, Cloneable {
       }
       break;
 
-    default:
-      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
     }
   }
 
-  public Object getFieldValue(int fieldID) {
-    switch (fieldID) {
+  public Object getFieldValue(_Fields field) {
+    switch (field) {
     case KEY:
       return getKey();
 
@@ -197,23 +272,25 @@ public class ConfigVariable implements TBase, java.io.Serializable, Cloneable {
     case DESCRIPTION:
       return getDescription();
 
-    default:
-      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
     }
+    throw new IllegalStateException();
   }
 
-  // Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise
-  public boolean isSet(int fieldID) {
-    switch (fieldID) {
+  /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
+  public boolean isSet(_Fields field) {
+    if (field == null) {
+      throw new IllegalArgumentException();
+    }
+
+    switch (field) {
     case KEY:
       return isSetKey();
     case VALUE:
       return isSetValue();
     case DESCRIPTION:
       return isSetDescription();
-    default:
-      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
     }
+    throw new IllegalStateException();
   }
 
   @Override
@@ -281,6 +358,51 @@ public class ConfigVariable implements TBase, java.io.Serializable, Cloneable {
     return builder.toHashCode();
   }
 
+  public int compareTo(ConfigVariable other) {
+    if (!getClass().equals(other.getClass())) {
+      return getClass().getName().compareTo(other.getClass().getName());
+    }
+
+    int lastComparison = 0;
+    ConfigVariable typedOther = (ConfigVariable)other;
+
+    lastComparison = Boolean.valueOf(isSetKey()).compareTo(typedOther.isSetKey());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetKey()) {
+      lastComparison = TBaseHelper.compareTo(this.key, typedOther.key);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetValue()).compareTo(typedOther.isSetValue());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetValue()) {
+      lastComparison = TBaseHelper.compareTo(this.value, typedOther.value);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetDescription()).compareTo(typedOther.isSetDescription());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetDescription()) {
+      lastComparison = TBaseHelper.compareTo(this.description, typedOther.description);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    return 0;
+  }
+
+  public _Fields fieldForId(int fieldId) {
+    return _Fields.findByThriftId(fieldId);
+  }
+
   public void read(TProtocol iprot) throws TException {
     TField field;
     iprot.readStructBegin();
@@ -290,23 +412,22 @@ public class ConfigVariable implements TBase, java.io.Serializable, Cloneable {
       if (field.type == TType.STOP) { 
         break;
       }
-      switch (field.id)
-      {
-        case KEY:
+      switch (field.id) {
+        case 1: // KEY
           if (field.type == TType.STRING) {
             this.key = iprot.readString();
           } else { 
             TProtocolUtil.skip(iprot, field.type);
           }
           break;
-        case VALUE:
+        case 2: // VALUE
           if (field.type == TType.STRING) {
             this.value = iprot.readString();
           } else { 
             TProtocolUtil.skip(iprot, field.type);
           }
           break;
-        case DESCRIPTION:
+        case 3: // DESCRIPTION
           if (field.type == TType.STRING) {
             this.description = iprot.readString();
           } else { 
@@ -315,13 +436,11 @@ public class ConfigVariable implements TBase, java.io.Serializable, Cloneable {
           break;
         default:
           TProtocolUtil.skip(iprot, field.type);
-          break;
       }
       iprot.readFieldEnd();
     }
     iprot.readStructEnd();
 
-
     // check for required fields of primitive type, which can't be checked in the validate method
     validate();
   }
@@ -383,7 +502,6 @@ public class ConfigVariable implements TBase, java.io.Serializable, Cloneable {
 
   public void validate() throws TException {
     // check for required fields
-    // check that fields of type enum have valid values
   }
 
 }

+ 0 - 313
apps/beeswax/java/gen-java/com/cloudera/beeswax/api/FileResource.java

@@ -1,313 +0,0 @@
-/**
- * Autogenerated by Thrift
- *
- * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
- */
-package com.cloudera.beeswax.api;
-
-import org.apache.commons.lang.builder.HashCodeBuilder;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Collections;
-import org.apache.log4j.Logger;
-
-import org.apache.thrift.*;
-import org.apache.thrift.meta_data.*;
-import org.apache.thrift.protocol.*;
-
-public class FileResource implements TBase, java.io.Serializable, Cloneable {
-  private static final TStruct STRUCT_DESC = new TStruct("FileResource");
-  private static final TField TYPE_FIELD_DESC = new TField("type", TType.I32, (short)1);
-  private static final TField PATH_FIELD_DESC = new TField("path", TType.STRING, (short)2);
-
-  public int type;
-  public static final int TYPE = 1;
-  public String path;
-  public static final int PATH = 2;
-
-  private final Isset __isset = new Isset();
-  private static final class Isset implements java.io.Serializable {
-    public boolean type = false;
-  }
-
-  public static final Map<Integer, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new HashMap<Integer, FieldMetaData>() {{
-    put(TYPE, new FieldMetaData("type", TFieldRequirementType.DEFAULT, 
-        new FieldValueMetaData(TType.I32)));
-    put(PATH, new FieldMetaData("path", TFieldRequirementType.DEFAULT, 
-        new FieldValueMetaData(TType.STRING)));
-  }});
-
-  static {
-    FieldMetaData.addStructMetaDataMap(FileResource.class, metaDataMap);
-  }
-
-  public FileResource() {
-  }
-
-  public FileResource(
-    int type,
-    String path)
-  {
-    this();
-    this.type = type;
-    this.__isset.type = true;
-    this.path = path;
-  }
-
-  /**
-   * Performs a deep copy on <i>other</i>.
-   */
-  public FileResource(FileResource other) {
-    __isset.type = other.__isset.type;
-    this.type = other.type;
-    if (other.isSetPath()) {
-      this.path = other.path;
-    }
-  }
-
-  @Override
-  public FileResource clone() {
-    return new FileResource(this);
-  }
-
-  public int getType() {
-    return this.type;
-  }
-
-  public void setType(int type) {
-    this.type = type;
-    this.__isset.type = true;
-  }
-
-  public void unsetType() {
-    this.__isset.type = false;
-  }
-
-  // Returns true if field type is set (has been asigned a value) and false otherwise
-  public boolean isSetType() {
-    return this.__isset.type;
-  }
-
-  public void setTypeIsSet(boolean value) {
-    this.__isset.type = value;
-  }
-
-  public String getPath() {
-    return this.path;
-  }
-
-  public void setPath(String path) {
-    this.path = path;
-  }
-
-  public void unsetPath() {
-    this.path = null;
-  }
-
-  // Returns true if field path is set (has been asigned a value) and false otherwise
-  public boolean isSetPath() {
-    return this.path != null;
-  }
-
-  public void setPathIsSet(boolean value) {
-    if (!value) {
-      this.path = null;
-    }
-  }
-
-  public void setFieldValue(int fieldID, Object value) {
-    switch (fieldID) {
-    case TYPE:
-      if (value == null) {
-        unsetType();
-      } else {
-        setType((Integer)value);
-      }
-      break;
-
-    case PATH:
-      if (value == null) {
-        unsetPath();
-      } else {
-        setPath((String)value);
-      }
-      break;
-
-    default:
-      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
-    }
-  }
-
-  public Object getFieldValue(int fieldID) {
-    switch (fieldID) {
-    case TYPE:
-      return getType();
-
-    case PATH:
-      return getPath();
-
-    default:
-      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
-    }
-  }
-
-  // Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise
-  public boolean isSet(int fieldID) {
-    switch (fieldID) {
-    case TYPE:
-      return isSetType();
-    case PATH:
-      return isSetPath();
-    default:
-      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
-    }
-  }
-
-  @Override
-  public boolean equals(Object that) {
-    if (that == null)
-      return false;
-    if (that instanceof FileResource)
-      return this.equals((FileResource)that);
-    return false;
-  }
-
-  public boolean equals(FileResource that) {
-    if (that == null)
-      return false;
-
-    boolean this_present_type = true;
-    boolean that_present_type = true;
-    if (this_present_type || that_present_type) {
-      if (!(this_present_type && that_present_type))
-        return false;
-      if (this.type != that.type)
-        return false;
-    }
-
-    boolean this_present_path = true && this.isSetPath();
-    boolean that_present_path = true && that.isSetPath();
-    if (this_present_path || that_present_path) {
-      if (!(this_present_path && that_present_path))
-        return false;
-      if (!this.path.equals(that.path))
-        return false;
-    }
-
-    return true;
-  }
-
-  @Override
-  public int hashCode() {
-    HashCodeBuilder builder = new HashCodeBuilder();
-
-    boolean present_type = true;
-    builder.append(present_type);
-    if (present_type)
-      builder.append(type);
-
-    boolean present_path = true && (isSetPath());
-    builder.append(present_path);
-    if (present_path)
-      builder.append(path);
-
-    return builder.toHashCode();
-  }
-
-  public void read(TProtocol iprot) throws TException {
-    TField field;
-    iprot.readStructBegin();
-    while (true)
-    {
-      field = iprot.readFieldBegin();
-      if (field.type == TType.STOP) { 
-        break;
-      }
-      switch (field.id)
-      {
-        case TYPE:
-          if (field.type == TType.I32) {
-            this.type = iprot.readI32();
-            this.__isset.type = true;
-          } else { 
-            TProtocolUtil.skip(iprot, field.type);
-          }
-          break;
-        case PATH:
-          if (field.type == TType.STRING) {
-            this.path = iprot.readString();
-          } else { 
-            TProtocolUtil.skip(iprot, field.type);
-          }
-          break;
-        default:
-          TProtocolUtil.skip(iprot, field.type);
-          break;
-      }
-      iprot.readFieldEnd();
-    }
-    iprot.readStructEnd();
-
-
-    // check for required fields of primitive type, which can't be checked in the validate method
-    validate();
-  }
-
-  public void write(TProtocol oprot) throws TException {
-    validate();
-
-    oprot.writeStructBegin(STRUCT_DESC);
-    oprot.writeFieldBegin(TYPE_FIELD_DESC);
-    oprot.writeI32(this.type);
-    oprot.writeFieldEnd();
-    if (this.path != null) {
-      oprot.writeFieldBegin(PATH_FIELD_DESC);
-      oprot.writeString(this.path);
-      oprot.writeFieldEnd();
-    }
-    oprot.writeFieldStop();
-    oprot.writeStructEnd();
-  }
-
-  @Override
-  public String toString() {
-    StringBuilder sb = new StringBuilder("FileResource(");
-    boolean first = true;
-
-    sb.append("type:");
-    String type_name = FileResourceType.VALUES_TO_NAMES.get(this.type);
-    if (type_name != null) {
-      sb.append(type_name);
-      sb.append(" (");
-    }
-    sb.append(this.type);
-    if (type_name != null) {
-      sb.append(")");
-    }
-    first = false;
-    if (!first) sb.append(", ");
-    sb.append("path:");
-    if (this.path == null) {
-      sb.append("null");
-    } else {
-      sb.append(this.path);
-    }
-    first = false;
-    sb.append(")");
-    return sb.toString();
-  }
-
-  public void validate() throws TException {
-    // check for required fields
-    // check that fields of type enum have valid values
-    if (isSetType() && !FileResourceType.VALID_VALUES.contains(type)){
-      throw new TProtocolException("The field 'type' has been assigned the invalid value " + type);
-    }
-  }
-
-}
-

+ 0 - 31
apps/beeswax/java/gen-java/com/cloudera/beeswax/api/FileResourceType.java

@@ -1,31 +0,0 @@
-/**
- * Autogenerated by Thrift
- *
- * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
- */
-package com.cloudera.beeswax.api;
-
-
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Collections;
-import org.apache.thrift.IntRangeSet;
-import java.util.Map;
-import java.util.HashMap;
-
-public class FileResourceType {
-  public static final int JAR = 0;
-  public static final int ARCHIVE = 1;
-  public static final int FILE = 2;
-
-  public static final IntRangeSet VALID_VALUES = new IntRangeSet(
-    JAR, 
-    ARCHIVE, 
-    FILE );
-
-  public static final Map<Integer, String> VALUES_TO_NAMES = new HashMap<Integer, String>() {{
-    put(JAR, "JAR");
-    put(ARCHIVE, "ARCHIVE");
-    put(FILE, "FILE");
-  }};
-}

+ 0 - 307
apps/beeswax/java/gen-java/com/cloudera/beeswax/api/Function.java

@@ -1,307 +0,0 @@
-/**
- * Autogenerated by Thrift
- *
- * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
- */
-package com.cloudera.beeswax.api;
-
-import org.apache.commons.lang.builder.HashCodeBuilder;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Collections;
-import org.apache.log4j.Logger;
-
-import org.apache.thrift.*;
-import org.apache.thrift.meta_data.*;
-import org.apache.thrift.protocol.*;
-
-public class Function implements TBase, java.io.Serializable, Cloneable {
-  private static final TStruct STRUCT_DESC = new TStruct("Function");
-  private static final TField NAME_FIELD_DESC = new TField("name", TType.STRING, (short)1);
-  private static final TField CLASS_NAME_FIELD_DESC = new TField("class_name", TType.STRING, (short)2);
-
-  public String name;
-  public static final int NAME = 1;
-  public String class_name;
-  public static final int CLASS_NAME = 2;
-
-  private final Isset __isset = new Isset();
-  private static final class Isset implements java.io.Serializable {
-  }
-
-  public static final Map<Integer, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new HashMap<Integer, FieldMetaData>() {{
-    put(NAME, new FieldMetaData("name", TFieldRequirementType.DEFAULT, 
-        new FieldValueMetaData(TType.STRING)));
-    put(CLASS_NAME, new FieldMetaData("class_name", TFieldRequirementType.DEFAULT, 
-        new FieldValueMetaData(TType.STRING)));
-  }});
-
-  static {
-    FieldMetaData.addStructMetaDataMap(Function.class, metaDataMap);
-  }
-
-  public Function() {
-  }
-
-  public Function(
-    String name,
-    String class_name)
-  {
-    this();
-    this.name = name;
-    this.class_name = class_name;
-  }
-
-  /**
-   * Performs a deep copy on <i>other</i>.
-   */
-  public Function(Function other) {
-    if (other.isSetName()) {
-      this.name = other.name;
-    }
-    if (other.isSetClass_name()) {
-      this.class_name = other.class_name;
-    }
-  }
-
-  @Override
-  public Function clone() {
-    return new Function(this);
-  }
-
-  public String getName() {
-    return this.name;
-  }
-
-  public void setName(String name) {
-    this.name = name;
-  }
-
-  public void unsetName() {
-    this.name = null;
-  }
-
-  // Returns true if field name is set (has been asigned a value) and false otherwise
-  public boolean isSetName() {
-    return this.name != null;
-  }
-
-  public void setNameIsSet(boolean value) {
-    if (!value) {
-      this.name = null;
-    }
-  }
-
-  public String getClass_name() {
-    return this.class_name;
-  }
-
-  public void setClass_name(String class_name) {
-    this.class_name = class_name;
-  }
-
-  public void unsetClass_name() {
-    this.class_name = null;
-  }
-
-  // Returns true if field class_name is set (has been asigned a value) and false otherwise
-  public boolean isSetClass_name() {
-    return this.class_name != null;
-  }
-
-  public void setClass_nameIsSet(boolean value) {
-    if (!value) {
-      this.class_name = null;
-    }
-  }
-
-  public void setFieldValue(int fieldID, Object value) {
-    switch (fieldID) {
-    case NAME:
-      if (value == null) {
-        unsetName();
-      } else {
-        setName((String)value);
-      }
-      break;
-
-    case CLASS_NAME:
-      if (value == null) {
-        unsetClass_name();
-      } else {
-        setClass_name((String)value);
-      }
-      break;
-
-    default:
-      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
-    }
-  }
-
-  public Object getFieldValue(int fieldID) {
-    switch (fieldID) {
-    case NAME:
-      return getName();
-
-    case CLASS_NAME:
-      return getClass_name();
-
-    default:
-      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
-    }
-  }
-
-  // Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise
-  public boolean isSet(int fieldID) {
-    switch (fieldID) {
-    case NAME:
-      return isSetName();
-    case CLASS_NAME:
-      return isSetClass_name();
-    default:
-      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
-    }
-  }
-
-  @Override
-  public boolean equals(Object that) {
-    if (that == null)
-      return false;
-    if (that instanceof Function)
-      return this.equals((Function)that);
-    return false;
-  }
-
-  public boolean equals(Function that) {
-    if (that == null)
-      return false;
-
-    boolean this_present_name = true && this.isSetName();
-    boolean that_present_name = true && that.isSetName();
-    if (this_present_name || that_present_name) {
-      if (!(this_present_name && that_present_name))
-        return false;
-      if (!this.name.equals(that.name))
-        return false;
-    }
-
-    boolean this_present_class_name = true && this.isSetClass_name();
-    boolean that_present_class_name = true && that.isSetClass_name();
-    if (this_present_class_name || that_present_class_name) {
-      if (!(this_present_class_name && that_present_class_name))
-        return false;
-      if (!this.class_name.equals(that.class_name))
-        return false;
-    }
-
-    return true;
-  }
-
-  @Override
-  public int hashCode() {
-    HashCodeBuilder builder = new HashCodeBuilder();
-
-    boolean present_name = true && (isSetName());
-    builder.append(present_name);
-    if (present_name)
-      builder.append(name);
-
-    boolean present_class_name = true && (isSetClass_name());
-    builder.append(present_class_name);
-    if (present_class_name)
-      builder.append(class_name);
-
-    return builder.toHashCode();
-  }
-
-  public void read(TProtocol iprot) throws TException {
-    TField field;
-    iprot.readStructBegin();
-    while (true)
-    {
-      field = iprot.readFieldBegin();
-      if (field.type == TType.STOP) { 
-        break;
-      }
-      switch (field.id)
-      {
-        case NAME:
-          if (field.type == TType.STRING) {
-            this.name = iprot.readString();
-          } else { 
-            TProtocolUtil.skip(iprot, field.type);
-          }
-          break;
-        case CLASS_NAME:
-          if (field.type == TType.STRING) {
-            this.class_name = iprot.readString();
-          } else { 
-            TProtocolUtil.skip(iprot, field.type);
-          }
-          break;
-        default:
-          TProtocolUtil.skip(iprot, field.type);
-          break;
-      }
-      iprot.readFieldEnd();
-    }
-    iprot.readStructEnd();
-
-
-    // check for required fields of primitive type, which can't be checked in the validate method
-    validate();
-  }
-
-  public void write(TProtocol oprot) throws TException {
-    validate();
-
-    oprot.writeStructBegin(STRUCT_DESC);
-    if (this.name != null) {
-      oprot.writeFieldBegin(NAME_FIELD_DESC);
-      oprot.writeString(this.name);
-      oprot.writeFieldEnd();
-    }
-    if (this.class_name != null) {
-      oprot.writeFieldBegin(CLASS_NAME_FIELD_DESC);
-      oprot.writeString(this.class_name);
-      oprot.writeFieldEnd();
-    }
-    oprot.writeFieldStop();
-    oprot.writeStructEnd();
-  }
-
-  @Override
-  public String toString() {
-    StringBuilder sb = new StringBuilder("Function(");
-    boolean first = true;
-
-    sb.append("name:");
-    if (this.name == null) {
-      sb.append("null");
-    } else {
-      sb.append(this.name);
-    }
-    first = false;
-    if (!first) sb.append(", ");
-    sb.append("class_name:");
-    if (this.class_name == null) {
-      sb.append("null");
-    } else {
-      sb.append(this.class_name);
-    }
-    first = false;
-    sb.append(")");
-    return sb.toString();
-  }
-
-  public void validate() throws TException {
-    // check for required fields
-    // check that fields of type enum have valid values
-  }
-
-}
-

+ 165 - 162
apps/beeswax/java/gen-java/com/cloudera/beeswax/api/Query.java

@@ -10,49 +10,111 @@ import java.util.List;
 import java.util.ArrayList;
 import java.util.Map;
 import java.util.HashMap;
+import java.util.EnumMap;
 import java.util.Set;
 import java.util.HashSet;
+import java.util.EnumSet;
 import java.util.Collections;
-import org.apache.log4j.Logger;
+import java.util.BitSet;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.thrift.*;
+import org.apache.thrift.async.*;
 import org.apache.thrift.meta_data.*;
+import org.apache.thrift.transport.*;
 import org.apache.thrift.protocol.*;
 
-public class Query implements TBase, java.io.Serializable, Cloneable {
+public class Query implements TBase<Query, Query._Fields>, java.io.Serializable, Cloneable {
   private static final TStruct STRUCT_DESC = new TStruct("Query");
+
   private static final TField QUERY_FIELD_DESC = new TField("query", TType.STRING, (short)1);
   private static final TField CONFIGURATION_FIELD_DESC = new TField("configuration", TType.LIST, (short)3);
   private static final TField HADOOP_USER_FIELD_DESC = new TField("hadoop_user", TType.STRING, (short)4);
-  private static final TField HADOOP_GROUPS_FIELD_DESC = new TField("hadoop_groups", TType.LIST, (short)5);
 
   public String query;
-  public static final int QUERY = 1;
   public List<String> configuration;
-  public static final int CONFIGURATION = 3;
   public String hadoop_user;
-  public static final int HADOOP_USER = 4;
-  public List<String> hadoop_groups;
-  public static final int HADOOP_GROUPS = 5;
 
-  private final Isset __isset = new Isset();
-  private static final class Isset implements java.io.Serializable {
+  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+  public enum _Fields implements TFieldIdEnum {
+    QUERY((short)1, "query"),
+    CONFIGURATION((short)3, "configuration"),
+    HADOOP_USER((short)4, "hadoop_user");
+
+    private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+    static {
+      for (_Fields field : EnumSet.allOf(_Fields.class)) {
+        byName.put(field.getFieldName(), field);
+      }
+    }
+
+    /**
+     * Find the _Fields constant that matches fieldId, or null if its not found.
+     */
+    public static _Fields findByThriftId(int fieldId) {
+      switch(fieldId) {
+        case 1: // QUERY
+          return QUERY;
+        case 3: // CONFIGURATION
+          return CONFIGURATION;
+        case 4: // HADOOP_USER
+          return HADOOP_USER;
+        default:
+          return null;
+      }
+    }
+
+    /**
+     * Find the _Fields constant that matches fieldId, throwing an exception
+     * if it is not found.
+     */
+    public static _Fields findByThriftIdOrThrow(int fieldId) {
+      _Fields fields = findByThriftId(fieldId);
+      if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+      return fields;
+    }
+
+    /**
+     * Find the _Fields constant that matches name, or null if its not found.
+     */
+    public static _Fields findByName(String name) {
+      return byName.get(name);
+    }
+
+    private final short _thriftId;
+    private final String _fieldName;
+
+    _Fields(short thriftId, String fieldName) {
+      _thriftId = thriftId;
+      _fieldName = fieldName;
+    }
+
+    public short getThriftFieldId() {
+      return _thriftId;
+    }
+
+    public String getFieldName() {
+      return _fieldName;
+    }
   }
 
-  public static final Map<Integer, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new HashMap<Integer, FieldMetaData>() {{
-    put(QUERY, new FieldMetaData("query", TFieldRequirementType.DEFAULT, 
+  // isset id assignments
+
+  public static final Map<_Fields, FieldMetaData> metaDataMap;
+  static {
+    Map<_Fields, FieldMetaData> tmpMap = new EnumMap<_Fields, FieldMetaData>(_Fields.class);
+    tmpMap.put(_Fields.QUERY, new FieldMetaData("query", TFieldRequirementType.DEFAULT, 
         new FieldValueMetaData(TType.STRING)));
-    put(CONFIGURATION, new FieldMetaData("configuration", TFieldRequirementType.DEFAULT, 
+    tmpMap.put(_Fields.CONFIGURATION, new FieldMetaData("configuration", TFieldRequirementType.DEFAULT, 
         new ListMetaData(TType.LIST, 
             new FieldValueMetaData(TType.STRING))));
-    put(HADOOP_USER, new FieldMetaData("hadoop_user", TFieldRequirementType.DEFAULT, 
+    tmpMap.put(_Fields.HADOOP_USER, new FieldMetaData("hadoop_user", TFieldRequirementType.DEFAULT, 
         new FieldValueMetaData(TType.STRING)));
-    put(HADOOP_GROUPS, new FieldMetaData("hadoop_groups", TFieldRequirementType.DEFAULT, 
-        new ListMetaData(TType.LIST, 
-            new FieldValueMetaData(TType.STRING))));
-  }});
-
-  static {
+    metaDataMap = Collections.unmodifiableMap(tmpMap);
     FieldMetaData.addStructMetaDataMap(Query.class, metaDataMap);
   }
 
@@ -62,14 +124,12 @@ public class Query implements TBase, java.io.Serializable, Cloneable {
   public Query(
     String query,
     List<String> configuration,
-    String hadoop_user,
-    List<String> hadoop_groups)
+    String hadoop_user)
   {
     this();
     this.query = query;
     this.configuration = configuration;
     this.hadoop_user = hadoop_user;
-    this.hadoop_groups = hadoop_groups;
   }
 
   /**
@@ -89,33 +149,33 @@ public class Query implements TBase, java.io.Serializable, Cloneable {
     if (other.isSetHadoop_user()) {
       this.hadoop_user = other.hadoop_user;
     }
-    if (other.isSetHadoop_groups()) {
-      List<String> __this__hadoop_groups = new ArrayList<String>();
-      for (String other_element : other.hadoop_groups) {
-        __this__hadoop_groups.add(other_element);
-      }
-      this.hadoop_groups = __this__hadoop_groups;
-    }
   }
 
-  @Override
-  public Query clone() {
+  public Query deepCopy() {
     return new Query(this);
   }
 
+  @Override
+  public void clear() {
+    this.query = null;
+    this.configuration = null;
+    this.hadoop_user = null;
+  }
+
   public String getQuery() {
     return this.query;
   }
 
-  public void setQuery(String query) {
+  public Query setQuery(String query) {
     this.query = query;
+    return this;
   }
 
   public void unsetQuery() {
     this.query = null;
   }
 
-  // Returns true if field query is set (has been asigned a value) and false otherwise
+  /** Returns true if field query is set (has been asigned a value) and false otherwise */
   public boolean isSetQuery() {
     return this.query != null;
   }
@@ -145,15 +205,16 @@ public class Query implements TBase, java.io.Serializable, Cloneable {
     return this.configuration;
   }
 
-  public void setConfiguration(List<String> configuration) {
+  public Query setConfiguration(List<String> configuration) {
     this.configuration = configuration;
+    return this;
   }
 
   public void unsetConfiguration() {
     this.configuration = null;
   }
 
-  // Returns true if field configuration is set (has been asigned a value) and false otherwise
+  /** Returns true if field configuration is set (has been asigned a value) and false otherwise */
   public boolean isSetConfiguration() {
     return this.configuration != null;
   }
@@ -168,15 +229,16 @@ public class Query implements TBase, java.io.Serializable, Cloneable {
     return this.hadoop_user;
   }
 
-  public void setHadoop_user(String hadoop_user) {
+  public Query setHadoop_user(String hadoop_user) {
     this.hadoop_user = hadoop_user;
+    return this;
   }
 
   public void unsetHadoop_user() {
     this.hadoop_user = null;
   }
 
-  // Returns true if field hadoop_user is set (has been asigned a value) and false otherwise
+  /** Returns true if field hadoop_user is set (has been asigned a value) and false otherwise */
   public boolean isSetHadoop_user() {
     return this.hadoop_user != null;
   }
@@ -187,46 +249,8 @@ public class Query implements TBase, java.io.Serializable, Cloneable {
     }
   }
 
-  public int getHadoop_groupsSize() {
-    return (this.hadoop_groups == null) ? 0 : this.hadoop_groups.size();
-  }
-
-  public java.util.Iterator<String> getHadoop_groupsIterator() {
-    return (this.hadoop_groups == null) ? null : this.hadoop_groups.iterator();
-  }
-
-  public void addToHadoop_groups(String elem) {
-    if (this.hadoop_groups == null) {
-      this.hadoop_groups = new ArrayList<String>();
-    }
-    this.hadoop_groups.add(elem);
-  }
-
-  public List<String> getHadoop_groups() {
-    return this.hadoop_groups;
-  }
-
-  public void setHadoop_groups(List<String> hadoop_groups) {
-    this.hadoop_groups = hadoop_groups;
-  }
-
-  public void unsetHadoop_groups() {
-    this.hadoop_groups = null;
-  }
-
-  // Returns true if field hadoop_groups is set (has been asigned a value) and false otherwise
-  public boolean isSetHadoop_groups() {
-    return this.hadoop_groups != null;
-  }
-
-  public void setHadoop_groupsIsSet(boolean value) {
-    if (!value) {
-      this.hadoop_groups = null;
-    }
-  }
-
-  public void setFieldValue(int fieldID, Object value) {
-    switch (fieldID) {
+  public void setFieldValue(_Fields field, Object value) {
+    switch (field) {
     case QUERY:
       if (value == null) {
         unsetQuery();
@@ -251,21 +275,11 @@ public class Query implements TBase, java.io.Serializable, Cloneable {
       }
       break;
 
-    case HADOOP_GROUPS:
-      if (value == null) {
-        unsetHadoop_groups();
-      } else {
-        setHadoop_groups((List<String>)value);
-      }
-      break;
-
-    default:
-      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
     }
   }
 
-  public Object getFieldValue(int fieldID) {
-    switch (fieldID) {
+  public Object getFieldValue(_Fields field) {
+    switch (field) {
     case QUERY:
       return getQuery();
 
@@ -275,28 +289,25 @@ public class Query implements TBase, java.io.Serializable, Cloneable {
     case HADOOP_USER:
       return getHadoop_user();
 
-    case HADOOP_GROUPS:
-      return getHadoop_groups();
-
-    default:
-      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
     }
+    throw new IllegalStateException();
   }
 
-  // Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise
-  public boolean isSet(int fieldID) {
-    switch (fieldID) {
+  /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
+  public boolean isSet(_Fields field) {
+    if (field == null) {
+      throw new IllegalArgumentException();
+    }
+
+    switch (field) {
     case QUERY:
       return isSetQuery();
     case CONFIGURATION:
       return isSetConfiguration();
     case HADOOP_USER:
       return isSetHadoop_user();
-    case HADOOP_GROUPS:
-      return isSetHadoop_groups();
-    default:
-      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
     }
+    throw new IllegalStateException();
   }
 
   @Override
@@ -339,15 +350,6 @@ public class Query implements TBase, java.io.Serializable, Cloneable {
         return false;
     }
 
-    boolean this_present_hadoop_groups = true && this.isSetHadoop_groups();
-    boolean that_present_hadoop_groups = true && that.isSetHadoop_groups();
-    if (this_present_hadoop_groups || that_present_hadoop_groups) {
-      if (!(this_present_hadoop_groups && that_present_hadoop_groups))
-        return false;
-      if (!this.hadoop_groups.equals(that.hadoop_groups))
-        return false;
-    }
-
     return true;
   }
 
@@ -370,14 +372,54 @@ public class Query implements TBase, java.io.Serializable, Cloneable {
     if (present_hadoop_user)
       builder.append(hadoop_user);
 
-    boolean present_hadoop_groups = true && (isSetHadoop_groups());
-    builder.append(present_hadoop_groups);
-    if (present_hadoop_groups)
-      builder.append(hadoop_groups);
-
     return builder.toHashCode();
   }
 
+  public int compareTo(Query other) {
+    if (!getClass().equals(other.getClass())) {
+      return getClass().getName().compareTo(other.getClass().getName());
+    }
+
+    int lastComparison = 0;
+    Query typedOther = (Query)other;
+
+    lastComparison = Boolean.valueOf(isSetQuery()).compareTo(typedOther.isSetQuery());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetQuery()) {
+      lastComparison = TBaseHelper.compareTo(this.query, typedOther.query);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetConfiguration()).compareTo(typedOther.isSetConfiguration());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetConfiguration()) {
+      lastComparison = TBaseHelper.compareTo(this.configuration, typedOther.configuration);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetHadoop_user()).compareTo(typedOther.isSetHadoop_user());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetHadoop_user()) {
+      lastComparison = TBaseHelper.compareTo(this.hadoop_user, typedOther.hadoop_user);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    return 0;
+  }
+
+  public _Fields fieldForId(int fieldId) {
+    return _Fields.findByThriftId(fieldId);
+  }
+
   public void read(TProtocol iprot) throws TException {
     TField field;
     iprot.readStructBegin();
@@ -387,16 +429,15 @@ public class Query implements TBase, java.io.Serializable, Cloneable {
       if (field.type == TType.STOP) { 
         break;
       }
-      switch (field.id)
-      {
-        case QUERY:
+      switch (field.id) {
+        case 1: // QUERY
           if (field.type == TType.STRING) {
             this.query = iprot.readString();
           } else { 
             TProtocolUtil.skip(iprot, field.type);
           }
           break;
-        case CONFIGURATION:
+        case 3: // CONFIGURATION
           if (field.type == TType.LIST) {
             {
               TList _list0 = iprot.readListBegin();
@@ -413,39 +454,20 @@ public class Query implements TBase, java.io.Serializable, Cloneable {
             TProtocolUtil.skip(iprot, field.type);
           }
           break;
-        case HADOOP_USER:
+        case 4: // HADOOP_USER
           if (field.type == TType.STRING) {
             this.hadoop_user = iprot.readString();
           } else { 
             TProtocolUtil.skip(iprot, field.type);
           }
           break;
-        case HADOOP_GROUPS:
-          if (field.type == TType.LIST) {
-            {
-              TList _list3 = iprot.readListBegin();
-              this.hadoop_groups = new ArrayList<String>(_list3.size);
-              for (int _i4 = 0; _i4 < _list3.size; ++_i4)
-              {
-                String _elem5;
-                _elem5 = iprot.readString();
-                this.hadoop_groups.add(_elem5);
-              }
-              iprot.readListEnd();
-            }
-          } else { 
-            TProtocolUtil.skip(iprot, field.type);
-          }
-          break;
         default:
           TProtocolUtil.skip(iprot, field.type);
-          break;
       }
       iprot.readFieldEnd();
     }
     iprot.readStructEnd();
 
-
     // check for required fields of primitive type, which can't be checked in the validate method
     validate();
   }
@@ -463,8 +485,9 @@ public class Query implements TBase, java.io.Serializable, Cloneable {
       oprot.writeFieldBegin(CONFIGURATION_FIELD_DESC);
       {
         oprot.writeListBegin(new TList(TType.STRING, this.configuration.size()));
-        for (String _iter6 : this.configuration)        {
-          oprot.writeString(_iter6);
+        for (String _iter3 : this.configuration)
+        {
+          oprot.writeString(_iter3);
         }
         oprot.writeListEnd();
       }
@@ -475,17 +498,6 @@ public class Query implements TBase, java.io.Serializable, Cloneable {
       oprot.writeString(this.hadoop_user);
       oprot.writeFieldEnd();
     }
-    if (this.hadoop_groups != null) {
-      oprot.writeFieldBegin(HADOOP_GROUPS_FIELD_DESC);
-      {
-        oprot.writeListBegin(new TList(TType.STRING, this.hadoop_groups.size()));
-        for (String _iter7 : this.hadoop_groups)        {
-          oprot.writeString(_iter7);
-        }
-        oprot.writeListEnd();
-      }
-      oprot.writeFieldEnd();
-    }
     oprot.writeFieldStop();
     oprot.writeStructEnd();
   }
@@ -518,21 +530,12 @@ public class Query implements TBase, java.io.Serializable, Cloneable {
       sb.append(this.hadoop_user);
     }
     first = false;
-    if (!first) sb.append(", ");
-    sb.append("hadoop_groups:");
-    if (this.hadoop_groups == null) {
-      sb.append("null");
-    } else {
-      sb.append(this.hadoop_groups);
-    }
-    first = false;
     sb.append(")");
     return sb.toString();
   }
 
   public void validate() throws TException {
     // check for required fields
-    // check that fields of type enum have valid values
   }
 
 }

+ 122 - 32
apps/beeswax/java/gen-java/com/cloudera/beeswax/api/QueryExplanation.java

@@ -10,32 +10,96 @@ import java.util.List;
 import java.util.ArrayList;
 import java.util.Map;
 import java.util.HashMap;
+import java.util.EnumMap;
 import java.util.Set;
 import java.util.HashSet;
+import java.util.EnumSet;
 import java.util.Collections;
-import org.apache.log4j.Logger;
+import java.util.BitSet;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.thrift.*;
+import org.apache.thrift.async.*;
 import org.apache.thrift.meta_data.*;
+import org.apache.thrift.transport.*;
 import org.apache.thrift.protocol.*;
 
-public class QueryExplanation implements TBase, java.io.Serializable, Cloneable {
+public class QueryExplanation implements TBase<QueryExplanation, QueryExplanation._Fields>, java.io.Serializable, Cloneable {
   private static final TStruct STRUCT_DESC = new TStruct("QueryExplanation");
+
   private static final TField TEXTUAL_FIELD_DESC = new TField("textual", TType.STRING, (short)1);
 
   public String textual;
-  public static final int TEXTUAL = 1;
 
-  private final Isset __isset = new Isset();
-  private static final class Isset implements java.io.Serializable {
+  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+  public enum _Fields implements TFieldIdEnum {
+    TEXTUAL((short)1, "textual");
+
+    private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+    static {
+      for (_Fields field : EnumSet.allOf(_Fields.class)) {
+        byName.put(field.getFieldName(), field);
+      }
+    }
+
+    /**
+     * Find the _Fields constant that matches fieldId, or null if its not found.
+     */
+    public static _Fields findByThriftId(int fieldId) {
+      switch(fieldId) {
+        case 1: // TEXTUAL
+          return TEXTUAL;
+        default:
+          return null;
+      }
+    }
+
+    /**
+     * Find the _Fields constant that matches fieldId, throwing an exception
+     * if it is not found.
+     */
+    public static _Fields findByThriftIdOrThrow(int fieldId) {
+      _Fields fields = findByThriftId(fieldId);
+      if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+      return fields;
+    }
+
+    /**
+     * Find the _Fields constant that matches name, or null if its not found.
+     */
+    public static _Fields findByName(String name) {
+      return byName.get(name);
+    }
+
+    private final short _thriftId;
+    private final String _fieldName;
+
+    _Fields(short thriftId, String fieldName) {
+      _thriftId = thriftId;
+      _fieldName = fieldName;
+    }
+
+    public short getThriftFieldId() {
+      return _thriftId;
+    }
+
+    public String getFieldName() {
+      return _fieldName;
+    }
   }
 
-  public static final Map<Integer, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new HashMap<Integer, FieldMetaData>() {{
-    put(TEXTUAL, new FieldMetaData("textual", TFieldRequirementType.DEFAULT, 
-        new FieldValueMetaData(TType.STRING)));
-  }});
+  // isset id assignments
 
+  public static final Map<_Fields, FieldMetaData> metaDataMap;
   static {
+    Map<_Fields, FieldMetaData> tmpMap = new EnumMap<_Fields, FieldMetaData>(_Fields.class);
+    tmpMap.put(_Fields.TEXTUAL, new FieldMetaData("textual", TFieldRequirementType.DEFAULT, 
+        new FieldValueMetaData(TType.STRING)));
+    metaDataMap = Collections.unmodifiableMap(tmpMap);
     FieldMetaData.addStructMetaDataMap(QueryExplanation.class, metaDataMap);
   }
 
@@ -58,24 +122,29 @@ public class QueryExplanation implements TBase, java.io.Serializable, Cloneable
     }
   }
 
-  @Override
-  public QueryExplanation clone() {
+  public QueryExplanation deepCopy() {
     return new QueryExplanation(this);
   }
 
+  @Override
+  public void clear() {
+    this.textual = null;
+  }
+
   public String getTextual() {
     return this.textual;
   }
 
-  public void setTextual(String textual) {
+  public QueryExplanation setTextual(String textual) {
     this.textual = textual;
+    return this;
   }
 
   public void unsetTextual() {
     this.textual = null;
   }
 
-  // Returns true if field textual is set (has been asigned a value) and false otherwise
+  /** Returns true if field textual is set (has been asigned a value) and false otherwise */
   public boolean isSetTextual() {
     return this.textual != null;
   }
@@ -86,8 +155,8 @@ public class QueryExplanation implements TBase, java.io.Serializable, Cloneable
     }
   }
 
-  public void setFieldValue(int fieldID, Object value) {
-    switch (fieldID) {
+  public void setFieldValue(_Fields field, Object value) {
+    switch (field) {
     case TEXTUAL:
       if (value == null) {
         unsetTextual();
@@ -96,29 +165,29 @@ public class QueryExplanation implements TBase, java.io.Serializable, Cloneable
       }
       break;
 
-    default:
-      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
     }
   }
 
-  public Object getFieldValue(int fieldID) {
-    switch (fieldID) {
+  public Object getFieldValue(_Fields field) {
+    switch (field) {
     case TEXTUAL:
       return getTextual();
 
-    default:
-      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
     }
+    throw new IllegalStateException();
   }
 
-  // Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise
-  public boolean isSet(int fieldID) {
-    switch (fieldID) {
+  /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
+  public boolean isSet(_Fields field) {
+    if (field == null) {
+      throw new IllegalArgumentException();
+    }
+
+    switch (field) {
     case TEXTUAL:
       return isSetTextual();
-    default:
-      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
     }
+    throw new IllegalStateException();
   }
 
   @Override
@@ -158,6 +227,31 @@ public class QueryExplanation implements TBase, java.io.Serializable, Cloneable
     return builder.toHashCode();
   }
 
+  public int compareTo(QueryExplanation other) {
+    if (!getClass().equals(other.getClass())) {
+      return getClass().getName().compareTo(other.getClass().getName());
+    }
+
+    int lastComparison = 0;
+    QueryExplanation typedOther = (QueryExplanation)other;
+
+    lastComparison = Boolean.valueOf(isSetTextual()).compareTo(typedOther.isSetTextual());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetTextual()) {
+      lastComparison = TBaseHelper.compareTo(this.textual, typedOther.textual);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    return 0;
+  }
+
+  public _Fields fieldForId(int fieldId) {
+    return _Fields.findByThriftId(fieldId);
+  }
+
   public void read(TProtocol iprot) throws TException {
     TField field;
     iprot.readStructBegin();
@@ -167,9 +261,8 @@ public class QueryExplanation implements TBase, java.io.Serializable, Cloneable
       if (field.type == TType.STOP) { 
         break;
       }
-      switch (field.id)
-      {
-        case TEXTUAL:
+      switch (field.id) {
+        case 1: // TEXTUAL
           if (field.type == TType.STRING) {
             this.textual = iprot.readString();
           } else { 
@@ -178,13 +271,11 @@ public class QueryExplanation implements TBase, java.io.Serializable, Cloneable
           break;
         default:
           TProtocolUtil.skip(iprot, field.type);
-          break;
       }
       iprot.readFieldEnd();
     }
     iprot.readStructEnd();
 
-
     // check for required fields of primitive type, which can't be checked in the validate method
     validate();
   }
@@ -220,7 +311,6 @@ public class QueryExplanation implements TBase, java.io.Serializable, Cloneable
 
   public void validate() throws TException {
     // check for required fields
-    // check that fields of type enum have valid values
   }
 
 }

+ 142 - 38
apps/beeswax/java/gen-java/com/cloudera/beeswax/api/QueryHandle.java

@@ -10,37 +10,103 @@ import java.util.List;
 import java.util.ArrayList;
 import java.util.Map;
 import java.util.HashMap;
+import java.util.EnumMap;
 import java.util.Set;
 import java.util.HashSet;
+import java.util.EnumSet;
 import java.util.Collections;
-import org.apache.log4j.Logger;
+import java.util.BitSet;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.thrift.*;
+import org.apache.thrift.async.*;
 import org.apache.thrift.meta_data.*;
+import org.apache.thrift.transport.*;
 import org.apache.thrift.protocol.*;
 
-public class QueryHandle implements TBase, java.io.Serializable, Cloneable {
+public class QueryHandle implements TBase<QueryHandle, QueryHandle._Fields>, java.io.Serializable, Cloneable {
   private static final TStruct STRUCT_DESC = new TStruct("QueryHandle");
+
   private static final TField ID_FIELD_DESC = new TField("id", TType.STRING, (short)1);
   private static final TField LOG_CONTEXT_FIELD_DESC = new TField("log_context", TType.STRING, (short)2);
 
   public String id;
-  public static final int ID = 1;
   public String log_context;
-  public static final int LOG_CONTEXT = 2;
 
-  private final Isset __isset = new Isset();
-  private static final class Isset implements java.io.Serializable {
+  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+  public enum _Fields implements TFieldIdEnum {
+    ID((short)1, "id"),
+    LOG_CONTEXT((short)2, "log_context");
+
+    private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+    static {
+      for (_Fields field : EnumSet.allOf(_Fields.class)) {
+        byName.put(field.getFieldName(), field);
+      }
+    }
+
+    /**
+     * Find the _Fields constant that matches fieldId, or null if its not found.
+     */
+    public static _Fields findByThriftId(int fieldId) {
+      switch(fieldId) {
+        case 1: // ID
+          return ID;
+        case 2: // LOG_CONTEXT
+          return LOG_CONTEXT;
+        default:
+          return null;
+      }
+    }
+
+    /**
+     * Find the _Fields constant that matches fieldId, throwing an exception
+     * if it is not found.
+     */
+    public static _Fields findByThriftIdOrThrow(int fieldId) {
+      _Fields fields = findByThriftId(fieldId);
+      if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+      return fields;
+    }
+
+    /**
+     * Find the _Fields constant that matches name, or null if its not found.
+     */
+    public static _Fields findByName(String name) {
+      return byName.get(name);
+    }
+
+    private final short _thriftId;
+    private final String _fieldName;
+
+    _Fields(short thriftId, String fieldName) {
+      _thriftId = thriftId;
+      _fieldName = fieldName;
+    }
+
+    public short getThriftFieldId() {
+      return _thriftId;
+    }
+
+    public String getFieldName() {
+      return _fieldName;
+    }
   }
 
-  public static final Map<Integer, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new HashMap<Integer, FieldMetaData>() {{
-    put(ID, new FieldMetaData("id", TFieldRequirementType.DEFAULT, 
-        new FieldValueMetaData(TType.STRING)));
-    put(LOG_CONTEXT, new FieldMetaData("log_context", TFieldRequirementType.DEFAULT, 
-        new FieldValueMetaData(TType.STRING)));
-  }});
+  // isset id assignments
 
+  public static final Map<_Fields, FieldMetaData> metaDataMap;
   static {
+    Map<_Fields, FieldMetaData> tmpMap = new EnumMap<_Fields, FieldMetaData>(_Fields.class);
+    tmpMap.put(_Fields.ID, new FieldMetaData("id", TFieldRequirementType.DEFAULT, 
+        new FieldValueMetaData(TType.STRING)));
+    tmpMap.put(_Fields.LOG_CONTEXT, new FieldMetaData("log_context", TFieldRequirementType.DEFAULT, 
+        new FieldValueMetaData(TType.STRING        , "LogContextId")));
+    metaDataMap = Collections.unmodifiableMap(tmpMap);
     FieldMetaData.addStructMetaDataMap(QueryHandle.class, metaDataMap);
   }
 
@@ -68,24 +134,30 @@ public class QueryHandle implements TBase, java.io.Serializable, Cloneable {
     }
   }
 
-  @Override
-  public QueryHandle clone() {
+  public QueryHandle deepCopy() {
     return new QueryHandle(this);
   }
 
+  @Override
+  public void clear() {
+    this.id = null;
+    this.log_context = null;
+  }
+
   public String getId() {
     return this.id;
   }
 
-  public void setId(String id) {
+  public QueryHandle setId(String id) {
     this.id = id;
+    return this;
   }
 
   public void unsetId() {
     this.id = null;
   }
 
-  // Returns true if field id is set (has been asigned a value) and false otherwise
+  /** Returns true if field id is set (has been asigned a value) and false otherwise */
   public boolean isSetId() {
     return this.id != null;
   }
@@ -100,15 +172,16 @@ public class QueryHandle implements TBase, java.io.Serializable, Cloneable {
     return this.log_context;
   }
 
-  public void setLog_context(String log_context) {
+  public QueryHandle setLog_context(String log_context) {
     this.log_context = log_context;
+    return this;
   }
 
   public void unsetLog_context() {
     this.log_context = null;
   }
 
-  // Returns true if field log_context is set (has been asigned a value) and false otherwise
+  /** Returns true if field log_context is set (has been asigned a value) and false otherwise */
   public boolean isSetLog_context() {
     return this.log_context != null;
   }
@@ -119,8 +192,8 @@ public class QueryHandle implements TBase, java.io.Serializable, Cloneable {
     }
   }
 
-  public void setFieldValue(int fieldID, Object value) {
-    switch (fieldID) {
+  public void setFieldValue(_Fields field, Object value) {
+    switch (field) {
     case ID:
       if (value == null) {
         unsetId();
@@ -137,34 +210,34 @@ public class QueryHandle implements TBase, java.io.Serializable, Cloneable {
       }
       break;
 
-    default:
-      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
     }
   }
 
-  public Object getFieldValue(int fieldID) {
-    switch (fieldID) {
+  public Object getFieldValue(_Fields field) {
+    switch (field) {
     case ID:
       return getId();
 
     case LOG_CONTEXT:
       return getLog_context();
 
-    default:
-      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
     }
+    throw new IllegalStateException();
   }
 
-  // Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise
-  public boolean isSet(int fieldID) {
-    switch (fieldID) {
+  /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
+  public boolean isSet(_Fields field) {
+    if (field == null) {
+      throw new IllegalArgumentException();
+    }
+
+    switch (field) {
     case ID:
       return isSetId();
     case LOG_CONTEXT:
       return isSetLog_context();
-    default:
-      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
     }
+    throw new IllegalStateException();
   }
 
   @Override
@@ -218,6 +291,41 @@ public class QueryHandle implements TBase, java.io.Serializable, Cloneable {
     return builder.toHashCode();
   }
 
+  public int compareTo(QueryHandle other) {
+    if (!getClass().equals(other.getClass())) {
+      return getClass().getName().compareTo(other.getClass().getName());
+    }
+
+    int lastComparison = 0;
+    QueryHandle typedOther = (QueryHandle)other;
+
+    lastComparison = Boolean.valueOf(isSetId()).compareTo(typedOther.isSetId());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetId()) {
+      lastComparison = TBaseHelper.compareTo(this.id, typedOther.id);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetLog_context()).compareTo(typedOther.isSetLog_context());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetLog_context()) {
+      lastComparison = TBaseHelper.compareTo(this.log_context, typedOther.log_context);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    return 0;
+  }
+
+  public _Fields fieldForId(int fieldId) {
+    return _Fields.findByThriftId(fieldId);
+  }
+
   public void read(TProtocol iprot) throws TException {
     TField field;
     iprot.readStructBegin();
@@ -227,16 +335,15 @@ public class QueryHandle implements TBase, java.io.Serializable, Cloneable {
       if (field.type == TType.STOP) { 
         break;
       }
-      switch (field.id)
-      {
-        case ID:
+      switch (field.id) {
+        case 1: // ID
           if (field.type == TType.STRING) {
             this.id = iprot.readString();
           } else { 
             TProtocolUtil.skip(iprot, field.type);
           }
           break;
-        case LOG_CONTEXT:
+        case 2: // LOG_CONTEXT
           if (field.type == TType.STRING) {
             this.log_context = iprot.readString();
           } else { 
@@ -245,13 +352,11 @@ public class QueryHandle implements TBase, java.io.Serializable, Cloneable {
           break;
         default:
           TProtocolUtil.skip(iprot, field.type);
-          break;
       }
       iprot.readFieldEnd();
     }
     iprot.readStructEnd();
 
-
     // check for required fields of primitive type, which can't be checked in the validate method
     validate();
   }
@@ -300,7 +405,6 @@ public class QueryHandle implements TBase, java.io.Serializable, Cloneable {
 
   public void validate() throws TException {
     // check for required fields
-    // check that fields of type enum have valid values
   }
 
 }

+ 103 - 24
apps/beeswax/java/gen-java/com/cloudera/beeswax/api/QueryNotFoundException.java

@@ -10,22 +10,87 @@ import java.util.List;
 import java.util.ArrayList;
 import java.util.Map;
 import java.util.HashMap;
+import java.util.EnumMap;
 import java.util.Set;
 import java.util.HashSet;
+import java.util.EnumSet;
 import java.util.Collections;
-import org.apache.log4j.Logger;
+import java.util.BitSet;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.thrift.*;
+import org.apache.thrift.async.*;
 import org.apache.thrift.meta_data.*;
+import org.apache.thrift.transport.*;
 import org.apache.thrift.protocol.*;
 
-public class QueryNotFoundException extends Exception implements TBase, java.io.Serializable, Cloneable {
+public class QueryNotFoundException extends Exception implements TBase<QueryNotFoundException, QueryNotFoundException._Fields>, java.io.Serializable, Cloneable {
   private static final TStruct STRUCT_DESC = new TStruct("QueryNotFoundException");
 
-  public static final Map<Integer, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new HashMap<Integer, FieldMetaData>() {{
-  }});
 
+
+  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+  public enum _Fields implements TFieldIdEnum {
+;
+
+    private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+    static {
+      for (_Fields field : EnumSet.allOf(_Fields.class)) {
+        byName.put(field.getFieldName(), field);
+      }
+    }
+
+    /**
+     * Find the _Fields constant that matches fieldId, or null if its not found.
+     */
+    public static _Fields findByThriftId(int fieldId) {
+      switch(fieldId) {
+        default:
+          return null;
+      }
+    }
+
+    /**
+     * Find the _Fields constant that matches fieldId, throwing an exception
+     * if it is not found.
+     */
+    public static _Fields findByThriftIdOrThrow(int fieldId) {
+      _Fields fields = findByThriftId(fieldId);
+      if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+      return fields;
+    }
+
+    /**
+     * Find the _Fields constant that matches name, or null if its not found.
+     */
+    public static _Fields findByName(String name) {
+      return byName.get(name);
+    }
+
+    private final short _thriftId;
+    private final String _fieldName;
+
+    _Fields(short thriftId, String fieldName) {
+      _thriftId = thriftId;
+      _fieldName = fieldName;
+    }
+
+    public short getThriftFieldId() {
+      return _thriftId;
+    }
+
+    public String getFieldName() {
+      return _fieldName;
+    }
+  }
+  public static final Map<_Fields, FieldMetaData> metaDataMap;
   static {
+    Map<_Fields, FieldMetaData> tmpMap = new EnumMap<_Fields, FieldMetaData>(_Fields.class);
+    metaDataMap = Collections.unmodifiableMap(tmpMap);
     FieldMetaData.addStructMetaDataMap(QueryNotFoundException.class, metaDataMap);
   }
 
@@ -38,31 +103,34 @@ public class QueryNotFoundException extends Exception implements TBase, java.io.
   public QueryNotFoundException(QueryNotFoundException other) {
   }
 
-  @Override
-  public QueryNotFoundException clone() {
+  public QueryNotFoundException deepCopy() {
     return new QueryNotFoundException(this);
   }
 
-  public void setFieldValue(int fieldID, Object value) {
-    switch (fieldID) {
-    default:
-      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
+  @Override
+  public void clear() {
+  }
+
+  public void setFieldValue(_Fields field, Object value) {
+    switch (field) {
     }
   }
 
-  public Object getFieldValue(int fieldID) {
-    switch (fieldID) {
-    default:
-      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
+  public Object getFieldValue(_Fields field) {
+    switch (field) {
     }
+    throw new IllegalStateException();
   }
 
-  // Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise
-  public boolean isSet(int fieldID) {
-    switch (fieldID) {
-    default:
-      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
+  /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
+  public boolean isSet(_Fields field) {
+    if (field == null) {
+      throw new IllegalArgumentException();
+    }
+
+    switch (field) {
     }
+    throw new IllegalStateException();
   }
 
   @Override
@@ -88,6 +156,21 @@ public class QueryNotFoundException extends Exception implements TBase, java.io.
     return builder.toHashCode();
   }
 
+  public int compareTo(QueryNotFoundException other) {
+    if (!getClass().equals(other.getClass())) {
+      return getClass().getName().compareTo(other.getClass().getName());
+    }
+
+    int lastComparison = 0;
+    QueryNotFoundException typedOther = (QueryNotFoundException)other;
+
+    return 0;
+  }
+
+  public _Fields fieldForId(int fieldId) {
+    return _Fields.findByThriftId(fieldId);
+  }
+
   public void read(TProtocol iprot) throws TException {
     TField field;
     iprot.readStructBegin();
@@ -97,17 +180,14 @@ public class QueryNotFoundException extends Exception implements TBase, java.io.
       if (field.type == TType.STOP) { 
         break;
       }
-      switch (field.id)
-      {
+      switch (field.id) {
         default:
           TProtocolUtil.skip(iprot, field.type);
-          break;
       }
       iprot.readFieldEnd();
     }
     iprot.readStructEnd();
 
-
     // check for required fields of primitive type, which can't be checked in the validate method
     validate();
   }
@@ -131,7 +211,6 @@ public class QueryNotFoundException extends Exception implements TBase, java.io.
 
   public void validate() throws TException {
     // check for required fields
-    // check that fields of type enum have valid values
   }
 
 }

+ 42 - 26
apps/beeswax/java/gen-java/com/cloudera/beeswax/api/QueryState.java

@@ -6,35 +6,51 @@
 package com.cloudera.beeswax.api;
 
 
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Collections;
-import org.apache.thrift.IntRangeSet;
 import java.util.Map;
 import java.util.HashMap;
+import org.apache.thrift.TEnum;
 
-public class QueryState {
-  public static final int CREATED = 0;
-  public static final int INITIALIZED = 1;
-  public static final int COMPILED = 2;
-  public static final int RUNNING = 3;
-  public static final int FINISHED = 4;
-  public static final int EXCEPTION = 5;
+public enum QueryState implements TEnum {
+  CREATED(0),
+  INITIALIZED(1),
+  COMPILED(2),
+  RUNNING(3),
+  FINISHED(4),
+  EXCEPTION(5);
 
-  public static final IntRangeSet VALID_VALUES = new IntRangeSet(
-    CREATED, 
-    INITIALIZED, 
-    COMPILED, 
-    RUNNING, 
-    FINISHED, 
-    EXCEPTION );
+  private final int value;
 
-  public static final Map<Integer, String> VALUES_TO_NAMES = new HashMap<Integer, String>() {{
-    put(CREATED, "CREATED");
-    put(INITIALIZED, "INITIALIZED");
-    put(COMPILED, "COMPILED");
-    put(RUNNING, "RUNNING");
-    put(FINISHED, "FINISHED");
-    put(EXCEPTION, "EXCEPTION");
-  }};
+  private QueryState(int value) {
+    this.value = value;
+  }
+
+  /**
+   * Get the integer value of this enum value, as defined in the Thrift IDL.
+   */
+  public int getValue() {
+    return value;
+  }
+
+  /**
+   * Find a the enum type by its integer value, as defined in the Thrift IDL.
+   * @return null if the value is not found.
+   */
+  public static QueryState findByValue(int value) { 
+    switch (value) {
+      case 0:
+        return CREATED;
+      case 1:
+        return INITIALIZED;
+      case 2:
+        return COMPILED;
+      case 3:
+        return RUNNING;
+      case 4:
+        return FINISHED;
+      case 5:
+        return EXCEPTION;
+      default:
+        return null;
+    }
+  }
 }

+ 0 - 31
apps/beeswax/java/gen-java/com/cloudera/beeswax/api/QueryType.java

@@ -1,31 +0,0 @@
-/**
- * Autogenerated by Thrift
- *
- * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
- */
-package com.cloudera.beeswax.api;
-
-
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Collections;
-import org.apache.thrift.IntRangeSet;
-import java.util.Map;
-import java.util.HashMap;
-
-public class QueryType {
-  public static final int ANY = 0;
-  public static final int DDL = 1;
-  public static final int QUERY = 2;
-
-  public static final IntRangeSet VALID_VALUES = new IntRangeSet(
-    ANY, 
-    DDL, 
-    QUERY );
-
-  public static final Map<Integer, String> VALUES_TO_NAMES = new HashMap<Integer, String>() {{
-    put(ANY, "ANY");
-    put(DDL, "DDL");
-    put(QUERY, "QUERY");
-  }};
-}

+ 244 - 93
apps/beeswax/java/gen-java/com/cloudera/beeswax/api/Results.java

@@ -10,17 +10,26 @@ import java.util.List;
 import java.util.ArrayList;
 import java.util.Map;
 import java.util.HashMap;
+import java.util.EnumMap;
 import java.util.Set;
 import java.util.HashSet;
+import java.util.EnumSet;
 import java.util.Collections;
-import org.apache.log4j.Logger;
+import java.util.BitSet;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.thrift.*;
+import org.apache.thrift.async.*;
 import org.apache.thrift.meta_data.*;
+import org.apache.thrift.transport.*;
 import org.apache.thrift.protocol.*;
 
-public class Results implements TBase, java.io.Serializable, Cloneable {
+public class Results implements TBase<Results, Results._Fields>, java.io.Serializable, Cloneable {
   private static final TStruct STRUCT_DESC = new TStruct("Results");
+
   private static final TField READY_FIELD_DESC = new TField("ready", TType.BOOL, (short)1);
   private static final TField COLUMNS_FIELD_DESC = new TField("columns", TType.LIST, (short)2);
   private static final TField DATA_FIELD_DESC = new TField("data", TType.LIST, (short)3);
@@ -28,39 +37,103 @@ public class Results implements TBase, java.io.Serializable, Cloneable {
   private static final TField HAS_MORE_FIELD_DESC = new TField("has_more", TType.BOOL, (short)5);
 
   public boolean ready;
-  public static final int READY = 1;
   public List<String> columns;
-  public static final int COLUMNS = 2;
   public List<String> data;
-  public static final int DATA = 3;
   public long start_row;
-  public static final int START_ROW = 4;
   public boolean has_more;
-  public static final int HAS_MORE = 5;
 
-  private final Isset __isset = new Isset();
-  private static final class Isset implements java.io.Serializable {
-    public boolean ready = false;
-    public boolean start_row = false;
-    public boolean has_more = false;
+  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+  public enum _Fields implements TFieldIdEnum {
+    READY((short)1, "ready"),
+    COLUMNS((short)2, "columns"),
+    DATA((short)3, "data"),
+    START_ROW((short)4, "start_row"),
+    HAS_MORE((short)5, "has_more");
+
+    private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+    static {
+      for (_Fields field : EnumSet.allOf(_Fields.class)) {
+        byName.put(field.getFieldName(), field);
+      }
+    }
+
+    /**
+     * Find the _Fields constant that matches fieldId, or null if its not found.
+     */
+    public static _Fields findByThriftId(int fieldId) {
+      switch(fieldId) {
+        case 1: // READY
+          return READY;
+        case 2: // COLUMNS
+          return COLUMNS;
+        case 3: // DATA
+          return DATA;
+        case 4: // START_ROW
+          return START_ROW;
+        case 5: // HAS_MORE
+          return HAS_MORE;
+        default:
+          return null;
+      }
+    }
+
+    /**
+     * Find the _Fields constant that matches fieldId, throwing an exception
+     * if it is not found.
+     */
+    public static _Fields findByThriftIdOrThrow(int fieldId) {
+      _Fields fields = findByThriftId(fieldId);
+      if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+      return fields;
+    }
+
+    /**
+     * Find the _Fields constant that matches name, or null if its not found.
+     */
+    public static _Fields findByName(String name) {
+      return byName.get(name);
+    }
+
+    private final short _thriftId;
+    private final String _fieldName;
+
+    _Fields(short thriftId, String fieldName) {
+      _thriftId = thriftId;
+      _fieldName = fieldName;
+    }
+
+    public short getThriftFieldId() {
+      return _thriftId;
+    }
+
+    public String getFieldName() {
+      return _fieldName;
+    }
   }
 
-  public static final Map<Integer, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new HashMap<Integer, FieldMetaData>() {{
-    put(READY, new FieldMetaData("ready", TFieldRequirementType.DEFAULT, 
+  // isset id assignments
+  private static final int __READY_ISSET_ID = 0;
+  private static final int __START_ROW_ISSET_ID = 1;
+  private static final int __HAS_MORE_ISSET_ID = 2;
+  private BitSet __isset_bit_vector = new BitSet(3);
+
+  public static final Map<_Fields, FieldMetaData> metaDataMap;
+  static {
+    Map<_Fields, FieldMetaData> tmpMap = new EnumMap<_Fields, FieldMetaData>(_Fields.class);
+    tmpMap.put(_Fields.READY, new FieldMetaData("ready", TFieldRequirementType.DEFAULT, 
         new FieldValueMetaData(TType.BOOL)));
-    put(COLUMNS, new FieldMetaData("columns", TFieldRequirementType.DEFAULT, 
+    tmpMap.put(_Fields.COLUMNS, new FieldMetaData("columns", TFieldRequirementType.DEFAULT, 
         new ListMetaData(TType.LIST, 
             new FieldValueMetaData(TType.STRING))));
-    put(DATA, new FieldMetaData("data", TFieldRequirementType.DEFAULT, 
+    tmpMap.put(_Fields.DATA, new FieldMetaData("data", TFieldRequirementType.DEFAULT, 
         new ListMetaData(TType.LIST, 
             new FieldValueMetaData(TType.STRING))));
-    put(START_ROW, new FieldMetaData("start_row", TFieldRequirementType.DEFAULT, 
+    tmpMap.put(_Fields.START_ROW, new FieldMetaData("start_row", TFieldRequirementType.DEFAULT, 
         new FieldValueMetaData(TType.I64)));
-    put(HAS_MORE, new FieldMetaData("has_more", TFieldRequirementType.DEFAULT, 
+    tmpMap.put(_Fields.HAS_MORE, new FieldMetaData("has_more", TFieldRequirementType.DEFAULT, 
         new FieldValueMetaData(TType.BOOL)));
-  }});
-
-  static {
+    metaDataMap = Collections.unmodifiableMap(tmpMap);
     FieldMetaData.addStructMetaDataMap(Results.class, metaDataMap);
   }
 
@@ -76,20 +149,21 @@ public class Results implements TBase, java.io.Serializable, Cloneable {
   {
     this();
     this.ready = ready;
-    this.__isset.ready = true;
+    setReadyIsSet(true);
     this.columns = columns;
     this.data = data;
     this.start_row = start_row;
-    this.__isset.start_row = true;
+    setStart_rowIsSet(true);
     this.has_more = has_more;
-    this.__isset.has_more = true;
+    setHas_moreIsSet(true);
   }
 
   /**
    * Performs a deep copy on <i>other</i>.
    */
   public Results(Results other) {
-    __isset.ready = other.__isset.ready;
+    __isset_bit_vector.clear();
+    __isset_bit_vector.or(other.__isset_bit_vector);
     this.ready = other.ready;
     if (other.isSetColumns()) {
       List<String> __this__columns = new ArrayList<String>();
@@ -105,37 +179,47 @@ public class Results implements TBase, java.io.Serializable, Cloneable {
       }
       this.data = __this__data;
     }
-    __isset.start_row = other.__isset.start_row;
     this.start_row = other.start_row;
-    __isset.has_more = other.__isset.has_more;
     this.has_more = other.has_more;
   }
 
-  @Override
-  public Results clone() {
+  public Results deepCopy() {
     return new Results(this);
   }
 
+  @Override
+  public void clear() {
+    setReadyIsSet(false);
+    this.ready = false;
+    this.columns = null;
+    this.data = null;
+    setStart_rowIsSet(false);
+    this.start_row = 0;
+    setHas_moreIsSet(false);
+    this.has_more = false;
+  }
+
   public boolean isReady() {
     return this.ready;
   }
 
-  public void setReady(boolean ready) {
+  public Results setReady(boolean ready) {
     this.ready = ready;
-    this.__isset.ready = true;
+    setReadyIsSet(true);
+    return this;
   }
 
   public void unsetReady() {
-    this.__isset.ready = false;
+    __isset_bit_vector.clear(__READY_ISSET_ID);
   }
 
-  // Returns true if field ready is set (has been asigned a value) and false otherwise
+  /** Returns true if field ready is set (has been asigned a value) and false otherwise */
   public boolean isSetReady() {
-    return this.__isset.ready;
+    return __isset_bit_vector.get(__READY_ISSET_ID);
   }
 
   public void setReadyIsSet(boolean value) {
-    this.__isset.ready = value;
+    __isset_bit_vector.set(__READY_ISSET_ID, value);
   }
 
   public int getColumnsSize() {
@@ -157,15 +241,16 @@ public class Results implements TBase, java.io.Serializable, Cloneable {
     return this.columns;
   }
 
-  public void setColumns(List<String> columns) {
+  public Results setColumns(List<String> columns) {
     this.columns = columns;
+    return this;
   }
 
   public void unsetColumns() {
     this.columns = null;
   }
 
-  // Returns true if field columns is set (has been asigned a value) and false otherwise
+  /** Returns true if field columns is set (has been asigned a value) and false otherwise */
   public boolean isSetColumns() {
     return this.columns != null;
   }
@@ -195,15 +280,16 @@ public class Results implements TBase, java.io.Serializable, Cloneable {
     return this.data;
   }
 
-  public void setData(List<String> data) {
+  public Results setData(List<String> data) {
     this.data = data;
+    return this;
   }
 
   public void unsetData() {
     this.data = null;
   }
 
-  // Returns true if field data is set (has been asigned a value) and false otherwise
+  /** Returns true if field data is set (has been asigned a value) and false otherwise */
   public boolean isSetData() {
     return this.data != null;
   }
@@ -218,48 +304,50 @@ public class Results implements TBase, java.io.Serializable, Cloneable {
     return this.start_row;
   }
 
-  public void setStart_row(long start_row) {
+  public Results setStart_row(long start_row) {
     this.start_row = start_row;
-    this.__isset.start_row = true;
+    setStart_rowIsSet(true);
+    return this;
   }
 
   public void unsetStart_row() {
-    this.__isset.start_row = false;
+    __isset_bit_vector.clear(__START_ROW_ISSET_ID);
   }
 
-  // Returns true if field start_row is set (has been asigned a value) and false otherwise
+  /** Returns true if field start_row is set (has been asigned a value) and false otherwise */
   public boolean isSetStart_row() {
-    return this.__isset.start_row;
+    return __isset_bit_vector.get(__START_ROW_ISSET_ID);
   }
 
   public void setStart_rowIsSet(boolean value) {
-    this.__isset.start_row = value;
+    __isset_bit_vector.set(__START_ROW_ISSET_ID, value);
   }
 
   public boolean isHas_more() {
     return this.has_more;
   }
 
-  public void setHas_more(boolean has_more) {
+  public Results setHas_more(boolean has_more) {
     this.has_more = has_more;
-    this.__isset.has_more = true;
+    setHas_moreIsSet(true);
+    return this;
   }
 
   public void unsetHas_more() {
-    this.__isset.has_more = false;
+    __isset_bit_vector.clear(__HAS_MORE_ISSET_ID);
   }
 
-  // Returns true if field has_more is set (has been asigned a value) and false otherwise
+  /** Returns true if field has_more is set (has been asigned a value) and false otherwise */
   public boolean isSetHas_more() {
-    return this.__isset.has_more;
+    return __isset_bit_vector.get(__HAS_MORE_ISSET_ID);
   }
 
   public void setHas_moreIsSet(boolean value) {
-    this.__isset.has_more = value;
+    __isset_bit_vector.set(__HAS_MORE_ISSET_ID, value);
   }
 
-  public void setFieldValue(int fieldID, Object value) {
-    switch (fieldID) {
+  public void setFieldValue(_Fields field, Object value) {
+    switch (field) {
     case READY:
       if (value == null) {
         unsetReady();
@@ -300,13 +388,11 @@ public class Results implements TBase, java.io.Serializable, Cloneable {
       }
       break;
 
-    default:
-      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
     }
   }
 
-  public Object getFieldValue(int fieldID) {
-    switch (fieldID) {
+  public Object getFieldValue(_Fields field) {
+    switch (field) {
     case READY:
       return new Boolean(isReady());
 
@@ -322,14 +408,17 @@ public class Results implements TBase, java.io.Serializable, Cloneable {
     case HAS_MORE:
       return new Boolean(isHas_more());
 
-    default:
-      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
     }
+    throw new IllegalStateException();
   }
 
-  // Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise
-  public boolean isSet(int fieldID) {
-    switch (fieldID) {
+  /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
+  public boolean isSet(_Fields field) {
+    if (field == null) {
+      throw new IllegalArgumentException();
+    }
+
+    switch (field) {
     case READY:
       return isSetReady();
     case COLUMNS:
@@ -340,9 +429,8 @@ public class Results implements TBase, java.io.Serializable, Cloneable {
       return isSetStart_row();
     case HAS_MORE:
       return isSetHas_more();
-    default:
-      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
     }
+    throw new IllegalStateException();
   }
 
   @Override
@@ -438,6 +526,71 @@ public class Results implements TBase, java.io.Serializable, Cloneable {
     return builder.toHashCode();
   }
 
+  public int compareTo(Results other) {
+    if (!getClass().equals(other.getClass())) {
+      return getClass().getName().compareTo(other.getClass().getName());
+    }
+
+    int lastComparison = 0;
+    Results typedOther = (Results)other;
+
+    lastComparison = Boolean.valueOf(isSetReady()).compareTo(typedOther.isSetReady());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetReady()) {
+      lastComparison = TBaseHelper.compareTo(this.ready, typedOther.ready);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetColumns()).compareTo(typedOther.isSetColumns());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetColumns()) {
+      lastComparison = TBaseHelper.compareTo(this.columns, typedOther.columns);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetData()).compareTo(typedOther.isSetData());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetData()) {
+      lastComparison = TBaseHelper.compareTo(this.data, typedOther.data);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetStart_row()).compareTo(typedOther.isSetStart_row());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetStart_row()) {
+      lastComparison = TBaseHelper.compareTo(this.start_row, typedOther.start_row);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetHas_more()).compareTo(typedOther.isSetHas_more());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetHas_more()) {
+      lastComparison = TBaseHelper.compareTo(this.has_more, typedOther.has_more);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    return 0;
+  }
+
+  public _Fields fieldForId(int fieldId) {
+    return _Fields.findByThriftId(fieldId);
+  }
+
   public void read(TProtocol iprot) throws TException {
     TField field;
     iprot.readStructBegin();
@@ -447,26 +600,25 @@ public class Results implements TBase, java.io.Serializable, Cloneable {
       if (field.type == TType.STOP) { 
         break;
       }
-      switch (field.id)
-      {
-        case READY:
+      switch (field.id) {
+        case 1: // READY
           if (field.type == TType.BOOL) {
             this.ready = iprot.readBool();
-            this.__isset.ready = true;
+            setReadyIsSet(true);
           } else { 
             TProtocolUtil.skip(iprot, field.type);
           }
           break;
-        case COLUMNS:
+        case 2: // COLUMNS
           if (field.type == TType.LIST) {
             {
-              TList _list8 = iprot.readListBegin();
-              this.columns = new ArrayList<String>(_list8.size);
-              for (int _i9 = 0; _i9 < _list8.size; ++_i9)
+              TList _list4 = iprot.readListBegin();
+              this.columns = new ArrayList<String>(_list4.size);
+              for (int _i5 = 0; _i5 < _list4.size; ++_i5)
               {
-                String _elem10;
-                _elem10 = iprot.readString();
-                this.columns.add(_elem10);
+                String _elem6;
+                _elem6 = iprot.readString();
+                this.columns.add(_elem6);
               }
               iprot.readListEnd();
             }
@@ -474,16 +626,16 @@ public class Results implements TBase, java.io.Serializable, Cloneable {
             TProtocolUtil.skip(iprot, field.type);
           }
           break;
-        case DATA:
+        case 3: // DATA
           if (field.type == TType.LIST) {
             {
-              TList _list11 = iprot.readListBegin();
-              this.data = new ArrayList<String>(_list11.size);
-              for (int _i12 = 0; _i12 < _list11.size; ++_i12)
+              TList _list7 = iprot.readListBegin();
+              this.data = new ArrayList<String>(_list7.size);
+              for (int _i8 = 0; _i8 < _list7.size; ++_i8)
               {
-                String _elem13;
-                _elem13 = iprot.readString();
-                this.data.add(_elem13);
+                String _elem9;
+                _elem9 = iprot.readString();
+                this.data.add(_elem9);
               }
               iprot.readListEnd();
             }
@@ -491,31 +643,29 @@ public class Results implements TBase, java.io.Serializable, Cloneable {
             TProtocolUtil.skip(iprot, field.type);
           }
           break;
-        case START_ROW:
+        case 4: // START_ROW
           if (field.type == TType.I64) {
             this.start_row = iprot.readI64();
-            this.__isset.start_row = true;
+            setStart_rowIsSet(true);
           } else { 
             TProtocolUtil.skip(iprot, field.type);
           }
           break;
-        case HAS_MORE:
+        case 5: // HAS_MORE
           if (field.type == TType.BOOL) {
             this.has_more = iprot.readBool();
-            this.__isset.has_more = true;
+            setHas_moreIsSet(true);
           } else { 
             TProtocolUtil.skip(iprot, field.type);
           }
           break;
         default:
           TProtocolUtil.skip(iprot, field.type);
-          break;
       }
       iprot.readFieldEnd();
     }
     iprot.readStructEnd();
 
-
     // check for required fields of primitive type, which can't be checked in the validate method
     validate();
   }
@@ -531,8 +681,9 @@ public class Results implements TBase, java.io.Serializable, Cloneable {
       oprot.writeFieldBegin(COLUMNS_FIELD_DESC);
       {
         oprot.writeListBegin(new TList(TType.STRING, this.columns.size()));
-        for (String _iter14 : this.columns)        {
-          oprot.writeString(_iter14);
+        for (String _iter10 : this.columns)
+        {
+          oprot.writeString(_iter10);
         }
         oprot.writeListEnd();
       }
@@ -542,8 +693,9 @@ public class Results implements TBase, java.io.Serializable, Cloneable {
       oprot.writeFieldBegin(DATA_FIELD_DESC);
       {
         oprot.writeListBegin(new TList(TType.STRING, this.data.size()));
-        for (String _iter15 : this.data)        {
-          oprot.writeString(_iter15);
+        for (String _iter11 : this.data)
+        {
+          oprot.writeString(_iter11);
         }
         oprot.writeListEnd();
       }
@@ -597,7 +749,6 @@ public class Results implements TBase, java.io.Serializable, Cloneable {
 
   public void validate() throws TException {
     // check for required fields
-    // check that fields of type enum have valid values
   }
 
 }

+ 192 - 48
apps/beeswax/java/gen-java/com/cloudera/beeswax/api/ResultsMetadata.java

@@ -10,21 +10,30 @@ import java.util.List;
 import java.util.ArrayList;
 import java.util.Map;
 import java.util.HashMap;
+import java.util.EnumMap;
 import java.util.Set;
 import java.util.HashSet;
+import java.util.EnumSet;
 import java.util.Collections;
-import org.apache.log4j.Logger;
+import java.util.BitSet;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.apache.thrift.*;
+import org.apache.thrift.async.*;
 import org.apache.thrift.meta_data.*;
+import org.apache.thrift.transport.*;
 import org.apache.thrift.protocol.*;
 
 /**
  * Metadata information about the results.
  * Applicable only for SELECT.
  */
-public class ResultsMetadata implements TBase, java.io.Serializable, Cloneable {
+public class ResultsMetadata implements TBase<ResultsMetadata, ResultsMetadata._Fields>, java.io.Serializable, Cloneable {
   private static final TStruct STRUCT_DESC = new TStruct("ResultsMetadata");
+
   private static final TField SCHEMA_FIELD_DESC = new TField("schema", TType.STRUCT, (short)1);
   private static final TField TABLE_DIR_FIELD_DESC = new TField("table_dir", TType.STRING, (short)2);
   private static final TField IN_TABLENAME_FIELD_DESC = new TField("in_tablename", TType.STRING, (short)3);
@@ -34,39 +43,112 @@ public class ResultsMetadata implements TBase, java.io.Serializable, Cloneable {
    * The schema of the results
    */
   public org.apache.hadoop.hive.metastore.api.Schema schema;
-  public static final int SCHEMA = 1;
   /**
    * The directory containing the results. Not applicable for partition table.
    */
   public String table_dir;
-  public static final int TABLE_DIR = 2;
   /**
    * If the results are straight from an existing table, the table name.
    */
   public String in_tablename;
-  public static final int IN_TABLENAME = 3;
   /**
    * Field delimiter
    */
   public String delim;
-  public static final int DELIM = 4;
 
-  private final Isset __isset = new Isset();
-  private static final class Isset implements java.io.Serializable {
+  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+  public enum _Fields implements TFieldIdEnum {
+    /**
+     * The schema of the results
+     */
+    SCHEMA((short)1, "schema"),
+    /**
+     * The directory containing the results. Not applicable for partition table.
+     */
+    TABLE_DIR((short)2, "table_dir"),
+    /**
+     * If the results are straight from an existing table, the table name.
+     */
+    IN_TABLENAME((short)3, "in_tablename"),
+    /**
+     * Field delimiter
+     */
+    DELIM((short)4, "delim");
+
+    private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+    static {
+      for (_Fields field : EnumSet.allOf(_Fields.class)) {
+        byName.put(field.getFieldName(), field);
+      }
+    }
+
+    /**
+     * Find the _Fields constant that matches fieldId, or null if its not found.
+     */
+    public static _Fields findByThriftId(int fieldId) {
+      switch(fieldId) {
+        case 1: // SCHEMA
+          return SCHEMA;
+        case 2: // TABLE_DIR
+          return TABLE_DIR;
+        case 3: // IN_TABLENAME
+          return IN_TABLENAME;
+        case 4: // DELIM
+          return DELIM;
+        default:
+          return null;
+      }
+    }
+
+    /**
+     * Find the _Fields constant that matches fieldId, throwing an exception
+     * if it is not found.
+     */
+    public static _Fields findByThriftIdOrThrow(int fieldId) {
+      _Fields fields = findByThriftId(fieldId);
+      if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
+      return fields;
+    }
+
+    /**
+     * Find the _Fields constant that matches name, or null if its not found.
+     */
+    public static _Fields findByName(String name) {
+      return byName.get(name);
+    }
+
+    private final short _thriftId;
+    private final String _fieldName;
+
+    _Fields(short thriftId, String fieldName) {
+      _thriftId = thriftId;
+      _fieldName = fieldName;
+    }
+
+    public short getThriftFieldId() {
+      return _thriftId;
+    }
+
+    public String getFieldName() {
+      return _fieldName;
+    }
   }
 
-  public static final Map<Integer, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new HashMap<Integer, FieldMetaData>() {{
-    put(SCHEMA, new FieldMetaData("schema", TFieldRequirementType.DEFAULT, 
+  // isset id assignments
+
+  public static final Map<_Fields, FieldMetaData> metaDataMap;
+  static {
+    Map<_Fields, FieldMetaData> tmpMap = new EnumMap<_Fields, FieldMetaData>(_Fields.class);
+    tmpMap.put(_Fields.SCHEMA, new FieldMetaData("schema", TFieldRequirementType.DEFAULT, 
         new StructMetaData(TType.STRUCT, org.apache.hadoop.hive.metastore.api.Schema.class)));
-    put(TABLE_DIR, new FieldMetaData("table_dir", TFieldRequirementType.DEFAULT, 
+    tmpMap.put(_Fields.TABLE_DIR, new FieldMetaData("table_dir", TFieldRequirementType.DEFAULT, 
         new FieldValueMetaData(TType.STRING)));
-    put(IN_TABLENAME, new FieldMetaData("in_tablename", TFieldRequirementType.DEFAULT, 
+    tmpMap.put(_Fields.IN_TABLENAME, new FieldMetaData("in_tablename", TFieldRequirementType.DEFAULT, 
         new FieldValueMetaData(TType.STRING)));
-    put(DELIM, new FieldMetaData("delim", TFieldRequirementType.DEFAULT, 
+    tmpMap.put(_Fields.DELIM, new FieldMetaData("delim", TFieldRequirementType.DEFAULT, 
         new FieldValueMetaData(TType.STRING)));
-  }});
-
-  static {
+    metaDataMap = Collections.unmodifiableMap(tmpMap);
     FieldMetaData.addStructMetaDataMap(ResultsMetadata.class, metaDataMap);
   }
 
@@ -104,11 +186,18 @@ public class ResultsMetadata implements TBase, java.io.Serializable, Cloneable {
     }
   }
 
-  @Override
-  public ResultsMetadata clone() {
+  public ResultsMetadata deepCopy() {
     return new ResultsMetadata(this);
   }
 
+  @Override
+  public void clear() {
+    this.schema = null;
+    this.table_dir = null;
+    this.in_tablename = null;
+    this.delim = null;
+  }
+
   /**
    * The schema of the results
    */
@@ -119,15 +208,16 @@ public class ResultsMetadata implements TBase, java.io.Serializable, Cloneable {
   /**
    * The schema of the results
    */
-  public void setSchema(org.apache.hadoop.hive.metastore.api.Schema schema) {
+  public ResultsMetadata setSchema(org.apache.hadoop.hive.metastore.api.Schema schema) {
     this.schema = schema;
+    return this;
   }
 
   public void unsetSchema() {
     this.schema = null;
   }
 
-  // Returns true if field schema is set (has been asigned a value) and false otherwise
+  /** Returns true if field schema is set (has been asigned a value) and false otherwise */
   public boolean isSetSchema() {
     return this.schema != null;
   }
@@ -148,15 +238,16 @@ public class ResultsMetadata implements TBase, java.io.Serializable, Cloneable {
   /**
    * The directory containing the results. Not applicable for partition table.
    */
-  public void setTable_dir(String table_dir) {
+  public ResultsMetadata setTable_dir(String table_dir) {
     this.table_dir = table_dir;
+    return this;
   }
 
   public void unsetTable_dir() {
     this.table_dir = null;
   }
 
-  // Returns true if field table_dir is set (has been asigned a value) and false otherwise
+  /** Returns true if field table_dir is set (has been asigned a value) and false otherwise */
   public boolean isSetTable_dir() {
     return this.table_dir != null;
   }
@@ -177,15 +268,16 @@ public class ResultsMetadata implements TBase, java.io.Serializable, Cloneable {
   /**
    * If the results are straight from an existing table, the table name.
    */
-  public void setIn_tablename(String in_tablename) {
+  public ResultsMetadata setIn_tablename(String in_tablename) {
     this.in_tablename = in_tablename;
+    return this;
   }
 
   public void unsetIn_tablename() {
     this.in_tablename = null;
   }
 
-  // Returns true if field in_tablename is set (has been asigned a value) and false otherwise
+  /** Returns true if field in_tablename is set (has been asigned a value) and false otherwise */
   public boolean isSetIn_tablename() {
     return this.in_tablename != null;
   }
@@ -206,15 +298,16 @@ public class ResultsMetadata implements TBase, java.io.Serializable, Cloneable {
   /**
    * Field delimiter
    */
-  public void setDelim(String delim) {
+  public ResultsMetadata setDelim(String delim) {
     this.delim = delim;
+    return this;
   }
 
   public void unsetDelim() {
     this.delim = null;
   }
 
-  // Returns true if field delim is set (has been asigned a value) and false otherwise
+  /** Returns true if field delim is set (has been asigned a value) and false otherwise */
   public boolean isSetDelim() {
     return this.delim != null;
   }
@@ -225,8 +318,8 @@ public class ResultsMetadata implements TBase, java.io.Serializable, Cloneable {
     }
   }
 
-  public void setFieldValue(int fieldID, Object value) {
-    switch (fieldID) {
+  public void setFieldValue(_Fields field, Object value) {
+    switch (field) {
     case SCHEMA:
       if (value == null) {
         unsetSchema();
@@ -259,13 +352,11 @@ public class ResultsMetadata implements TBase, java.io.Serializable, Cloneable {
       }
       break;
 
-    default:
-      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
     }
   }
 
-  public Object getFieldValue(int fieldID) {
-    switch (fieldID) {
+  public Object getFieldValue(_Fields field) {
+    switch (field) {
     case SCHEMA:
       return getSchema();
 
@@ -278,14 +369,17 @@ public class ResultsMetadata implements TBase, java.io.Serializable, Cloneable {
     case DELIM:
       return getDelim();
 
-    default:
-      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
     }
+    throw new IllegalStateException();
   }
 
-  // Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise
-  public boolean isSet(int fieldID) {
-    switch (fieldID) {
+  /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
+  public boolean isSet(_Fields field) {
+    if (field == null) {
+      throw new IllegalArgumentException();
+    }
+
+    switch (field) {
     case SCHEMA:
       return isSetSchema();
     case TABLE_DIR:
@@ -294,9 +388,8 @@ public class ResultsMetadata implements TBase, java.io.Serializable, Cloneable {
       return isSetIn_tablename();
     case DELIM:
       return isSetDelim();
-    default:
-      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
     }
+    throw new IllegalStateException();
   }
 
   @Override
@@ -378,6 +471,61 @@ public class ResultsMetadata implements TBase, java.io.Serializable, Cloneable {
     return builder.toHashCode();
   }
 
+  public int compareTo(ResultsMetadata other) {
+    if (!getClass().equals(other.getClass())) {
+      return getClass().getName().compareTo(other.getClass().getName());
+    }
+
+    int lastComparison = 0;
+    ResultsMetadata typedOther = (ResultsMetadata)other;
+
+    lastComparison = Boolean.valueOf(isSetSchema()).compareTo(typedOther.isSetSchema());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetSchema()) {
+      lastComparison = TBaseHelper.compareTo(this.schema, typedOther.schema);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetTable_dir()).compareTo(typedOther.isSetTable_dir());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetTable_dir()) {
+      lastComparison = TBaseHelper.compareTo(this.table_dir, typedOther.table_dir);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetIn_tablename()).compareTo(typedOther.isSetIn_tablename());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetIn_tablename()) {
+      lastComparison = TBaseHelper.compareTo(this.in_tablename, typedOther.in_tablename);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    lastComparison = Boolean.valueOf(isSetDelim()).compareTo(typedOther.isSetDelim());
+    if (lastComparison != 0) {
+      return lastComparison;
+    }
+    if (isSetDelim()) {
+      lastComparison = TBaseHelper.compareTo(this.delim, typedOther.delim);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+    }
+    return 0;
+  }
+
+  public _Fields fieldForId(int fieldId) {
+    return _Fields.findByThriftId(fieldId);
+  }
+
   public void read(TProtocol iprot) throws TException {
     TField field;
     iprot.readStructBegin();
@@ -387,9 +535,8 @@ public class ResultsMetadata implements TBase, java.io.Serializable, Cloneable {
       if (field.type == TType.STOP) { 
         break;
       }
-      switch (field.id)
-      {
-        case SCHEMA:
+      switch (field.id) {
+        case 1: // SCHEMA
           if (field.type == TType.STRUCT) {
             this.schema = new org.apache.hadoop.hive.metastore.api.Schema();
             this.schema.read(iprot);
@@ -397,21 +544,21 @@ public class ResultsMetadata implements TBase, java.io.Serializable, Cloneable {
             TProtocolUtil.skip(iprot, field.type);
           }
           break;
-        case TABLE_DIR:
+        case 2: // TABLE_DIR
           if (field.type == TType.STRING) {
             this.table_dir = iprot.readString();
           } else { 
             TProtocolUtil.skip(iprot, field.type);
           }
           break;
-        case IN_TABLENAME:
+        case 3: // IN_TABLENAME
           if (field.type == TType.STRING) {
             this.in_tablename = iprot.readString();
           } else { 
             TProtocolUtil.skip(iprot, field.type);
           }
           break;
-        case DELIM:
+        case 4: // DELIM
           if (field.type == TType.STRING) {
             this.delim = iprot.readString();
           } else { 
@@ -420,13 +567,11 @@ public class ResultsMetadata implements TBase, java.io.Serializable, Cloneable {
           break;
         default:
           TProtocolUtil.skip(iprot, field.type);
-          break;
       }
       iprot.readFieldEnd();
     }
     iprot.readStructEnd();
 
-
     // check for required fields of primitive type, which can't be checked in the validate method
     validate();
   }
@@ -501,7 +646,6 @@ public class ResultsMetadata implements TBase, java.io.Serializable, Cloneable {
 
   public void validate() throws TException {
     // check for required fields
-    // check that fields of type enum have valid values
   }
 
 }

+ 0 - 307
apps/beeswax/java/gen-java/com/cloudera/beeswax/api/Setting.java

@@ -1,307 +0,0 @@
-/**
- * Autogenerated by Thrift
- *
- * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
- */
-package com.cloudera.beeswax.api;
-
-import org.apache.commons.lang.builder.HashCodeBuilder;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Collections;
-import org.apache.log4j.Logger;
-
-import org.apache.thrift.*;
-import org.apache.thrift.meta_data.*;
-import org.apache.thrift.protocol.*;
-
-public class Setting implements TBase, java.io.Serializable, Cloneable {
-  private static final TStruct STRUCT_DESC = new TStruct("Setting");
-  private static final TField KEY_FIELD_DESC = new TField("key", TType.STRING, (short)1);
-  private static final TField VALUE_FIELD_DESC = new TField("value", TType.STRING, (short)2);
-
-  public String key;
-  public static final int KEY = 1;
-  public String value;
-  public static final int VALUE = 2;
-
-  private final Isset __isset = new Isset();
-  private static final class Isset implements java.io.Serializable {
-  }
-
-  public static final Map<Integer, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new HashMap<Integer, FieldMetaData>() {{
-    put(KEY, new FieldMetaData("key", TFieldRequirementType.DEFAULT, 
-        new FieldValueMetaData(TType.STRING)));
-    put(VALUE, new FieldMetaData("value", TFieldRequirementType.DEFAULT, 
-        new FieldValueMetaData(TType.STRING)));
-  }});
-
-  static {
-    FieldMetaData.addStructMetaDataMap(Setting.class, metaDataMap);
-  }
-
-  public Setting() {
-  }
-
-  public Setting(
-    String key,
-    String value)
-  {
-    this();
-    this.key = key;
-    this.value = value;
-  }
-
-  /**
-   * Performs a deep copy on <i>other</i>.
-   */
-  public Setting(Setting other) {
-    if (other.isSetKey()) {
-      this.key = other.key;
-    }
-    if (other.isSetValue()) {
-      this.value = other.value;
-    }
-  }
-
-  @Override
-  public Setting clone() {
-    return new Setting(this);
-  }
-
-  public String getKey() {
-    return this.key;
-  }
-
-  public void setKey(String key) {
-    this.key = key;
-  }
-
-  public void unsetKey() {
-    this.key = null;
-  }
-
-  // Returns true if field key is set (has been asigned a value) and false otherwise
-  public boolean isSetKey() {
-    return this.key != null;
-  }
-
-  public void setKeyIsSet(boolean value) {
-    if (!value) {
-      this.key = null;
-    }
-  }
-
-  public String getValue() {
-    return this.value;
-  }
-
-  public void setValue(String value) {
-    this.value = value;
-  }
-
-  public void unsetValue() {
-    this.value = null;
-  }
-
-  // Returns true if field value is set (has been asigned a value) and false otherwise
-  public boolean isSetValue() {
-    return this.value != null;
-  }
-
-  public void setValueIsSet(boolean value) {
-    if (!value) {
-      this.value = null;
-    }
-  }
-
-  public void setFieldValue(int fieldID, Object value) {
-    switch (fieldID) {
-    case KEY:
-      if (value == null) {
-        unsetKey();
-      } else {
-        setKey((String)value);
-      }
-      break;
-
-    case VALUE:
-      if (value == null) {
-        unsetValue();
-      } else {
-        setValue((String)value);
-      }
-      break;
-
-    default:
-      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
-    }
-  }
-
-  public Object getFieldValue(int fieldID) {
-    switch (fieldID) {
-    case KEY:
-      return getKey();
-
-    case VALUE:
-      return getValue();
-
-    default:
-      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
-    }
-  }
-
-  // Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise
-  public boolean isSet(int fieldID) {
-    switch (fieldID) {
-    case KEY:
-      return isSetKey();
-    case VALUE:
-      return isSetValue();
-    default:
-      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
-    }
-  }
-
-  @Override
-  public boolean equals(Object that) {
-    if (that == null)
-      return false;
-    if (that instanceof Setting)
-      return this.equals((Setting)that);
-    return false;
-  }
-
-  public boolean equals(Setting that) {
-    if (that == null)
-      return false;
-
-    boolean this_present_key = true && this.isSetKey();
-    boolean that_present_key = true && that.isSetKey();
-    if (this_present_key || that_present_key) {
-      if (!(this_present_key && that_present_key))
-        return false;
-      if (!this.key.equals(that.key))
-        return false;
-    }
-
-    boolean this_present_value = true && this.isSetValue();
-    boolean that_present_value = true && that.isSetValue();
-    if (this_present_value || that_present_value) {
-      if (!(this_present_value && that_present_value))
-        return false;
-      if (!this.value.equals(that.value))
-        return false;
-    }
-
-    return true;
-  }
-
-  @Override
-  public int hashCode() {
-    HashCodeBuilder builder = new HashCodeBuilder();
-
-    boolean present_key = true && (isSetKey());
-    builder.append(present_key);
-    if (present_key)
-      builder.append(key);
-
-    boolean present_value = true && (isSetValue());
-    builder.append(present_value);
-    if (present_value)
-      builder.append(value);
-
-    return builder.toHashCode();
-  }
-
-  public void read(TProtocol iprot) throws TException {
-    TField field;
-    iprot.readStructBegin();
-    while (true)
-    {
-      field = iprot.readFieldBegin();
-      if (field.type == TType.STOP) { 
-        break;
-      }
-      switch (field.id)
-      {
-        case KEY:
-          if (field.type == TType.STRING) {
-            this.key = iprot.readString();
-          } else { 
-            TProtocolUtil.skip(iprot, field.type);
-          }
-          break;
-        case VALUE:
-          if (field.type == TType.STRING) {
-            this.value = iprot.readString();
-          } else { 
-            TProtocolUtil.skip(iprot, field.type);
-          }
-          break;
-        default:
-          TProtocolUtil.skip(iprot, field.type);
-          break;
-      }
-      iprot.readFieldEnd();
-    }
-    iprot.readStructEnd();
-
-
-    // check for required fields of primitive type, which can't be checked in the validate method
-    validate();
-  }
-
-  public void write(TProtocol oprot) throws TException {
-    validate();
-
-    oprot.writeStructBegin(STRUCT_DESC);
-    if (this.key != null) {
-      oprot.writeFieldBegin(KEY_FIELD_DESC);
-      oprot.writeString(this.key);
-      oprot.writeFieldEnd();
-    }
-    if (this.value != null) {
-      oprot.writeFieldBegin(VALUE_FIELD_DESC);
-      oprot.writeString(this.value);
-      oprot.writeFieldEnd();
-    }
-    oprot.writeFieldStop();
-    oprot.writeStructEnd();
-  }
-
-  @Override
-  public String toString() {
-    StringBuilder sb = new StringBuilder("Setting(");
-    boolean first = true;
-
-    sb.append("key:");
-    if (this.key == null) {
-      sb.append("null");
-    } else {
-      sb.append(this.key);
-    }
-    first = false;
-    if (!first) sb.append(", ");
-    sb.append("value:");
-    if (this.value == null) {
-      sb.append("null");
-    } else {
-      sb.append(this.value);
-    }
-    first = false;
-    sb.append(")");
-    return sb.toString();
-  }
-
-  public void validate() throws TException {
-    // check for required fields
-    // check that fields of type enum have valid values
-  }
-
-}
-

+ 0 - 399
apps/beeswax/java/gen-java/com/cloudera/beeswax/api/WrongQueryTypeException.java

@@ -1,399 +0,0 @@
-/**
- * Autogenerated by Thrift
- *
- * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
- */
-package com.cloudera.beeswax.api;
-
-import org.apache.commons.lang.builder.HashCodeBuilder;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Collections;
-import org.apache.log4j.Logger;
-
-import org.apache.thrift.*;
-import org.apache.thrift.meta_data.*;
-import org.apache.thrift.protocol.*;
-
-public class WrongQueryTypeException extends Exception implements TBase, java.io.Serializable, Cloneable {
-  private static final TStruct STRUCT_DESC = new TStruct("WrongQueryTypeException");
-  private static final TField QUERY_FIELD_DESC = new TField("query", TType.STRING, (short)1);
-  private static final TField EXPECTED_FIELD_DESC = new TField("expected", TType.I32, (short)2);
-  private static final TField RECEIVED_FIELD_DESC = new TField("received", TType.I32, (short)3);
-
-  public String query;
-  public static final int QUERY = 1;
-  public int expected;
-  public static final int EXPECTED = 2;
-  public int received;
-  public static final int RECEIVED = 3;
-
-  private final Isset __isset = new Isset();
-  private static final class Isset implements java.io.Serializable {
-    public boolean expected = false;
-    public boolean received = false;
-  }
-
-  public static final Map<Integer, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new HashMap<Integer, FieldMetaData>() {{
-    put(QUERY, new FieldMetaData("query", TFieldRequirementType.DEFAULT, 
-        new FieldValueMetaData(TType.STRING)));
-    put(EXPECTED, new FieldMetaData("expected", TFieldRequirementType.DEFAULT, 
-        new FieldValueMetaData(TType.I32)));
-    put(RECEIVED, new FieldMetaData("received", TFieldRequirementType.DEFAULT, 
-        new FieldValueMetaData(TType.I32)));
-  }});
-
-  static {
-    FieldMetaData.addStructMetaDataMap(WrongQueryTypeException.class, metaDataMap);
-  }
-
-  public WrongQueryTypeException() {
-  }
-
-  public WrongQueryTypeException(
-    String query,
-    int expected,
-    int received)
-  {
-    this();
-    this.query = query;
-    this.expected = expected;
-    this.__isset.expected = true;
-    this.received = received;
-    this.__isset.received = true;
-  }
-
-  /**
-   * Performs a deep copy on <i>other</i>.
-   */
-  public WrongQueryTypeException(WrongQueryTypeException other) {
-    if (other.isSetQuery()) {
-      this.query = other.query;
-    }
-    __isset.expected = other.__isset.expected;
-    this.expected = other.expected;
-    __isset.received = other.__isset.received;
-    this.received = other.received;
-  }
-
-  @Override
-  public WrongQueryTypeException clone() {
-    return new WrongQueryTypeException(this);
-  }
-
-  public String getQuery() {
-    return this.query;
-  }
-
-  public void setQuery(String query) {
-    this.query = query;
-  }
-
-  public void unsetQuery() {
-    this.query = null;
-  }
-
-  // Returns true if field query is set (has been asigned a value) and false otherwise
-  public boolean isSetQuery() {
-    return this.query != null;
-  }
-
-  public void setQueryIsSet(boolean value) {
-    if (!value) {
-      this.query = null;
-    }
-  }
-
-  public int getExpected() {
-    return this.expected;
-  }
-
-  public void setExpected(int expected) {
-    this.expected = expected;
-    this.__isset.expected = true;
-  }
-
-  public void unsetExpected() {
-    this.__isset.expected = false;
-  }
-
-  // Returns true if field expected is set (has been asigned a value) and false otherwise
-  public boolean isSetExpected() {
-    return this.__isset.expected;
-  }
-
-  public void setExpectedIsSet(boolean value) {
-    this.__isset.expected = value;
-  }
-
-  public int getReceived() {
-    return this.received;
-  }
-
-  public void setReceived(int received) {
-    this.received = received;
-    this.__isset.received = true;
-  }
-
-  public void unsetReceived() {
-    this.__isset.received = false;
-  }
-
-  // Returns true if field received is set (has been asigned a value) and false otherwise
-  public boolean isSetReceived() {
-    return this.__isset.received;
-  }
-
-  public void setReceivedIsSet(boolean value) {
-    this.__isset.received = value;
-  }
-
-  public void setFieldValue(int fieldID, Object value) {
-    switch (fieldID) {
-    case QUERY:
-      if (value == null) {
-        unsetQuery();
-      } else {
-        setQuery((String)value);
-      }
-      break;
-
-    case EXPECTED:
-      if (value == null) {
-        unsetExpected();
-      } else {
-        setExpected((Integer)value);
-      }
-      break;
-
-    case RECEIVED:
-      if (value == null) {
-        unsetReceived();
-      } else {
-        setReceived((Integer)value);
-      }
-      break;
-
-    default:
-      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
-    }
-  }
-
-  public Object getFieldValue(int fieldID) {
-    switch (fieldID) {
-    case QUERY:
-      return getQuery();
-
-    case EXPECTED:
-      return getExpected();
-
-    case RECEIVED:
-      return getReceived();
-
-    default:
-      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
-    }
-  }
-
-  // Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise
-  public boolean isSet(int fieldID) {
-    switch (fieldID) {
-    case QUERY:
-      return isSetQuery();
-    case EXPECTED:
-      return isSetExpected();
-    case RECEIVED:
-      return isSetReceived();
-    default:
-      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
-    }
-  }
-
-  @Override
-  public boolean equals(Object that) {
-    if (that == null)
-      return false;
-    if (that instanceof WrongQueryTypeException)
-      return this.equals((WrongQueryTypeException)that);
-    return false;
-  }
-
-  public boolean equals(WrongQueryTypeException that) {
-    if (that == null)
-      return false;
-
-    boolean this_present_query = true && this.isSetQuery();
-    boolean that_present_query = true && that.isSetQuery();
-    if (this_present_query || that_present_query) {
-      if (!(this_present_query && that_present_query))
-        return false;
-      if (!this.query.equals(that.query))
-        return false;
-    }
-
-    boolean this_present_expected = true;
-    boolean that_present_expected = true;
-    if (this_present_expected || that_present_expected) {
-      if (!(this_present_expected && that_present_expected))
-        return false;
-      if (this.expected != that.expected)
-        return false;
-    }
-
-    boolean this_present_received = true;
-    boolean that_present_received = true;
-    if (this_present_received || that_present_received) {
-      if (!(this_present_received && that_present_received))
-        return false;
-      if (this.received != that.received)
-        return false;
-    }
-
-    return true;
-  }
-
-  @Override
-  public int hashCode() {
-    HashCodeBuilder builder = new HashCodeBuilder();
-
-    boolean present_query = true && (isSetQuery());
-    builder.append(present_query);
-    if (present_query)
-      builder.append(query);
-
-    boolean present_expected = true;
-    builder.append(present_expected);
-    if (present_expected)
-      builder.append(expected);
-
-    boolean present_received = true;
-    builder.append(present_received);
-    if (present_received)
-      builder.append(received);
-
-    return builder.toHashCode();
-  }
-
-  public void read(TProtocol iprot) throws TException {
-    TField field;
-    iprot.readStructBegin();
-    while (true)
-    {
-      field = iprot.readFieldBegin();
-      if (field.type == TType.STOP) { 
-        break;
-      }
-      switch (field.id)
-      {
-        case QUERY:
-          if (field.type == TType.STRING) {
-            this.query = iprot.readString();
-          } else { 
-            TProtocolUtil.skip(iprot, field.type);
-          }
-          break;
-        case EXPECTED:
-          if (field.type == TType.I32) {
-            this.expected = iprot.readI32();
-            this.__isset.expected = true;
-          } else { 
-            TProtocolUtil.skip(iprot, field.type);
-          }
-          break;
-        case RECEIVED:
-          if (field.type == TType.I32) {
-            this.received = iprot.readI32();
-            this.__isset.received = true;
-          } else { 
-            TProtocolUtil.skip(iprot, field.type);
-          }
-          break;
-        default:
-          TProtocolUtil.skip(iprot, field.type);
-          break;
-      }
-      iprot.readFieldEnd();
-    }
-    iprot.readStructEnd();
-
-
-    // check for required fields of primitive type, which can't be checked in the validate method
-    validate();
-  }
-
-  public void write(TProtocol oprot) throws TException {
-    validate();
-
-    oprot.writeStructBegin(STRUCT_DESC);
-    if (this.query != null) {
-      oprot.writeFieldBegin(QUERY_FIELD_DESC);
-      oprot.writeString(this.query);
-      oprot.writeFieldEnd();
-    }
-    oprot.writeFieldBegin(EXPECTED_FIELD_DESC);
-    oprot.writeI32(this.expected);
-    oprot.writeFieldEnd();
-    oprot.writeFieldBegin(RECEIVED_FIELD_DESC);
-    oprot.writeI32(this.received);
-    oprot.writeFieldEnd();
-    oprot.writeFieldStop();
-    oprot.writeStructEnd();
-  }
-
-  @Override
-  public String toString() {
-    StringBuilder sb = new StringBuilder("WrongQueryTypeException(");
-    boolean first = true;
-
-    sb.append("query:");
-    if (this.query == null) {
-      sb.append("null");
-    } else {
-      sb.append(this.query);
-    }
-    first = false;
-    if (!first) sb.append(", ");
-    sb.append("expected:");
-    String expected_name = QueryType.VALUES_TO_NAMES.get(this.expected);
-    if (expected_name != null) {
-      sb.append(expected_name);
-      sb.append(" (");
-    }
-    sb.append(this.expected);
-    if (expected_name != null) {
-      sb.append(")");
-    }
-    first = false;
-    if (!first) sb.append(", ");
-    sb.append("received:");
-    String received_name = QueryType.VALUES_TO_NAMES.get(this.received);
-    if (received_name != null) {
-      sb.append(received_name);
-      sb.append(" (");
-    }
-    sb.append(this.received);
-    if (received_name != null) {
-      sb.append(")");
-    }
-    first = false;
-    sb.append(")");
-    return sb.toString();
-  }
-
-  public void validate() throws TException {
-    // check for required fields
-    // check that fields of type enum have valid values
-    if (isSetExpected() && !QueryType.VALID_VALUES.contains(expected)){
-      throw new TProtocolException("The field 'expected' has been assigned the invalid value " + expected);
-    }
-    if (isSetReceived() && !QueryType.VALID_VALUES.contains(received)){
-      throw new TProtocolException("The field 'received' has been assigned the invalid value " + received);
-    }
-  }
-
-}
-

+ 117 - 55
apps/beeswax/java/src/com/cloudera/beeswax/BeeswaxServiceImpl.java

@@ -21,10 +21,13 @@ import java.io.IOException;
 import java.io.OutputStream;
 import java.io.PrintStream;
 import java.io.UnsupportedEncodingException;
+import java.lang.reflect.UndeclaredThrowableException;
 import java.net.HttpURLConnection;
 import java.net.URL;
 import java.security.KeyManagementException;
 import java.security.NoSuchAlgorithmException;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 import java.security.SecureRandom;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
@@ -61,7 +64,7 @@ import org.apache.hadoop.hive.ql.processors.CommandProcessorFactory;
 import org.apache.hadoop.hive.ql.QueryPlan;
 import org.apache.hadoop.hive.ql.session.SessionState;
 import org.apache.hadoop.hive.serde.Constants;
-import org.apache.hadoop.security.UnixUserGroupInformation;
+import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.log4j.Logger;
 import org.apache.thrift.TException;
 
@@ -109,7 +112,7 @@ public class BeeswaxServiceImpl implements BeeswaxService.Iface {
    * EXCEPTION is also valid.
    */
   private class RunningQueryState {
-    private int state = QueryState.CREATED;
+    private QueryState state = QueryState.CREATED;
     // Thread local used by Hive quite a bit.
     private SessionState sessionState;
     private Throwable exception;
@@ -183,7 +186,7 @@ public class BeeswaxServiceImpl implements BeeswaxService.Iface {
       state = QueryState.COMPILED;
     }
 
-    private void assertState(int expected) {
+    private void assertState(QueryState expected) {
       if (state != expected) {
         throw new IllegalStateException(String.format("Expected %s, but state is: %s",
             expected, state));
@@ -242,13 +245,6 @@ public class BeeswaxServiceImpl implements BeeswaxService.Iface {
       if (query.hadoop_user == null) {
         throw new RuntimeException("User must be specified.");
       }
-      StringBuilder ugi = new StringBuilder();
-      ugi.append(query.hadoop_user);
-      for (String group : query.hadoop_groups) {
-        ugi.append(",");
-        ugi.append(group);
-      }
-      hiveConf.set(UnixUserGroupInformation.UGI_PROPERTY_NAME, ugi.toString());
 
       // Update scratch dir (to have one per user)
       File scratchDir = new File("/tmp/hive-beeswax-" + query.hadoop_user);
@@ -448,10 +444,10 @@ public class BeeswaxServiceImpl implements BeeswaxService.Iface {
       // Only one person can access a running query at a time.
       synchronized(this) {
         switch(state) {
-        case QueryState.RUNNING:
+        case RUNNING:
           r.ready = false;
           break;
-        case QueryState.FINISHED:
+        case FINISHED:
           bringUp();
           r.ready = true;
           try {
@@ -460,7 +456,7 @@ public class BeeswaxServiceImpl implements BeeswaxService.Iface {
             throw new BeeswaxException(e.toString(), logContext.getName(), handle);
           }
           break;
-        case QueryState.EXCEPTION:
+        case EXCEPTION:
           if (exception instanceof BeeswaxException) {
             throw (BeeswaxException) exception;
           } else {
@@ -607,6 +603,37 @@ public class BeeswaxServiceImpl implements BeeswaxService.Iface {
     evicter.start();
   }
 
+
+  private <T> T doWithState(RunningQueryState state, PrivilegedExceptionAction<T> action)
+  throws BeeswaxException
+  {
+    try{
+      UserGroupInformation ugi;
+      if (UserGroupInformation.isSecurityEnabled())
+        ugi = UserGroupInformation.createProxyUser(state.query.hadoop_user, UserGroupInformation.getLoginUser());
+      else {
+        ugi = UserGroupInformation.createRemoteUser(state.query.hadoop_user);
+      }
+      return ugi.doAs(action);
+    } catch (UndeclaredThrowableException e) {
+      if (e.getUndeclaredThrowable() instanceof PrivilegedActionException) {
+        Throwable bwe = e.getUndeclaredThrowable().getCause();
+        if (bwe instanceof BeeswaxException) {
+          LOG.error("Caught BeeswaxException", (BeeswaxException) bwe);
+          throw (BeeswaxException) bwe;
+        }
+      }
+      LOG.error("Caught unexpected exception.", e);
+      throw new BeeswaxException(e.getMessage(), state.handle.log_context, state.handle);
+    } catch (IOException e) {
+      LOG.error("Caught IOException", e);
+      throw new BeeswaxException(e.getMessage(), state.handle.log_context, state.handle);
+    } catch (InterruptedException e) {
+      LOG.error("Caught InterruptedException", e);
+      throw new BeeswaxException(e.getMessage(), state.handle.log_context, state.handle);
+    }
+  }
+
   /**
    * Submit a query and return a handle (QueryHandle). The query runs asynchronously.
    * Queries can be long-lasting, so we push the execution into a new state.
@@ -622,23 +649,31 @@ public class BeeswaxServiceImpl implements BeeswaxService.Iface {
 
     // Make an administrative record
     final RunningQueryState state = new RunningQueryState(query, lc);
-    state.setQueryHandle(handle);
-    runningQueries.put(handle.id, state);
-    state.initialize();
-    // All kinds of things can go wrong when we compile it. So catch all.
     try {
-      state.compile();
-    } catch (BeeswaxException perr) {
-      state.saveException(perr);
-      throw perr;
-    } catch (Throwable t) {
-      state.saveException(t);
-      throw new BeeswaxException(t.toString(), handle.log_context, handle);
-    }
-    // Now spin off the query.
-    state.submitTo(executor, lc);
-
-    return handle;
+      return doWithState(state,
+          new PrivilegedExceptionAction<QueryHandle>() {
+            public QueryHandle run() throws Exception {
+              state.setQueryHandle(handle);
+              runningQueries.put(handle.id, state);
+              state.initialize();
+              // All kinds of things can go wrong when we compile it. So catch all.
+              try {
+                state.compile();
+              } catch (BeeswaxException perr) {
+                state.saveException(perr);
+                throw perr;
+              } catch (Throwable t) {
+                state.saveException(t);
+                throw new BeeswaxException(t.toString(), handle.log_context, handle);
+              }
+              // Now spin off the query.
+              state.submitTo(executor, lc);
+              return handle;
+            }
+          });
+    } catch (BeeswaxException e) {
+      throw e;
+    }
   }
 
   /**
@@ -664,23 +699,32 @@ public class BeeswaxServiceImpl implements BeeswaxService.Iface {
    * Get the query plan for a query.
    */
   @Override
-  public QueryExplanation explain(Query query) throws BeeswaxException, TException {
-    String contextName = UUID.randomUUID().toString();
+  public QueryExplanation explain(final Query query) throws BeeswaxException, TException {
+    final String contextName = UUID.randomUUID().toString();
     LogContext lc = LogContext.registerCurrentThread(contextName);
-    RunningQueryState state = new RunningQueryState(query, lc);
-    state.initialize();
-    // All kinds of things can go wrong when we compile it. So catch all.
-    QueryExplanation exp;
+    final RunningQueryState state = new RunningQueryState(query, lc);
     try {
-      exp = state.explain();
-    } catch (BeeswaxException perr) {
-      throw perr;
-    } catch (Throwable t) {
-      throw new BeeswaxException(t.toString(), contextName, null);
-    }
-    // On success, we remove the LogContext
-    LogContext.destroyContext(contextName);
-    return exp;
+      return doWithState(state,
+          new PrivilegedExceptionAction<QueryExplanation>() {
+            public QueryExplanation run() throws Exception {
+              state.initialize();
+              QueryExplanation exp;
+              // All kinds of things can go wrong when we compile it. So catch all.
+              try {
+                exp = state.explain();
+              } catch (BeeswaxException perr) {
+                throw perr;
+              } catch (Throwable t) {
+                throw new BeeswaxException(t.toString(), contextName, null);
+              }
+              // On success, we remove the LogContext
+              LogContext.destroyContext(contextName);
+              return exp;
+            }
+          });
+    } catch (BeeswaxException e) {
+      throw e;
+    }
   }
 
   /**
@@ -691,17 +735,25 @@ public class BeeswaxServiceImpl implements BeeswaxService.Iface {
    * @param fromBeginning  If true, rewind to the first row. Otherwise fetch from last position.
    */
   @Override
-  public Results fetch(QueryHandle handle, boolean fromBeginning)
+  public Results fetch(final QueryHandle handle, final boolean fromBeginning)
       throws QueryNotFoundException, BeeswaxException {
     LogContext.unregisterCurrentThread();
     validateHandle(handle);
     LogContext.registerCurrentThread(handle.log_context);
-    RunningQueryState state = runningQueries.get(handle.id);
-    if (state == null) {
-      throw new QueryNotFoundException();
+    final RunningQueryState state = runningQueries.get(handle.id);
+    try {
+      return doWithState(state,
+          new PrivilegedExceptionAction<Results>() {
+            public Results run() throws Exception {
+              if (state == null) {
+                throw new QueryNotFoundException();
+              }
+              return state.fetch(fromBeginning);
+            }
+          });
+    } catch (BeeswaxException e) {
+      throw e;
     }
-    Results res = state.fetch(fromBeginning);
-    return res;
   }
 
   @Override
@@ -722,7 +774,7 @@ public class BeeswaxServiceImpl implements BeeswaxService.Iface {
    * @param handle The handle from query()
    */
   @Override
-  public int get_state(QueryHandle handle) throws QueryNotFoundException {
+  public QueryState get_state(final QueryHandle handle) throws QueryNotFoundException {
     LogContext.unregisterCurrentThread();
     validateHandle(handle);
     LogContext.registerCurrentThread(handle.log_context);
@@ -739,15 +791,25 @@ public class BeeswaxServiceImpl implements BeeswaxService.Iface {
    * @param handle
    */
   @Override
-  public ResultsMetadata get_results_metadata(QueryHandle handle) throws QueryNotFoundException {
+  public ResultsMetadata get_results_metadata(final QueryHandle handle) throws QueryNotFoundException {
     LogContext.unregisterCurrentThread();
     validateHandle(handle);
     LogContext.registerCurrentThread(handle.log_context);
-    RunningQueryState state = runningQueries.get(handle.id);
-    if (state == null) {
+    final RunningQueryState state = runningQueries.get(handle.id);
+    try {
+      return doWithState(state,
+          new PrivilegedExceptionAction<ResultsMetadata>() {
+            public ResultsMetadata run() throws Exception {
+              if (state == null) {
+                throw new QueryNotFoundException();
+              }
+              return state.getResultMetadata();
+            }
+          });
+    } catch (BeeswaxException e) {
+      LOG.error("Caught BeeswaxException.", e);
       throw new QueryNotFoundException();
     }
-    return state.getResultMetadata();
   }
 
   /**

+ 4 - 2
apps/beeswax/java/src/com/cloudera/beeswax/Server.java

@@ -157,8 +157,8 @@ public class Server {
    */
   private static void createDirectoriesAsNecessary() {
     try {
+      LOG.debug("Classpath: " + System.getProperty("java.class.path"));
       HiveConf conf = new HiveConf(Driver.class);
-      conf.set("hadoop.ugi", superUser + ",supergroup");
       FileSystem fs = FileSystem.get(conf);
       Path tmpDir = new Path("/tmp");
       Path metaDir = new Path(conf
@@ -174,7 +174,9 @@ public class Server {
         }
       }
     } catch (IOException e) {
-      LOG.error("Error while trying to check/create /tmp and warehouse directory.", e);
+      HiveConf conf = new HiveConf(Driver.class);
+      LOG.error("Error while trying to check/create /tmp and warehouse directory " + conf
+          .get(HiveConf.ConfVars.METASTOREWAREHOUSE.varname), e);
     }
   }
 

+ 46 - 0
apps/beeswax/regenerate_thrift.sh

@@ -0,0 +1,46 @@
+#!/usr/bin/env bash
+# Licensed to Cloudera, Inc. under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  Cloudera, Inc. licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -o errexit
+set -o xtrace
+
+cd $(dirname $0)
+
+thrift -I thrift/include -r --gen py:new_style -o ./ thrift/beeswax.thrift
+thrift -I thrift/include -r --gen java:hashcode -o java thrift/beeswax.thrift
+
+# We don't need to have generated code for the metastore, since that's
+# in one of the hive jars that we include
+rm -Rf java/gen-java/com/facebook java/gen-java/org/apache
+
+cat <<EOF
+======================================================================
+NOTE:
+======================================================================
+
+This script does *not* remove old generated files that may not be necessary anymore.
+You should probably do something like:
+ > git rm -rf java/gen-java gen-py
+ > ./regenerate_thrift.sh
+ > git add java/gen-java gen-py
+
+======================================================================
+
+EOF
+
+# This is based on thirdparty.
+# thrift -r --gen py:new_style -o ../ ../../../../ext/thirdparty/py/thrift/contrib/fb303/if/fb303.thrift

+ 0 - 2
apps/beeswax/src/beeswax/management/commands/beeswax_install_examples.py

@@ -49,7 +49,6 @@ import hive_metastore.ttypes
 
 LOG = logging.getLogger(__name__)
 HADOOP_USER = 'hue'
-HADOOP_GRP = 'supergroup'
 
 class InstallException(Exception):
   pass
@@ -141,7 +140,6 @@ def _make_query_msg(hql):
   """
   query_msg = BeeswaxService.Query(query=hql, configuration=[])
   query_msg.hadoop_user = HADOOP_USER
-  query_msg.hadoop_groups = (HADOOP_GRP,)
   return query_msg
 
 

+ 2 - 1
apps/beeswax/src/beeswax/management/commands/beeswax_server.py

@@ -52,7 +52,8 @@ class Command(NoArgsCommand):
       '--desktop-host',
       str(dt_host),
       '--desktop-port',
-      str(desktop.conf.HTTP_PORT.get()),
+      "8000",
+      #str(desktop.conf.HTTP_PORT.get()),
     ]
 
     # Running on HTTPS?

+ 5 - 2
apps/beeswax/src/beeswax/test_base.py

@@ -116,6 +116,8 @@ def get_shared_beeswax_server():
         time.sleep(sleep)
         sleep *= 2
       except:
+        time.sleep(sleep)
+        sleep *= 2
         pass
     if not started:
       raise Exception("Beeswax server took too long to come up.")
@@ -147,8 +149,9 @@ def wait_for_query_to_finish(client, response, max=30.0):
     time.sleep(sleep_time)
     sleep_time = min(1.0, sleep_time * 2) # Capped exponential
     if (time.time() - start) > max:
-      LOG.warning("Query took too long!")
-      raise Exception("Query took too long.")
+      message = "Query took too long! %d seconds" % (time.time() - start,)
+      LOG.warning(message)
+      raise Exception(message)
 
     # Find out url to retry
     match = REFRESH_RE.search(response.content)

+ 7 - 2
apps/beeswax/src/beeswax/tests.py

@@ -214,6 +214,9 @@ for x in sys.stdin:
     assert_equal(257, response.content.count("\n"))
 
   def test_query_with_udf(self):
+    """
+    Testing query with udf
+    """
     response = _make_query(self.client, "SELECT my_sqrt(foo), my_power(foo, foo) FROM test WHERE foo=4",
       udfs=[('my_sqrt', 'org.apache.hadoop.hive.ql.udf.UDFSqrt'),
         ('my_power', 'org.apache.hadoop.hive.ql.udf.UDFPower')], local=False)
@@ -264,6 +267,9 @@ for x in sys.stdin:
     check_error_in_response(resp)
 
   def test_parameterization(self):
+    """
+    Test parameterization
+    """
     response = _make_query(self.client, "SELECT foo FROM test WHERE foo='$x' and bar='$y'", is_parameterized=False)
     # Assert no parameterization was offered
     assert_equal("watch_wait.mako", response.template, "we should have seen the template for a query executing")
@@ -377,7 +383,6 @@ for x in sys.stdin:
     query_msg.query = 'SELECT * FROM test'
     query_msg.configuration = []
     query_msg.hadoop_user = "test"
-    query_msg.hadoop_groups = ["test"]
     handle = beeswax.db_utils.db_client().query(query_msg)
     query_data = beeswax.models.QueryHistory(server_id=handle.id, log_context=handle.log_context)
     # Get the result in xls. Then translate it into csv.
@@ -563,7 +568,7 @@ for x in sys.stdin:
         'save': True
       }
       resp = self.client.post('/beeswax/save_results/%s' % (qid,), save_data, follow=True)
-      wait_for_query_to_finish(self.client, resp, max=60)
+      wait_for_query_to_finish(self.client, resp, max=120)
 
       # Check that data is right. The SELECT may not give us the whole table.
       resp = _make_query(self.client, 'SELECT * FROM %s' % (target_tbl,), wait=True)

+ 2 - 3
apps/beeswax/src/beeswax/views.py

@@ -108,7 +108,7 @@ def drop_table(request, table):
 
 def read_table(request, table):
   """View function for select * from table"""
-  hql = "SELECT * FROM `%s`" % (table,)
+  hql = "SELECT * FROM %s" % (table,)
   query_msg = make_beeswax_query(request, hql)
   try:
     return execute_directly(request, query_msg, tablename=table)
@@ -177,7 +177,6 @@ def make_beeswax_query(request, hql, query_form=None):
 
   # Configure running user and group.
   query_msg.hadoop_user = request.user.username
-  query_msg.hadoop_groups = request.user.get_groups()
 
   if query_form is not None:
     for f in query_form.settings.forms:
@@ -962,7 +961,7 @@ def _save_results_ctas(request, query_history, target_table, result_meta):
   """
   # Case 1: The results are straight from an existing table
   if result_meta.in_tablename:
-    hql = 'CREATE TABLE `%s` AS SELECT * FROM `%s`' % (target_table, result_meta.in_tablename)
+    hql = 'CREATE TABLE `%s` AS SELECT * FROM %s' % (target_table, result_meta.in_tablename)
     query_msg = make_beeswax_query(request, hql)
     # Display the CTAS running. Could take a long time.
     return execute_directly(request, query_msg, on_success_url=urlresolvers.reverse(show_tables))

+ 0 - 1
apps/beeswax/thrift/beeswax.thrift

@@ -31,7 +31,6 @@ struct Query {
 
   // User and groups to "act as" for purposes of Hadoop.
   4: string hadoop_user;
-  5: list<string> hadoop_groups;
 }
 
 typedef string LogContextId

+ 1 - 0
apps/filebrowser/src/filebrowser/views.py

@@ -417,6 +417,7 @@ def display(request, path):
       try:
         contents = GzipFile('', 'r', 0, StringIO(f.read())).read(length)
       except:
+        logging.warn("Could not decompress file at %s" % path, exc_info=True)
         contents = ''
         raise PopupException("Failed to decompress file")
     finally:

+ 0 - 1
apps/filebrowser/src/filebrowser/views_test.py

@@ -112,7 +112,6 @@ def test_view_gz():
   try:
     c = make_logged_in_client()
     cluster.fs.setuser(cluster.superuser)
-
     if cluster.fs.isdir("/test-gz-filebrowser"):
       cluster.fs.rmtree('/test-gz-filebrowser/')
 

+ 1 - 1
apps/jobbrowser/src/jobbrowser/models.py

@@ -413,7 +413,7 @@ class TaskAttempt(object):
                       '%s:%s' % (tracker.host, tracker.httpPort),
                       'tasklog',
                       None,
-                      'taskid=%s' % (self.attemptId,),
+                      'attemptid=%s' % (self.attemptId,),
                       None))
     LOGGER.info('Retrieving %s' % (url,))
     try:

+ 18 - 18
apps/jobbrowser/src/jobbrowser/tests.py

@@ -67,6 +67,11 @@ class TestJobBrowserWithHadoop(object):
     if not cluster.fs.exists("/user/test"):
       cluster.fs.mkdir("/user/test")
     cluster.fs.chown("/user/test", "test", "test")
+
+    if not cluster.fs.exists("/tmp"):
+      cluster.fs.mkdir("/tmp")
+    cluster.fs.chmod("/tmp", int('777', 8))
+
     cluster.fs.setuser("test")
 
     cls.cluster = cluster
@@ -184,24 +189,17 @@ class TestJobBrowserWithHadoop(object):
     assert_equal(
       response.context['job'].counters['FileSystemCounters']['counters']['FILE_BYTES_WRITTEN'],
       {'map': 44L, 'reduce': 12L, 'displayName': 'FILE_BYTES_WRITTEN', 'name': 'FILE_BYTES_WRITTEN'}
-      )
-    assert_equal(
-      response.context['job'].counters['org.apache.hadoop.mapred.JobInProgress$Counter'],
-      {'displayName': 'Job Counters ',
-       'name': 'org.apache.hadoop.mapred.JobInProgress$Counter',
-       'counters': {
-          'TOTAL_LAUNCHED_MAPS': {
-            'total': 1L,
-            'displayName': 'Launched map tasks',
-            'name': 'TOTAL_LAUNCHED_MAPS'
-            },
-          'TOTAL_LAUNCHED_REDUCES': {
-            'total': 1L,
-            'displayName': 'Launched reduce tasks',
-            'name': 'TOTAL_LAUNCHED_REDUCES'
-            }
-          }
-       })
+    )
+
+    # We can't just check the complete contents of the python map because the
+    # SLOTS_MILLIS_* entries have a variable number of milliseconds from
+    # run-to-run.
+    assert_equal(response.context['job'].counters['org.apache.hadoop.mapred.JobInProgress$Counter']['counters']['TOTAL_LAUNCHED_MAPS']['total'], 1)
+    assert_equal(response.context['job'].counters['org.apache.hadoop.mapred.JobInProgress$Counter']['counters']['TOTAL_LAUNCHED_REDUCES']['total'], 1)
+    assert_equal(response.context['job'].counters['org.apache.hadoop.mapred.JobInProgress$Counter']['counters']['FALLOW_SLOTS_MILLIS_MAPS']['total'], 0)
+    assert_equal(response.context['job'].counters['org.apache.hadoop.mapred.JobInProgress$Counter']['counters']['FALLOW_SLOTS_MILLIS_REDUCES']['total'], 0)
+    assert_true(response.context['job'].counters['org.apache.hadoop.mapred.JobInProgress$Counter']['counters']['SLOTS_MILLIS_MAPS']['total'] > 0)
+    assert_true(response.context['job'].counters['org.apache.hadoop.mapred.JobInProgress$Counter']['counters']['SLOTS_MILLIS_REDUCES']['total'] > 0)
 
     # Check conf keys made it
     assert_equal(response.context['job'].conf_keys['mapredReducerClass'],
@@ -272,4 +270,6 @@ class TestJobBrowserWithHadoop(object):
     # Test dock jobs
     response = self.client.get('/jobbrowser/dock_jobs/')
     assert_true('completed' in response.content)
+    # TODO(atm): I'm pretty sure the following test only passes because of
+    # failed jobs which are run in test_failed_jobs
     assert_true('failed' in response.content)

+ 8 - 2
apps/jobsub/gen-py/jobsubd/JobSubmissionService-remote

@@ -35,20 +35,22 @@ http = False
 argi = 1
 
 if sys.argv[argi] == '-h':
-  parts = sys.argv[argi+1].split(':') 
+  parts = sys.argv[argi+1].split(':')
   host = parts[0]
   port = int(parts[1])
   argi += 2
 
 if sys.argv[argi] == '-u':
   url = urlparse(sys.argv[argi+1])
-  parts = url[1].split(':') 
+  parts = url[1].split(':')
   host = parts[0]
   if len(parts) > 1:
     port = int(parts[1])
   else:
     port = 80
   uri = url[2]
+  if url[4]:
+    uri += '?%s' % url[4]
   http = True
   argi += 2
 
@@ -83,4 +85,8 @@ elif cmd == 'get_job_data':
     sys.exit(1)
   pp.pprint(client.get_job_data(eval(args[0]),))
 
+else:
+  print 'Unrecognized method %s' % cmd
+  sys.exit(1)
+
 transport.close()

+ 15 - 18
apps/jobsub/gen-py/jobsubd/JobSubmissionService.py

@@ -3,34 +3,19 @@
 #
 # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 #
-# Licensed to Cloudera, Inc. under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  Cloudera, Inc. licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
 
 from thrift.Thrift import *
 from ttypes import *
 from thrift.Thrift import TProcessor
 from thrift.transport import TTransport
-from thrift.protocol import TBinaryProtocol
+from thrift.protocol import TBinaryProtocol, TProtocol
 try:
   from thrift.protocol import fastbinary
 except:
   fastbinary = None
 
 
-class Iface:
+class Iface(object):
   def submit(self, plan):
     """
     Parameters:
@@ -216,6 +201,9 @@ class submit_args(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -285,6 +273,9 @@ class submit_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -342,6 +333,9 @@ class get_job_data_args(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -411,6 +405,9 @@ class get_job_data_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -421,4 +418,4 @@ class get_job_data_result(object):
     return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
 
   def __ne__(self, other):
-    return not (self == other)
+    return not (self == other)

+ 1 - 16
apps/jobsub/gen-py/jobsubd/__init__.py

@@ -1,16 +1 @@
-# Licensed to Cloudera, Inc. under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  Cloudera, Inc. licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-__all__ = ['ttypes', 'constants', 'JobSubmissionService']
+__all__ = ['ttypes', 'constants', 'JobSubmissionService']

+ 2 - 16
apps/jobsub/gen-py/jobsubd/constants.py

@@ -3,21 +3,7 @@
 #
 # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 #
-# Licensed to Cloudera, Inc. under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  Cloudera, Inc. licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
 
 from thrift.Thrift import *
-from ttypes import *
+from ttypes import *
+

+ 33 - 23
apps/jobsub/gen-py/jobsubd/ttypes.py

@@ -3,26 +3,11 @@
 #
 # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 #
-# Licensed to Cloudera, Inc. under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  Cloudera, Inc. licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
 
 from thrift.Thrift import *
 
 from thrift.transport import TTransport
-from thrift.protocol import TBinaryProtocol
+from thrift.protocol import TBinaryProtocol, TProtocol
 try:
   from thrift.protocol import fastbinary
 except:
@@ -67,6 +52,7 @@ class PreFabLocalizedFiles(object):
     "STREAMING": 1,
   }
 
+
 class SubmissionHandle(object):
   """
   Attributes:
@@ -115,6 +101,9 @@ class SubmissionHandle(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -216,6 +205,9 @@ class JobData(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -284,6 +276,9 @@ class SubmissionError(Exception):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __str__(self):
     return repr(self)
@@ -302,7 +297,7 @@ class SubmissionError(Exception):
 class LocalizedFile(object):
   """
   File to be copied in a LocalizeFilesStep
-  
+
   Attributes:
    - target_name: Name of file in current directory.
   Framework has the right to make this a symlink.
@@ -370,6 +365,9 @@ class LocalizedFile(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -385,7 +383,7 @@ class LocalizedFile(object):
 class LocalizeFilesStep(object):
   """
   Places files into the working directory of "jobsub plan execution".
-  
+
   Attributes:
    - localize_files
   """
@@ -437,6 +435,9 @@ class LocalizeFilesStep(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -453,7 +454,7 @@ class BinHadoopStep(object):
   """
   Runs bin/hadoop, with enough environment to point at the
   configured cluster, and to assume the correct user.
-  
+
   Attributes:
    - arguments
   """
@@ -504,6 +505,9 @@ class BinHadoopStep(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -519,10 +523,10 @@ class BinHadoopStep(object):
 class SubmissionPlanStep(object):
   """
   A union of all possible steps.
-  
+
   Note: THRIFT-409 (committed Sep 1 09) added support for unions
   to Thrift.  After a thrift release, we could switch to that syntax.
-  
+
   Attributes:
    - localize_files_step: Only one of these fields may be specified!
    - bin_hadoop_step
@@ -579,6 +583,9 @@ class SubmissionPlanStep(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -594,7 +601,7 @@ class SubmissionPlanStep(object):
 class SubmissionPlan(object):
   """
   Plan to be executed by jobsub.
-  
+
   Attributes:
    - name
    - user
@@ -702,6 +709,9 @@ class SubmissionPlan(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -712,4 +722,4 @@ class SubmissionPlan(object):
     return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
 
   def __ne__(self, other):
-    return not (self == other)
+    return not (self == other)

+ 4 - 0
apps/jobsub/regenerate_thrift.sh

@@ -0,0 +1,4 @@
+#!/bin/bash
+
+cd $(dirname $0)
+thrift -r --gen py:new_style -o . src/jobsub/jobsubd.thrift

+ 1 - 1
apps/jobsub/src/jobsub/java/build.xml

@@ -43,7 +43,7 @@
 
   <target name="build" depends="init">
     <iajc sourceroots="${src.dir}"
-          destDir="${build.dir}/out">
+          destDir="${build.dir}/out" source="1.5">
       <classpath refid="build.classpath" />
     </iajc>
   </target>

+ 2 - 2
apps/jobsub/src/jobsub/java/src/META-INF/aop-ajc.xml

@@ -17,8 +17,8 @@
 -->
 <aspectj>
 <aspects>
-<aspect name="com.cloudera.jobsub.JobClientTrace"/>
-<aspect name="com.cloudera.jobsub.UgiFixer"/>
+<aspect name="org.apache.hadoop.security.JobClientTrace"/>
+<aspect name="org.apache.hadoop.security.UgiFixer"/>
 </aspects>
 </aspectj>
 

+ 0 - 35
apps/jobsub/src/jobsub/java/src/com/cloudera/jobsub/JobClientTrace.aj

@@ -1,35 +0,0 @@
-// Licensed to Cloudera, Inc. under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  Cloudera, Inc. licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-package com.cloudera.jobsub;
-
-import org.apache.hadoop.mapred.*;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public aspect JobClientTrace {
-  private static final Log LOG = LogFactory.getLog(JobClientTracer.class);
-
-  JobClientTrace() {
-    LOG.info("Hue job submission aspect loaded.");
-  }
-  RunningJob around(JobConf conf):
-    call(RunningJob JobClient.submitJobInternal(JobConf))
-    && args(conf) {
-    RunningJob ret = proceed(conf);
-    JobClientTracer.getInstance().submittedJob(ret);
-    return ret;
-  }
-}

+ 0 - 59
apps/jobsub/src/jobsub/java/src/com/cloudera/jobsub/UgiFixer.aj

@@ -1,59 +0,0 @@
-// Licensed to Cloudera, Inc. under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  Cloudera, Inc. licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-package com.cloudera.jobsub;
-
-import org.apache.hadoop.security.UnixUserGroupInformation;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Overrides the 'whoami' and 'groups' calls that Hadoop does with
- * environment variables, specifying the username and group.
- */
-public aspect UgiFixer {
-  private static final Log LOG = LogFactory.getLog(UgiFixer.class);
-  private static final String USER_VAR = "HUE_JOBSUB_USER";
-  private static final String DEFAULT_USER = "default_jobsub_user";
-  
-  // TODO(philip): Full-on group support would mean
-  // dealing with comma-delimited values here.
-  private static final String GROUPS_VAR = "HUE_JOBSUB_GROUPS";
-  private static final String DEFAULT_GROUP = "default_jobsub_group";
-
-  UgiFixer() {
-    LOG.info("Hue UGI fixer aspect loaded.");
-  }
-
-  pointcut getUserName():
-        call(String UnixUserGroupInformation.getUnixUserName());
-
-  pointcut getUnixGroups():
-        call(String[] UnixUserGroupInformation.getUnixGroups());
-
-  String around(): getUserName() {
-    String user = System.getenv(USER_VAR);
-    return user == null ? DEFAULT_USER : user;
-  }
-
-  String[] around(): getUnixGroups() {
-    String group = System.getenv(GROUPS_VAR);
-    if (group == null) {
-      return new String[] { DEFAULT_GROUP };
-    } else {
-      return group.split(",");
-    }
-  }
-}

+ 60 - 0
apps/jobsub/src/jobsub/java/src/org/apache/hadoop/security/JobClientTrace.aj

@@ -0,0 +1,60 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package org.apache.hadoop.security;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.mapred.*;
+import org.apache.hadoop.security.Credentials;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public aspect JobClientTrace {
+  private static final Log LOG = LogFactory.getLog(JobClientTracer.class);
+
+  JobClientTrace() {
+    LOG.info("Hue job submission aspect loaded.");
+  }
+
+  RunningJob around(JobConf conf):
+    call(RunningJob JobClient.submitJobInternal(JobConf)) && args(conf) {
+    RunningJob ret = proceed(conf);
+    JobClientTracer.getInstance().submittedJob(ret);
+    return ret;
+  }
+
+  /**
+   * The JobClient assumes that the user is authenticated via kerberos for the
+   * purpose of job submission, and thus that delegation tokens for the NN(s)
+   * can be retrieved. This doesn't work, however, in the case that the job is
+   * actually being submitted to the JT via an MR delegation token, because new
+   * delegation tokens can't be retrieved if one is only authenticated via
+   * delegation tokens. The work-around here is to pre-fetch NN delegation
+   * tokens from jobsubd, and pass them in. We set the
+   * <code>mapreduce.job.credentials.binary</code> here because this happens
+   * immediately before we try to fill the token cache with delegation tokens
+   * from the NN(s).
+   */
+  void around(Configuration conf, Credentials credentials):
+    call(void JobClient.readTokensFromFiles(Configuration, Credentials)) && args(conf, credentials) {
+
+    String hadoopTokenFileLocation = System.getenv("HADOOP_TOKEN_FILE_LOCATION");
+    if (hadoopTokenFileLocation != null) {
+      conf.set("mapreduce.job.credentials.binary", System.getenv("HADOOP_TOKEN_FILE_LOCATION"));
+      conf.setBoolean("mapreduce.job.complete.cancel.delegation.tokens", false);
+    }
+    proceed(conf, credentials);
+  }
+}

+ 2 - 2
apps/jobsub/src/jobsub/java/src/com/cloudera/jobsub/JobClientTracer.java → apps/jobsub/src/jobsub/java/src/org/apache/hadoop/security/JobClientTracer.java

@@ -13,7 +13,7 @@
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 // See the License for the specific language governing permissions and
 // limitations under the License.
-package com.cloudera.jobsub;
+package org.apache.hadoop.security;
 
 import org.apache.hadoop.mapred.RunningJob;
 import java.io.PrintStream;
@@ -26,7 +26,7 @@ public class JobClientTracer {
   private static JobClientTracer instance = new JobClientTracer();
   private PrintStream reportStream;
 
-  public static final String DEFAULT_JOB_LOG="reported-jobs.txt";
+  public static final String DEFAULT_JOB_LOG = "reported-jobs.txt";
 
   public synchronized static JobClientTracer getInstance() {
     return instance;

+ 97 - 0
apps/jobsub/src/jobsub/java/src/org/apache/hadoop/security/UgiFixer.aj

@@ -0,0 +1,97 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package org.apache.hadoop.security;
+
+import java.security.Principal;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.security.auth.Subject;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.login.AppConfigurationEntry;
+import javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag;
+import javax.security.auth.login.LoginException;
+import javax.security.auth.login.Configuration;
+import javax.security.auth.spi.LoginModule;
+
+import org.apache.hadoop.security.User;
+import org.apache.hadoop.security.UserGroupInformation;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Overrides the HadoopConfiguration.getAppConfigurationEntry to return the
+ * user that Jobsub is running this job as.
+ */
+public aspect UgiFixer {
+  private static final Log LOG = LogFactory.getLog(UgiFixer.class);
+
+  static {
+    LOG.info("Hue UGI fixer aspect loaded.");
+  }
+
+  private static final String USER_VAR = "HUE_JOBSUB_USER";
+  private static final String DEFAULT_USER = "default_jobsub_user";
+
+  private static final AppConfigurationEntry JOBSUB_LOGIN =
+    new AppConfigurationEntry(JobsubLoginModule.class.getName(),
+                              LoginModuleControlFlag.REQUIRED,
+                              new HashMap<String,String>());
+
+  private static final AppConfigurationEntry[] JOBSUB_CONF =
+    new AppConfigurationEntry[]{ JOBSUB_LOGIN };
+
+  public static class JobsubLoginModule implements LoginModule {
+    private Subject subject;
+
+    public boolean abort() throws LoginException {
+      return true;
+    }
+
+    public boolean commit() throws LoginException {
+      if (!subject.getPrincipals(User.class).isEmpty()) {
+        return true;
+      }
+      String user = System.getenv(USER_VAR);
+      subject.getPrincipals().add(new User(user == null ? DEFAULT_USER : user));
+      return true;
+    }
+
+    public void initialize(Subject subject, CallbackHandler callbackHandler,
+                           Map<String, ?> sharedState, Map<String, ?> options) {
+      this.subject = subject;
+    }
+
+    public boolean login() throws LoginException {
+      return true;
+    }
+
+    public boolean logout() throws LoginException {
+      return true;
+    }
+  }
+
+  pointcut getAppConfigurationEntry(String appName):
+    execution(AppConfigurationEntry[] Configuration.getAppConfigurationEntry(String)) && args(appName) && within(UserGroupInformation);
+
+  AppConfigurationEntry[] around(String appName):
+    getAppConfigurationEntry(appName) {
+      if (!appName.equals("hadoop-simple")) {
+        LOG.warn("getAppConfigurationEntry() called for auth method other than simple, returning JOBSUB_CONF anyway: " + appName);
+      }
+      return JOBSUB_CONF;
+    }
+}

+ 9 - 5
apps/jobsub/src/jobsub/management/commands/jobsub_setup.py

@@ -32,13 +32,15 @@ from hadoop import cluster
 import hadoop.conf
 import jobsub.conf
 
+LOG = logging.getLogger(__name__)
+
 class Command(NoArgsCommand):
   """Creates file system for testing."""
   def handle_noargs(self, **options):
     remote_fs = cluster.get_hdfs()
     if hasattr(remote_fs, "setuser"):
-      remote_fs.setuser("hue", ["supergroup"])
-    logging.info("Using remote fs: %s" % str(remote_fs))
+      remote_fs.setuser(remote_fs.superuser)
+    LOG.info("Using remote fs: %s" % str(remote_fs))
 
     # Copy over examples/ and script_templates/ directories
     for dirname in ("examples", "script_templates"):
@@ -113,8 +115,10 @@ def copy_dir(local_dir, remote_fs, remote_dir):
 
 def copy_file(local_src, remote_fs, remote_dst):
   if remote_fs.exists(remote_dst):
-    logging.info("%s already exists.  Skipping." % remote_dst)
+    LOG.info("%s already exists.  Skipping." % remote_dst)
     return
+  else:
+    LOG.info("%s does not exist. trying to copy" % remote_dst)
     
   if os.path.isfile(local_src):
     src = file(local_src)
@@ -122,10 +126,10 @@ def copy_file(local_src, remote_fs, remote_dst):
       dst = remote_fs.open(remote_dst, "w")
       try:
         shutil.copyfileobj(src, dst)
-        logging.info("Copied %s -> %s" % (local_src, remote_dst))
+        LOG.info("Copied %s -> %s" % (local_src, remote_dst))
       finally:
         dst.close()
     finally:
       src.close()
   else:
-    logging.info("Skipping %s (not a file)" % local_src)
+    LOG.info("Skipping %s (not a file)" % local_src)

+ 22 - 2
apps/jobsub/src/jobsub/server.py

@@ -54,6 +54,7 @@ from jobbrowser.views import single_job
 import desktop.lib.django_util
 import hadoop.cluster
 import hadoop.conf
+from hadoop.cluster import all_mrclusters, get_all_hdfs
 import jobsub.conf
 
 LOG = logging.getLogger(__name__)
@@ -226,12 +227,29 @@ class PlanRunner(object):
     env = {      
       'HADOOP_HOME': hadoop.conf.HADOOP_HOME.get(), 
       'HADOOP_OPTS': "-javaagent:%s %s" % (jobsub.conf.ASPECTJWEAVER.get(), java_prop_str),
-      'HADOOP_CLASSPATH': jobsub.conf.ASPECTPATH.get(),
+      'HADOOP_CLASSPATH': ':'.join([jobsub.conf.ASPECTPATH.get(), hadoop.conf.HADOOP_STATIC_GROUP_MAPPING_CLASSPATH.get()]),
       'HUE_JOBTRACE_LOG': self.internal_file_name("jobs"),
       'HUE_JOBSUB_USER': self.plan.user,
       'HUE_JOBSUB_GROUPS': ",".join(self.plan.groups),
     }
-    
+
+    delegation_token_files = []
+    all_clusters = []
+    all_clusters += all_mrclusters().values()
+    all_clusters += get_all_hdfs().values()
+    LOG.info("all_clusters: %s" % (repr(all_clusters),))
+    for cluster in all_clusters:
+      if cluster.security_enabled:
+        cluster.setuser(self.plan.user)
+        token = cluster.get_delegation_token()
+        token_file = tempfile.NamedTemporaryFile()
+        token_file.write(token.delegationTokenBytes)
+        token_file.flush()
+        delegation_token_files.append(token_file)
+
+    if delegation_token_files:
+      env['HADOOP_TOKEN_FILE_LOCATION'] = ','.join([token_file.name for token_file in delegation_token_files])
+
     java_home = os.getenv('JAVA_HOME')
     if java_home:
       env["JAVA_HOME"] = java_home
@@ -259,6 +277,8 @@ class PlanRunner(object):
     if 0 != retcode:
       raise Exception("bin/hadoop returned non-zero %d" % retcode)
     LOG.info("bin/hadoop returned %d" % retcode)
+    for token_file in delegation_token_files:
+      token_file.close()
 
 class JobSubmissionServiceImpl(object):
   @coerce_exceptions

+ 7 - 4
apps/jobsub/src/jobsub/tests.py

@@ -174,7 +174,7 @@ def test_job_design_cycle():
   response = c.post("/jobsub/delete/%d" % not_mine.id)
   assert_true("Permission Denied." in response.context["error"])
 
-def create_test_user_homedir(cluster):
+def setup_cluster_fs(cluster):
   """
   Irritatingly, pi doesn't run unless /user/test exists.
   """
@@ -182,8 +182,11 @@ def create_test_user_homedir(cluster):
   if not cluster.fs.exists("/user/test"):
     cluster.fs.mkdir("/user/test")
   cluster.fs.chown("/user/test", "test", "test")
+  if not cluster.fs.exists("/tmp"):
+    cluster.fs.mkdir("/tmp")
+  cluster.fs.chmod("/tmp", int('777', 8))
   cluster.fs.setuser("test")
-create_test_user_homedir.__test__ = False # Don't confuse nose.
+setup_cluster_fs.__test__ = False # Don't confuse nose.
 
 @attr('requires_hadoop')
 def test_job_submission():
@@ -208,7 +211,7 @@ def test_job_submission():
       assert_true("<form " in response.content)
 
       # Create home dir
-      create_test_user_homedir(cluster)
+      setup_cluster_fs(cluster)
 
       # Prepare sample data
       f = cluster.fs.open("/user/test/input", "w")
@@ -323,7 +326,7 @@ def test_jobsub_setup_and_samples():
     # And now submit and run the samples
     # pi Example
     # Irritatingly, /user/test needs to exist first
-    create_test_user_homedir(cluster)
+    setup_cluster_fs(cluster)
     id = JobDesign.objects.get(name__contains="Example: Pi").id
     response = c.get("/jobsub/submit/%d" % id)
     assert_true("Iterations per mapper" in response.content)

+ 1 - 0
desktop/core/ext-py/sasl-0.1.1/MANIFEST.in

@@ -0,0 +1 @@
+include sasl/saslwrapper.h

+ 10 - 0
desktop/core/ext-py/sasl-0.1.1/PKG-INFO

@@ -0,0 +1,10 @@
+Metadata-Version: 1.0
+Name: sasl
+Version: 0.1.1
+Summary: Cyrus-SASL bindings for Python
+Home-page: http://github.com/toddlipcon/python-sasl/tree/master
+Author: Todd Lipcon
+Author-email: todd@cloudera.com
+License: UNKNOWN
+Description: UNKNOWN
+Platform: UNKNOWN

+ 1 - 0
desktop/core/ext-py/sasl-0.1.1/sasl/__init__.py

@@ -0,0 +1 @@
+from sasl.saslwrapper import *

+ 383 - 0
desktop/core/ext-py/sasl-0.1.1/sasl/saslwrapper.cpp

@@ -0,0 +1,383 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+#include "saslwrapper.h"
+#include <sasl/sasl.h>
+#include <sstream>
+#include <malloc.h>
+#include <string.h>
+#include <unistd.h>
+#include <iostream>
+
+using namespace std;
+using namespace saslwrapper;
+
+namespace saslwrapper {
+
+    class ClientImpl {
+        friend class Client;
+        ClientImpl() : conn(0), cbIndex(0), maxBufSize(65535), minSsf(0), maxSsf(65535), externalSsf(0), secret(0) {}
+        ~ClientImpl() { if (conn) sasl_dispose(&conn); conn = 0; }
+        bool setAttr(const string& key, const string& value);
+        bool setAttr(const string& key, uint32_t value);
+        bool init();
+        bool start(const string& mechList, output_string& chosen, output_string& initialResponse);
+        bool step(const string& challenge, output_string& response);
+        bool encode(const string& clearText, output_string& cipherText);
+        bool decode(const string& cipherText, output_string& clearText);
+        bool getUserId(output_string& userId);
+        void getError(output_string& error);
+
+        void addCallback(unsigned long id, void* proc);
+        void lastCallback() { addCallback(SASL_CB_LIST_END, 0); }
+        void setError(const string& context, int code, const string& text = "", const string& text2 = "");
+        void interact(sasl_interact_t* prompt);
+
+        static int cbName(void *context, int id, const char **result, unsigned *len);
+        static int cbPassword(sasl_conn_t *conn, void *context, int id, sasl_secret_t **psecret);
+
+        static bool initialized;
+        sasl_conn_t* conn;
+        sasl_callback_t callbacks[8];
+        int cbIndex;
+        string error;
+        string serviceName;
+        string userName;
+        string authName;
+        string password;
+        string hostName;
+        string externalUserName;
+        uint32_t maxBufSize;
+        uint32_t minSsf;
+        uint32_t maxSsf;
+        uint32_t externalSsf;
+        sasl_secret_t* secret;
+    };
+}
+
+bool ClientImpl::initialized = false;
+
+bool ClientImpl::init()
+{
+    int result;
+
+    if (!initialized) {
+        initialized = true;
+        result = sasl_client_init(0);
+        if (result != SASL_OK) {
+            setError("sasl_client_init", result, sasl_errstring(result, 0, 0));
+            return false;
+        }
+    }
+
+    int cbIndex = 0;
+
+    addCallback(SASL_CB_GETREALM, 0);
+    if (!userName.empty()) {
+        addCallback(SASL_CB_USER, (void*) cbName);
+        addCallback(SASL_CB_AUTHNAME, (void*) cbName);
+
+        if (!password.empty())
+            addCallback(SASL_CB_PASS, (void*) cbPassword);
+        else
+            addCallback(SASL_CB_PASS, 0);
+    }
+    lastCallback();
+
+    unsigned flags;
+
+    flags = 0;
+    if (!authName.empty() && authName != userName)
+        flags |= SASL_NEED_PROXY;
+
+    result = sasl_client_new(serviceName.c_str(), hostName.c_str(), 0, 0, callbacks, flags, &conn);
+    if (result != SASL_OK) {
+        setError("sasl_client_new", result, sasl_errstring(result, 0, 0));
+        return false;
+    }
+
+    sasl_security_properties_t secprops;
+
+    secprops.min_ssf = minSsf;
+    secprops.max_ssf = maxSsf;
+    secprops.maxbufsize = maxBufSize;
+    secprops.property_names = 0;
+    secprops.property_values = 0;
+    secprops.security_flags = 0;
+
+    result = sasl_setprop(conn, SASL_SEC_PROPS, &secprops);
+    if (result != SASL_OK) {
+        setError("sasl_setprop(SASL_SEC_PROPS)", result);
+        sasl_dispose(&conn);
+        conn = 0;
+        return false;
+    }
+
+    if (!externalUserName.empty()) {
+        result = sasl_setprop(conn, SASL_AUTH_EXTERNAL, externalUserName.c_str());
+        if (result != SASL_OK) {
+            setError("sasl_setprop(SASL_AUTH_EXTERNAL)", result);
+            sasl_dispose(&conn);
+            conn = 0;
+            return false;
+        }
+
+        result = sasl_setprop(conn, SASL_SSF_EXTERNAL, &externalSsf);
+        if (result != SASL_OK) {
+            setError("sasl_setprop(SASL_SSF_EXTERNAL)", result);
+            sasl_dispose(&conn);
+            conn = 0;
+            return false;
+        }
+    }
+
+    return true;
+}
+
+bool ClientImpl::setAttr(const string& key, const string& value)
+{
+    if (key == "service")
+        serviceName = value;
+    else if (key == "username")
+        userName = value;
+    else if (key == "authname")
+        authName = value;
+    else if (key == "password") {
+        password = value;
+        free(secret);
+        secret = (sasl_secret_t*) malloc(sizeof(sasl_secret_t) + password.length());
+    }
+    else if (key == "host")
+        hostName = value;
+    else if (key == "externaluser")
+        externalUserName = value;
+    else {
+        setError("setAttr", -1, "Unknown string attribute name", key);
+        return false;
+    }
+
+    return true;
+}
+
+bool ClientImpl::setAttr(const string& key, uint32_t value)
+{
+    if (key == "minssf")
+        minSsf = value;
+    else if (key == "maxssf")
+        maxSsf = value;
+    else if (key == "externalssf")
+        externalSsf = value;
+    else if (key == "maxbufsize")
+        maxBufSize = value;
+    else {
+        setError("setAttr", -1, "Unknown integer attribute name", key);
+        return false;
+    }
+
+    return true;
+}
+
+bool ClientImpl::start(const string& mechList, output_string& chosen, output_string& initialResponse)
+{
+    int result;
+    sasl_interact_t* prompt = 0;
+    const char* resp;
+    const char* mech;
+    unsigned int len;
+
+    do {
+        result = sasl_client_start(conn, mechList.c_str(), &prompt, &resp, &len, &mech);
+        if (result == SASL_INTERACT)
+            interact(prompt);
+    } while (result == SASL_INTERACT);
+    if (result != SASL_OK && result != SASL_CONTINUE) {
+        setError("sasl_client_start", result);
+        return false;
+    }
+
+    chosen = string(mech);
+    initialResponse = string(resp, len);
+    return true;
+}
+
+bool ClientImpl::step(const string& challenge, output_string& response)
+{
+    int result;
+    sasl_interact_t* prompt = 0;
+    const char* resp;
+    unsigned int len;
+
+    do {
+        result = sasl_client_step(conn, challenge.c_str(), challenge.size(), &prompt, &resp, &len);
+        if (result == SASL_INTERACT)
+            interact(prompt);
+    } while (result == SASL_INTERACT);
+    if (result != SASL_OK && result != SASL_CONTINUE) {
+        setError("sasl_client_step", result);
+        return false;
+    }
+
+    response = string(resp, len);
+    return true;
+}
+
+bool ClientImpl::encode(const string& clearText, output_string& cipherText)
+{
+    const char* output;
+    unsigned int outlen;
+    int result = sasl_encode(conn, clearText.c_str(), clearText.size(), &output, &outlen);
+    if (result != SASL_OK) {
+        setError("sasl_encode", result);
+        return false;
+    }
+    cipherText = string(output, outlen);
+    return true;
+}
+
+bool ClientImpl::decode(const string& cipherText, output_string& clearText)
+{
+    const char* input = cipherText.c_str();
+    unsigned int inLen = cipherText.size();
+    unsigned int remaining = inLen;
+    const char* cursor = input;
+    const char* output;
+    unsigned int outlen;
+
+    clearText = string();
+    while (remaining > 0) {
+        unsigned int segmentLen = (remaining < maxBufSize) ? remaining : maxBufSize;
+        int result = sasl_decode(conn, cursor, segmentLen, &output, &outlen);
+        if (result != SASL_OK) {
+            setError("sasl_decode", result);
+            return false;
+        }
+        clearText = clearText + string(output, outlen);
+        cursor += segmentLen;
+        remaining -= segmentLen;
+    }
+    return true;
+}
+
+bool ClientImpl::getUserId(output_string& userId)
+{
+    int result;
+    const char* operName;
+
+    result = sasl_getprop(conn, SASL_USERNAME, (const void**) &operName);
+    if (result != SASL_OK) {
+        setError("sasl_getprop(SASL_USERNAME)", result);
+        return false;
+    }
+
+    userId = string(operName);
+    return true;
+}
+
+void ClientImpl::getError(output_string& _error)
+{
+    _error = error;
+    error.clear();
+}
+
+void ClientImpl::addCallback(unsigned long id, void* proc)
+{
+    callbacks[cbIndex].id = id;
+    callbacks[cbIndex].proc = (int (*)()) proc;
+    callbacks[cbIndex].context = this;
+    cbIndex++;
+}
+
+void ClientImpl::setError(const string& context, int code, const string& text, const string& text2)
+{
+    stringstream err;
+    string etext(text.empty() ? sasl_errdetail(conn) : text);
+    err << "Error in " << context << " (" << code << ") " << etext;
+    if (!text2.empty())
+        err << " - " << text2;
+    error = err.str();
+}
+
+void ClientImpl::interact(sasl_interact_t* prompt)
+{
+    string output;
+    char* input;
+
+    if (prompt->id == SASL_CB_PASS) {
+        string ppt(prompt->prompt);
+        ppt += ": ";
+        char* pass = getpass(ppt.c_str());
+        output = string(pass);
+    } else {
+        cout << prompt->prompt;
+        if (prompt->defresult)
+            cout << " [" << prompt->defresult << "]";
+        cout << ": ";
+        cin >> output;
+    }
+    prompt->result = output.c_str();
+    prompt->len = output.length();
+}
+
+int ClientImpl::cbName(void *context, int id, const char **result, unsigned *len)
+{
+    ClientImpl* impl = (ClientImpl*) context;
+
+    if (id == SASL_CB_USER || (id == SASL_CB_AUTHNAME && impl->authName.empty())) {
+        *result = impl->userName.c_str();
+        //*len    = impl->userName.length();
+    } else if (id == SASL_CB_AUTHNAME) {
+        *result = impl->authName.c_str();
+        //*len    = impl->authName.length();
+    }
+
+    return SASL_OK;
+}
+
+int ClientImpl::cbPassword(sasl_conn_t *conn, void *context, int id, sasl_secret_t **psecret)
+{
+    ClientImpl* impl = (ClientImpl*) context;
+    size_t length = impl->password.length();
+
+    if (id == SASL_CB_PASS) {
+        impl->secret->len = length;
+        ::memcpy(impl->secret->data, impl->password.c_str(), length);
+    } else
+        impl->secret->len = 0;
+
+    *psecret = impl->secret;
+    return SASL_OK;
+}
+
+
+//==========================================================
+// WRAPPERS
+//==========================================================
+
+Client::Client() : impl(new ClientImpl()) {}
+Client::~Client() { delete impl; }
+bool Client::setAttr(const string& key, const string& value) { return impl->setAttr(key, value); }
+bool Client::setAttr(const string& key, uint32_t value) { return impl->setAttr(key, value); }
+bool Client::init() { return impl->init(); }
+bool Client::start(const string& mechList, output_string& chosen, output_string& initialResponse) { return impl->start(mechList, chosen, initialResponse); }
+bool Client::step(const string& challenge, output_string& response) { return impl->step(challenge, response); }
+bool Client::encode(const string& clearText, output_string& cipherText) { return impl->encode(clearText, cipherText); }
+bool Client::decode(const string& cipherText, output_string& clearText) { return impl->decode(cipherText, clearText); }
+bool Client::getUserId(output_string& userId) { return impl->getUserId(userId); }
+void Client::getError(output_string& error) { impl->getError(error); }
+

+ 146 - 0
desktop/core/ext-py/sasl-0.1.1/sasl/saslwrapper.h

@@ -0,0 +1,146 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+#include <stdint.h>
+#include <string>
+
+namespace saslwrapper {
+
+    /**
+     * The following type is used for output arguments (that are strings).  The fact that it has
+     * a unique name is used in a SWIG typemap to indicate output arguments.  For scripting languages
+     * such as Python and Ruby (which do not support output arguments), the outputs are placed in and
+     * array that is returned by the function.  For example, a function that looks like:
+     *
+     *      bool function(const string& input, output_string& out1, output_string& out2);
+     *
+     * would be called (in Python) like this:
+     *
+     *      boolResult, out1, out2 = function(input)
+     */
+    typedef std::string output_string;
+    class ClientImpl;
+
+    class Client {
+    public:
+
+        Client();
+        ~Client();
+
+        /**
+         * Set attributes to be used in authenticating the session.  All attributes should be set
+         * before init() is called.
+         *
+         * @param key Name of attribute being set
+         * @param value Value of attribute being set
+         * @return true iff success.  If false is returned, call getError() for error details.
+         *
+         * Available attribute keys:
+         *
+         *    service      - Name of the service being accessed
+         *    username     - User identity for authentication
+         *    authname     - User identity for authorization (if different from username)
+         *    password     - Password associated with username
+         *    host         - Fully qualified domain name of the server host
+         *    maxbufsize   - Maximum receive buffer size for the security layer
+         *    minssf       - Minimum acceptable security strength factor (integer)
+         *    maxssf       - Maximum acceptable security strength factor (integer)
+         *    externalssf  - Security strength factor supplied by external mechanism (i.e. SSL/TLS)
+         *    externaluser - Authentication ID (of client) as established by external mechanism
+         */
+        bool setAttr(const std::string& key, const std::string& value);
+        bool setAttr(const std::string& key, uint32_t value);
+
+        /**
+         * Initialize the client object.  This should be called after all of the properties have been set.
+         *
+         * @return true iff success.  If false is returned, call getError() for error details.
+         */
+        bool init();
+
+        /**
+         * Start the SASL exchange with the server.
+         *
+         * @param mechList List of mechanisms provided by the server
+         * @param chosen The mechanism chosen by the client
+         * @param initialResponse Initial block of data to send to the server
+         *
+         * @return true iff success.  If false is returned, call getError() for error details.
+         */
+        bool start(const std::string& mechList, output_string& chosen, output_string& initialResponse);
+
+        /**
+         * Step the SASL handshake.
+         *
+         * @param challenge The challenge supplied by the server
+         * @param response (output) The response to be sent back to the server
+         *
+         * @return true iff success.  If false is returned, call getError() for error details.
+         */
+        bool step(const std::string& challenge, output_string& response);
+
+        /**
+         * Encode data for secure transmission to the server.
+         *
+         * @param clearText Clear text data to be encrypted
+         * @param cipherText (output) Encrypted data to be transmitted
+         *
+         * @return true iff success.  If false is returned, call getError() for error details.
+         */
+        bool encode(const std::string& clearText, output_string& cipherText);
+
+        /**
+         * Decode data received from the server.
+         *
+         * @param cipherText Encrypted data received from the server
+         * @param clearText (output) Decrypted clear text data 
+         *
+         * @return true iff success.  If false is returned, call getError() for error details.
+         */
+        bool decode(const std::string& cipherText, output_string& clearText);
+
+        /**
+         * Get the user identity (used for authentication) associated with this session.
+         * Note that this is particularly useful for single-sign-on mechanisms in which the 
+         * username is not supplied by the application.
+         *
+         * @param userId (output) Authenticated user ID for this session.
+         */
+        bool getUserId(output_string& userId);
+
+        /**
+         * Get error message for last error.
+         * This function will return the last error message then clear the error state.
+         * If there was no error or the error state has been cleared, this function will output
+         * an empty string.
+         *
+         * @param error Error message string
+         */
+        void getError(output_string& error);
+
+    private:
+        ClientImpl* impl;
+
+        // Declare private copy constructor and assignment operator.  Ensure that this
+        // class is non-copyable.
+        Client(const Client&);
+        const Client& operator=(const Client&);
+    };
+
+}

+ 103 - 0
desktop/core/ext-py/sasl-0.1.1/sasl/saslwrapper.py

@@ -0,0 +1,103 @@
+# This file was automatically generated by SWIG (http://www.swig.org).
+# Version 1.3.36
+#
+# Don't modify this file, modify the SWIG interface instead.
+# This file is compatible with both classic and new-style classes.
+
+import _saslwrapper
+import new
+new_instancemethod = new.instancemethod
+try:
+    _swig_property = property
+except NameError:
+    pass # Python < 2.2 doesn't have 'property'.
+def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
+    if (name == "thisown"): return self.this.own(value)
+    if (name == "this"):
+        if type(value).__name__ == 'PySwigObject':
+            self.__dict__[name] = value
+            return
+    method = class_type.__swig_setmethods__.get(name,None)
+    if method: return method(self,value)
+    if (not static) or hasattr(self,name):
+        self.__dict__[name] = value
+    else:
+        raise AttributeError("You cannot add attributes to %s" % self)
+
+def _swig_setattr(self,class_type,name,value):
+    return _swig_setattr_nondynamic(self,class_type,name,value,0)
+
+def _swig_getattr(self,class_type,name):
+    if (name == "thisown"): return self.this.own()
+    method = class_type.__swig_getmethods__.get(name,None)
+    if method: return method(self)
+    raise AttributeError,name
+
+def _swig_repr(self):
+    try: strthis = "proxy of " + self.this.__repr__()
+    except: strthis = ""
+    return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
+
+import types
+try:
+    _object = types.ObjectType
+    _newclass = 1
+except AttributeError:
+    class _object : pass
+    _newclass = 0
+del types
+
+
+class PySwigIterator(_object):
+    __swig_setmethods__ = {}
+    __setattr__ = lambda self, name, value: _swig_setattr(self, PySwigIterator, name, value)
+    __swig_getmethods__ = {}
+    __getattr__ = lambda self, name: _swig_getattr(self, PySwigIterator, name)
+    def __init__(self, *args, **kwargs): raise AttributeError, "No constructor defined"
+    __repr__ = _swig_repr
+    __swig_destroy__ = _saslwrapper.delete_PySwigIterator
+    __del__ = lambda self : None;
+    def value(*args): return _saslwrapper.PySwigIterator_value(*args)
+    def incr(*args): return _saslwrapper.PySwigIterator_incr(*args)
+    def decr(*args): return _saslwrapper.PySwigIterator_decr(*args)
+    def distance(*args): return _saslwrapper.PySwigIterator_distance(*args)
+    def equal(*args): return _saslwrapper.PySwigIterator_equal(*args)
+    def copy(*args): return _saslwrapper.PySwigIterator_copy(*args)
+    def next(*args): return _saslwrapper.PySwigIterator_next(*args)
+    def previous(*args): return _saslwrapper.PySwigIterator_previous(*args)
+    def advance(*args): return _saslwrapper.PySwigIterator_advance(*args)
+    def __eq__(*args): return _saslwrapper.PySwigIterator___eq__(*args)
+    def __ne__(*args): return _saslwrapper.PySwigIterator___ne__(*args)
+    def __iadd__(*args): return _saslwrapper.PySwigIterator___iadd__(*args)
+    def __isub__(*args): return _saslwrapper.PySwigIterator___isub__(*args)
+    def __add__(*args): return _saslwrapper.PySwigIterator___add__(*args)
+    def __sub__(*args): return _saslwrapper.PySwigIterator___sub__(*args)
+    def __iter__(self): return self
+PySwigIterator_swigregister = _saslwrapper.PySwigIterator_swigregister
+PySwigIterator_swigregister(PySwigIterator)
+
+class Client(_object):
+    __swig_setmethods__ = {}
+    __setattr__ = lambda self, name, value: _swig_setattr(self, Client, name, value)
+    __swig_getmethods__ = {}
+    __getattr__ = lambda self, name: _swig_getattr(self, Client, name)
+    __repr__ = _swig_repr
+    def __init__(self, *args): 
+        this = _saslwrapper.new_Client(*args)
+        try: self.this.append(this)
+        except: self.this = this
+    __swig_destroy__ = _saslwrapper.delete_Client
+    __del__ = lambda self : None;
+    def setAttr(*args): return _saslwrapper.Client_setAttr(*args)
+    def init(*args): return _saslwrapper.Client_init(*args)
+    def start(*args): return _saslwrapper.Client_start(*args)
+    def step(*args): return _saslwrapper.Client_step(*args)
+    def encode(*args): return _saslwrapper.Client_encode(*args)
+    def decode(*args): return _saslwrapper.Client_decode(*args)
+    def getUserId(*args): return _saslwrapper.Client_getUserId(*args)
+    def getError(*args): return _saslwrapper.Client_getError(*args)
+Client_swigregister = _saslwrapper.Client_swigregister
+Client_swigregister(Client)
+
+
+

+ 5068 - 0
desktop/core/ext-py/sasl-0.1.1/sasl/saslwrapper_wrap.cxx

@@ -0,0 +1,5068 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 1.3.36
+ * 
+ * This file is not intended to be easily readable and contains a number of 
+ * coding conventions designed to improve portability and efficiency. Do not make
+ * changes to this file unless you know what you are doing--modify the SWIG 
+ * interface file instead. 
+ * ----------------------------------------------------------------------------- */
+
+#define SWIGPYTHON
+#define SWIG_PYTHON_DIRECTOR_NO_VTABLE
+
+#ifdef __cplusplus
+template<typename T> class SwigValueWrapper {
+    T *tt;
+public:
+    SwigValueWrapper() : tt(0) { }
+    SwigValueWrapper(const SwigValueWrapper<T>& rhs) : tt(new T(*rhs.tt)) { }
+    SwigValueWrapper(const T& t) : tt(new T(t)) { }
+    ~SwigValueWrapper() { delete tt; } 
+    SwigValueWrapper& operator=(const T& t) { delete tt; tt = new T(t); return *this; }
+    operator T&() const { return *tt; }
+    T *operator&() { return tt; }
+private:
+    SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs);
+};
+
+template <typename T> T SwigValueInit() {
+  return T();
+}
+#endif
+
+/* -----------------------------------------------------------------------------
+ *  This section contains generic SWIG labels for method/variable
+ *  declarations/attributes, and other compiler dependent labels.
+ * ----------------------------------------------------------------------------- */
+
+/* template workaround for compilers that cannot correctly implement the C++ standard */
+#ifndef SWIGTEMPLATEDISAMBIGUATOR
+# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
+#  define SWIGTEMPLATEDISAMBIGUATOR template
+# elif defined(__HP_aCC)
+/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
+/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
+#  define SWIGTEMPLATEDISAMBIGUATOR template
+# else
+#  define SWIGTEMPLATEDISAMBIGUATOR
+# endif
+#endif
+
+/* inline attribute */
+#ifndef SWIGINLINE
+# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
+#   define SWIGINLINE inline
+# else
+#   define SWIGINLINE
+# endif
+#endif
+
+/* attribute recognised by some compilers to avoid 'unused' warnings */
+#ifndef SWIGUNUSED
+# if defined(__GNUC__)
+#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
+#     define SWIGUNUSED __attribute__ ((__unused__)) 
+#   else
+#     define SWIGUNUSED
+#   endif
+# elif defined(__ICC)
+#   define SWIGUNUSED __attribute__ ((__unused__)) 
+# else
+#   define SWIGUNUSED 
+# endif
+#endif
+
+#ifndef SWIG_MSC_UNSUPPRESS_4505
+# if defined(_MSC_VER)
+#   pragma warning(disable : 4505) /* unreferenced local function has been removed */
+# endif 
+#endif
+
+#ifndef SWIGUNUSEDPARM
+# ifdef __cplusplus
+#   define SWIGUNUSEDPARM(p)
+# else
+#   define SWIGUNUSEDPARM(p) p SWIGUNUSED 
+# endif
+#endif
+
+/* internal SWIG method */
+#ifndef SWIGINTERN
+# define SWIGINTERN static SWIGUNUSED
+#endif
+
+/* internal inline SWIG method */
+#ifndef SWIGINTERNINLINE
+# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
+#endif
+
+/* exporting methods */
+#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+#  ifndef GCC_HASCLASSVISIBILITY
+#    define GCC_HASCLASSVISIBILITY
+#  endif
+#endif
+
+#ifndef SWIGEXPORT
+# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+#   if defined(STATIC_LINKED)
+#     define SWIGEXPORT
+#   else
+#     define SWIGEXPORT __declspec(dllexport)
+#   endif
+# else
+#   if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
+#     define SWIGEXPORT __attribute__ ((visibility("default")))
+#   else
+#     define SWIGEXPORT
+#   endif
+# endif
+#endif
+
+/* calling conventions for Windows */
+#ifndef SWIGSTDCALL
+# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+#   define SWIGSTDCALL __stdcall
+# else
+#   define SWIGSTDCALL
+# endif 
+#endif
+
+/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
+#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
+# define _CRT_SECURE_NO_DEPRECATE
+#endif
+
+/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
+#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
+# define _SCL_SECURE_NO_DEPRECATE
+#endif
+
+
+
+/* Python.h has to appear first */
+#include <Python.h>
+
+/* -----------------------------------------------------------------------------
+ * swigrun.swg
+ *
+ * This file contains generic CAPI SWIG runtime support for pointer
+ * type checking.
+ * ----------------------------------------------------------------------------- */
+
+/* This should only be incremented when either the layout of swig_type_info changes,
+   or for whatever reason, the runtime changes incompatibly */
+#define SWIG_RUNTIME_VERSION "4"
+
+/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
+#ifdef SWIG_TYPE_TABLE
+# define SWIG_QUOTE_STRING(x) #x
+# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x)
+# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE)
+#else
+# define SWIG_TYPE_TABLE_NAME
+#endif
+
+/*
+  You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for
+  creating a static or dynamic library from the swig runtime code.
+  In 99.9% of the cases, swig just needs to declare them as 'static'.
+  
+  But only do this if is strictly necessary, ie, if you have problems
+  with your compiler or so.
+*/
+
+#ifndef SWIGRUNTIME
+# define SWIGRUNTIME SWIGINTERN
+#endif
+
+#ifndef SWIGRUNTIMEINLINE
+# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE
+#endif
+
+/*  Generic buffer size */
+#ifndef SWIG_BUFFER_SIZE
+# define SWIG_BUFFER_SIZE 1024
+#endif
+
+/* Flags for pointer conversions */
+#define SWIG_POINTER_DISOWN        0x1
+#define SWIG_CAST_NEW_MEMORY       0x2
+
+/* Flags for new pointer objects */
+#define SWIG_POINTER_OWN           0x1
+
+
+/* 
+   Flags/methods for returning states.
+   
+   The swig conversion methods, as ConvertPtr, return and integer 
+   that tells if the conversion was successful or not. And if not,
+   an error code can be returned (see swigerrors.swg for the codes).
+   
+   Use the following macros/flags to set or process the returning
+   states.
+   
+   In old swig versions, you usually write code as:
+
+     if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
+       // success code
+     } else {
+       //fail code
+     }
+
+   Now you can be more explicit as:
+
+    int res = SWIG_ConvertPtr(obj,vptr,ty.flags);
+    if (SWIG_IsOK(res)) {
+      // success code
+    } else {
+      // fail code
+    }
+
+   that seems to be the same, but now you can also do
+
+    Type *ptr;
+    int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags);
+    if (SWIG_IsOK(res)) {
+      // success code
+      if (SWIG_IsNewObj(res) {
+        ...
+	delete *ptr;
+      } else {
+        ...
+      }
+    } else {
+      // fail code
+    }
+    
+   I.e., now SWIG_ConvertPtr can return new objects and you can
+   identify the case and take care of the deallocation. Of course that
+   requires also to SWIG_ConvertPtr to return new result values, as
+
+      int SWIG_ConvertPtr(obj, ptr,...) {         
+        if (<obj is ok>) {			       
+          if (<need new object>) {		       
+            *ptr = <ptr to new allocated object>; 
+            return SWIG_NEWOBJ;		       
+          } else {				       
+            *ptr = <ptr to old object>;	       
+            return SWIG_OLDOBJ;		       
+          } 				       
+        } else {				       
+          return SWIG_BADOBJ;		       
+        }					       
+      }
+
+   Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
+   more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the
+   swig errors code.
+
+   Finally, if the SWIG_CASTRANK_MODE is enabled, the result code
+   allows to return the 'cast rank', for example, if you have this
+
+       int food(double)
+       int fooi(int);
+
+   and you call
+ 
+      food(1)   // cast rank '1'  (1 -> 1.0)
+      fooi(1)   // cast rank '0'
+
+   just use the SWIG_AddCast()/SWIG_CheckState()
+
+
+ */
+#define SWIG_OK                    (0) 
+#define SWIG_ERROR                 (-1)
+#define SWIG_IsOK(r)               (r >= 0)
+#define SWIG_ArgError(r)           ((r != SWIG_ERROR) ? r : SWIG_TypeError)  
+
+/* The CastRankLimit says how many bits are used for the cast rank */
+#define SWIG_CASTRANKLIMIT         (1 << 8)
+/* The NewMask denotes the object was created (using new/malloc) */
+#define SWIG_NEWOBJMASK            (SWIG_CASTRANKLIMIT  << 1)
+/* The TmpMask is for in/out typemaps that use temporal objects */
+#define SWIG_TMPOBJMASK            (SWIG_NEWOBJMASK << 1)
+/* Simple returning values */
+#define SWIG_BADOBJ                (SWIG_ERROR)
+#define SWIG_OLDOBJ                (SWIG_OK)
+#define SWIG_NEWOBJ                (SWIG_OK | SWIG_NEWOBJMASK)
+#define SWIG_TMPOBJ                (SWIG_OK | SWIG_TMPOBJMASK)
+/* Check, add and del mask methods */
+#define SWIG_AddNewMask(r)         (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r)
+#define SWIG_DelNewMask(r)         (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r)
+#define SWIG_IsNewObj(r)           (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK))
+#define SWIG_AddTmpMask(r)         (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r)
+#define SWIG_DelTmpMask(r)         (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r)
+#define SWIG_IsTmpObj(r)           (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK))
+
+
+/* Cast-Rank Mode */
+#if defined(SWIG_CASTRANK_MODE)
+#  ifndef SWIG_TypeRank
+#    define SWIG_TypeRank             unsigned long
+#  endif
+#  ifndef SWIG_MAXCASTRANK            /* Default cast allowed */
+#    define SWIG_MAXCASTRANK          (2)
+#  endif
+#  define SWIG_CASTRANKMASK          ((SWIG_CASTRANKLIMIT) -1)
+#  define SWIG_CastRank(r)           (r & SWIG_CASTRANKMASK)
+SWIGINTERNINLINE int SWIG_AddCast(int r) { 
+  return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r;
+}
+SWIGINTERNINLINE int SWIG_CheckState(int r) { 
+  return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; 
+}
+#else /* no cast-rank mode */
+#  define SWIG_AddCast
+#  define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0)
+#endif
+
+
+
+
+#include <string.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void *(*swig_converter_func)(void *, int *);
+typedef struct swig_type_info *(*swig_dycast_func)(void **);
+
+/* Structure to store information on one type */
+typedef struct swig_type_info {
+  const char             *name;			/* mangled name of this type */
+  const char             *str;			/* human readable name of this type */
+  swig_dycast_func        dcast;		/* dynamic cast function down a hierarchy */
+  struct swig_cast_info  *cast;			/* linked list of types that can cast into this type */
+  void                   *clientdata;		/* language specific type data */
+  int                    owndata;		/* flag if the structure owns the clientdata */
+} swig_type_info;
+
+/* Structure to store a type and conversion function used for casting */
+typedef struct swig_cast_info {
+  swig_type_info         *type;			/* pointer to type that is equivalent to this type */
+  swig_converter_func     converter;		/* function to cast the void pointers */
+  struct swig_cast_info  *next;			/* pointer to next cast in linked list */
+  struct swig_cast_info  *prev;			/* pointer to the previous cast */
+} swig_cast_info;
+
+/* Structure used to store module information
+ * Each module generates one structure like this, and the runtime collects
+ * all of these structures and stores them in a circularly linked list.*/
+typedef struct swig_module_info {
+  swig_type_info         **types;		/* Array of pointers to swig_type_info structures that are in this module */
+  size_t                 size;		        /* Number of types in this module */
+  struct swig_module_info *next;		/* Pointer to next element in circularly linked list */
+  swig_type_info         **type_initial;	/* Array of initially generated type structures */
+  swig_cast_info         **cast_initial;	/* Array of initially generated casting structures */
+  void                    *clientdata;		/* Language specific module data */
+} swig_module_info;
+
+/* 
+  Compare two type names skipping the space characters, therefore
+  "char*" == "char *" and "Class<int>" == "Class<int >", etc.
+
+  Return 0 when the two name types are equivalent, as in
+  strncmp, but skipping ' '.
+*/
+SWIGRUNTIME int
+SWIG_TypeNameComp(const char *f1, const char *l1,
+		  const char *f2, const char *l2) {
+  for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) {
+    while ((*f1 == ' ') && (f1 != l1)) ++f1;
+    while ((*f2 == ' ') && (f2 != l2)) ++f2;
+    if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1;
+  }
+  return (int)((l1 - f1) - (l2 - f2));
+}
+
+/*
+  Check type equivalence in a name list like <name1>|<name2>|...
+  Return 0 if not equal, 1 if equal
+*/
+SWIGRUNTIME int
+SWIG_TypeEquiv(const char *nb, const char *tb) {
+  int equiv = 0;
+  const char* te = tb + strlen(tb);
+  const char* ne = nb;
+  while (!equiv && *ne) {
+    for (nb = ne; *ne; ++ne) {
+      if (*ne == '|') break;
+    }
+    equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
+    if (*ne) ++ne;
+  }
+  return equiv;
+}
+
+/*
+  Check type equivalence in a name list like <name1>|<name2>|...
+  Return 0 if equal, -1 if nb < tb, 1 if nb > tb
+*/
+SWIGRUNTIME int
+SWIG_TypeCompare(const char *nb, const char *tb) {
+  int equiv = 0;
+  const char* te = tb + strlen(tb);
+  const char* ne = nb;
+  while (!equiv && *ne) {
+    for (nb = ne; *ne; ++ne) {
+      if (*ne == '|') break;
+    }
+    equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
+    if (*ne) ++ne;
+  }
+  return equiv;
+}
+
+
+/* think of this as a c++ template<> or a scheme macro */
+#define SWIG_TypeCheck_Template(comparison, ty)         \
+  if (ty) {                                             \
+    swig_cast_info *iter = ty->cast;                    \
+    while (iter) {                                      \
+      if (comparison) {                                 \
+        if (iter == ty->cast) return iter;              \
+        /* Move iter to the top of the linked list */   \
+        iter->prev->next = iter->next;                  \
+        if (iter->next)                                 \
+          iter->next->prev = iter->prev;                \
+        iter->next = ty->cast;                          \
+        iter->prev = 0;                                 \
+        if (ty->cast) ty->cast->prev = iter;            \
+        ty->cast = iter;                                \
+        return iter;                                    \
+      }                                                 \
+      iter = iter->next;                                \
+    }                                                   \
+  }                                                     \
+  return 0
+
+/*
+  Check the typename
+*/
+SWIGRUNTIME swig_cast_info *
+SWIG_TypeCheck(const char *c, swig_type_info *ty) {
+  SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty);
+}
+
+/* Same as previous function, except strcmp is replaced with a pointer comparison */
+SWIGRUNTIME swig_cast_info *
+SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) {
+  SWIG_TypeCheck_Template(iter->type == from, into);
+}
+
+/*
+  Cast a pointer up an inheritance hierarchy
+*/
+SWIGRUNTIMEINLINE void *
+SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
+  return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
+}
+
+/* 
+   Dynamic pointer casting. Down an inheritance hierarchy
+*/
+SWIGRUNTIME swig_type_info *
+SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) {
+  swig_type_info *lastty = ty;
+  if (!ty || !ty->dcast) return ty;
+  while (ty && (ty->dcast)) {
+    ty = (*ty->dcast)(ptr);
+    if (ty) lastty = ty;
+  }
+  return lastty;
+}
+
+/*
+  Return the name associated with this type
+*/
+SWIGRUNTIMEINLINE const char *
+SWIG_TypeName(const swig_type_info *ty) {
+  return ty->name;
+}
+
+/*
+  Return the pretty name associated with this type,
+  that is an unmangled type name in a form presentable to the user.
+*/
+SWIGRUNTIME const char *
+SWIG_TypePrettyName(const swig_type_info *type) {
+  /* The "str" field contains the equivalent pretty names of the
+     type, separated by vertical-bar characters.  We choose
+     to print the last name, as it is often (?) the most
+     specific. */
+  if (!type) return NULL;
+  if (type->str != NULL) {
+    const char *last_name = type->str;
+    const char *s;
+    for (s = type->str; *s; s++)
+      if (*s == '|') last_name = s+1;
+    return last_name;
+  }
+  else
+    return type->name;
+}
+
+/* 
+   Set the clientdata field for a type
+*/
+SWIGRUNTIME void
+SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
+  swig_cast_info *cast = ti->cast;
+  /* if (ti->clientdata == clientdata) return; */
+  ti->clientdata = clientdata;
+  
+  while (cast) {
+    if (!cast->converter) {
+      swig_type_info *tc = cast->type;
+      if (!tc->clientdata) {
+	SWIG_TypeClientData(tc, clientdata);
+      }
+    }    
+    cast = cast->next;
+  }
+}
+SWIGRUNTIME void
+SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) {
+  SWIG_TypeClientData(ti, clientdata);
+  ti->owndata = 1;
+}
+  
+/*
+  Search for a swig_type_info structure only by mangled name
+  Search is a O(log #types)
+  
+  We start searching at module start, and finish searching when start == end.  
+  Note: if start == end at the beginning of the function, we go all the way around
+  the circular list.
+*/
+SWIGRUNTIME swig_type_info *
+SWIG_MangledTypeQueryModule(swig_module_info *start, 
+                            swig_module_info *end, 
+		            const char *name) {
+  swig_module_info *iter = start;
+  do {
+    if (iter->size) {
+      register size_t l = 0;
+      register size_t r = iter->size - 1;
+      do {
+	/* since l+r >= 0, we can (>> 1) instead (/ 2) */
+	register size_t i = (l + r) >> 1; 
+	const char *iname = iter->types[i]->name;
+	if (iname) {
+	  register int compare = strcmp(name, iname);
+	  if (compare == 0) {	    
+	    return iter->types[i];
+	  } else if (compare < 0) {
+	    if (i) {
+	      r = i - 1;
+	    } else {
+	      break;
+	    }
+	  } else if (compare > 0) {
+	    l = i + 1;
+	  }
+	} else {
+	  break; /* should never happen */
+	}
+      } while (l <= r);
+    }
+    iter = iter->next;
+  } while (iter != end);
+  return 0;
+}
+
+/*
+  Search for a swig_type_info structure for either a mangled name or a human readable name.
+  It first searches the mangled names of the types, which is a O(log #types)
+  If a type is not found it then searches the human readable names, which is O(#types).
+  
+  We start searching at module start, and finish searching when start == end.  
+  Note: if start == end at the beginning of the function, we go all the way around
+  the circular list.
+*/
+SWIGRUNTIME swig_type_info *
+SWIG_TypeQueryModule(swig_module_info *start, 
+                     swig_module_info *end, 
+		     const char *name) {
+  /* STEP 1: Search the name field using binary search */
+  swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name);
+  if (ret) {
+    return ret;
+  } else {
+    /* STEP 2: If the type hasn't been found, do a complete search
+       of the str field (the human readable name) */
+    swig_module_info *iter = start;
+    do {
+      register size_t i = 0;
+      for (; i < iter->size; ++i) {
+	if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name)))
+	  return iter->types[i];
+      }
+      iter = iter->next;
+    } while (iter != end);
+  }
+  
+  /* neither found a match */
+  return 0;
+}
+
+/* 
+   Pack binary data into a string
+*/
+SWIGRUNTIME char *
+SWIG_PackData(char *c, void *ptr, size_t sz) {
+  static const char hex[17] = "0123456789abcdef";
+  register const unsigned char *u = (unsigned char *) ptr;
+  register const unsigned char *eu =  u + sz;
+  for (; u != eu; ++u) {
+    register unsigned char uu = *u;
+    *(c++) = hex[(uu & 0xf0) >> 4];
+    *(c++) = hex[uu & 0xf];
+  }
+  return c;
+}
+
+/* 
+   Unpack binary data from a string
+*/
+SWIGRUNTIME const char *
+SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
+  register unsigned char *u = (unsigned char *) ptr;
+  register const unsigned char *eu = u + sz;
+  for (; u != eu; ++u) {
+    register char d = *(c++);
+    register unsigned char uu;
+    if ((d >= '0') && (d <= '9'))
+      uu = ((d - '0') << 4);
+    else if ((d >= 'a') && (d <= 'f'))
+      uu = ((d - ('a'-10)) << 4);
+    else 
+      return (char *) 0;
+    d = *(c++);
+    if ((d >= '0') && (d <= '9'))
+      uu |= (d - '0');
+    else if ((d >= 'a') && (d <= 'f'))
+      uu |= (d - ('a'-10));
+    else 
+      return (char *) 0;
+    *u = uu;
+  }
+  return c;
+}
+
+/* 
+   Pack 'void *' into a string buffer.
+*/
+SWIGRUNTIME char *
+SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) {
+  char *r = buff;
+  if ((2*sizeof(void *) + 2) > bsz) return 0;
+  *(r++) = '_';
+  r = SWIG_PackData(r,&ptr,sizeof(void *));
+  if (strlen(name) + 1 > (bsz - (r - buff))) return 0;
+  strcpy(r,name);
+  return buff;
+}
+
+SWIGRUNTIME const char *
+SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) {
+  if (*c != '_') {
+    if (strcmp(c,"NULL") == 0) {
+      *ptr = (void *) 0;
+      return name;
+    } else {
+      return 0;
+    }
+  }
+  return SWIG_UnpackData(++c,ptr,sizeof(void *));
+}
+
+SWIGRUNTIME char *
+SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) {
+  char *r = buff;
+  size_t lname = (name ? strlen(name) : 0);
+  if ((2*sz + 2 + lname) > bsz) return 0;
+  *(r++) = '_';
+  r = SWIG_PackData(r,ptr,sz);
+  if (lname) {
+    strncpy(r,name,lname+1);
+  } else {
+    *r = 0;
+  }
+  return buff;
+}
+
+SWIGRUNTIME const char *
+SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
+  if (*c != '_') {
+    if (strcmp(c,"NULL") == 0) {
+      memset(ptr,0,sz);
+      return name;
+    } else {
+      return 0;
+    }
+  }
+  return SWIG_UnpackData(++c,ptr,sz);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+/*  Errors in SWIG */
+#define  SWIG_UnknownError    	   -1 
+#define  SWIG_IOError        	   -2 
+#define  SWIG_RuntimeError   	   -3 
+#define  SWIG_IndexError     	   -4 
+#define  SWIG_TypeError      	   -5 
+#define  SWIG_DivisionByZero 	   -6 
+#define  SWIG_OverflowError  	   -7 
+#define  SWIG_SyntaxError    	   -8 
+#define  SWIG_ValueError     	   -9 
+#define  SWIG_SystemError    	   -10
+#define  SWIG_AttributeError 	   -11
+#define  SWIG_MemoryError    	   -12 
+#define  SWIG_NullReferenceError   -13
+
+
+
+
+/* Add PyOS_snprintf for old Pythons */
+#if PY_VERSION_HEX < 0x02020000
+# if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM)
+#  define PyOS_snprintf _snprintf
+# else
+#  define PyOS_snprintf snprintf
+# endif
+#endif
+
+/* A crude PyString_FromFormat implementation for old Pythons */
+#if PY_VERSION_HEX < 0x02020000
+
+#ifndef SWIG_PYBUFFER_SIZE
+# define SWIG_PYBUFFER_SIZE 1024
+#endif
+
+static PyObject *
+PyString_FromFormat(const char *fmt, ...) {
+  va_list ap;
+  char buf[SWIG_PYBUFFER_SIZE * 2];
+  int res;
+  va_start(ap, fmt);
+  res = vsnprintf(buf, sizeof(buf), fmt, ap);
+  va_end(ap);
+  return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf);
+}
+#endif
+
+/* Add PyObject_Del for old Pythons */
+#if PY_VERSION_HEX < 0x01060000
+# define PyObject_Del(op) PyMem_DEL((op))
+#endif
+#ifndef PyObject_DEL
+# define PyObject_DEL PyObject_Del
+#endif
+
+/* A crude PyExc_StopIteration exception for old Pythons */
+#if PY_VERSION_HEX < 0x02020000
+# ifndef PyExc_StopIteration
+#  define PyExc_StopIteration PyExc_RuntimeError
+# endif
+# ifndef PyObject_GenericGetAttr
+#  define PyObject_GenericGetAttr 0
+# endif
+#endif
+/* Py_NotImplemented is defined in 2.1 and up. */
+#if PY_VERSION_HEX < 0x02010000
+# ifndef Py_NotImplemented
+#  define Py_NotImplemented PyExc_RuntimeError
+# endif
+#endif
+
+
+/* A crude PyString_AsStringAndSize implementation for old Pythons */
+#if PY_VERSION_HEX < 0x02010000
+# ifndef PyString_AsStringAndSize
+#  define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;}
+# endif
+#endif
+
+/* PySequence_Size for old Pythons */
+#if PY_VERSION_HEX < 0x02000000
+# ifndef PySequence_Size
+#  define PySequence_Size PySequence_Length
+# endif
+#endif
+
+
+/* PyBool_FromLong for old Pythons */
+#if PY_VERSION_HEX < 0x02030000
+static
+PyObject *PyBool_FromLong(long ok)
+{
+  PyObject *result = ok ? Py_True : Py_False;
+  Py_INCREF(result);
+  return result;
+}
+#endif
+
+/* Py_ssize_t for old Pythons */
+/* This code is as recommended by: */
+/* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */
+#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
+typedef int Py_ssize_t;
+# define PY_SSIZE_T_MAX INT_MAX
+# define PY_SSIZE_T_MIN INT_MIN
+#endif
+
+/* -----------------------------------------------------------------------------
+ * error manipulation
+ * ----------------------------------------------------------------------------- */
+
+SWIGRUNTIME PyObject*
+SWIG_Python_ErrorType(int code) {
+  PyObject* type = 0;
+  switch(code) {
+  case SWIG_MemoryError:
+    type = PyExc_MemoryError;
+    break;
+  case SWIG_IOError:
+    type = PyExc_IOError;
+    break;
+  case SWIG_RuntimeError:
+    type = PyExc_RuntimeError;
+    break;
+  case SWIG_IndexError:
+    type = PyExc_IndexError;
+    break;
+  case SWIG_TypeError:
+    type = PyExc_TypeError;
+    break;
+  case SWIG_DivisionByZero:
+    type = PyExc_ZeroDivisionError;
+    break;
+  case SWIG_OverflowError:
+    type = PyExc_OverflowError;
+    break;
+  case SWIG_SyntaxError:
+    type = PyExc_SyntaxError;
+    break;
+  case SWIG_ValueError:
+    type = PyExc_ValueError;
+    break;
+  case SWIG_SystemError:
+    type = PyExc_SystemError;
+    break;
+  case SWIG_AttributeError:
+    type = PyExc_AttributeError;
+    break;
+  default:
+    type = PyExc_RuntimeError;
+  }
+  return type;
+}
+
+
+SWIGRUNTIME void
+SWIG_Python_AddErrorMsg(const char* mesg)
+{
+  PyObject *type = 0;
+  PyObject *value = 0;
+  PyObject *traceback = 0;
+
+  if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback);
+  if (value) {
+    PyObject *old_str = PyObject_Str(value);
+    PyErr_Clear();
+    Py_XINCREF(type);
+    PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg);
+    Py_DECREF(old_str);
+    Py_DECREF(value);
+  } else {
+    PyErr_SetString(PyExc_RuntimeError, mesg);
+  }
+}
+
+
+
+#if defined(SWIG_PYTHON_NO_THREADS)
+#  if defined(SWIG_PYTHON_THREADS)
+#    undef SWIG_PYTHON_THREADS
+#  endif
+#endif
+#if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */
+#  if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL)
+#    if (PY_VERSION_HEX >= 0x02030000) /* For 2.3 or later, use the PyGILState calls */
+#      define SWIG_PYTHON_USE_GIL
+#    endif
+#  endif
+#  if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */
+#    ifndef SWIG_PYTHON_INITIALIZE_THREADS
+#     define SWIG_PYTHON_INITIALIZE_THREADS  PyEval_InitThreads() 
+#    endif
+#    ifdef __cplusplus /* C++ code */
+       class SWIG_Python_Thread_Block {
+         bool status;
+         PyGILState_STATE state;
+       public:
+         void end() { if (status) { PyGILState_Release(state); status = false;} }
+         SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {}
+         ~SWIG_Python_Thread_Block() { end(); }
+       };
+       class SWIG_Python_Thread_Allow {
+         bool status;
+         PyThreadState *save;
+       public:
+         void end() { if (status) { PyEval_RestoreThread(save); status = false; }}
+         SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {}
+         ~SWIG_Python_Thread_Allow() { end(); }
+       };
+#      define SWIG_PYTHON_THREAD_BEGIN_BLOCK   SWIG_Python_Thread_Block _swig_thread_block
+#      define SWIG_PYTHON_THREAD_END_BLOCK     _swig_thread_block.end()
+#      define SWIG_PYTHON_THREAD_BEGIN_ALLOW   SWIG_Python_Thread_Allow _swig_thread_allow
+#      define SWIG_PYTHON_THREAD_END_ALLOW     _swig_thread_allow.end()
+#    else /* C code */
+#      define SWIG_PYTHON_THREAD_BEGIN_BLOCK   PyGILState_STATE _swig_thread_block = PyGILState_Ensure()
+#      define SWIG_PYTHON_THREAD_END_BLOCK     PyGILState_Release(_swig_thread_block)
+#      define SWIG_PYTHON_THREAD_BEGIN_ALLOW   PyThreadState *_swig_thread_allow = PyEval_SaveThread()
+#      define SWIG_PYTHON_THREAD_END_ALLOW     PyEval_RestoreThread(_swig_thread_allow)
+#    endif
+#  else /* Old thread way, not implemented, user must provide it */
+#    if !defined(SWIG_PYTHON_INITIALIZE_THREADS)
+#      define SWIG_PYTHON_INITIALIZE_THREADS
+#    endif
+#    if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK)
+#      define SWIG_PYTHON_THREAD_BEGIN_BLOCK
+#    endif
+#    if !defined(SWIG_PYTHON_THREAD_END_BLOCK)
+#      define SWIG_PYTHON_THREAD_END_BLOCK
+#    endif
+#    if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW)
+#      define SWIG_PYTHON_THREAD_BEGIN_ALLOW
+#    endif
+#    if !defined(SWIG_PYTHON_THREAD_END_ALLOW)
+#      define SWIG_PYTHON_THREAD_END_ALLOW
+#    endif
+#  endif
+#else /* No thread support */
+#  define SWIG_PYTHON_INITIALIZE_THREADS
+#  define SWIG_PYTHON_THREAD_BEGIN_BLOCK
+#  define SWIG_PYTHON_THREAD_END_BLOCK
+#  define SWIG_PYTHON_THREAD_BEGIN_ALLOW
+#  define SWIG_PYTHON_THREAD_END_ALLOW
+#endif
+
+/* -----------------------------------------------------------------------------
+ * Python API portion that goes into the runtime
+ * ----------------------------------------------------------------------------- */
+
+#ifdef __cplusplus
+extern "C" {
+#if 0
+} /* cc-mode */
+#endif
+#endif
+
+/* -----------------------------------------------------------------------------
+ * Constant declarations
+ * ----------------------------------------------------------------------------- */
+
+/* Constant Types */
+#define SWIG_PY_POINTER 4
+#define SWIG_PY_BINARY  5
+
+/* Constant information structure */
+typedef struct swig_const_info {
+  int type;
+  char *name;
+  long lvalue;
+  double dvalue;
+  void   *pvalue;
+  swig_type_info **ptype;
+} swig_const_info;
+
+#ifdef __cplusplus
+#if 0
+{ /* cc-mode */
+#endif
+}
+#endif
+
+
+/* -----------------------------------------------------------------------------
+ * See the LICENSE file for information on copyright, usage and redistribution
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
+ *
+ * pyrun.swg
+ *
+ * This file contains the runtime support for Python modules
+ * and includes code for managing global variables and pointer
+ * type checking.
+ *
+ * ----------------------------------------------------------------------------- */
+
+/* Common SWIG API */
+
+/* for raw pointers */
+#define SWIG_Python_ConvertPtr(obj, pptr, type, flags)  SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0)
+#define SWIG_ConvertPtr(obj, pptr, type, flags)         SWIG_Python_ConvertPtr(obj, pptr, type, flags)
+#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own)  SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own)
+#define SWIG_NewPointerObj(ptr, type, flags)            SWIG_Python_NewPointerObj(ptr, type, flags)
+#define SWIG_CheckImplicit(ty)                          SWIG_Python_CheckImplicit(ty) 
+#define SWIG_AcquirePtr(ptr, src)                       SWIG_Python_AcquirePtr(ptr, src)
+#define swig_owntype                                    int
+
+/* for raw packed data */
+#define SWIG_ConvertPacked(obj, ptr, sz, ty)            SWIG_Python_ConvertPacked(obj, ptr, sz, ty)
+#define SWIG_NewPackedObj(ptr, sz, type)                SWIG_Python_NewPackedObj(ptr, sz, type)
+
+/* for class or struct pointers */
+#define SWIG_ConvertInstance(obj, pptr, type, flags)    SWIG_ConvertPtr(obj, pptr, type, flags)
+#define SWIG_NewInstanceObj(ptr, type, flags)           SWIG_NewPointerObj(ptr, type, flags)
+
+/* for C or C++ function pointers */
+#define SWIG_ConvertFunctionPtr(obj, pptr, type)        SWIG_Python_ConvertFunctionPtr(obj, pptr, type)
+#define SWIG_NewFunctionPtrObj(ptr, type)               SWIG_Python_NewPointerObj(ptr, type, 0)
+
+/* for C++ member pointers, ie, member methods */
+#define SWIG_ConvertMember(obj, ptr, sz, ty)            SWIG_Python_ConvertPacked(obj, ptr, sz, ty)
+#define SWIG_NewMemberObj(ptr, sz, type)                SWIG_Python_NewPackedObj(ptr, sz, type)
+
+
+/* Runtime API */
+
+#define SWIG_GetModule(clientdata)                      SWIG_Python_GetModule()
+#define SWIG_SetModule(clientdata, pointer)             SWIG_Python_SetModule(pointer)
+#define SWIG_NewClientData(obj)                         PySwigClientData_New(obj)
+
+#define SWIG_SetErrorObj                                SWIG_Python_SetErrorObj                            
+#define SWIG_SetErrorMsg                        	SWIG_Python_SetErrorMsg				   
+#define SWIG_ErrorType(code)                    	SWIG_Python_ErrorType(code)                        
+#define SWIG_Error(code, msg)            		SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) 
+#define SWIG_fail                        		goto fail					   
+
+
+/* Runtime API implementation */
+
+/* Error manipulation */
+
+SWIGINTERN void 
+SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) {
+  SWIG_PYTHON_THREAD_BEGIN_BLOCK; 
+  PyErr_SetObject(errtype, obj);
+  Py_DECREF(obj);
+  SWIG_PYTHON_THREAD_END_BLOCK;
+}
+
+SWIGINTERN void 
+SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) {
+  SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+  PyErr_SetString(errtype, (char *) msg);
+  SWIG_PYTHON_THREAD_END_BLOCK;
+}
+
+#define SWIG_Python_Raise(obj, type, desc)  SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj)
+
+/* Set a constant value */
+
+SWIGINTERN void
+SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) {   
+  PyDict_SetItemString(d, (char*) name, obj);
+  Py_DECREF(obj);                            
+}
+
+/* Append a value to the result obj */
+
+SWIGINTERN PyObject*
+SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) {
+#if !defined(SWIG_PYTHON_OUTPUT_TUPLE)
+  if (!result) {
+    result = obj;
+  } else if (result == Py_None) {
+    Py_DECREF(result);
+    result = obj;
+  } else {
+    if (!PyList_Check(result)) {
+      PyObject *o2 = result;
+      result = PyList_New(1);
+      PyList_SetItem(result, 0, o2);
+    }
+    PyList_Append(result,obj);
+    Py_DECREF(obj);
+  }
+  return result;
+#else
+  PyObject*   o2;
+  PyObject*   o3;
+  if (!result) {
+    result = obj;
+  } else if (result == Py_None) {
+    Py_DECREF(result);
+    result = obj;
+  } else {
+    if (!PyTuple_Check(result)) {
+      o2 = result;
+      result = PyTuple_New(1);
+      PyTuple_SET_ITEM(result, 0, o2);
+    }
+    o3 = PyTuple_New(1);
+    PyTuple_SET_ITEM(o3, 0, obj);
+    o2 = result;
+    result = PySequence_Concat(o2, o3);
+    Py_DECREF(o2);
+    Py_DECREF(o3);
+  }
+  return result;
+#endif
+}
+
+/* Unpack the argument tuple */
+
+SWIGINTERN int
+SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs)
+{
+  if (!args) {
+    if (!min && !max) {
+      return 1;
+    } else {
+      PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none", 
+		   name, (min == max ? "" : "at least "), (int)min);
+      return 0;
+    }
+  }  
+  if (!PyTuple_Check(args)) {
+    PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple");
+    return 0;
+  } else {
+    register Py_ssize_t l = PyTuple_GET_SIZE(args);
+    if (l < min) {
+      PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", 
+		   name, (min == max ? "" : "at least "), (int)min, (int)l);
+      return 0;
+    } else if (l > max) {
+      PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", 
+		   name, (min == max ? "" : "at most "), (int)max, (int)l);
+      return 0;
+    } else {
+      register int i;
+      for (i = 0; i < l; ++i) {
+	objs[i] = PyTuple_GET_ITEM(args, i);
+      }
+      for (; l < max; ++l) {
+	objs[l] = 0;
+      }
+      return i + 1;
+    }    
+  }
+}
+
+/* A functor is a function object with one single object argument */
+#if PY_VERSION_HEX >= 0x02020000
+#define SWIG_Python_CallFunctor(functor, obj)	        PyObject_CallFunctionObjArgs(functor, obj, NULL);
+#else
+#define SWIG_Python_CallFunctor(functor, obj)	        PyObject_CallFunction(functor, "O", obj);
+#endif
+
+/*
+  Helper for static pointer initialization for both C and C++ code, for example
+  static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...);
+*/
+#ifdef __cplusplus
+#define SWIG_STATIC_POINTER(var)  var
+#else
+#define SWIG_STATIC_POINTER(var)  var = 0; if (!var) var
+#endif
+
+/* -----------------------------------------------------------------------------
+ * Pointer declarations
+ * ----------------------------------------------------------------------------- */
+
+/* Flags for new pointer objects */
+#define SWIG_POINTER_NOSHADOW       (SWIG_POINTER_OWN      << 1)
+#define SWIG_POINTER_NEW            (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN)
+
+#define SWIG_POINTER_IMPLICIT_CONV  (SWIG_POINTER_DISOWN   << 1)
+
+#ifdef __cplusplus
+extern "C" {
+#if 0
+} /* cc-mode */
+#endif
+#endif
+
+/*  How to access Py_None */
+#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+#  ifndef SWIG_PYTHON_NO_BUILD_NONE
+#    ifndef SWIG_PYTHON_BUILD_NONE
+#      define SWIG_PYTHON_BUILD_NONE
+#    endif
+#  endif
+#endif
+
+#ifdef SWIG_PYTHON_BUILD_NONE
+#  ifdef Py_None
+#   undef Py_None
+#   define Py_None SWIG_Py_None()
+#  endif
+SWIGRUNTIMEINLINE PyObject * 
+_SWIG_Py_None(void)
+{
+  PyObject *none = Py_BuildValue((char*)"");
+  Py_DECREF(none);
+  return none;
+}
+SWIGRUNTIME PyObject * 
+SWIG_Py_None(void)
+{
+  static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None();
+  return none;
+}
+#endif
+
+/* The python void return value */
+
+SWIGRUNTIMEINLINE PyObject * 
+SWIG_Py_Void(void)
+{
+  PyObject *none = Py_None;
+  Py_INCREF(none);
+  return none;
+}
+
+/* PySwigClientData */
+
+typedef struct {
+  PyObject *klass;
+  PyObject *newraw;
+  PyObject *newargs;
+  PyObject *destroy;
+  int delargs;
+  int implicitconv;
+} PySwigClientData;
+
+SWIGRUNTIMEINLINE int 
+SWIG_Python_CheckImplicit(swig_type_info *ty)
+{
+  PySwigClientData *data = (PySwigClientData *)ty->clientdata;
+  return data ? data->implicitconv : 0;
+}
+
+SWIGRUNTIMEINLINE PyObject *
+SWIG_Python_ExceptionType(swig_type_info *desc) {
+  PySwigClientData *data = desc ? (PySwigClientData *) desc->clientdata : 0;
+  PyObject *klass = data ? data->klass : 0;
+  return (klass ? klass : PyExc_RuntimeError);
+}
+
+
+SWIGRUNTIME PySwigClientData * 
+PySwigClientData_New(PyObject* obj)
+{
+  if (!obj) {
+    return 0;
+  } else {
+    PySwigClientData *data = (PySwigClientData *)malloc(sizeof(PySwigClientData));
+    /* the klass element */
+    data->klass = obj;
+    Py_INCREF(data->klass);
+    /* the newraw method and newargs arguments used to create a new raw instance */
+    if (PyClass_Check(obj)) {
+      data->newraw = 0;
+      data->newargs = obj;
+      Py_INCREF(obj);
+    } else {
+#if (PY_VERSION_HEX < 0x02020000)
+      data->newraw = 0;
+#else
+      data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__");
+#endif
+      if (data->newraw) {
+	Py_INCREF(data->newraw);
+	data->newargs = PyTuple_New(1);
+	PyTuple_SetItem(data->newargs, 0, obj);
+      } else {
+	data->newargs = obj;
+      }
+      Py_INCREF(data->newargs);
+    }
+    /* the destroy method, aka as the C++ delete method */
+    data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__");
+    if (PyErr_Occurred()) {
+      PyErr_Clear();
+      data->destroy = 0;
+    }
+    if (data->destroy) {
+      int flags;
+      Py_INCREF(data->destroy);
+      flags = PyCFunction_GET_FLAGS(data->destroy);
+#ifdef METH_O
+      data->delargs = !(flags & (METH_O));
+#else
+      data->delargs = 0;
+#endif
+    } else {
+      data->delargs = 0;
+    }
+    data->implicitconv = 0;
+    return data;
+  }
+}
+
+SWIGRUNTIME void 
+PySwigClientData_Del(PySwigClientData* data)
+{
+  Py_XDECREF(data->newraw);
+  Py_XDECREF(data->newargs);
+  Py_XDECREF(data->destroy);
+}
+
+/* =============== PySwigObject =====================*/
+
+typedef struct {
+  PyObject_HEAD
+  void *ptr;
+  swig_type_info *ty;
+  int own;
+  PyObject *next;
+} PySwigObject;
+
+SWIGRUNTIME PyObject *
+PySwigObject_long(PySwigObject *v)
+{
+  return PyLong_FromVoidPtr(v->ptr);
+}
+
+SWIGRUNTIME PyObject *
+PySwigObject_format(const char* fmt, PySwigObject *v)
+{
+  PyObject *res = NULL;
+  PyObject *args = PyTuple_New(1);
+  if (args) {
+    if (PyTuple_SetItem(args, 0, PySwigObject_long(v)) == 0) {
+      PyObject *ofmt = PyString_FromString(fmt);
+      if (ofmt) {
+	res = PyString_Format(ofmt,args);
+	Py_DECREF(ofmt);
+      }
+      Py_DECREF(args);
+    }
+  }
+  return res;
+}
+
+SWIGRUNTIME PyObject *
+PySwigObject_oct(PySwigObject *v)
+{
+  return PySwigObject_format("%o",v);
+}
+
+SWIGRUNTIME PyObject *
+PySwigObject_hex(PySwigObject *v)
+{
+  return PySwigObject_format("%x",v);
+}
+
+SWIGRUNTIME PyObject *
+#ifdef METH_NOARGS
+PySwigObject_repr(PySwigObject *v)
+#else
+PySwigObject_repr(PySwigObject *v, PyObject *args)
+#endif
+{
+  const char *name = SWIG_TypePrettyName(v->ty);
+  PyObject *hex = PySwigObject_hex(v);    
+  PyObject *repr = PyString_FromFormat("<Swig Object of type '%s' at 0x%s>", name, PyString_AsString(hex));
+  Py_DECREF(hex);
+  if (v->next) {
+#ifdef METH_NOARGS
+    PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next);
+#else
+    PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next, args);
+#endif
+    PyString_ConcatAndDel(&repr,nrep);
+  }
+  return repr;  
+}
+
+SWIGRUNTIME int
+PySwigObject_print(PySwigObject *v, FILE *fp, int SWIGUNUSEDPARM(flags))
+{
+#ifdef METH_NOARGS
+  PyObject *repr = PySwigObject_repr(v);
+#else
+  PyObject *repr = PySwigObject_repr(v, NULL);
+#endif
+  if (repr) {
+    fputs(PyString_AsString(repr), fp);
+    Py_DECREF(repr);
+    return 0; 
+  } else {
+    return 1; 
+  }
+}
+
+SWIGRUNTIME PyObject *
+PySwigObject_str(PySwigObject *v)
+{
+  char result[SWIG_BUFFER_SIZE];
+  return SWIG_PackVoidPtr(result, v->ptr, v->ty->name, sizeof(result)) ?
+    PyString_FromString(result) : 0;
+}
+
+SWIGRUNTIME int
+PySwigObject_compare(PySwigObject *v, PySwigObject *w)
+{
+  void *i = v->ptr;
+  void *j = w->ptr;
+  return (i < j) ? -1 : ((i > j) ? 1 : 0);
+}
+
+SWIGRUNTIME PyTypeObject* _PySwigObject_type(void);
+
+SWIGRUNTIME PyTypeObject*
+PySwigObject_type(void) {
+  static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigObject_type();
+  return type;
+}
+
+SWIGRUNTIMEINLINE int
+PySwigObject_Check(PyObject *op) {
+  return ((op)->ob_type == PySwigObject_type())
+    || (strcmp((op)->ob_type->tp_name,"PySwigObject") == 0);
+}
+
+SWIGRUNTIME PyObject *
+PySwigObject_New(void *ptr, swig_type_info *ty, int own);
+
+SWIGRUNTIME void
+PySwigObject_dealloc(PyObject *v)
+{
+  PySwigObject *sobj = (PySwigObject *) v;
+  PyObject *next = sobj->next;
+  if (sobj->own == SWIG_POINTER_OWN) {
+    swig_type_info *ty = sobj->ty;
+    PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0;
+    PyObject *destroy = data ? data->destroy : 0;
+    if (destroy) {
+      /* destroy is always a VARARGS method */
+      PyObject *res;
+      if (data->delargs) {
+	/* we need to create a temporal object to carry the destroy operation */
+	PyObject *tmp = PySwigObject_New(sobj->ptr, ty, 0);
+	res = SWIG_Python_CallFunctor(destroy, tmp);
+	Py_DECREF(tmp);
+      } else {
+	PyCFunction meth = PyCFunction_GET_FUNCTION(destroy);
+	PyObject *mself = PyCFunction_GET_SELF(destroy);
+	res = ((*meth)(mself, v));
+      }
+      Py_XDECREF(res);
+    } 
+#if !defined(SWIG_PYTHON_SILENT_MEMLEAK)
+    else {
+      const char *name = SWIG_TypePrettyName(ty);
+      printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown"));
+    }
+#endif
+  } 
+  Py_XDECREF(next);
+  PyObject_DEL(v);
+}
+
+SWIGRUNTIME PyObject* 
+PySwigObject_append(PyObject* v, PyObject* next)
+{
+  PySwigObject *sobj = (PySwigObject *) v;
+#ifndef METH_O
+  PyObject *tmp = 0;
+  if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL;
+  next = tmp;
+#endif
+  if (!PySwigObject_Check(next)) {
+    return NULL;
+  }
+  sobj->next = next;
+  Py_INCREF(next);
+  return SWIG_Py_Void();
+}
+
+SWIGRUNTIME PyObject* 
+#ifdef METH_NOARGS
+PySwigObject_next(PyObject* v)
+#else
+PySwigObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
+#endif
+{
+  PySwigObject *sobj = (PySwigObject *) v;
+  if (sobj->next) {    
+    Py_INCREF(sobj->next);
+    return sobj->next;
+  } else {
+    return SWIG_Py_Void();
+  }
+}
+
+SWIGINTERN PyObject*
+#ifdef METH_NOARGS
+PySwigObject_disown(PyObject *v)
+#else
+PySwigObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
+#endif
+{
+  PySwigObject *sobj = (PySwigObject *)v;
+  sobj->own = 0;
+  return SWIG_Py_Void();
+}
+
+SWIGINTERN PyObject*
+#ifdef METH_NOARGS
+PySwigObject_acquire(PyObject *v)
+#else
+PySwigObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
+#endif
+{
+  PySwigObject *sobj = (PySwigObject *)v;
+  sobj->own = SWIG_POINTER_OWN;
+  return SWIG_Py_Void();
+}
+
+SWIGINTERN PyObject*
+PySwigObject_own(PyObject *v, PyObject *args)
+{
+  PyObject *val = 0;
+#if (PY_VERSION_HEX < 0x02020000)
+  if (!PyArg_ParseTuple(args,(char *)"|O:own",&val))
+#else
+  if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val)) 
+#endif
+    {
+      return NULL;
+    } 
+  else
+    {
+      PySwigObject *sobj = (PySwigObject *)v;
+      PyObject *obj = PyBool_FromLong(sobj->own);
+      if (val) {
+#ifdef METH_NOARGS
+	if (PyObject_IsTrue(val)) {
+	  PySwigObject_acquire(v);
+	} else {
+	  PySwigObject_disown(v);
+	}
+#else
+	if (PyObject_IsTrue(val)) {
+	  PySwigObject_acquire(v,args);
+	} else {
+	  PySwigObject_disown(v,args);
+	}
+#endif
+      } 
+      return obj;
+    }
+}
+
+#ifdef METH_O
+static PyMethodDef
+swigobject_methods[] = {
+  {(char *)"disown",  (PyCFunction)PySwigObject_disown,  METH_NOARGS,  (char *)"releases ownership of the pointer"},
+  {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_NOARGS,  (char *)"aquires ownership of the pointer"},
+  {(char *)"own",     (PyCFunction)PySwigObject_own,     METH_VARARGS, (char *)"returns/sets ownership of the pointer"},
+  {(char *)"append",  (PyCFunction)PySwigObject_append,  METH_O,       (char *)"appends another 'this' object"},
+  {(char *)"next",    (PyCFunction)PySwigObject_next,    METH_NOARGS,  (char *)"returns the next 'this' object"},
+  {(char *)"__repr__",(PyCFunction)PySwigObject_repr,    METH_NOARGS,  (char *)"returns object representation"},
+  {0, 0, 0, 0}  
+};
+#else
+static PyMethodDef
+swigobject_methods[] = {
+  {(char *)"disown",  (PyCFunction)PySwigObject_disown,  METH_VARARGS,  (char *)"releases ownership of the pointer"},
+  {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_VARARGS,  (char *)"aquires ownership of the pointer"},
+  {(char *)"own",     (PyCFunction)PySwigObject_own,     METH_VARARGS,  (char *)"returns/sets ownership of the pointer"},
+  {(char *)"append",  (PyCFunction)PySwigObject_append,  METH_VARARGS,  (char *)"appends another 'this' object"},
+  {(char *)"next",    (PyCFunction)PySwigObject_next,    METH_VARARGS,  (char *)"returns the next 'this' object"},
+  {(char *)"__repr__",(PyCFunction)PySwigObject_repr,   METH_VARARGS,  (char *)"returns object representation"},
+  {0, 0, 0, 0}  
+};
+#endif
+
+#if PY_VERSION_HEX < 0x02020000
+SWIGINTERN PyObject *
+PySwigObject_getattr(PySwigObject *sobj,char *name)
+{
+  return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name);
+}
+#endif
+
+SWIGRUNTIME PyTypeObject*
+_PySwigObject_type(void) {
+  static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer";
+  
+  static PyNumberMethods PySwigObject_as_number = {
+    (binaryfunc)0, /*nb_add*/
+    (binaryfunc)0, /*nb_subtract*/
+    (binaryfunc)0, /*nb_multiply*/
+    (binaryfunc)0, /*nb_divide*/
+    (binaryfunc)0, /*nb_remainder*/
+    (binaryfunc)0, /*nb_divmod*/
+    (ternaryfunc)0,/*nb_power*/
+    (unaryfunc)0,  /*nb_negative*/
+    (unaryfunc)0,  /*nb_positive*/
+    (unaryfunc)0,  /*nb_absolute*/
+    (inquiry)0,    /*nb_nonzero*/
+    0,		   /*nb_invert*/
+    0,		   /*nb_lshift*/
+    0,		   /*nb_rshift*/
+    0,		   /*nb_and*/
+    0,		   /*nb_xor*/
+    0,		   /*nb_or*/
+    (coercion)0,   /*nb_coerce*/
+    (unaryfunc)PySwigObject_long, /*nb_int*/
+    (unaryfunc)PySwigObject_long, /*nb_long*/
+    (unaryfunc)0,                 /*nb_float*/
+    (unaryfunc)PySwigObject_oct,  /*nb_oct*/
+    (unaryfunc)PySwigObject_hex,  /*nb_hex*/
+#if PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */
+    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */
+#elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */
+    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */
+#elif PY_VERSION_HEX >= 0x02000000 /* 2.0.0 */
+    0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */
+#endif
+  };
+
+  static PyTypeObject pyswigobject_type;  
+  static int type_init = 0;
+  if (!type_init) {
+    const PyTypeObject tmp
+      = {
+	PyObject_HEAD_INIT(NULL)
+	0,				    /* ob_size */
+	(char *)"PySwigObject",		    /* tp_name */
+	sizeof(PySwigObject),		    /* tp_basicsize */
+	0,			            /* tp_itemsize */
+	(destructor)PySwigObject_dealloc,   /* tp_dealloc */
+	(printfunc)PySwigObject_print,	    /* tp_print */
+#if PY_VERSION_HEX < 0x02020000
+	(getattrfunc)PySwigObject_getattr,  /* tp_getattr */ 
+#else
+	(getattrfunc)0,			    /* tp_getattr */ 
+#endif
+	(setattrfunc)0,			    /* tp_setattr */ 
+	(cmpfunc)PySwigObject_compare,	    /* tp_compare */ 
+	(reprfunc)PySwigObject_repr,	    /* tp_repr */    
+	&PySwigObject_as_number,	    /* tp_as_number */
+	0,				    /* tp_as_sequence */
+	0,				    /* tp_as_mapping */
+	(hashfunc)0,			    /* tp_hash */
+	(ternaryfunc)0,			    /* tp_call */
+	(reprfunc)PySwigObject_str,	    /* tp_str */
+	PyObject_GenericGetAttr,            /* tp_getattro */
+	0,				    /* tp_setattro */
+	0,		                    /* tp_as_buffer */
+	Py_TPFLAGS_DEFAULT,	            /* tp_flags */
+	swigobject_doc, 	            /* tp_doc */        
+	0,                                  /* tp_traverse */
+	0,                                  /* tp_clear */
+	0,                                  /* tp_richcompare */
+	0,                                  /* tp_weaklistoffset */
+#if PY_VERSION_HEX >= 0x02020000
+	0,                                  /* tp_iter */
+	0,                                  /* tp_iternext */
+	swigobject_methods,		    /* tp_methods */ 
+	0,			            /* tp_members */
+	0,				    /* tp_getset */	    	
+	0,			            /* tp_base */	        
+	0,				    /* tp_dict */	    	
+	0,				    /* tp_descr_get */  	
+	0,				    /* tp_descr_set */  	
+	0,				    /* tp_dictoffset */ 	
+	0,				    /* tp_init */	    	
+	0,				    /* tp_alloc */	    	
+	0,			            /* tp_new */	    	
+	0,	                            /* tp_free */	   
+        0,                                  /* tp_is_gc */  
+	0,				    /* tp_bases */   
+	0,				    /* tp_mro */
+	0,				    /* tp_cache */   
+ 	0,				    /* tp_subclasses */
+	0,				    /* tp_weaklist */
+#endif
+#if PY_VERSION_HEX >= 0x02030000
+	0,                                  /* tp_del */
+#endif
+#ifdef COUNT_ALLOCS
+	0,0,0,0                             /* tp_alloc -> tp_next */
+#endif
+      };
+    pyswigobject_type = tmp;
+    pyswigobject_type.ob_type = &PyType_Type;
+    type_init = 1;
+  }
+  return &pyswigobject_type;
+}
+
+SWIGRUNTIME PyObject *
+PySwigObject_New(void *ptr, swig_type_info *ty, int own)
+{
+  PySwigObject *sobj = PyObject_NEW(PySwigObject, PySwigObject_type());
+  if (sobj) {
+    sobj->ptr  = ptr;
+    sobj->ty   = ty;
+    sobj->own  = own;
+    sobj->next = 0;
+  }
+  return (PyObject *)sobj;
+}
+
+/* -----------------------------------------------------------------------------
+ * Implements a simple Swig Packed type, and use it instead of string
+ * ----------------------------------------------------------------------------- */
+
+typedef struct {
+  PyObject_HEAD
+  void *pack;
+  swig_type_info *ty;
+  size_t size;
+} PySwigPacked;
+
+SWIGRUNTIME int
+PySwigPacked_print(PySwigPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags))
+{
+  char result[SWIG_BUFFER_SIZE];
+  fputs("<Swig Packed ", fp); 
+  if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) {
+    fputs("at ", fp); 
+    fputs(result, fp); 
+  }
+  fputs(v->ty->name,fp); 
+  fputs(">", fp);
+  return 0; 
+}
+  
+SWIGRUNTIME PyObject *
+PySwigPacked_repr(PySwigPacked *v)
+{
+  char result[SWIG_BUFFER_SIZE];
+  if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) {
+    return PyString_FromFormat("<Swig Packed at %s%s>", result, v->ty->name);
+  } else {
+    return PyString_FromFormat("<Swig Packed %s>", v->ty->name);
+  }  
+}
+
+SWIGRUNTIME PyObject *
+PySwigPacked_str(PySwigPacked *v)
+{
+  char result[SWIG_BUFFER_SIZE];
+  if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){
+    return PyString_FromFormat("%s%s", result, v->ty->name);
+  } else {
+    return PyString_FromString(v->ty->name);
+  }  
+}
+
+SWIGRUNTIME int
+PySwigPacked_compare(PySwigPacked *v, PySwigPacked *w)
+{
+  size_t i = v->size;
+  size_t j = w->size;
+  int s = (i < j) ? -1 : ((i > j) ? 1 : 0);
+  return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size);
+}
+
+SWIGRUNTIME PyTypeObject* _PySwigPacked_type(void);
+
+SWIGRUNTIME PyTypeObject*
+PySwigPacked_type(void) {
+  static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigPacked_type();
+  return type;
+}
+
+SWIGRUNTIMEINLINE int
+PySwigPacked_Check(PyObject *op) {
+  return ((op)->ob_type == _PySwigPacked_type()) 
+    || (strcmp((op)->ob_type->tp_name,"PySwigPacked") == 0);
+}
+
+SWIGRUNTIME void
+PySwigPacked_dealloc(PyObject *v)
+{
+  if (PySwigPacked_Check(v)) {
+    PySwigPacked *sobj = (PySwigPacked *) v;
+    free(sobj->pack);
+  }
+  PyObject_DEL(v);
+}
+
+SWIGRUNTIME PyTypeObject*
+_PySwigPacked_type(void) {
+  static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer";
+  static PyTypeObject pyswigpacked_type;
+  static int type_init = 0;  
+  if (!type_init) {
+    const PyTypeObject tmp
+      = {
+	PyObject_HEAD_INIT(NULL)
+	0,				    /* ob_size */	
+	(char *)"PySwigPacked",		    /* tp_name */	
+	sizeof(PySwigPacked),		    /* tp_basicsize */	
+	0,				    /* tp_itemsize */	
+	(destructor)PySwigPacked_dealloc,   /* tp_dealloc */	
+	(printfunc)PySwigPacked_print,	    /* tp_print */   	
+	(getattrfunc)0,			    /* tp_getattr */ 	
+	(setattrfunc)0,			    /* tp_setattr */ 	
+	(cmpfunc)PySwigPacked_compare,	    /* tp_compare */ 	
+	(reprfunc)PySwigPacked_repr,	    /* tp_repr */    	
+	0,	                            /* tp_as_number */	
+	0,				    /* tp_as_sequence */
+	0,				    /* tp_as_mapping */	
+	(hashfunc)0,			    /* tp_hash */	
+	(ternaryfunc)0,			    /* tp_call */	
+	(reprfunc)PySwigPacked_str,	    /* tp_str */	
+	PyObject_GenericGetAttr,            /* tp_getattro */
+	0,				    /* tp_setattro */
+	0,		                    /* tp_as_buffer */
+	Py_TPFLAGS_DEFAULT,	            /* tp_flags */
+	swigpacked_doc, 	            /* tp_doc */
+	0,                                  /* tp_traverse */
+	0,                                  /* tp_clear */
+	0,                                  /* tp_richcompare */
+	0,                                  /* tp_weaklistoffset */
+#if PY_VERSION_HEX >= 0x02020000
+	0,                                  /* tp_iter */
+	0,                                  /* tp_iternext */
+	0,		                    /* tp_methods */ 
+	0,			            /* tp_members */
+	0,				    /* tp_getset */	    	
+	0,			            /* tp_base */	        
+	0,				    /* tp_dict */	    	
+	0,				    /* tp_descr_get */  	
+	0,				    /* tp_descr_set */  	
+	0,				    /* tp_dictoffset */ 	
+	0,				    /* tp_init */	    	
+	0,				    /* tp_alloc */	    	
+	0,			            /* tp_new */	    	
+	0, 	                            /* tp_free */	   
+        0,                                  /* tp_is_gc */  
+	0,				    /* tp_bases */   
+	0,				    /* tp_mro */
+	0,				    /* tp_cache */   
+ 	0,				    /* tp_subclasses */
+	0,				    /* tp_weaklist */
+#endif
+#if PY_VERSION_HEX >= 0x02030000
+	0,                                  /* tp_del */
+#endif
+#ifdef COUNT_ALLOCS
+	0,0,0,0                             /* tp_alloc -> tp_next */
+#endif
+      };
+    pyswigpacked_type = tmp;
+    pyswigpacked_type.ob_type = &PyType_Type;
+    type_init = 1;
+  }
+  return &pyswigpacked_type;
+}
+
+SWIGRUNTIME PyObject *
+PySwigPacked_New(void *ptr, size_t size, swig_type_info *ty)
+{
+  PySwigPacked *sobj = PyObject_NEW(PySwigPacked, PySwigPacked_type());
+  if (sobj) {
+    void *pack = malloc(size);
+    if (pack) {
+      memcpy(pack, ptr, size);
+      sobj->pack = pack;
+      sobj->ty   = ty;
+      sobj->size = size;
+    } else {
+      PyObject_DEL((PyObject *) sobj);
+      sobj = 0;
+    }
+  }
+  return (PyObject *) sobj;
+}
+
+SWIGRUNTIME swig_type_info *
+PySwigPacked_UnpackData(PyObject *obj, void *ptr, size_t size)
+{
+  if (PySwigPacked_Check(obj)) {
+    PySwigPacked *sobj = (PySwigPacked *)obj;
+    if (sobj->size != size) return 0;
+    memcpy(ptr, sobj->pack, size);
+    return sobj->ty;
+  } else {
+    return 0;
+  }
+}
+
+/* -----------------------------------------------------------------------------
+ * pointers/data manipulation
+ * ----------------------------------------------------------------------------- */
+
+SWIGRUNTIMEINLINE PyObject *
+_SWIG_This(void)
+{
+  return PyString_FromString("this");
+}
+
+SWIGRUNTIME PyObject *
+SWIG_This(void)
+{
+  static PyObject *SWIG_STATIC_POINTER(swig_this) = _SWIG_This();
+  return swig_this;
+}
+
+/* #define SWIG_PYTHON_SLOW_GETSET_THIS */
+
+SWIGRUNTIME PySwigObject *
+SWIG_Python_GetSwigThis(PyObject *pyobj) 
+{
+  if (PySwigObject_Check(pyobj)) {
+    return (PySwigObject *) pyobj;
+  } else {
+    PyObject *obj = 0;
+#if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000))
+    if (PyInstance_Check(pyobj)) {
+      obj = _PyInstance_Lookup(pyobj, SWIG_This());      
+    } else {
+      PyObject **dictptr = _PyObject_GetDictPtr(pyobj);
+      if (dictptr != NULL) {
+	PyObject *dict = *dictptr;
+	obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0;
+      } else {
+#ifdef PyWeakref_CheckProxy
+	if (PyWeakref_CheckProxy(pyobj)) {
+	  PyObject *wobj = PyWeakref_GET_OBJECT(pyobj);
+	  return wobj ? SWIG_Python_GetSwigThis(wobj) : 0;
+	}
+#endif
+	obj = PyObject_GetAttr(pyobj,SWIG_This());
+	if (obj) {
+	  Py_DECREF(obj);
+	} else {
+	  if (PyErr_Occurred()) PyErr_Clear();
+	  return 0;
+	}
+      }
+    }
+#else
+    obj = PyObject_GetAttr(pyobj,SWIG_This());
+    if (obj) {
+      Py_DECREF(obj);
+    } else {
+      if (PyErr_Occurred()) PyErr_Clear();
+      return 0;
+    }
+#endif
+    if (obj && !PySwigObject_Check(obj)) {
+      /* a PyObject is called 'this', try to get the 'real this'
+	 PySwigObject from it */ 
+      return SWIG_Python_GetSwigThis(obj);
+    }
+    return (PySwigObject *)obj;
+  }
+}
+
+/* Acquire a pointer value */
+
+SWIGRUNTIME int
+SWIG_Python_AcquirePtr(PyObject *obj, int own) {
+  if (own == SWIG_POINTER_OWN) {
+    PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
+    if (sobj) {
+      int oldown = sobj->own;
+      sobj->own = own;
+      return oldown;
+    }
+  }
+  return 0;
+}
+
+/* Convert a pointer value */
+
+SWIGRUNTIME int
+SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) {
+  if (!obj) return SWIG_ERROR;
+  if (obj == Py_None) {
+    if (ptr) *ptr = 0;
+    return SWIG_OK;
+  } else {
+    PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
+    if (own)
+      *own = 0;
+    while (sobj) {
+      void *vptr = sobj->ptr;
+      if (ty) {
+	swig_type_info *to = sobj->ty;
+	if (to == ty) {
+	  /* no type cast needed */
+	  if (ptr) *ptr = vptr;
+	  break;
+	} else {
+	  swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);
+	  if (!tc) {
+	    sobj = (PySwigObject *)sobj->next;
+	  } else {
+	    if (ptr) {
+              int newmemory = 0;
+              *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
+              if (newmemory == SWIG_CAST_NEW_MEMORY) {
+                assert(own);
+                if (own)
+                  *own = *own | SWIG_CAST_NEW_MEMORY;
+              }
+            }
+	    break;
+	  }
+	}
+      } else {
+	if (ptr) *ptr = vptr;
+	break;
+      }
+    }
+    if (sobj) {
+      if (own)
+        *own = *own | sobj->own;
+      if (flags & SWIG_POINTER_DISOWN) {
+	sobj->own = 0;
+      }
+      return SWIG_OK;
+    } else {
+      int res = SWIG_ERROR;
+      if (flags & SWIG_POINTER_IMPLICIT_CONV) {
+	PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0;
+	if (data && !data->implicitconv) {
+	  PyObject *klass = data->klass;
+	  if (klass) {
+	    PyObject *impconv;
+	    data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/
+	    impconv = SWIG_Python_CallFunctor(klass, obj);
+	    data->implicitconv = 0;
+	    if (PyErr_Occurred()) {
+	      PyErr_Clear();
+	      impconv = 0;
+	    }
+	    if (impconv) {
+	      PySwigObject *iobj = SWIG_Python_GetSwigThis(impconv);
+	      if (iobj) {
+		void *vptr;
+		res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0);
+		if (SWIG_IsOK(res)) {
+		  if (ptr) {
+		    *ptr = vptr;
+		    /* transfer the ownership to 'ptr' */
+		    iobj->own = 0;
+		    res = SWIG_AddCast(res);
+		    res = SWIG_AddNewMask(res);
+		  } else {
+		    res = SWIG_AddCast(res);		    
+		  }
+		}
+	      }
+	      Py_DECREF(impconv);
+	    }
+	  }
+	}
+      }
+      return res;
+    }
+  }
+}
+
+/* Convert a function ptr value */
+
+SWIGRUNTIME int
+SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {
+  if (!PyCFunction_Check(obj)) {
+    return SWIG_ConvertPtr(obj, ptr, ty, 0);
+  } else {
+    void *vptr = 0;
+    
+    /* here we get the method pointer for callbacks */
+    const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc);
+    const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0;
+    if (desc) {
+      desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0;
+      if (!desc) return SWIG_ERROR;
+    }
+    if (ty) {
+      swig_cast_info *tc = SWIG_TypeCheck(desc,ty);
+      if (tc) {
+        int newmemory = 0;
+        *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
+        assert(!newmemory); /* newmemory handling not yet implemented */
+      } else {
+        return SWIG_ERROR;
+      }
+    } else {
+      *ptr = vptr;
+    }
+    return SWIG_OK;
+  }
+}
+
+/* Convert a packed value value */
+
+SWIGRUNTIME int
+SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) {
+  swig_type_info *to = PySwigPacked_UnpackData(obj, ptr, sz);
+  if (!to) return SWIG_ERROR;
+  if (ty) {
+    if (to != ty) {
+      /* check type cast? */
+      swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);
+      if (!tc) return SWIG_ERROR;
+    }
+  }
+  return SWIG_OK;
+}  
+
+/* -----------------------------------------------------------------------------
+ * Create a new pointer object
+ * ----------------------------------------------------------------------------- */
+
+/*
+  Create a new instance object, whitout calling __init__, and set the
+  'this' attribute.
+*/
+
+SWIGRUNTIME PyObject* 
+SWIG_Python_NewShadowInstance(PySwigClientData *data, PyObject *swig_this)
+{
+#if (PY_VERSION_HEX >= 0x02020000)
+  PyObject *inst = 0;
+  PyObject *newraw = data->newraw;
+  if (newraw) {
+    inst = PyObject_Call(newraw, data->newargs, NULL);
+    if (inst) {
+#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS)
+      PyObject **dictptr = _PyObject_GetDictPtr(inst);
+      if (dictptr != NULL) {
+	PyObject *dict = *dictptr;
+	if (dict == NULL) {
+	  dict = PyDict_New();
+	  *dictptr = dict;
+	  PyDict_SetItem(dict, SWIG_This(), swig_this);
+	}
+      }
+#else
+      PyObject *key = SWIG_This();
+      PyObject_SetAttr(inst, key, swig_this);
+#endif
+    }
+  } else {
+    PyObject *dict = PyDict_New();
+    PyDict_SetItem(dict, SWIG_This(), swig_this);
+    inst = PyInstance_NewRaw(data->newargs, dict);
+    Py_DECREF(dict);
+  }
+  return inst;
+#else
+#if (PY_VERSION_HEX >= 0x02010000)
+  PyObject *inst;
+  PyObject *dict = PyDict_New();
+  PyDict_SetItem(dict, SWIG_This(), swig_this);
+  inst = PyInstance_NewRaw(data->newargs, dict);
+  Py_DECREF(dict);
+  return (PyObject *) inst;
+#else
+  PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type);
+  if (inst == NULL) {
+    return NULL;
+  }
+  inst->in_class = (PyClassObject *)data->newargs;
+  Py_INCREF(inst->in_class);
+  inst->in_dict = PyDict_New();
+  if (inst->in_dict == NULL) {
+    Py_DECREF(inst);
+    return NULL;
+  }
+#ifdef Py_TPFLAGS_HAVE_WEAKREFS
+  inst->in_weakreflist = NULL;
+#endif
+#ifdef Py_TPFLAGS_GC
+  PyObject_GC_Init(inst);
+#endif
+  PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this);
+  return (PyObject *) inst;
+#endif
+#endif
+}
+
+SWIGRUNTIME void
+SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this)
+{
+ PyObject *dict;
+#if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS)
+ PyObject **dictptr = _PyObject_GetDictPtr(inst);
+ if (dictptr != NULL) {
+   dict = *dictptr;
+   if (dict == NULL) {
+     dict = PyDict_New();
+     *dictptr = dict;
+   }
+   PyDict_SetItem(dict, SWIG_This(), swig_this);
+   return;
+ }
+#endif
+ dict = PyObject_GetAttrString(inst, (char*)"__dict__");
+ PyDict_SetItem(dict, SWIG_This(), swig_this);
+ Py_DECREF(dict);
+} 
+
+
+SWIGINTERN PyObject *
+SWIG_Python_InitShadowInstance(PyObject *args) {
+  PyObject *obj[2];
+  if (!SWIG_Python_UnpackTuple(args,(char*)"swiginit", 2, 2, obj)) {
+    return NULL;
+  } else {
+    PySwigObject *sthis = SWIG_Python_GetSwigThis(obj[0]);
+    if (sthis) {
+      PySwigObject_append((PyObject*) sthis, obj[1]);
+    } else {
+      SWIG_Python_SetSwigThis(obj[0], obj[1]);
+    }
+    return SWIG_Py_Void();
+  }
+}
+
+/* Create a new pointer object */
+
+SWIGRUNTIME PyObject *
+SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int flags) {
+  if (!ptr) {
+    return SWIG_Py_Void();
+  } else {
+    int own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0;
+    PyObject *robj = PySwigObject_New(ptr, type, own);
+    PySwigClientData *clientdata = type ? (PySwigClientData *)(type->clientdata) : 0;
+    if (clientdata && !(flags & SWIG_POINTER_NOSHADOW)) {
+      PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj);
+      if (inst) {
+	Py_DECREF(robj);
+	robj = inst;
+      }
+    }
+    return robj;
+  }
+}
+
+/* Create a new packed object */
+
+SWIGRUNTIMEINLINE PyObject *
+SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) {
+  return ptr ? PySwigPacked_New((void *) ptr, sz, type) : SWIG_Py_Void();
+}
+
+/* -----------------------------------------------------------------------------*
+ *  Get type list 
+ * -----------------------------------------------------------------------------*/
+
+#ifdef SWIG_LINK_RUNTIME
+void *SWIG_ReturnGlobalTypeList(void *);
+#endif
+
+SWIGRUNTIME swig_module_info *
+SWIG_Python_GetModule(void) {
+  static void *type_pointer = (void *)0;
+  /* first check if module already created */
+  if (!type_pointer) {
+#ifdef SWIG_LINK_RUNTIME
+    type_pointer = SWIG_ReturnGlobalTypeList((void *)0);
+#else
+    type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
+				    (char*)"type_pointer" SWIG_TYPE_TABLE_NAME);
+    if (PyErr_Occurred()) {
+      PyErr_Clear();
+      type_pointer = (void *)0;
+    }
+#endif
+  }
+  return (swig_module_info *) type_pointer;
+}
+
+#if PY_MAJOR_VERSION < 2
+/* PyModule_AddObject function was introduced in Python 2.0.  The following function
+   is copied out of Python/modsupport.c in python version 2.3.4 */
+SWIGINTERN int
+PyModule_AddObject(PyObject *m, char *name, PyObject *o)
+{
+  PyObject *dict;
+  if (!PyModule_Check(m)) {
+    PyErr_SetString(PyExc_TypeError,
+		    "PyModule_AddObject() needs module as first arg");
+    return SWIG_ERROR;
+  }
+  if (!o) {
+    PyErr_SetString(PyExc_TypeError,
+		    "PyModule_AddObject() needs non-NULL value");
+    return SWIG_ERROR;
+  }
+  
+  dict = PyModule_GetDict(m);
+  if (dict == NULL) {
+    /* Internal error -- modules must have a dict! */
+    PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__",
+		 PyModule_GetName(m));
+    return SWIG_ERROR;
+  }
+  if (PyDict_SetItemString(dict, name, o))
+    return SWIG_ERROR;
+  Py_DECREF(o);
+  return SWIG_OK;
+}
+#endif
+
+SWIGRUNTIME void
+SWIG_Python_DestroyModule(void *vptr)
+{
+  swig_module_info *swig_module = (swig_module_info *) vptr;
+  swig_type_info **types = swig_module->types;
+  size_t i;
+  for (i =0; i < swig_module->size; ++i) {
+    swig_type_info *ty = types[i];
+    if (ty->owndata) {
+      PySwigClientData *data = (PySwigClientData *) ty->clientdata;
+      if (data) PySwigClientData_Del(data);
+    }
+  }
+  Py_DECREF(SWIG_This());
+}
+
+SWIGRUNTIME void
+SWIG_Python_SetModule(swig_module_info *swig_module) {
+  static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */
+
+  PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
+				   swig_empty_runtime_method_table);
+  PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule);
+  if (pointer && module) {
+    PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer);
+  } else {
+    Py_XDECREF(pointer);
+  }
+}
+
+/* The python cached type query */
+SWIGRUNTIME PyObject *
+SWIG_Python_TypeCache(void) {
+  static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New();
+  return cache;
+}
+
+SWIGRUNTIME swig_type_info *
+SWIG_Python_TypeQuery(const char *type)
+{
+  PyObject *cache = SWIG_Python_TypeCache();
+  PyObject *key = PyString_FromString(type); 
+  PyObject *obj = PyDict_GetItem(cache, key);
+  swig_type_info *descriptor;
+  if (obj) {
+    descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj);
+  } else {
+    swig_module_info *swig_module = SWIG_Python_GetModule();
+    descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type);
+    if (descriptor) {
+      obj = PyCObject_FromVoidPtr(descriptor, NULL);
+      PyDict_SetItem(cache, key, obj);
+      Py_DECREF(obj);
+    }
+  }
+  Py_DECREF(key);
+  return descriptor;
+}
+
+/* 
+   For backward compatibility only
+*/
+#define SWIG_POINTER_EXCEPTION  0
+#define SWIG_arg_fail(arg)      SWIG_Python_ArgFail(arg)
+#define SWIG_MustGetPtr(p, type, argnum, flags)  SWIG_Python_MustGetPtr(p, type, argnum, flags)
+
+SWIGRUNTIME int
+SWIG_Python_AddErrMesg(const char* mesg, int infront)
+{
+  if (PyErr_Occurred()) {
+    PyObject *type = 0;
+    PyObject *value = 0;
+    PyObject *traceback = 0;
+    PyErr_Fetch(&type, &value, &traceback);
+    if (value) {
+      PyObject *old_str = PyObject_Str(value);
+      Py_XINCREF(type);
+      PyErr_Clear();
+      if (infront) {
+	PyErr_Format(type, "%s %s", mesg, PyString_AsString(old_str));
+      } else {
+	PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg);
+      }
+      Py_DECREF(old_str);
+    }
+    return 1;
+  } else {
+    return 0;
+  }
+}
+  
+SWIGRUNTIME int
+SWIG_Python_ArgFail(int argnum)
+{
+  if (PyErr_Occurred()) {
+    /* add information about failing argument */
+    char mesg[256];
+    PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum);
+    return SWIG_Python_AddErrMesg(mesg, 1);
+  } else {
+    return 0;
+  }
+}
+
+SWIGRUNTIMEINLINE const char *
+PySwigObject_GetDesc(PyObject *self)
+{
+  PySwigObject *v = (PySwigObject *)self;
+  swig_type_info *ty = v ? v->ty : 0;
+  return ty ? ty->str : (char*)"";
+}
+
+SWIGRUNTIME void
+SWIG_Python_TypeError(const char *type, PyObject *obj)
+{
+  if (type) {
+#if defined(SWIG_COBJECT_TYPES)
+    if (obj && PySwigObject_Check(obj)) {
+      const char *otype = (const char *) PySwigObject_GetDesc(obj);
+      if (otype) {
+	PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'PySwigObject(%s)' is received",
+		     type, otype);
+	return;
+      }
+    } else 
+#endif      
+    {
+      const char *otype = (obj ? obj->ob_type->tp_name : 0); 
+      if (otype) {
+	PyObject *str = PyObject_Str(obj);
+	const char *cstr = str ? PyString_AsString(str) : 0;
+	if (cstr) {
+	  PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received",
+		       type, otype, cstr);
+	} else {
+	  PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received",
+		       type, otype);
+	}
+	Py_XDECREF(str);
+	return;
+      }
+    }   
+    PyErr_Format(PyExc_TypeError, "a '%s' is expected", type);
+  } else {
+    PyErr_Format(PyExc_TypeError, "unexpected type is received");
+  }
+}
+
+
+/* Convert a pointer value, signal an exception on a type mismatch */
+SWIGRUNTIME void *
+SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) {
+  void *result;
+  if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) {
+    PyErr_Clear();
+    if (flags & SWIG_POINTER_EXCEPTION) {
+      SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj);
+      SWIG_Python_ArgFail(argnum);
+    }
+  }
+  return result;
+}
+
+
+#ifdef __cplusplus
+#if 0
+{ /* cc-mode */
+#endif
+}
+#endif
+
+
+
+#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0) 
+
+#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else 
+
+
+
+  #define SWIG_exception(code, msg) do { SWIG_Error(code, msg); SWIG_fail;; } while(0) 
+
+
+/* -------- TYPES TABLE (BEGIN) -------- */
+
+#define SWIGTYPE_p_char swig_types[0]
+#define SWIGTYPE_p_saslwrapper__Client swig_types[1]
+#define SWIGTYPE_p_std__invalid_argument swig_types[2]
+#define SWIGTYPE_p_std__string swig_types[3]
+#define SWIGTYPE_p_swig__PySwigIterator swig_types[4]
+static swig_type_info *swig_types[6];
+static swig_module_info swig_module = {swig_types, 5, 0, 0, 0, 0};
+#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
+#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
+
+/* -------- TYPES TABLE (END) -------- */
+
+#if (PY_VERSION_HEX <= 0x02000000)
+# if !defined(SWIG_PYTHON_CLASSIC)
+#  error "This python version requires swig to be run with the '-classic' option"
+# endif
+#endif
+
+/*-----------------------------------------------
+              @(target):= _saslwrapper.so
+  ------------------------------------------------*/
+#define SWIG_init    init_saslwrapper
+
+#define SWIG_name    "_saslwrapper"
+
+#define SWIGVERSION 0x010336 
+#define SWIG_VERSION SWIGVERSION
+
+
+#define SWIG_as_voidptr(a) const_cast< void * >(static_cast< const void * >(a)) 
+#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),reinterpret_cast< void** >(a)) 
+
+
+#include <stdexcept>
+
+
+namespace swig {
+  class PyObject_ptr {
+  protected:
+    PyObject *_obj;
+
+  public:
+    PyObject_ptr() :_obj(0)
+    {
+    }
+
+    PyObject_ptr(const PyObject_ptr& item) : _obj(item._obj)
+    {
+      Py_XINCREF(_obj);      
+    }
+    
+    PyObject_ptr(PyObject *obj, bool initial_ref = true) :_obj(obj)
+    {
+      if (initial_ref) {
+        Py_XINCREF(_obj);
+      }
+    }
+    
+    PyObject_ptr & operator=(const PyObject_ptr& item) 
+    {
+      Py_XINCREF(item._obj);
+      Py_XDECREF(_obj);
+      _obj = item._obj;
+      return *this;      
+    }
+    
+    ~PyObject_ptr() 
+    {
+      Py_XDECREF(_obj);
+    }
+    
+    operator PyObject *() const
+    {
+      return _obj;
+    }
+
+    PyObject *operator->() const
+    {
+      return _obj;
+    }
+  };
+}
+
+
+namespace swig {
+  struct PyObject_var : PyObject_ptr {
+    PyObject_var(PyObject* obj = 0) : PyObject_ptr(obj, false) { }
+    
+    PyObject_var & operator = (PyObject* obj)
+    {
+      Py_XDECREF(_obj);
+      _obj = obj;
+      return *this;      
+    }
+  };
+}
+
+
+#include "saslwrapper.h"
+
+
+#include <stdexcept>
+
+
+#if defined(__GNUC__)
+#  if __GNUC__ == 2 && __GNUC_MINOR <= 96
+#     define SWIG_STD_NOMODERN_STL
+#  endif
+#endif
+
+
+#include <string>
+#include <stdexcept>
+
+
+#include <string>
+
+
+#include <iostream>
+
+  
+namespace swig {
+  struct stop_iteration {
+  };
+
+  struct PySwigIterator {
+  private:
+    PyObject_ptr _seq;
+
+  protected:
+    PySwigIterator(PyObject *seq) : _seq(seq)
+    {
+    }
+      
+  public:
+    virtual ~PySwigIterator() {}
+
+    // Access iterator method, required by Python
+    virtual PyObject *value() const = 0;
+
+    // Forward iterator method, required by Python
+    virtual PySwigIterator *incr(size_t n = 1) = 0;
+    
+    // Backward iterator method, very common in C++, but not required in Python
+    virtual PySwigIterator *decr(size_t /*n*/ = 1)
+    {
+      throw stop_iteration();
+    }
+
+    // Random access iterator methods, but not required in Python
+    virtual ptrdiff_t distance(const PySwigIterator &/*x*/) const
+    {
+      throw std::invalid_argument("operation not supported");
+    }
+
+    virtual bool equal (const PySwigIterator &/*x*/) const
+    {
+      throw std::invalid_argument("operation not supported");
+    }
+    
+    // C++ common/needed methods
+    virtual PySwigIterator *copy() const = 0;
+
+    PyObject *next()     
+    {
+      SWIG_PYTHON_THREAD_BEGIN_BLOCK; // disable threads       
+      PyObject *obj = value();
+      incr();       
+      SWIG_PYTHON_THREAD_END_BLOCK; // re-enable threads
+      return obj;     
+    }
+
+    PyObject *previous()
+    {
+      SWIG_PYTHON_THREAD_BEGIN_BLOCK; // disable threads       
+      decr();
+      PyObject *obj = value();
+      SWIG_PYTHON_THREAD_END_BLOCK; // re-enable threads       
+      return obj;
+    }
+
+    PySwigIterator *advance(ptrdiff_t n)
+    {
+      return  (n > 0) ?  incr(n) : decr(-n);
+    }
+      
+    bool operator == (const PySwigIterator& x)  const
+    {
+      return equal(x);
+    }
+      
+    bool operator != (const PySwigIterator& x) const
+    {
+      return ! operator==(x);
+    }
+      
+    PySwigIterator& operator += (ptrdiff_t n)
+    {
+      return *advance(n);
+    }
+
+    PySwigIterator& operator -= (ptrdiff_t n)
+    {
+      return *advance(-n);
+    }
+      
+    PySwigIterator* operator + (ptrdiff_t n) const
+    {
+      return copy()->advance(n);
+    }
+
+    PySwigIterator* operator - (ptrdiff_t n) const
+    {
+      return copy()->advance(-n);
+    }
+      
+    ptrdiff_t operator - (const PySwigIterator& x) const
+    {
+      return x.distance(*this);
+    }
+      
+    static swig_type_info* descriptor() {
+      static int init = 0;
+      static swig_type_info* desc = 0;
+      if (!init) {
+	desc = SWIG_TypeQuery("swig::PySwigIterator *");
+	init = 1;
+      }	
+      return desc;
+    }    
+  };
+}
+
+
+SWIGINTERN int
+SWIG_AsVal_double (PyObject *obj, double *val)
+{
+  int res = SWIG_TypeError;
+  if (PyFloat_Check(obj)) {
+    if (val) *val = PyFloat_AsDouble(obj);
+    return SWIG_OK;
+  } else if (PyInt_Check(obj)) {
+    if (val) *val = PyInt_AsLong(obj);
+    return SWIG_OK;
+  } else if (PyLong_Check(obj)) {
+    double v = PyLong_AsDouble(obj);
+    if (!PyErr_Occurred()) {
+      if (val) *val = v;
+      return SWIG_OK;
+    } else {
+      PyErr_Clear();
+    }
+  }
+#ifdef SWIG_PYTHON_CAST_MODE
+  {
+    int dispatch = 0;
+    double d = PyFloat_AsDouble(obj);
+    if (!PyErr_Occurred()) {
+      if (val) *val = d;
+      return SWIG_AddCast(SWIG_OK);
+    } else {
+      PyErr_Clear();
+    }
+    if (!dispatch) {
+      long v = PyLong_AsLong(obj);
+      if (!PyErr_Occurred()) {
+	if (val) *val = v;
+	return SWIG_AddCast(SWIG_AddCast(SWIG_OK));
+      } else {
+	PyErr_Clear();
+      }
+    }
+  }
+#endif
+  return res;
+}
+
+
+#include <float.h>
+
+
+#include <math.h>
+
+
+SWIGINTERNINLINE int
+SWIG_CanCastAsInteger(double *d, double min, double max) {
+  double x = *d;
+  if ((min <= x && x <= max)) {
+   double fx = floor(x);
+   double cx = ceil(x);
+   double rd =  ((x - fx) < 0.5) ? fx : cx; /* simple rint */
+   if ((errno == EDOM) || (errno == ERANGE)) {
+     errno = 0;
+   } else {
+     double summ, reps, diff;
+     if (rd < x) {
+       diff = x - rd;
+     } else if (rd > x) {
+       diff = rd - x;
+     } else {
+       return 1;
+     }
+     summ = rd + x;
+     reps = diff/summ;
+     if (reps < 8*DBL_EPSILON) {
+       *d = rd;
+       return 1;
+     }
+   }
+  }
+  return 0;
+}
+
+
+SWIGINTERN int
+SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val) 
+{
+  if (PyInt_Check(obj)) {
+    long v = PyInt_AsLong(obj);
+    if (v >= 0) {
+      if (val) *val = v;
+      return SWIG_OK;
+    } else {
+      return SWIG_OverflowError;
+    }
+  } else if (PyLong_Check(obj)) {
+    unsigned long v = PyLong_AsUnsignedLong(obj);
+    if (!PyErr_Occurred()) {
+      if (val) *val = v;
+      return SWIG_OK;
+    } else {
+      PyErr_Clear();
+    }
+  }
+#ifdef SWIG_PYTHON_CAST_MODE
+  {
+    int dispatch = 0;
+    unsigned long v = PyLong_AsUnsignedLong(obj);
+    if (!PyErr_Occurred()) {
+      if (val) *val = v;
+      return SWIG_AddCast(SWIG_OK);
+    } else {
+      PyErr_Clear();
+    }
+    if (!dispatch) {
+      double d;
+      int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d));
+      if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) {
+	if (val) *val = (unsigned long)(d);
+	return res;
+      }
+    }
+  }
+#endif
+  return SWIG_TypeError;
+}
+
+
+SWIGINTERNINLINE int
+SWIG_AsVal_size_t (PyObject * obj, size_t *val)
+{
+  unsigned long v;
+  int res = SWIG_AsVal_unsigned_SS_long (obj, val ? &v : 0);
+  if (SWIG_IsOK(res) && val) *val = static_cast< size_t >(v);
+  return res;
+}
+
+
+  #define SWIG_From_long   PyInt_FromLong 
+
+
+SWIGINTERNINLINE PyObject *
+SWIG_From_ptrdiff_t  (ptrdiff_t value)
+{    
+  return SWIG_From_long  (static_cast< long >(value));
+}
+
+
+SWIGINTERNINLINE PyObject*
+  SWIG_From_bool  (bool value)
+{
+  return PyBool_FromLong(value ? 1 : 0);
+}
+
+
+SWIGINTERN int
+SWIG_AsVal_long (PyObject *obj, long* val)
+{
+  if (PyInt_Check(obj)) {
+    if (val) *val = PyInt_AsLong(obj);
+    return SWIG_OK;
+  } else if (PyLong_Check(obj)) {
+    long v = PyLong_AsLong(obj);
+    if (!PyErr_Occurred()) {
+      if (val) *val = v;
+      return SWIG_OK;
+    } else {
+      PyErr_Clear();
+    }
+  }
+#ifdef SWIG_PYTHON_CAST_MODE
+  {
+    int dispatch = 0;
+    long v = PyInt_AsLong(obj);
+    if (!PyErr_Occurred()) {
+      if (val) *val = v;
+      return SWIG_AddCast(SWIG_OK);
+    } else {
+      PyErr_Clear();
+    }
+    if (!dispatch) {
+      double d;
+      int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d));
+      if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) {
+	if (val) *val = (long)(d);
+	return res;
+      }
+    }
+  }
+#endif
+  return SWIG_TypeError;
+}
+
+
+SWIGINTERNINLINE int
+SWIG_AsVal_ptrdiff_t (PyObject * obj, ptrdiff_t *val)
+{
+  long v;
+  int res = SWIG_AsVal_long (obj, val ? &v : 0);
+  if (SWIG_IsOK(res) && val) *val = static_cast< ptrdiff_t >(v);
+  return res;
+}
+
+
+#include <stdexcept>
+
+
+#include <algorithm>
+
+
+#include <vector>
+
+
+#include <utility>
+
+
+#include <map>
+#include <algorithm>
+#include <stdexcept>
+
+
+SWIGINTERN swig_type_info*
+SWIG_pchar_descriptor(void)
+{
+  static int init = 0;
+  static swig_type_info* info = 0;
+  if (!init) {
+    info = SWIG_TypeQuery("_p_char");
+    init = 1;
+  }
+  return info;
+}
+
+
+SWIGINTERN int
+SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc)
+{
+  if (PyString_Check(obj)) {
+    char *cstr; Py_ssize_t len;
+    PyString_AsStringAndSize(obj, &cstr, &len);
+    if (cptr)  {
+      if (alloc) {
+	/* 
+	   In python the user should not be able to modify the inner
+	   string representation. To warranty that, if you define
+	   SWIG_PYTHON_SAFE_CSTRINGS, a new/copy of the python string
+	   buffer is always returned.
+
+	   The default behavior is just to return the pointer value,
+	   so, be careful.
+	*/ 
+#if defined(SWIG_PYTHON_SAFE_CSTRINGS)
+	if (*alloc != SWIG_OLDOBJ) 
+#else
+	if (*alloc == SWIG_NEWOBJ) 
+#endif
+	  {
+	    *cptr = reinterpret_cast< char* >(memcpy((new char[len + 1]), cstr, sizeof(char)*(len + 1)));
+	    *alloc = SWIG_NEWOBJ;
+	  }
+	else {
+	  *cptr = cstr;
+	  *alloc = SWIG_OLDOBJ;
+	}
+      } else {
+	*cptr = PyString_AsString(obj);
+      }
+    }
+    if (psize) *psize = len + 1;
+    return SWIG_OK;
+  } else {
+    swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
+    if (pchar_descriptor) {
+      void* vptr = 0;
+      if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) {
+	if (cptr) *cptr = (char *) vptr;
+	if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0;
+	if (alloc) *alloc = SWIG_OLDOBJ;
+	return SWIG_OK;
+      }
+    }
+  }
+  return SWIG_TypeError;
+}
+
+
+SWIGINTERN int
+SWIG_AsPtr_std_string (PyObject * obj, std::string **val) 
+{
+  char* buf = 0 ; size_t size = 0; int alloc = SWIG_OLDOBJ;
+  if (SWIG_IsOK((SWIG_AsCharPtrAndSize(obj, &buf, &size, &alloc)))) {
+    if (buf) {
+      if (val) *val = new std::string(buf, size - 1);
+      if (alloc == SWIG_NEWOBJ) delete[] buf;
+      return SWIG_NEWOBJ;
+    } else {
+      if (val) *val = 0;
+      return SWIG_OLDOBJ;
+    }
+  } else {
+    static int init = 0;
+    static swig_type_info* descriptor = 0;
+    if (!init) {
+      descriptor = SWIG_TypeQuery("std::string" " *");
+      init = 1;
+    }
+    if (descriptor) {
+      std::string *vptr;
+      int res = SWIG_ConvertPtr(obj, (void**)&vptr, descriptor, 0);
+      if (SWIG_IsOK(res) && val) *val = vptr;
+      return res;
+    }
+  }
+  return SWIG_ERROR;
+}
+
+
+
+using namespace std;
+using namespace saslwrapper;
+
+namespace saslwrapper {
+
+}
+
+
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+SWIGINTERN PyObject *_wrap_delete_PySwigIterator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  swig::PySwigIterator *arg1 = (swig::PySwigIterator *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:delete_PySwigIterator",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__PySwigIterator, SWIG_POINTER_DISOWN |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_PySwigIterator" "', argument " "1"" of type '" "swig::PySwigIterator *""'"); 
+  }
+  arg1 = reinterpret_cast< swig::PySwigIterator * >(argp1);
+  delete arg1;
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_PySwigIterator_value(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  swig::PySwigIterator *arg1 = (swig::PySwigIterator *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:PySwigIterator_value",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__PySwigIterator, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PySwigIterator_value" "', argument " "1"" of type '" "swig::PySwigIterator const *""'"); 
+  }
+  arg1 = reinterpret_cast< swig::PySwigIterator * >(argp1);
+  try {
+    result = (PyObject *)((swig::PySwigIterator const *)arg1)->value();
+  }
+  catch(swig::stop_iteration &_e) {
+    {
+      (void)_e;
+      SWIG_SetErrorObj(PyExc_StopIteration, SWIG_Py_Void());
+      SWIG_fail;
+    }
+  }
+  
+  resultobj = result;
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_PySwigIterator_incr__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  swig::PySwigIterator *arg1 = (swig::PySwigIterator *) 0 ;
+  size_t arg2 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  size_t val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  swig::PySwigIterator *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:PySwigIterator_incr",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__PySwigIterator, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PySwigIterator_incr" "', argument " "1"" of type '" "swig::PySwigIterator *""'"); 
+  }
+  arg1 = reinterpret_cast< swig::PySwigIterator * >(argp1);
+  ecode2 = SWIG_AsVal_size_t(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "PySwigIterator_incr" "', argument " "2"" of type '" "size_t""'");
+  } 
+  arg2 = static_cast< size_t >(val2);
+  try {
+    result = (swig::PySwigIterator *)(arg1)->incr(arg2);
+  }
+  catch(swig::stop_iteration &_e) {
+    {
+      (void)_e;
+      SWIG_SetErrorObj(PyExc_StopIteration, SWIG_Py_Void());
+      SWIG_fail;
+    }
+  }
+  
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__PySwigIterator, 0 |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_PySwigIterator_incr__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  swig::PySwigIterator *arg1 = (swig::PySwigIterator *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  swig::PySwigIterator *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:PySwigIterator_incr",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__PySwigIterator, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PySwigIterator_incr" "', argument " "1"" of type '" "swig::PySwigIterator *""'"); 
+  }
+  arg1 = reinterpret_cast< swig::PySwigIterator * >(argp1);
+  try {
+    result = (swig::PySwigIterator *)(arg1)->incr();
+  }
+  catch(swig::stop_iteration &_e) {
+    {
+      (void)_e;
+      SWIG_SetErrorObj(PyExc_StopIteration, SWIG_Py_Void());
+      SWIG_fail;
+    }
+  }
+  
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__PySwigIterator, 0 |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_PySwigIterator_incr(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[3];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = (int)PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 2); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 1) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_swig__PySwigIterator, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_PySwigIterator_incr__SWIG_1(self, args);
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_swig__PySwigIterator, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        int res = SWIG_AsVal_size_t(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        return _wrap_PySwigIterator_incr__SWIG_0(self, args);
+      }
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'PySwigIterator_incr'.\n"
+    "  Possible C/C++ prototypes are:\n"
+    "    incr(swig::PySwigIterator *,size_t)\n"
+    "    incr(swig::PySwigIterator *)\n");
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_PySwigIterator_decr__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  swig::PySwigIterator *arg1 = (swig::PySwigIterator *) 0 ;
+  size_t arg2 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  size_t val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  swig::PySwigIterator *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:PySwigIterator_decr",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__PySwigIterator, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PySwigIterator_decr" "', argument " "1"" of type '" "swig::PySwigIterator *""'"); 
+  }
+  arg1 = reinterpret_cast< swig::PySwigIterator * >(argp1);
+  ecode2 = SWIG_AsVal_size_t(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "PySwigIterator_decr" "', argument " "2"" of type '" "size_t""'");
+  } 
+  arg2 = static_cast< size_t >(val2);
+  try {
+    result = (swig::PySwigIterator *)(arg1)->decr(arg2);
+  }
+  catch(swig::stop_iteration &_e) {
+    {
+      (void)_e;
+      SWIG_SetErrorObj(PyExc_StopIteration, SWIG_Py_Void());
+      SWIG_fail;
+    }
+  }
+  
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__PySwigIterator, 0 |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_PySwigIterator_decr__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  swig::PySwigIterator *arg1 = (swig::PySwigIterator *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  swig::PySwigIterator *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:PySwigIterator_decr",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__PySwigIterator, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PySwigIterator_decr" "', argument " "1"" of type '" "swig::PySwigIterator *""'"); 
+  }
+  arg1 = reinterpret_cast< swig::PySwigIterator * >(argp1);
+  try {
+    result = (swig::PySwigIterator *)(arg1)->decr();
+  }
+  catch(swig::stop_iteration &_e) {
+    {
+      (void)_e;
+      SWIG_SetErrorObj(PyExc_StopIteration, SWIG_Py_Void());
+      SWIG_fail;
+    }
+  }
+  
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__PySwigIterator, 0 |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_PySwigIterator_decr(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[3];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = (int)PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 2); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 1) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_swig__PySwigIterator, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_PySwigIterator_decr__SWIG_1(self, args);
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_swig__PySwigIterator, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        int res = SWIG_AsVal_size_t(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        return _wrap_PySwigIterator_decr__SWIG_0(self, args);
+      }
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'PySwigIterator_decr'.\n"
+    "  Possible C/C++ prototypes are:\n"
+    "    decr(swig::PySwigIterator *,size_t)\n"
+    "    decr(swig::PySwigIterator *)\n");
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_PySwigIterator_distance(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  swig::PySwigIterator *arg1 = (swig::PySwigIterator *) 0 ;
+  swig::PySwigIterator *arg2 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  void *argp2 = 0 ;
+  int res2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  ptrdiff_t result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:PySwigIterator_distance",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__PySwigIterator, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PySwigIterator_distance" "', argument " "1"" of type '" "swig::PySwigIterator const *""'"); 
+  }
+  arg1 = reinterpret_cast< swig::PySwigIterator * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_swig__PySwigIterator,  0  | 0);
+  if (!SWIG_IsOK(res2)) {
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "PySwigIterator_distance" "', argument " "2"" of type '" "swig::PySwigIterator const &""'"); 
+  }
+  if (!argp2) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "PySwigIterator_distance" "', argument " "2"" of type '" "swig::PySwigIterator const &""'"); 
+  }
+  arg2 = reinterpret_cast< swig::PySwigIterator * >(argp2);
+  try {
+    result = ((swig::PySwigIterator const *)arg1)->distance((swig::PySwigIterator const &)*arg2);
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_Python_Raise(SWIG_NewPointerObj((new std::invalid_argument(static_cast< const std::invalid_argument& >(_e))),SWIGTYPE_p_std__invalid_argument,SWIG_POINTER_OWN), "std::invalid_argument", SWIGTYPE_p_std__invalid_argument); SWIG_fail;
+  }
+  
+  resultobj = SWIG_From_ptrdiff_t(static_cast< ptrdiff_t >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_PySwigIterator_equal(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  swig::PySwigIterator *arg1 = (swig::PySwigIterator *) 0 ;
+  swig::PySwigIterator *arg2 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  void *argp2 = 0 ;
+  int res2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  bool result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:PySwigIterator_equal",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__PySwigIterator, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PySwigIterator_equal" "', argument " "1"" of type '" "swig::PySwigIterator const *""'"); 
+  }
+  arg1 = reinterpret_cast< swig::PySwigIterator * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_swig__PySwigIterator,  0  | 0);
+  if (!SWIG_IsOK(res2)) {
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "PySwigIterator_equal" "', argument " "2"" of type '" "swig::PySwigIterator const &""'"); 
+  }
+  if (!argp2) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "PySwigIterator_equal" "', argument " "2"" of type '" "swig::PySwigIterator const &""'"); 
+  }
+  arg2 = reinterpret_cast< swig::PySwigIterator * >(argp2);
+  try {
+    result = (bool)((swig::PySwigIterator const *)arg1)->equal((swig::PySwigIterator const &)*arg2);
+  }
+  catch(std::invalid_argument &_e) {
+    SWIG_Python_Raise(SWIG_NewPointerObj((new std::invalid_argument(static_cast< const std::invalid_argument& >(_e))),SWIGTYPE_p_std__invalid_argument,SWIG_POINTER_OWN), "std::invalid_argument", SWIGTYPE_p_std__invalid_argument); SWIG_fail;
+  }
+  
+  resultobj = SWIG_From_bool(static_cast< bool >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_PySwigIterator_copy(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  swig::PySwigIterator *arg1 = (swig::PySwigIterator *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  swig::PySwigIterator *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:PySwigIterator_copy",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__PySwigIterator, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PySwigIterator_copy" "', argument " "1"" of type '" "swig::PySwigIterator const *""'"); 
+  }
+  arg1 = reinterpret_cast< swig::PySwigIterator * >(argp1);
+  result = (swig::PySwigIterator *)((swig::PySwigIterator const *)arg1)->copy();
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__PySwigIterator, SWIG_POINTER_OWN |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_PySwigIterator_next(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  swig::PySwigIterator *arg1 = (swig::PySwigIterator *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:PySwigIterator_next",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__PySwigIterator, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PySwigIterator_next" "', argument " "1"" of type '" "swig::PySwigIterator *""'"); 
+  }
+  arg1 = reinterpret_cast< swig::PySwigIterator * >(argp1);
+  try {
+    result = (PyObject *)(arg1)->next();
+  }
+  catch(swig::stop_iteration &_e) {
+    {
+      (void)_e;
+      SWIG_SetErrorObj(PyExc_StopIteration, SWIG_Py_Void());
+      SWIG_fail;
+    }
+  }
+  
+  resultobj = result;
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_PySwigIterator_previous(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  swig::PySwigIterator *arg1 = (swig::PySwigIterator *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:PySwigIterator_previous",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__PySwigIterator, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PySwigIterator_previous" "', argument " "1"" of type '" "swig::PySwigIterator *""'"); 
+  }
+  arg1 = reinterpret_cast< swig::PySwigIterator * >(argp1);
+  try {
+    result = (PyObject *)(arg1)->previous();
+  }
+  catch(swig::stop_iteration &_e) {
+    {
+      (void)_e;
+      SWIG_SetErrorObj(PyExc_StopIteration, SWIG_Py_Void());
+      SWIG_fail;
+    }
+  }
+  
+  resultobj = result;
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_PySwigIterator_advance(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  swig::PySwigIterator *arg1 = (swig::PySwigIterator *) 0 ;
+  ptrdiff_t arg2 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  ptrdiff_t val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  swig::PySwigIterator *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:PySwigIterator_advance",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__PySwigIterator, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PySwigIterator_advance" "', argument " "1"" of type '" "swig::PySwigIterator *""'"); 
+  }
+  arg1 = reinterpret_cast< swig::PySwigIterator * >(argp1);
+  ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "PySwigIterator_advance" "', argument " "2"" of type '" "ptrdiff_t""'");
+  } 
+  arg2 = static_cast< ptrdiff_t >(val2);
+  try {
+    result = (swig::PySwigIterator *)(arg1)->advance(arg2);
+  }
+  catch(swig::stop_iteration &_e) {
+    {
+      (void)_e;
+      SWIG_SetErrorObj(PyExc_StopIteration, SWIG_Py_Void());
+      SWIG_fail;
+    }
+  }
+  
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__PySwigIterator, 0 |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_PySwigIterator___eq__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  swig::PySwigIterator *arg1 = (swig::PySwigIterator *) 0 ;
+  swig::PySwigIterator *arg2 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  void *argp2 = 0 ;
+  int res2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  bool result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:PySwigIterator___eq__",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__PySwigIterator, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PySwigIterator___eq__" "', argument " "1"" of type '" "swig::PySwigIterator const *""'"); 
+  }
+  arg1 = reinterpret_cast< swig::PySwigIterator * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_swig__PySwigIterator,  0  | 0);
+  if (!SWIG_IsOK(res2)) {
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "PySwigIterator___eq__" "', argument " "2"" of type '" "swig::PySwigIterator const &""'"); 
+  }
+  if (!argp2) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "PySwigIterator___eq__" "', argument " "2"" of type '" "swig::PySwigIterator const &""'"); 
+  }
+  arg2 = reinterpret_cast< swig::PySwigIterator * >(argp2);
+  result = (bool)((swig::PySwigIterator const *)arg1)->operator ==((swig::PySwigIterator const &)*arg2);
+  resultobj = SWIG_From_bool(static_cast< bool >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_PySwigIterator___ne__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  swig::PySwigIterator *arg1 = (swig::PySwigIterator *) 0 ;
+  swig::PySwigIterator *arg2 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  void *argp2 = 0 ;
+  int res2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  bool result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:PySwigIterator___ne__",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__PySwigIterator, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PySwigIterator___ne__" "', argument " "1"" of type '" "swig::PySwigIterator const *""'"); 
+  }
+  arg1 = reinterpret_cast< swig::PySwigIterator * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_swig__PySwigIterator,  0  | 0);
+  if (!SWIG_IsOK(res2)) {
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "PySwigIterator___ne__" "', argument " "2"" of type '" "swig::PySwigIterator const &""'"); 
+  }
+  if (!argp2) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "PySwigIterator___ne__" "', argument " "2"" of type '" "swig::PySwigIterator const &""'"); 
+  }
+  arg2 = reinterpret_cast< swig::PySwigIterator * >(argp2);
+  result = (bool)((swig::PySwigIterator const *)arg1)->operator !=((swig::PySwigIterator const &)*arg2);
+  resultobj = SWIG_From_bool(static_cast< bool >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_PySwigIterator___iadd__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  swig::PySwigIterator *arg1 = (swig::PySwigIterator *) 0 ;
+  ptrdiff_t arg2 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  ptrdiff_t val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  swig::PySwigIterator *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:PySwigIterator___iadd__",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__PySwigIterator, SWIG_POINTER_DISOWN |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PySwigIterator___iadd__" "', argument " "1"" of type '" "swig::PySwigIterator *""'"); 
+  }
+  arg1 = reinterpret_cast< swig::PySwigIterator * >(argp1);
+  ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "PySwigIterator___iadd__" "', argument " "2"" of type '" "ptrdiff_t""'");
+  } 
+  arg2 = static_cast< ptrdiff_t >(val2);
+  try {
+    {
+      swig::PySwigIterator &_result_ref = (arg1)->operator +=(arg2);
+      result = (swig::PySwigIterator *) &_result_ref;
+    }
+  }
+  catch(swig::stop_iteration &_e) {
+    {
+      (void)_e;
+      SWIG_SetErrorObj(PyExc_StopIteration, SWIG_Py_Void());
+      SWIG_fail;
+    }
+  }
+  
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__PySwigIterator, SWIG_POINTER_OWN |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_PySwigIterator___isub__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  swig::PySwigIterator *arg1 = (swig::PySwigIterator *) 0 ;
+  ptrdiff_t arg2 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  ptrdiff_t val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  swig::PySwigIterator *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:PySwigIterator___isub__",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__PySwigIterator, SWIG_POINTER_DISOWN |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PySwigIterator___isub__" "', argument " "1"" of type '" "swig::PySwigIterator *""'"); 
+  }
+  arg1 = reinterpret_cast< swig::PySwigIterator * >(argp1);
+  ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "PySwigIterator___isub__" "', argument " "2"" of type '" "ptrdiff_t""'");
+  } 
+  arg2 = static_cast< ptrdiff_t >(val2);
+  try {
+    {
+      swig::PySwigIterator &_result_ref = (arg1)->operator -=(arg2);
+      result = (swig::PySwigIterator *) &_result_ref;
+    }
+  }
+  catch(swig::stop_iteration &_e) {
+    {
+      (void)_e;
+      SWIG_SetErrorObj(PyExc_StopIteration, SWIG_Py_Void());
+      SWIG_fail;
+    }
+  }
+  
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__PySwigIterator, SWIG_POINTER_OWN |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_PySwigIterator___add__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  swig::PySwigIterator *arg1 = (swig::PySwigIterator *) 0 ;
+  ptrdiff_t arg2 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  ptrdiff_t val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  swig::PySwigIterator *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:PySwigIterator___add__",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__PySwigIterator, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PySwigIterator___add__" "', argument " "1"" of type '" "swig::PySwigIterator const *""'"); 
+  }
+  arg1 = reinterpret_cast< swig::PySwigIterator * >(argp1);
+  ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "PySwigIterator___add__" "', argument " "2"" of type '" "ptrdiff_t""'");
+  } 
+  arg2 = static_cast< ptrdiff_t >(val2);
+  try {
+    result = (swig::PySwigIterator *)((swig::PySwigIterator const *)arg1)->operator +(arg2);
+  }
+  catch(swig::stop_iteration &_e) {
+    {
+      (void)_e;
+      SWIG_SetErrorObj(PyExc_StopIteration, SWIG_Py_Void());
+      SWIG_fail;
+    }
+  }
+  
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__PySwigIterator, SWIG_POINTER_OWN |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_PySwigIterator___sub____SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  swig::PySwigIterator *arg1 = (swig::PySwigIterator *) 0 ;
+  ptrdiff_t arg2 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  ptrdiff_t val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  swig::PySwigIterator *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:PySwigIterator___sub__",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__PySwigIterator, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PySwigIterator___sub__" "', argument " "1"" of type '" "swig::PySwigIterator const *""'"); 
+  }
+  arg1 = reinterpret_cast< swig::PySwigIterator * >(argp1);
+  ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "PySwigIterator___sub__" "', argument " "2"" of type '" "ptrdiff_t""'");
+  } 
+  arg2 = static_cast< ptrdiff_t >(val2);
+  try {
+    result = (swig::PySwigIterator *)((swig::PySwigIterator const *)arg1)->operator -(arg2);
+  }
+  catch(swig::stop_iteration &_e) {
+    {
+      (void)_e;
+      SWIG_SetErrorObj(PyExc_StopIteration, SWIG_Py_Void());
+      SWIG_fail;
+    }
+  }
+  
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__PySwigIterator, SWIG_POINTER_OWN |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_PySwigIterator___sub____SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  swig::PySwigIterator *arg1 = (swig::PySwigIterator *) 0 ;
+  swig::PySwigIterator *arg2 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  void *argp2 = 0 ;
+  int res2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  ptrdiff_t result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:PySwigIterator___sub__",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__PySwigIterator, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PySwigIterator___sub__" "', argument " "1"" of type '" "swig::PySwigIterator const *""'"); 
+  }
+  arg1 = reinterpret_cast< swig::PySwigIterator * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_swig__PySwigIterator,  0  | 0);
+  if (!SWIG_IsOK(res2)) {
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "PySwigIterator___sub__" "', argument " "2"" of type '" "swig::PySwigIterator const &""'"); 
+  }
+  if (!argp2) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "PySwigIterator___sub__" "', argument " "2"" of type '" "swig::PySwigIterator const &""'"); 
+  }
+  arg2 = reinterpret_cast< swig::PySwigIterator * >(argp2);
+  result = ((swig::PySwigIterator const *)arg1)->operator -((swig::PySwigIterator const &)*arg2);
+  resultobj = SWIG_From_ptrdiff_t(static_cast< ptrdiff_t >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_PySwigIterator___sub__(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[3];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = (int)PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 2); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 2) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_swig__PySwigIterator, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      int res = SWIG_ConvertPtr(argv[1], 0, SWIGTYPE_p_swig__PySwigIterator, 0);
+      _v = SWIG_CheckState(res);
+      if (_v) {
+        return _wrap_PySwigIterator___sub____SWIG_1(self, args);
+      }
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_swig__PySwigIterator, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        int res = SWIG_AsVal_ptrdiff_t(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        return _wrap_PySwigIterator___sub____SWIG_0(self, args);
+      }
+    }
+  }
+  
+fail:
+  Py_INCREF(Py_NotImplemented);
+  return Py_NotImplemented;
+}
+
+
+SWIGINTERN PyObject *PySwigIterator_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *obj;
+  if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL;
+  SWIG_TypeNewClientData(SWIGTYPE_p_swig__PySwigIterator, SWIG_NewClientData(obj));
+  return SWIG_Py_Void();
+}
+
+SWIGINTERN PyObject *_wrap_new_Client(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  saslwrapper::Client *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)":new_Client")) SWIG_fail;
+  result = (saslwrapper::Client *)new saslwrapper::Client();
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_saslwrapper__Client, SWIG_POINTER_NEW |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_delete_Client(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  saslwrapper::Client *arg1 = (saslwrapper::Client *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:delete_Client",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_saslwrapper__Client, SWIG_POINTER_DISOWN |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_Client" "', argument " "1"" of type '" "saslwrapper::Client *""'"); 
+  }
+  arg1 = reinterpret_cast< saslwrapper::Client * >(argp1);
+  delete arg1;
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_Client_setAttr__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  saslwrapper::Client *arg1 = (saslwrapper::Client *) 0 ;
+  std::string *arg2 = 0 ;
+  std::string *arg3 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  int res2 = SWIG_OLDOBJ ;
+  int res3 = SWIG_OLDOBJ ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
+  bool result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OOO:Client_setAttr",&obj0,&obj1,&obj2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_saslwrapper__Client, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Client_setAttr" "', argument " "1"" of type '" "saslwrapper::Client *""'"); 
+  }
+  arg1 = reinterpret_cast< saslwrapper::Client * >(argp1);
+  {
+    std::string *ptr = (std::string *)0;
+    res2 = SWIG_AsPtr_std_string(obj1, &ptr);
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Client_setAttr" "', argument " "2"" of type '" "std::string const &""'"); 
+    }
+    if (!ptr) {
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Client_setAttr" "', argument " "2"" of type '" "std::string const &""'"); 
+    }
+    arg2 = ptr;
+  }
+  {
+    std::string *ptr = (std::string *)0;
+    res3 = SWIG_AsPtr_std_string(obj2, &ptr);
+    if (!SWIG_IsOK(res3)) {
+      SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Client_setAttr" "', argument " "3"" of type '" "std::string const &""'"); 
+    }
+    if (!ptr) {
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Client_setAttr" "', argument " "3"" of type '" "std::string const &""'"); 
+    }
+    arg3 = ptr;
+  }
+  result = (bool)(arg1)->setAttr((std::string const &)*arg2,(std::string const &)*arg3);
+  resultobj = SWIG_From_bool(static_cast< bool >(result));
+  if (SWIG_IsNewObj(res2)) delete arg2;
+  if (SWIG_IsNewObj(res3)) delete arg3;
+  return resultobj;
+fail:
+  if (SWIG_IsNewObj(res2)) delete arg2;
+  if (SWIG_IsNewObj(res3)) delete arg3;
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_Client_setAttr__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  saslwrapper::Client *arg1 = (saslwrapper::Client *) 0 ;
+  std::string *arg2 = 0 ;
+  uint32_t arg3 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  int res2 = SWIG_OLDOBJ ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
+  bool result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OOO:Client_setAttr",&obj0,&obj1,&obj2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_saslwrapper__Client, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Client_setAttr" "', argument " "1"" of type '" "saslwrapper::Client *""'"); 
+  }
+  arg1 = reinterpret_cast< saslwrapper::Client * >(argp1);
+  {
+    std::string *ptr = (std::string *)0;
+    res2 = SWIG_AsPtr_std_string(obj1, &ptr);
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Client_setAttr" "', argument " "2"" of type '" "std::string const &""'"); 
+    }
+    if (!ptr) {
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Client_setAttr" "', argument " "2"" of type '" "std::string const &""'"); 
+    }
+    arg2 = ptr;
+  }
+  {
+    if (PyInt_Check(obj2)) {
+      arg3 = (uint32_t) PyInt_AsUnsignedLongMask(obj2);
+    } else if (PyLong_Check(obj2)) {
+      arg3 = (uint32_t) PyLong_AsUnsignedLong(obj2);
+    } else {
+      SWIG_exception_fail(SWIG_ValueError, "unknown integer type");
+    }
+  }
+  result = (bool)(arg1)->setAttr((std::string const &)*arg2,arg3);
+  resultobj = SWIG_From_bool(static_cast< bool >(result));
+  if (SWIG_IsNewObj(res2)) delete arg2;
+  return resultobj;
+fail:
+  if (SWIG_IsNewObj(res2)) delete arg2;
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_Client_setAttr(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[4];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = (int)PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 3); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 3) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_saslwrapper__Client, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      int res = SWIG_AsPtr_std_string(argv[1], (std::string**)(0));
+      _v = SWIG_CheckState(res);
+      if (_v) {
+        {
+          _v = PyInt_Check(argv[2]) ? 1 : 0;
+        }
+        if (_v) {
+          return _wrap_Client_setAttr__SWIG_1(self, args);
+        }
+      }
+    }
+  }
+  if (argc == 3) {
+    int _v;
+    void *vptr = 0;
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_saslwrapper__Client, 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      int res = SWIG_AsPtr_std_string(argv[1], (std::string**)(0));
+      _v = SWIG_CheckState(res);
+      if (_v) {
+        int res = SWIG_AsPtr_std_string(argv[2], (std::string**)(0));
+        _v = SWIG_CheckState(res);
+        if (_v) {
+          return _wrap_Client_setAttr__SWIG_0(self, args);
+        }
+      }
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'Client_setAttr'.\n"
+    "  Possible C/C++ prototypes are:\n"
+    "    setAttr(saslwrapper::Client *,std::string const &,std::string const &)\n"
+    "    setAttr(saslwrapper::Client *,std::string const &,uint32_t)\n");
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_Client_init(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  saslwrapper::Client *arg1 = (saslwrapper::Client *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  bool result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:Client_init",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_saslwrapper__Client, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Client_init" "', argument " "1"" of type '" "saslwrapper::Client *""'"); 
+  }
+  arg1 = reinterpret_cast< saslwrapper::Client * >(argp1);
+  result = (bool)(arg1)->init();
+  resultobj = SWIG_From_bool(static_cast< bool >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_Client_start(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  saslwrapper::Client *arg1 = (saslwrapper::Client *) 0 ;
+  std::string *arg2 = 0 ;
+  saslwrapper::output_string *arg3 = 0 ;
+  saslwrapper::output_string *arg4 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  int res2 = SWIG_OLDOBJ ;
+  std::string temp3 ;
+  std::string temp4 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  bool result;
+  
+  {
+    arg3 = &temp3;
+  }
+  {
+    arg4 = &temp4;
+  }
+  if (!PyArg_ParseTuple(args,(char *)"OO:Client_start",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_saslwrapper__Client, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Client_start" "', argument " "1"" of type '" "saslwrapper::Client *""'"); 
+  }
+  arg1 = reinterpret_cast< saslwrapper::Client * >(argp1);
+  {
+    std::string *ptr = (std::string *)0;
+    res2 = SWIG_AsPtr_std_string(obj1, &ptr);
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Client_start" "', argument " "2"" of type '" "std::string const &""'"); 
+    }
+    if (!ptr) {
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Client_start" "', argument " "2"" of type '" "std::string const &""'"); 
+    }
+    arg2 = ptr;
+  }
+  result = (bool)(arg1)->start((std::string const &)*arg2,*arg3,*arg4);
+  resultobj = SWIG_From_bool(static_cast< bool >(result));
+  {
+    // Append output value arg3 to resultobj
+    PyObject *o, *o2, *o3;
+    o = PyString_FromStringAndSize(arg3->c_str(), arg3->length());
+    if ((!resultobj) || (resultobj == Py_None)) {
+      resultobj = o;
+    } else {
+      if (!PyTuple_Check(resultobj)) {
+        PyObject *o2 = resultobj;
+        resultobj = PyTuple_New(1);
+        PyTuple_SetItem(resultobj,0,o2);
+      }
+      o3 = PyTuple_New(1);
+      PyTuple_SetItem(o3,0,o);
+      o2 = resultobj;
+      resultobj = PySequence_Concat(o2,o3);
+      Py_DECREF(o2);
+      Py_DECREF(o3);
+    }
+  }
+  {
+    // Append output value arg4 to resultobj
+    PyObject *o, *o2, *o3;
+    o = PyString_FromStringAndSize(arg4->c_str(), arg4->length());
+    if ((!resultobj) || (resultobj == Py_None)) {
+      resultobj = o;
+    } else {
+      if (!PyTuple_Check(resultobj)) {
+        PyObject *o2 = resultobj;
+        resultobj = PyTuple_New(1);
+        PyTuple_SetItem(resultobj,0,o2);
+      }
+      o3 = PyTuple_New(1);
+      PyTuple_SetItem(o3,0,o);
+      o2 = resultobj;
+      resultobj = PySequence_Concat(o2,o3);
+      Py_DECREF(o2);
+      Py_DECREF(o3);
+    }
+  }
+  if (SWIG_IsNewObj(res2)) delete arg2;
+  return resultobj;
+fail:
+  if (SWIG_IsNewObj(res2)) delete arg2;
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_Client_step(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  saslwrapper::Client *arg1 = (saslwrapper::Client *) 0 ;
+  std::string *arg2 = 0 ;
+  saslwrapper::output_string *arg3 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  int res2 = SWIG_OLDOBJ ;
+  std::string temp3 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  bool result;
+  
+  {
+    arg3 = &temp3;
+  }
+  if (!PyArg_ParseTuple(args,(char *)"OO:Client_step",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_saslwrapper__Client, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Client_step" "', argument " "1"" of type '" "saslwrapper::Client *""'"); 
+  }
+  arg1 = reinterpret_cast< saslwrapper::Client * >(argp1);
+  {
+    std::string *ptr = (std::string *)0;
+    res2 = SWIG_AsPtr_std_string(obj1, &ptr);
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Client_step" "', argument " "2"" of type '" "std::string const &""'"); 
+    }
+    if (!ptr) {
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Client_step" "', argument " "2"" of type '" "std::string const &""'"); 
+    }
+    arg2 = ptr;
+  }
+  result = (bool)(arg1)->step((std::string const &)*arg2,*arg3);
+  resultobj = SWIG_From_bool(static_cast< bool >(result));
+  {
+    // Append output value arg3 to resultobj
+    PyObject *o, *o2, *o3;
+    o = PyString_FromStringAndSize(arg3->c_str(), arg3->length());
+    if ((!resultobj) || (resultobj == Py_None)) {
+      resultobj = o;
+    } else {
+      if (!PyTuple_Check(resultobj)) {
+        PyObject *o2 = resultobj;
+        resultobj = PyTuple_New(1);
+        PyTuple_SetItem(resultobj,0,o2);
+      }
+      o3 = PyTuple_New(1);
+      PyTuple_SetItem(o3,0,o);
+      o2 = resultobj;
+      resultobj = PySequence_Concat(o2,o3);
+      Py_DECREF(o2);
+      Py_DECREF(o3);
+    }
+  }
+  if (SWIG_IsNewObj(res2)) delete arg2;
+  return resultobj;
+fail:
+  if (SWIG_IsNewObj(res2)) delete arg2;
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_Client_encode(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  saslwrapper::Client *arg1 = (saslwrapper::Client *) 0 ;
+  std::string *arg2 = 0 ;
+  saslwrapper::output_string *arg3 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  int res2 = SWIG_OLDOBJ ;
+  std::string temp3 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  bool result;
+  
+  {
+    arg3 = &temp3;
+  }
+  if (!PyArg_ParseTuple(args,(char *)"OO:Client_encode",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_saslwrapper__Client, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Client_encode" "', argument " "1"" of type '" "saslwrapper::Client *""'"); 
+  }
+  arg1 = reinterpret_cast< saslwrapper::Client * >(argp1);
+  {
+    std::string *ptr = (std::string *)0;
+    res2 = SWIG_AsPtr_std_string(obj1, &ptr);
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Client_encode" "', argument " "2"" of type '" "std::string const &""'"); 
+    }
+    if (!ptr) {
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Client_encode" "', argument " "2"" of type '" "std::string const &""'"); 
+    }
+    arg2 = ptr;
+  }
+  result = (bool)(arg1)->encode((std::string const &)*arg2,*arg3);
+  resultobj = SWIG_From_bool(static_cast< bool >(result));
+  {
+    // Append output value arg3 to resultobj
+    PyObject *o, *o2, *o3;
+    o = PyString_FromStringAndSize(arg3->c_str(), arg3->length());
+    if ((!resultobj) || (resultobj == Py_None)) {
+      resultobj = o;
+    } else {
+      if (!PyTuple_Check(resultobj)) {
+        PyObject *o2 = resultobj;
+        resultobj = PyTuple_New(1);
+        PyTuple_SetItem(resultobj,0,o2);
+      }
+      o3 = PyTuple_New(1);
+      PyTuple_SetItem(o3,0,o);
+      o2 = resultobj;
+      resultobj = PySequence_Concat(o2,o3);
+      Py_DECREF(o2);
+      Py_DECREF(o3);
+    }
+  }
+  if (SWIG_IsNewObj(res2)) delete arg2;
+  return resultobj;
+fail:
+  if (SWIG_IsNewObj(res2)) delete arg2;
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_Client_decode(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  saslwrapper::Client *arg1 = (saslwrapper::Client *) 0 ;
+  std::string *arg2 = 0 ;
+  saslwrapper::output_string *arg3 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  int res2 = SWIG_OLDOBJ ;
+  std::string temp3 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  bool result;
+  
+  {
+    arg3 = &temp3;
+  }
+  if (!PyArg_ParseTuple(args,(char *)"OO:Client_decode",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_saslwrapper__Client, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Client_decode" "', argument " "1"" of type '" "saslwrapper::Client *""'"); 
+  }
+  arg1 = reinterpret_cast< saslwrapper::Client * >(argp1);
+  {
+    std::string *ptr = (std::string *)0;
+    res2 = SWIG_AsPtr_std_string(obj1, &ptr);
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Client_decode" "', argument " "2"" of type '" "std::string const &""'"); 
+    }
+    if (!ptr) {
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Client_decode" "', argument " "2"" of type '" "std::string const &""'"); 
+    }
+    arg2 = ptr;
+  }
+  result = (bool)(arg1)->decode((std::string const &)*arg2,*arg3);
+  resultobj = SWIG_From_bool(static_cast< bool >(result));
+  {
+    // Append output value arg3 to resultobj
+    PyObject *o, *o2, *o3;
+    o = PyString_FromStringAndSize(arg3->c_str(), arg3->length());
+    if ((!resultobj) || (resultobj == Py_None)) {
+      resultobj = o;
+    } else {
+      if (!PyTuple_Check(resultobj)) {
+        PyObject *o2 = resultobj;
+        resultobj = PyTuple_New(1);
+        PyTuple_SetItem(resultobj,0,o2);
+      }
+      o3 = PyTuple_New(1);
+      PyTuple_SetItem(o3,0,o);
+      o2 = resultobj;
+      resultobj = PySequence_Concat(o2,o3);
+      Py_DECREF(o2);
+      Py_DECREF(o3);
+    }
+  }
+  if (SWIG_IsNewObj(res2)) delete arg2;
+  return resultobj;
+fail:
+  if (SWIG_IsNewObj(res2)) delete arg2;
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_Client_getUserId(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  saslwrapper::Client *arg1 = (saslwrapper::Client *) 0 ;
+  saslwrapper::output_string *arg2 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  std::string temp2 ;
+  PyObject * obj0 = 0 ;
+  bool result;
+  
+  {
+    arg2 = &temp2;
+  }
+  if (!PyArg_ParseTuple(args,(char *)"O:Client_getUserId",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_saslwrapper__Client, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Client_getUserId" "', argument " "1"" of type '" "saslwrapper::Client *""'"); 
+  }
+  arg1 = reinterpret_cast< saslwrapper::Client * >(argp1);
+  result = (bool)(arg1)->getUserId(*arg2);
+  resultobj = SWIG_From_bool(static_cast< bool >(result));
+  {
+    // Append output value arg2 to resultobj
+    PyObject *o, *o2, *o3;
+    o = PyString_FromStringAndSize(arg2->c_str(), arg2->length());
+    if ((!resultobj) || (resultobj == Py_None)) {
+      resultobj = o;
+    } else {
+      if (!PyTuple_Check(resultobj)) {
+        PyObject *o2 = resultobj;
+        resultobj = PyTuple_New(1);
+        PyTuple_SetItem(resultobj,0,o2);
+      }
+      o3 = PyTuple_New(1);
+      PyTuple_SetItem(o3,0,o);
+      o2 = resultobj;
+      resultobj = PySequence_Concat(o2,o3);
+      Py_DECREF(o2);
+      Py_DECREF(o3);
+    }
+  }
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_Client_getError(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  saslwrapper::Client *arg1 = (saslwrapper::Client *) 0 ;
+  saslwrapper::output_string *arg2 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  std::string temp2 ;
+  PyObject * obj0 = 0 ;
+  
+  {
+    arg2 = &temp2;
+  }
+  if (!PyArg_ParseTuple(args,(char *)"O:Client_getError",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_saslwrapper__Client, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Client_getError" "', argument " "1"" of type '" "saslwrapper::Client *""'"); 
+  }
+  arg1 = reinterpret_cast< saslwrapper::Client * >(argp1);
+  (arg1)->getError(*arg2);
+  resultobj = SWIG_Py_Void();
+  {
+    // Append output value arg2 to resultobj
+    PyObject *o, *o2, *o3;
+    o = PyString_FromStringAndSize(arg2->c_str(), arg2->length());
+    if ((!resultobj) || (resultobj == Py_None)) {
+      resultobj = o;
+    } else {
+      if (!PyTuple_Check(resultobj)) {
+        PyObject *o2 = resultobj;
+        resultobj = PyTuple_New(1);
+        PyTuple_SetItem(resultobj,0,o2);
+      }
+      o3 = PyTuple_New(1);
+      PyTuple_SetItem(o3,0,o);
+      o2 = resultobj;
+      resultobj = PySequence_Concat(o2,o3);
+      Py_DECREF(o2);
+      Py_DECREF(o3);
+    }
+  }
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *Client_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *obj;
+  if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL;
+  SWIG_TypeNewClientData(SWIGTYPE_p_saslwrapper__Client, SWIG_NewClientData(obj));
+  return SWIG_Py_Void();
+}
+
+static PyMethodDef SwigMethods[] = {
+	 { (char *)"delete_PySwigIterator", _wrap_delete_PySwigIterator, METH_VARARGS, NULL},
+	 { (char *)"PySwigIterator_value", _wrap_PySwigIterator_value, METH_VARARGS, NULL},
+	 { (char *)"PySwigIterator_incr", _wrap_PySwigIterator_incr, METH_VARARGS, NULL},
+	 { (char *)"PySwigIterator_decr", _wrap_PySwigIterator_decr, METH_VARARGS, NULL},
+	 { (char *)"PySwigIterator_distance", _wrap_PySwigIterator_distance, METH_VARARGS, NULL},
+	 { (char *)"PySwigIterator_equal", _wrap_PySwigIterator_equal, METH_VARARGS, NULL},
+	 { (char *)"PySwigIterator_copy", _wrap_PySwigIterator_copy, METH_VARARGS, NULL},
+	 { (char *)"PySwigIterator_next", _wrap_PySwigIterator_next, METH_VARARGS, NULL},
+	 { (char *)"PySwigIterator_previous", _wrap_PySwigIterator_previous, METH_VARARGS, NULL},
+	 { (char *)"PySwigIterator_advance", _wrap_PySwigIterator_advance, METH_VARARGS, NULL},
+	 { (char *)"PySwigIterator___eq__", _wrap_PySwigIterator___eq__, METH_VARARGS, NULL},
+	 { (char *)"PySwigIterator___ne__", _wrap_PySwigIterator___ne__, METH_VARARGS, NULL},
+	 { (char *)"PySwigIterator___iadd__", _wrap_PySwigIterator___iadd__, METH_VARARGS, NULL},
+	 { (char *)"PySwigIterator___isub__", _wrap_PySwigIterator___isub__, METH_VARARGS, NULL},
+	 { (char *)"PySwigIterator___add__", _wrap_PySwigIterator___add__, METH_VARARGS, NULL},
+	 { (char *)"PySwigIterator___sub__", _wrap_PySwigIterator___sub__, METH_VARARGS, NULL},
+	 { (char *)"PySwigIterator_swigregister", PySwigIterator_swigregister, METH_VARARGS, NULL},
+	 { (char *)"new_Client", _wrap_new_Client, METH_VARARGS, NULL},
+	 { (char *)"delete_Client", _wrap_delete_Client, METH_VARARGS, NULL},
+	 { (char *)"Client_setAttr", _wrap_Client_setAttr, METH_VARARGS, NULL},
+	 { (char *)"Client_init", _wrap_Client_init, METH_VARARGS, NULL},
+	 { (char *)"Client_start", _wrap_Client_start, METH_VARARGS, NULL},
+	 { (char *)"Client_step", _wrap_Client_step, METH_VARARGS, NULL},
+	 { (char *)"Client_encode", _wrap_Client_encode, METH_VARARGS, NULL},
+	 { (char *)"Client_decode", _wrap_Client_decode, METH_VARARGS, NULL},
+	 { (char *)"Client_getUserId", _wrap_Client_getUserId, METH_VARARGS, NULL},
+	 { (char *)"Client_getError", _wrap_Client_getError, METH_VARARGS, NULL},
+	 { (char *)"Client_swigregister", Client_swigregister, METH_VARARGS, NULL},
+	 { NULL, NULL, 0, NULL }
+};
+
+
+/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
+
+static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_saslwrapper__Client = {"_p_saslwrapper__Client", "saslwrapper::Client *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__invalid_argument = {"_p_std__invalid_argument", "std::invalid_argument *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__string = {"_p_std__string", "std::string *|saslwrapper::output_string *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_swig__PySwigIterator = {"_p_swig__PySwigIterator", "swig::PySwigIterator *", 0, 0, (void*)0, 0};
+
+static swig_type_info *swig_type_initial[] = {
+  &_swigt__p_char,
+  &_swigt__p_saslwrapper__Client,
+  &_swigt__p_std__invalid_argument,
+  &_swigt__p_std__string,
+  &_swigt__p_swig__PySwigIterator,
+};
+
+static swig_cast_info _swigc__p_char[] = {  {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_saslwrapper__Client[] = {  {&_swigt__p_saslwrapper__Client, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_std__invalid_argument[] = {  {&_swigt__p_std__invalid_argument, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_std__string[] = {  {&_swigt__p_std__string, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_swig__PySwigIterator[] = {  {&_swigt__p_swig__PySwigIterator, 0, 0, 0},{0, 0, 0, 0}};
+
+static swig_cast_info *swig_cast_initial[] = {
+  _swigc__p_char,
+  _swigc__p_saslwrapper__Client,
+  _swigc__p_std__invalid_argument,
+  _swigc__p_std__string,
+  _swigc__p_swig__PySwigIterator,
+};
+
+
+/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */
+
+static swig_const_info swig_const_table[] = {
+{0, 0, 0, 0.0, 0, 0}};
+
+#ifdef __cplusplus
+}
+#endif
+/* -----------------------------------------------------------------------------
+ * Type initialization:
+ * This problem is tough by the requirement that no dynamic 
+ * memory is used. Also, since swig_type_info structures store pointers to 
+ * swig_cast_info structures and swig_cast_info structures store pointers back
+ * to swig_type_info structures, we need some lookup code at initialization. 
+ * The idea is that swig generates all the structures that are needed. 
+ * The runtime then collects these partially filled structures. 
+ * The SWIG_InitializeModule function takes these initial arrays out of 
+ * swig_module, and does all the lookup, filling in the swig_module.types
+ * array with the correct data and linking the correct swig_cast_info
+ * structures together.
+ *
+ * The generated swig_type_info structures are assigned staticly to an initial 
+ * array. We just loop through that array, and handle each type individually.
+ * First we lookup if this type has been already loaded, and if so, use the
+ * loaded structure instead of the generated one. Then we have to fill in the
+ * cast linked list. The cast data is initially stored in something like a
+ * two-dimensional array. Each row corresponds to a type (there are the same
+ * number of rows as there are in the swig_type_initial array). Each entry in
+ * a column is one of the swig_cast_info structures for that type.
+ * The cast_initial array is actually an array of arrays, because each row has
+ * a variable number of columns. So to actually build the cast linked list,
+ * we find the array of casts associated with the type, and loop through it 
+ * adding the casts to the list. The one last trick we need to do is making
+ * sure the type pointer in the swig_cast_info struct is correct.
+ *
+ * First off, we lookup the cast->type name to see if it is already loaded. 
+ * There are three cases to handle:
+ *  1) If the cast->type has already been loaded AND the type we are adding
+ *     casting info to has not been loaded (it is in this module), THEN we
+ *     replace the cast->type pointer with the type pointer that has already
+ *     been loaded.
+ *  2) If BOTH types (the one we are adding casting info to, and the 
+ *     cast->type) are loaded, THEN the cast info has already been loaded by
+ *     the previous module so we just ignore it.
+ *  3) Finally, if cast->type has not already been loaded, then we add that
+ *     swig_cast_info to the linked list (because the cast->type) pointer will
+ *     be correct.
+ * ----------------------------------------------------------------------------- */
+
+#ifdef __cplusplus
+extern "C" {
+#if 0
+} /* c-mode */
+#endif
+#endif
+
+#if 0
+#define SWIGRUNTIME_DEBUG
+#endif
+
+
+SWIGRUNTIME void
+SWIG_InitializeModule(void *clientdata) {
+  size_t i;
+  swig_module_info *module_head, *iter;
+  int found, init;
+  
+  clientdata = clientdata;
+  
+  /* check to see if the circular list has been setup, if not, set it up */
+  if (swig_module.next==0) {
+    /* Initialize the swig_module */
+    swig_module.type_initial = swig_type_initial;
+    swig_module.cast_initial = swig_cast_initial;
+    swig_module.next = &swig_module;
+    init = 1;
+  } else {
+    init = 0;
+  }
+  
+  /* Try and load any already created modules */
+  module_head = SWIG_GetModule(clientdata);
+  if (!module_head) {
+    /* This is the first module loaded for this interpreter */
+    /* so set the swig module into the interpreter */
+    SWIG_SetModule(clientdata, &swig_module);
+    module_head = &swig_module;
+  } else {
+    /* the interpreter has loaded a SWIG module, but has it loaded this one? */
+    found=0;
+    iter=module_head;
+    do {
+      if (iter==&swig_module) {
+        found=1;
+        break;
+      }
+      iter=iter->next;
+    } while (iter!= module_head);
+    
+    /* if the is found in the list, then all is done and we may leave */
+    if (found) return;
+    /* otherwise we must add out module into the list */
+    swig_module.next = module_head->next;
+    module_head->next = &swig_module;
+  }
+  
+  /* When multiple interpeters are used, a module could have already been initialized in
+       a different interpreter, but not yet have a pointer in this interpreter.
+       In this case, we do not want to continue adding types... everything should be
+       set up already */
+  if (init == 0) return;
+  
+  /* Now work on filling in swig_module.types */
+#ifdef SWIGRUNTIME_DEBUG
+  printf("SWIG_InitializeModule: size %d\n", swig_module.size);
+#endif
+  for (i = 0; i < swig_module.size; ++i) {
+    swig_type_info *type = 0;
+    swig_type_info *ret;
+    swig_cast_info *cast;
+    
+#ifdef SWIGRUNTIME_DEBUG
+    printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
+#endif
+    
+    /* if there is another module already loaded */
+    if (swig_module.next != &swig_module) {
+      type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name);
+    }
+    if (type) {
+      /* Overwrite clientdata field */
+#ifdef SWIGRUNTIME_DEBUG
+      printf("SWIG_InitializeModule: found type %s\n", type->name);
+#endif
+      if (swig_module.type_initial[i]->clientdata) {
+        type->clientdata = swig_module.type_initial[i]->clientdata;
+#ifdef SWIGRUNTIME_DEBUG
+        printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name);
+#endif
+      }
+    } else {
+      type = swig_module.type_initial[i];
+    }
+    
+    /* Insert casting types */
+    cast = swig_module.cast_initial[i];
+    while (cast->type) {
+      /* Don't need to add information already in the list */
+      ret = 0;
+#ifdef SWIGRUNTIME_DEBUG
+      printf("SWIG_InitializeModule: look cast %s\n", cast->type->name);
+#endif
+      if (swig_module.next != &swig_module) {
+        ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name);
+#ifdef SWIGRUNTIME_DEBUG
+        if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name);
+#endif
+      }
+      if (ret) {
+        if (type == swig_module.type_initial[i]) {
+#ifdef SWIGRUNTIME_DEBUG
+          printf("SWIG_InitializeModule: skip old type %s\n", ret->name);
+#endif
+          cast->type = ret;
+          ret = 0;
+        } else {
+          /* Check for casting already in the list */
+          swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type);
+#ifdef SWIGRUNTIME_DEBUG
+          if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name);
+#endif
+          if (!ocast) ret = 0;
+        }
+      }
+      
+      if (!ret) {
+#ifdef SWIGRUNTIME_DEBUG
+        printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name);
+#endif
+        if (type->cast) {
+          type->cast->prev = cast;
+          cast->next = type->cast;
+        }
+        type->cast = cast;
+      }
+      cast++;
+    }
+    /* Set entry in modules->types array equal to the type */
+    swig_module.types[i] = type;
+  }
+  swig_module.types[i] = 0;
+  
+#ifdef SWIGRUNTIME_DEBUG
+  printf("**** SWIG_InitializeModule: Cast List ******\n");
+  for (i = 0; i < swig_module.size; ++i) {
+    int j = 0;
+    swig_cast_info *cast = swig_module.cast_initial[i];
+    printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
+    while (cast->type) {
+      printf("SWIG_InitializeModule: cast type %s\n", cast->type->name);
+      cast++;
+      ++j;
+    }
+    printf("---- Total casts: %d\n",j);
+  }
+  printf("**** SWIG_InitializeModule: Cast List ******\n");
+#endif
+}
+
+/* This function will propagate the clientdata field of type to
+* any new swig_type_info structures that have been added into the list
+* of equivalent types.  It is like calling
+* SWIG_TypeClientData(type, clientdata) a second time.
+*/
+SWIGRUNTIME void
+SWIG_PropagateClientData(void) {
+  size_t i;
+  swig_cast_info *equiv;
+  static int init_run = 0;
+  
+  if (init_run) return;
+  init_run = 1;
+  
+  for (i = 0; i < swig_module.size; i++) {
+    if (swig_module.types[i]->clientdata) {
+      equiv = swig_module.types[i]->cast;
+      while (equiv) {
+        if (!equiv->converter) {
+          if (equiv->type && !equiv->type->clientdata)
+          SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata);
+        }
+        equiv = equiv->next;
+      }
+    }
+  }
+}
+
+#ifdef __cplusplus
+#if 0
+{
+  /* c-mode */
+#endif
+}
+#endif
+
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+  
+  /* Python-specific SWIG API */
+#define SWIG_newvarlink()                             SWIG_Python_newvarlink()
+#define SWIG_addvarlink(p, name, get_attr, set_attr)  SWIG_Python_addvarlink(p, name, get_attr, set_attr)
+#define SWIG_InstallConstants(d, constants)           SWIG_Python_InstallConstants(d, constants)
+  
+  /* -----------------------------------------------------------------------------
+   * global variable support code.
+   * ----------------------------------------------------------------------------- */
+  
+  typedef struct swig_globalvar {
+    char       *name;                  /* Name of global variable */
+    PyObject *(*get_attr)(void);       /* Return the current value */
+    int       (*set_attr)(PyObject *); /* Set the value */
+    struct swig_globalvar *next;
+  } swig_globalvar;
+  
+  typedef struct swig_varlinkobject {
+    PyObject_HEAD
+    swig_globalvar *vars;
+  } swig_varlinkobject;
+  
+  SWIGINTERN PyObject *
+  swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) {
+    return PyString_FromString("<Swig global variables>");
+  }
+  
+  SWIGINTERN PyObject *
+  swig_varlink_str(swig_varlinkobject *v) {
+    PyObject *str = PyString_FromString("(");
+    swig_globalvar  *var;
+    for (var = v->vars; var; var=var->next) {
+      PyString_ConcatAndDel(&str,PyString_FromString(var->name));
+      if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", "));
+    }
+    PyString_ConcatAndDel(&str,PyString_FromString(")"));
+    return str;
+  }
+  
+  SWIGINTERN int
+  swig_varlink_print(swig_varlinkobject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) {
+    PyObject *str = swig_varlink_str(v);
+    fprintf(fp,"Swig global variables ");
+    fprintf(fp,"%s\n", PyString_AsString(str));
+    Py_DECREF(str);
+    return 0;
+  }
+  
+  SWIGINTERN void
+  swig_varlink_dealloc(swig_varlinkobject *v) {
+    swig_globalvar *var = v->vars;
+    while (var) {
+      swig_globalvar *n = var->next;
+      free(var->name);
+      free(var);
+      var = n;
+    }
+  }
+  
+  SWIGINTERN PyObject *
+  swig_varlink_getattr(swig_varlinkobject *v, char *n) {
+    PyObject *res = NULL;
+    swig_globalvar *var = v->vars;
+    while (var) {
+      if (strcmp(var->name,n) == 0) {
+        res = (*var->get_attr)();
+        break;
+      }
+      var = var->next;
+    }
+    if (res == NULL && !PyErr_Occurred()) {
+      PyErr_SetString(PyExc_NameError,"Unknown C global variable");
+    }
+    return res;
+  }
+  
+  SWIGINTERN int
+  swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) {
+    int res = 1;
+    swig_globalvar *var = v->vars;
+    while (var) {
+      if (strcmp(var->name,n) == 0) {
+        res = (*var->set_attr)(p);
+        break;
+      }
+      var = var->next;
+    }
+    if (res == 1 && !PyErr_Occurred()) {
+      PyErr_SetString(PyExc_NameError,"Unknown C global variable");
+    }
+    return res;
+  }
+  
+  SWIGINTERN PyTypeObject*
+  swig_varlink_type(void) {
+    static char varlink__doc__[] = "Swig var link object";
+    static PyTypeObject varlink_type;
+    static int type_init = 0;  
+    if (!type_init) {
+      const PyTypeObject tmp
+      = {
+        PyObject_HEAD_INIT(NULL)
+        0,                                  /* Number of items in variable part (ob_size) */
+        (char *)"swigvarlink",              /* Type name (tp_name) */
+        sizeof(swig_varlinkobject),         /* Basic size (tp_basicsize) */
+        0,                                  /* Itemsize (tp_itemsize) */
+        (destructor) swig_varlink_dealloc,   /* Deallocator (tp_dealloc) */ 
+        (printfunc) swig_varlink_print,     /* Print (tp_print) */
+        (getattrfunc) swig_varlink_getattr, /* get attr (tp_getattr) */
+        (setattrfunc) swig_varlink_setattr, /* Set attr (tp_setattr) */
+        0,                                  /* tp_compare */
+        (reprfunc) swig_varlink_repr,       /* tp_repr */
+        0,                                  /* tp_as_number */
+        0,                                  /* tp_as_sequence */
+        0,                                  /* tp_as_mapping */
+        0,                                  /* tp_hash */
+        0,                                  /* tp_call */
+        (reprfunc)swig_varlink_str,        /* tp_str */
+        0,                                  /* tp_getattro */
+        0,                                  /* tp_setattro */
+        0,                                  /* tp_as_buffer */
+        0,                                  /* tp_flags */
+        varlink__doc__,                     /* tp_doc */
+        0,                                  /* tp_traverse */
+        0,                                  /* tp_clear */
+        0,                                  /* tp_richcompare */
+        0,                                  /* tp_weaklistoffset */
+#if PY_VERSION_HEX >= 0x02020000
+        0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */
+#endif
+#if PY_VERSION_HEX >= 0x02030000
+        0,                                  /* tp_del */
+#endif
+#ifdef COUNT_ALLOCS
+        0,0,0,0                             /* tp_alloc -> tp_next */
+#endif
+      };
+      varlink_type = tmp;
+      varlink_type.ob_type = &PyType_Type;
+      type_init = 1;
+    }
+    return &varlink_type;
+  }
+  
+  /* Create a variable linking object for use later */
+  SWIGINTERN PyObject *
+  SWIG_Python_newvarlink(void) {
+    swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_type());
+    if (result) {
+      result->vars = 0;
+    }
+    return ((PyObject*) result);
+  }
+  
+  SWIGINTERN void 
+  SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) {
+    swig_varlinkobject *v = (swig_varlinkobject *) p;
+    swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar));
+    if (gv) {
+      size_t size = strlen(name)+1;
+      gv->name = (char *)malloc(size);
+      if (gv->name) {
+        strncpy(gv->name,name,size);
+        gv->get_attr = get_attr;
+        gv->set_attr = set_attr;
+        gv->next = v->vars;
+      }
+    }
+    v->vars = gv;
+  }
+  
+  SWIGINTERN PyObject *
+  SWIG_globals(void) {
+    static PyObject *_SWIG_globals = 0; 
+    if (!_SWIG_globals) _SWIG_globals = SWIG_newvarlink();  
+    return _SWIG_globals;
+  }
+  
+  /* -----------------------------------------------------------------------------
+   * constants/methods manipulation
+   * ----------------------------------------------------------------------------- */
+  
+  /* Install Constants */
+  SWIGINTERN void
+  SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) {
+    PyObject *obj = 0;
+    size_t i;
+    for (i = 0; constants[i].type; ++i) {
+      switch(constants[i].type) {
+      case SWIG_PY_POINTER:
+        obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0);
+        break;
+      case SWIG_PY_BINARY:
+        obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype));
+        break;
+      default:
+        obj = 0;
+        break;
+      }
+      if (obj) {
+        PyDict_SetItemString(d, constants[i].name, obj);
+        Py_DECREF(obj);
+      }
+    }
+  }
+  
+  /* -----------------------------------------------------------------------------*/
+  /* Fix SwigMethods to carry the callback ptrs when needed */
+  /* -----------------------------------------------------------------------------*/
+  
+  SWIGINTERN void
+  SWIG_Python_FixMethods(PyMethodDef *methods,
+    swig_const_info *const_table,
+    swig_type_info **types,
+    swig_type_info **types_initial) {
+    size_t i;
+    for (i = 0; methods[i].ml_name; ++i) {
+      const char *c = methods[i].ml_doc;
+      if (c && (c = strstr(c, "swig_ptr: "))) {
+        int j;
+        swig_const_info *ci = 0;
+        const char *name = c + 10;
+        for (j = 0; const_table[j].type; ++j) {
+          if (strncmp(const_table[j].name, name, 
+              strlen(const_table[j].name)) == 0) {
+            ci = &(const_table[j]);
+            break;
+          }
+        }
+        if (ci) {
+          size_t shift = (ci->ptype) - types;
+          swig_type_info *ty = types_initial[shift];
+          size_t ldoc = (c - methods[i].ml_doc);
+          size_t lptr = strlen(ty->name)+2*sizeof(void*)+2;
+          char *ndoc = (char*)malloc(ldoc + lptr + 10);
+          if (ndoc) {
+            char *buff = ndoc;
+            void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0;
+            if (ptr) {
+              strncpy(buff, methods[i].ml_doc, ldoc);
+              buff += ldoc;
+              strncpy(buff, "swig_ptr: ", 10);
+              buff += 10;
+              SWIG_PackVoidPtr(buff, ptr, ty->name, lptr);
+              methods[i].ml_doc = ndoc;
+            }
+          }
+        }
+      }
+    }
+  } 
+  
+#ifdef __cplusplus
+}
+#endif
+
+/* -----------------------------------------------------------------------------*
+ *  Partial Init method
+ * -----------------------------------------------------------------------------*/
+
+#ifdef __cplusplus
+extern "C"
+#endif
+SWIGEXPORT void SWIG_init(void) {
+  PyObject *m, *d;
+  
+  /* Fix SwigMethods to carry the callback ptrs when needed */
+  SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial);
+  
+  m = Py_InitModule((char *) SWIG_name, SwigMethods);
+  d = PyModule_GetDict(m);
+  
+  SWIG_InitializeModule(0);
+  SWIG_InstallConstants(d,swig_const_table);
+  
+  
+}
+

+ 5 - 0
desktop/core/ext-py/sasl-0.1.1/setup.cfg

@@ -0,0 +1,5 @@
+[egg_info]
+tag_build = 
+tag_date = 0
+tag_svn_revision = 0
+

+ 25 - 0
desktop/core/ext-py/sasl-0.1.1/setup.py

@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+
+"""
+setup.py file for SWIG example
+"""
+
+from setuptools import setup, Extension
+
+sasl_module = Extension('_saslwrapper',
+                           sources=['sasl/saslwrapper.cpp', "sasl/saslwrapper_wrap.cxx"],
+                           include_dirs=["sasl"],
+                           libraries=["sasl2"],
+                           language="c++",
+                           )
+dist = setup (name = 'sasl',
+       version = '0.1.1',
+       url = "http://github.com/toddlipcon/python-sasl/tree/master",
+       maintainer = "Todd Lipcon",
+       maintainer_email = "todd@cloudera.com",
+       description = """Cyrus-SASL bindings for Python""",
+       ext_modules = [sasl_module],
+       py_modules = ["sasl.saslwrapper"],
+       include_package_data = True,
+       )
+

+ 4 - 0
desktop/core/regenerate_thrift.sh

@@ -0,0 +1,4 @@
+#!/bin/bash
+
+cd $(dirname $0)/src/desktop/lib
+thrift -r --gen py:new_style *thrift

+ 3 - 1
desktop/core/setup.py

@@ -26,6 +26,8 @@ setup(
 
       entry_points = { 'console_scripts': [ 'supervisor = desktop.supervisor:main',
                                             'hue = desktop.manage_entry:entry', ],
-                       'desktop.supervisor.specs': [ 'runcpserver = desktop:SUPERVISOR_SPEC' ]
+                       'desktop.supervisor.specs': [ 'runcpserver = desktop:SUPERVISOR_SPEC',
+                                                     'kt_renewer = desktop.kt_renewer:SPEC',
+                                                     ]
                        },
       )

+ 53 - 0
desktop/core/src/desktop/conf.py

@@ -21,6 +21,7 @@ from desktop.lib.conf import coerce_bool, validate_path
 from desktop.lib.paths import get_desktop_root
 import os
 import socket
+import stat
 
 HTTP_HOST = Config(
   key="http_host",
@@ -172,6 +173,42 @@ DATABASE = ConfigSection(
   )
 )
 
+KERBEROS = ConfigSection(
+  key="kerberos",
+  help="""Configuration options for specifying Hue's kerberos integration for
+          secured Hadoop clusters.""",
+  members=dict(
+    HUE_KEYTAB=Config(
+      key='hue_keytab',
+      help="Path to a Kerberos keytab file containing Hue's service credentials.",
+      type=str,
+      default=None),
+    HUE_PRINCIPAL=Config(
+      key='hue_principal',
+      help="Kerberos principal name for hue. Typically 'hue/hostname.foo.com'",
+      type=str,
+      default="hue/%s" % socket.getfqdn()),
+    KEYTAB_REINIT_FREQUENCY=Config(
+      key='reinit_frequency',
+      help="Frequency in seconds with which Hue will renew its keytab",
+      type=int,
+      default=60*60), #1h
+    CCACHE_PATH=Config(
+      key='ccache_path',
+      help="Path to keep kerberos credentials cached",
+      private=True,
+      type=str,
+      default="/tmp/hue_krb5_ccache_%d" % os.geteuid(),
+    ),
+    KINIT_PATH=Config(
+      key='kinit_path',
+      help="Path to kerberos 'kinit' command",
+      type=str,
+      default="kinit", # use PATH!
+    )
+  )
+)
+
 # See python's documentation for time.tzset for valid values.
 TIME_ZONE = Config(
   key="time_zone",
@@ -276,13 +313,29 @@ def config_validator():
   if not SECRET_KEY.get():
     res.append((SECRET_KEY, "Secret key should be configured as a random string."))
 
+  # Validate SSL setup
   if SSL_CERTIFICATE.get():
     res.extend(validate_path(SSL_CERTIFICATE, is_dir=False))
     if not SSL_PRIVATE_KEY.get():
       res.append((SSL_PRIVATE_KEY, "SSL private key file should be set to enable HTTPS."))
     else:
       res.extend(validate_path(SSL_PRIVATE_KEY, is_dir=False))
+
+  # Validate encoding
   if not i18n.validate_encoding(DEFAULT_SITE_ENCODING.get()):
     res.append((DEFAULT_SITE_ENCODING, "Encoding not supported."))
 
+  # Validate kerberos
+  if KERBEROS.HUE_KEYTAB.get() is not None:
+    res.extend(validate_path(KERBEROS.HUE_KEYTAB, is_dir=False))
+    # Keytab should not be world or group accessible
+    kt_stat = os.stat(KERBEROS.HUE_KEYTAB.get())
+    if stat.S_IMODE(kt_stat.st_mode) & 0077:
+      res.append((KERBEROS.HUE_KEYTAB,
+                  "Keytab should have 0600 permissions (has %o)" %
+                  stat.S_IMODE(kt_stat.st_mode)))
+
+    res.extend(validate_path(KERBEROS.KINIT_PATH, is_dir=False))
+    res.extend(validate_path(KERBEROS.CCACHE_PATH, is_dir=False))
+
   return res

+ 49 - 0
desktop/core/src/desktop/kt_renewer.py

@@ -0,0 +1,49 @@
+#!/usr/bin/env python
+# Licensed to Cloudera, Inc. under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  Cloudera, Inc. licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import logging
+import subprocess
+import sys
+import time
+from desktop.supervisor import DjangoCommandSupervisee
+from desktop.conf import KERBEROS as CONF
+
+LOG = logging.getLogger(__name__)
+
+SPEC = DjangoCommandSupervisee("kt_renewer")
+
+def renew_from_kt():
+  cmdv = [CONF.KINIT_PATH.get(),
+          "-k", # host ticket
+          "-t", CONF.HUE_KEYTAB.get(), # specify keytab
+          "-c", CONF.CCACHE_PATH.get(), # specify credentials cache
+          CONF.HUE_PRINCIPAL.get()]
+  LOG.info("Reinitting kerberos from keytab: " +
+           " ".join(cmdv))
+  ret = subprocess.call(cmdv)
+  if ret != 0:
+    LOG.error("Couldn't reinit from keytab!")
+    sys.exit(ret)
+
+def run():
+  if CONF.HUE_KEYTAB.get() is None:
+    LOG.debug("Keytab renewer not starting, no keytab configured")
+    sys.exit(0)
+
+  while True:
+    renew_from_kt()
+    time.sleep(CONF.KEYTAB_REINIT_FREQUENCY.get())

+ 8 - 2
desktop/core/src/desktop/lib/gen-py/djangothrift_test_gen/TestService-remote

@@ -34,20 +34,22 @@ http = False
 argi = 1
 
 if sys.argv[argi] == '-h':
-  parts = sys.argv[argi+1].split(':') 
+  parts = sys.argv[argi+1].split(':')
   host = parts[0]
   port = int(parts[1])
   argi += 2
 
 if sys.argv[argi] == '-u':
   url = urlparse(sys.argv[argi+1])
-  parts = url[1].split(':') 
+  parts = url[1].split(':')
   host = parts[0]
   if len(parts) > 1:
     port = int(parts[1])
   else:
     port = 80
   uri = url[2]
+  if url[4]:
+    uri += '?%s' % url[4]
   http = True
   argi += 2
 
@@ -76,4 +78,8 @@ if cmd == 'ping':
     sys.exit(1)
   pp.pprint(client.ping(eval(args[0]),))
 
+else:
+  print 'Unrecognized method %s' % cmd
+  sys.exit(1)
+
 transport.close()

+ 7 - 3
desktop/core/src/desktop/lib/gen-py/djangothrift_test_gen/TestService.py

@@ -8,7 +8,7 @@ from thrift.Thrift import *
 from ttypes import *
 from thrift.Thrift import TProcessor
 from thrift.transport import TTransport
-from thrift.protocol import TBinaryProtocol
+from thrift.protocol import TBinaryProtocol, TProtocol
 try:
   from thrift.protocol import fastbinary
 except:
@@ -141,6 +141,9 @@ class ping_args(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -196,6 +199,9 @@ class ping_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -207,5 +213,3 @@ class ping_result(object):
 
   def __ne__(self, other):
     return not (self == other)
-
-

+ 11 - 2
desktop/core/src/desktop/lib/gen-py/djangothrift_test_gen/ttypes.py

@@ -7,7 +7,7 @@
 from thrift.Thrift import *
 
 from thrift.transport import TTransport
-from thrift.protocol import TBinaryProtocol
+from thrift.protocol import TBinaryProtocol, TProtocol
 try:
   from thrift.protocol import fastbinary
 except:
@@ -31,6 +31,7 @@ class TestEnum(object):
     "ENUM_THREE": 2,
   }
 
+
 class TestStruct(object):
   """
   Attributes:
@@ -87,6 +88,9 @@ class TestStruct(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -156,6 +160,9 @@ class TestNesting(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -417,6 +424,9 @@ class TestManyTypes(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -428,4 +438,3 @@ class TestManyTypes(object):
 
   def __ne__(self, other):
     return not (self == other)
-

+ 156 - 0
desktop/core/src/desktop/lib/thrift_sasl.py

@@ -0,0 +1,156 @@
+#!/usr/bin/env python
+
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+""" SASL transports for Thrift. """
+
+import sys
+
+from cStringIO import StringIO
+from thrift.transport import TTransport
+from thrift.transport.TTransport import *
+from thrift.protocol import TBinaryProtocol
+import sasl
+import struct
+
+class TSaslClientTransport(TTransportBase, CReadableTransport):
+  START = 1
+  OK = 2
+  BAD = 3
+  ERROR = 4
+  COMPLETE = 5
+
+  def __init__(self, sasl_client_factory, mechanism, trans):
+    """
+    @param sasl_client_factory: a callable that returns a new sasl.Client object
+    @param mechanism: the SASL mechanism (e.g. "GSSAPI")
+    @param trans: the underlying transport over which to communicate.
+    """
+    self._trans = trans
+    self.sasl_client_factory = sasl_client_factory
+    self.sasl = None
+    self.mechanism = mechanism
+    self.__wbuf = StringIO()
+    self.__rbuf = StringIO()
+    self.opened = False
+
+  def isOpen(self):
+    return self._trans.isOpen()
+
+  def open(self):
+    if not self._trans.isOpen():
+      self._trans.open()
+
+    if self.sasl is not None:
+      raise TTransportException(
+        type=TTransportException.NOT_OPEN,
+        message="Already open!")
+    self.sasl = self.sasl_client_factory()
+
+    ret, chosen_mech, initial_response = self.sasl.start(self.mechanism)
+    if not ret:
+      raise TTransportException(type=TTransportException.NOT_OPEN,
+        message=("Could not start SASL: %s" % self.sasl.getError()))
+
+    # Send initial response
+    self._send_message(self.START, chosen_mech)
+    self._send_message(self.OK, initial_response)
+
+    # SASL negotiation loop
+    while True:
+      status, payload = self._recv_sasl_message()
+      if status not in (self.OK, self.COMPLETE):
+        raise TTransportException(type=TTransportException.NOT_OPEN,
+          message=("Bad status: %d (%s)" % (status, payload)))
+      if status == self.COMPLETE:
+        break
+      ret, response = self.sasl.step(payload)
+      if not ret:
+        raise TTransportException(type=TTransportException.NOT_OPEN,
+          message=("Bad SASL result: %s" % (self.sasl.getError())))
+      self._send_message(self.OK, response)
+
+  def _send_message(self, status, body):
+    header = struct.pack(">BI", status, len(body))
+    self._trans.write(header + body)
+    self._trans.flush()
+
+  def _recv_sasl_message(self):
+    header = self._trans.readAll(5)
+    status, length = struct.unpack(">BI", header)
+    if length > 0:
+      payload = self._trans.readAll(length)
+    else:
+      payload = ""
+    return status, payload
+
+  def write(self, data):
+    self.__wbuf.write(data)
+
+  def flush(self):
+    success, encoded = self.sasl.encode(self.__wbuf.getvalue())
+    if not success:
+      raise TTransportException(type=TTransportException.UNKNOWN,
+                                message=self.sasl.getError())
+    # Note stolen from TFramedTransport:
+    # N.B.: Doing this string concatenation is WAY cheaper than making
+    # two separate calls to the underlying socket object. Socket writes in
+    # Python turn out to be REALLY expensive, but it seems to do a pretty
+    # good job of managing string buffer operations without excessive copies
+    self._trans.write(struct.pack(">I", len(encoded)) + encoded)
+    self._trans.flush()
+    self.__wbuf = StringIO()
+
+  def read(self, sz):
+    ret = self.__rbuf.read(sz)
+    if len(ret) != 0:
+      return ret
+
+    self._read_frame()
+    return self.__rbuf.read(sz)
+
+  def _read_frame(self):
+    header = self._trans.readAll(4)
+    (length,) = struct.unpack(">I", header)
+    encoded = self._trans.readAll(length)
+    success, decoded = self.sasl.decode(encoded)
+    if not success:
+      raise TTransportException(type=TTransportException.UNKNOWN,
+                                message=self.sasl.getError())
+    self.__rbuf = StringIO(decoded)
+
+  def close(self):
+    self._trans.close()
+    self.sasl = None
+
+  # Implement the CReadableTransport interface.
+  # Stolen shamelessly from TFramedTransport
+  @property
+  def cstringio_buf(self):
+    return self.__rbuf
+
+  def cstringio_refill(self, prefix, reqlen):
+    # self.__rbuf will already be empty here because fastbinary doesn't
+    # ask for a refill until the previous buffer is empty.  Therefore,
+    # we can start reading new frames immediately.
+    while len(prefix) < reqlen:
+      self._read_frame()
+      prefix += self.__rbuf.getvalue()
+    self.__rbuf = StringIO(prefix)
+    return self.__rbuf

+ 90 - 33
desktop/core/src/desktop/lib/thrift_util.py

@@ -20,6 +20,7 @@
 import socket
 import logging
 import Queue
+import sasl
 import select
 import sys
 import threading
@@ -30,6 +31,7 @@ from thrift.transport.TSocket import TSocket
 from thrift.transport.TTransport import TBufferedTransport, TMemoryBuffer,\
                                         TTransportException
 from thrift.protocol.TBinaryProtocol import TBinaryProtocol
+from desktop.lib.thrift_sasl import TSaslClientTransport
 
 # The maximum depth that we will recurse through a "jsonable" structure
 # while converting to thrift. This prevents us from infinite recursion
@@ -41,6 +43,32 @@ MAX_RECURSION_DEPTH = 50
 WARN_LEVEL_CALL_DURATION_MS = 5000
 INFO_LEVEL_CALL_DURATION_MS = 1000
 
+class ConnectionConfig(object):
+  """ Struct-like class encapsulating the configuration of a Thrift client. """
+  def __init__(self, klass, host, port, service_name,
+               use_sasl=False,
+               kerberos_principal="thrift",
+               timeout_seconds=45):
+    """
+    @param klass The thrift client class
+    @param host Host to connect to
+    @param port Port to connect to
+    @param service_name A human-readable name to describe the service
+    @param use_sasl If true, will use Kerberos over SASL to authenticate
+    @param kerberos_principal The Kerberos service name to connect to.
+              NOTE: for a service like fooservice/foo.blah.com@REALM only
+              specify "fooservice", NOT the full principal name.
+    @param timeout_seconds Timeout for thrift calls
+    """
+    self.klass = klass
+    self.host = host
+    self.port = port
+    self.service_name = service_name
+    self.use_sasl = use_sasl
+    self.kerberos_principal = kerberos_principal
+    self.timeout_seconds = timeout_seconds
+
+
 class ConnectionPooler(object):
   """
   Thread-safe connection pooling for thrift. (With about 3 changes,
@@ -63,7 +91,7 @@ class ConnectionPooler(object):
     self.poolsize = poolsize
     self.dictlock = threading.Lock()
 
-  def get_client(self, klass, host, port, service_name="Unknown",
+  def get_client(self, conf,
                  get_client_timeout=None):
     """
     Could block while we wait for the pool to become non-empty.
@@ -71,9 +99,8 @@ class ConnectionPooler(object):
     @param get_client_timeout: how long (in seconds) to wait on the pool
                                to get a client before failing
     """
-
     # First up, check to see if we have a pool for this endpoint
-    if (host,port) not in self.pooldict:
+    if (conf.host, conf.port) not in self.pooldict:
       # Uh-oh, we need to initialise the queue. Take the dict lock.
       # Note that this is 'double-checked locking'.
 
@@ -89,11 +116,11 @@ class ConnectionPooler(object):
 
       self.dictlock.acquire()
       try:
-        if (host, port) not in self.pooldict:
+        if (conf.host, conf.port) not in self.pooldict:
           q = Queue.Queue(self.poolsize)
-          self.pooldict[(host, port)] = q
+          self.pooldict[(conf.host, conf.port)] = q
           for i in xrange(self.poolsize):
-            client = construct_client(klass, host, port, service_name)
+            client = construct_superclient(conf)
             client.CID = i
             q.put(client, False)
       finally:
@@ -110,16 +137,16 @@ class ConnectionPooler(object):
         this_round_timeout = None
 
       try:
-        connection = self.pooldict[(host, port)].get(
+        connection = self.pooldict[(conf.host, conf.port)].get(
           block=True, timeout=this_round_timeout)
       except Queue.Empty:
         has_waited_for = time.time() - start_pool_get_time
         if get_client_timeout is not None and has_waited_for > get_client_timeout:
           raise socket.timeout(
             ("Timed out after %.2f seconds waiting to retrieve a " +
-             "%s client from the pool.") % (has_waited_for, service_name))
+             "%s client from the pool.") % (has_waited_for, conf.service_name))
         logging.warn("Waited %d seconds for a thrift client to %s:%d" %
-          (has_waited_for, host, port))
+          (has_waited_for, conf.host, conf.port))
 
     return connection
 
@@ -131,43 +158,73 @@ class ConnectionPooler(object):
     """
     self.pooldict[(host, port)].put(client)
 
-def construct_client(klass, host, port, service_name, timeout_seconds=45):
+def construct_superclient(conf):
   """
   Constructs a thrift client, lazily.
   """
-  sock = TSocket(host, port)
-  if timeout_seconds:
+  service, protocol, transport = connect_to_thrift(conf)
+  return SuperClient(service, transport, timeout_seconds=conf.timeout_seconds)
+
+
+def connect_to_thrift(conf):
+  """
+  Connect to a thrift endpoint as determined by the 'conf' parameter.
+  Note that this does *not* open the transport.
+
+  Returns a tuple of (service, protocol, transport)
+  """
+  sock = TSocket(conf.host, conf.port)
+  if conf.timeout_seconds:
     # Thrift trivia: You can do this after the fact with
-    # self.wrapped.transport._TBufferedTransport__trans.setTimeout(seconds*1000)
-    sock.setTimeout(timeout_seconds*1000.0)
-  transport = TBufferedTransport(sock)
+    # _grab_transport_from_wrapper(self.wrapped.transport).setTimeout(seconds*1000)
+    sock.setTimeout(conf.timeout_seconds*1000.0)
+  if conf.use_sasl:
+    def sasl_factory():
+      saslc = sasl.Client()
+      saslc.setAttr("host", conf.host)
+      saslc.setAttr("service", conf.kerberos_principal)
+      saslc.init()
+      return saslc
+
+    transport = TSaslClientTransport(sasl_factory, "GSSAPI", sock)
+  else:
+    transport = TBufferedTransport(sock)
+
   protocol = TBinaryProtocol(transport)
-  service = klass(protocol)
-  return SuperClient(service, transport, timeout_seconds=timeout_seconds)
+  service = conf.klass(protocol)
+  return service, protocol, transport
+
 
 _connection_pool = ConnectionPooler()
 
-def get_client(klass, host, port, service_name, timeout_seconds=None):
-  return PooledClient(klass,host,port,service_name,timeout_seconds)
+def get_client(klass, host, port, service_name,
+               **kwargs):
+  conf = ConnectionConfig(
+    klass, host, port, service_name,
+    **kwargs)
+  return PooledClient(conf)
+
+def _grab_transport_from_wrapper(outer_transport):
+  if isinstance(outer_transport, TBufferedTransport):
+    return outer_transport._TBufferedTransport__trans
+  elif isinstance(outer_transport, TSaslClientTransport):
+    return outer_transport._trans
+  else:
+    raise Exception("Unknown transport type: " + outer_transport.__class__)
 
 class PooledClient(object):
   """
   A wrapper for a SuperClient
   """
-  def __init__(self, klass, host, port, service_name = "Unknown", timeout_seconds=None):
-    self.klass = klass
-    self.host = host
-    self.port = port
-    self.timeout_seconds = timeout_seconds
-    self.service_name = service_name
+  def __init__(self, conf):
+    self.conf = conf
 
   def __getattr__(self,attr):
     if attr in self.__dict__:
       return self.__dict__[attr]
 
     # Fetch the thrift client from the pool
-    superclient = _connection_pool.get_client(self.klass, self.host, self.port,
-                                              get_client_timeout=self.timeout_seconds)
+    superclient = _connection_pool.get_client(self.conf)
 
     res = getattr(superclient, attr)
     if hasattr(res,"__call__"):
@@ -176,7 +233,7 @@ class PooledClient(object):
           try:
             # Poke it to see if it's closed on the other end. This can happen if a connection
             # sits in the connection pool longer than the read timeout of the server.
-            sock = superclient.transport._TBufferedTransport__trans.handle
+            sock = _grab_transport_from_wrapper(superclient.transport).handle
             if sock:
               rlist,wlist,xlist = select.select([sock], [], [], 0)
               if rlist:
@@ -186,18 +243,18 @@ class PooledClient(object):
                 superclient.transport.close()
                 superclient.transport.open()
 
-            superclient.set_timeout(self.timeout_seconds)
+            superclient.set_timeout(self.conf.timeout_seconds)
             ret = res(*args, **kwargs)
             return ret
           except Exception, e:
             # Stack tends to be only noisy here.
             logging.info("Thrift saw exception: " + str(e), exc_info=False)
             msg = "Exception communicating with %s at %s:%d: %s" % (
-              self.service_name, self.host, self.port, str(e))
+              self.conf.service_name, self.conf.host, self.conf.port, str(e))
             e.response_data = dict(code="THRIFT_EXCEPTION", message=msg, data="")
             raise
         finally:
-          _connection_pool.return_client(self.host,self.port,superclient)
+          _connection_pool.return_client(self.conf.host,self.conf.port,superclient)
       return wrapper
     return res
 
@@ -277,9 +334,9 @@ class SuperClient(object):
       self.timeout_seconds = timeout_seconds
       # ugh, None is a valid timeout
       if self.timeout_seconds is not None:
-        self.transport._TBufferedTransport__trans.setTimeout(self.timeout_seconds * 1000)
+        _grab_transport_from_wrapper(self.transport).setTimeout(self.timeout_seconds * 1000)
       else:
-        self.transport._TBufferedTransport__trans.setTimeout(None)
+        _grab_transport_from_wrapper(self.transport).setTimeout(None)
 
 def simpler_string(thrift_obj):
   """

+ 8 - 10
apps/beeswax/thrift/gen.sh → desktop/core/src/desktop/management/commands/kt_renewer.py

@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/usr/bin/env python
 # Licensed to Cloudera, Inc. under one
 # or more contributor license agreements.  See the NOTICE file
 # distributed with this work for additional information
@@ -15,13 +15,11 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-set -o errexit
-set -o xtrace
+from django.core.management.base import NoArgsCommand
+import desktop.kt_renewer
 
-cd $(dirname $0)
-
-thrift -I include -r --gen py:new_style -o ../ beeswax.thrift
-thrift -I include -r --gen java:hashcode -o ../java beeswax.thrift
-
-# This is based on thirdparty.
-# thrift -r --gen py:new_style -o ../ ../../../../ext/thirdparty/py/thrift/contrib/fb303/if/fb303.thrift
+class Command(NoArgsCommand):
+  """ Starts a daemon which renews Kerberos credentials from a keytab
+  periodically. """
+  def handle_noargs(self, **options):
+    desktop.kt_renewer.run()

+ 2 - 2
desktop/core/src/desktop/middleware.py

@@ -135,12 +135,12 @@ class ClusterMiddleware(object):
         raise
 
     if request.user.is_authenticated() and request.fs is not None:
-      request.fs.setuser(request.user.username, request.user.get_groups())
+      request.fs.setuser(request.user.username)
 
     if request.user.is_authenticated() and has_hadoop:
       request.jt = cluster.get_mrcluster()
       if request.jt is not None:
-        request.jt.setuser(request.user.username, request.user.get_groups())
+        request.jt.setuser(request.user.username)
     else:
       request.jt = None
 

+ 4 - 0
desktop/core/src/desktop/settings.py

@@ -251,3 +251,7 @@ DEPENDER_DEBUG = os.getenv("DESKTOP_DEPENDER_DEBUG", "0") not in ["0",""]
 
 # Necessary for South to not futz with tests.  Fixed in South 0.7.1
 SKIP_SOUTH_TESTS = True
+
+# Set up environment variable so Kerberos libraries look at our private
+# ticket cache
+os.environ['KRB5CCNAME'] = desktop.conf.KERBEROS.CCACHE_PATH.get()

+ 18 - 2
desktop/libs/hadoop/Makefile

@@ -45,10 +45,16 @@ PLUGIN_JAVA_DIR := $(PLUGIN_DIR)/java
 PLUGIN := $(PLUGIN_JAVA_LIB)/hue-plugins-$(DESKTOP_VERSION).jar
 BLD_DIR_PLUGINS := $(PLUGIN_DIR)/build/java
 
-compile: $(PLUGIN)
+STATIC_GROUP_MAPPING_DIR := $(realpath .)/static-group-mapping
+STATIC_GROUP_MAPPING_SRC := $(STATIC_GROUP_MAPPING_DIR)/src
+STATIC_GROUP_MAPPING_BUILD := $(STATIC_GROUP_MAPPING_DIR)/build
+STATIC_GROUP_MAPPING_LIB := $(STATIC_GROUP_MAPPING_DIR)/java-lib
+STATIC_GROUP_MAPPING := $(STATIC_GROUP_MAPPING_LIB)/static-group-mapping-$(DESKTOP_VERSION).jar
+
+compile: $(PLUGIN) $(STATIC_GROUP_MAPPING)
 
 clean::
-	rm -Rf $(PLUGIN_JAVA_LIB)
+	rm -Rf $(PLUGIN_JAVA_LIB) $(STATIC_GROUP_MAPPING_LIB)
 
 ifneq (,$(wildcard $(PLUGIN_JAVA_DIR)))
 PLUGIN_OPTS := -Dbuild.dir=$(BLD_DIR_PLUGINS) \
@@ -65,6 +71,16 @@ $(PLUGIN):
 	$(error Cannot build hadoop plugin without source)
 endif
 
+STATIC_GROUP_MAPPING_OPTS := -Dbuild.dir=$(STATIC_GROUP_MAPPING_BUILD) \
+         -Dhadoop.home=$(HADOOP_HOME) \
+         -Dstatic-group-mapping.version=$(DESKTOP_VERSION)
+
+$(STATIC_GROUP_MAPPING): $(shell find $(STATIC_GROUP_MAPPING_SRC))
+	mkdir -p $(STATIC_GROUP_MAPPING_LIB)
+	@echo "--- Building static UserGroupMappingService"
+	cd $(STATIC_GROUP_MAPPING_DIR) && ant $(ANT_OPTS) $(STATIC_GROUP_MAPPING_OPTS) jar
+	cp $(STATIC_GROUP_MAPPING_BUILD)/$(notdir $(STATIC_GROUP_MAPPING)) $(STATIC_GROUP_MAPPING)
+
 #
 # Tell the `bdist' target to exclude our java source.
 #

+ 8 - 2
desktop/libs/hadoop/gen-py/hadoop/api/common/HadoopServiceBase-remote

@@ -38,20 +38,22 @@ http = False
 argi = 1
 
 if sys.argv[argi] == '-h':
-  parts = sys.argv[argi+1].split(':') 
+  parts = sys.argv[argi+1].split(':')
   host = parts[0]
   port = int(parts[1])
   argi += 2
 
 if sys.argv[argi] == '-u':
   url = urlparse(sys.argv[argi+1])
-  parts = url[1].split(':') 
+  parts = url[1].split(':')
   host = parts[0]
   if len(parts) > 1:
     port = int(parts[1])
   else:
     port = 80
   uri = url[2]
+  if url[4]:
+    uri += '?%s' % url[4]
   http = True
   argi += 2
 
@@ -104,4 +106,8 @@ elif cmd == 'getMetricsContext':
     sys.exit(1)
   pp.pprint(client.getMetricsContext(eval(args[0]),args[1],))
 
+else:
+  print 'Unrecognized method %s' % cmd
+  sys.exit(1)
+
 transport.close()

+ 33 - 5
desktop/libs/hadoop/gen-py/hadoop/api/common/HadoopServiceBase.py

@@ -8,7 +8,7 @@ from thrift.Thrift import *
 from ttypes import *
 from thrift.Thrift import TProcessor
 from thrift.transport import TTransport
-from thrift.protocol import TBinaryProtocol
+from thrift.protocol import TBinaryProtocol, TProtocol
 try:
   from thrift.protocol import fastbinary
 except:
@@ -19,7 +19,7 @@ class Iface(object):
   def getVersionInfo(self, ctx):
     """
     Return the version information for this server
-    
+
     Parameters:
      - ctx
     """
@@ -65,7 +65,7 @@ class Client(Iface):
   def getVersionInfo(self, ctx):
     """
     Return the version information for this server
-    
+
     Parameters:
      - ctx
     """
@@ -364,6 +364,9 @@ class getVersionInfo_args(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -420,6 +423,9 @@ class getVersionInfo_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -486,6 +492,9 @@ class getRuntimeInfo_args(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -542,6 +551,9 @@ class getRuntimeInfo_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -608,6 +620,9 @@ class getThreadDump_args(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -672,6 +687,9 @@ class getThreadDump_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -738,6 +756,9 @@ class getAllMetrics_args(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -815,6 +836,9 @@ class getAllMetrics_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -892,6 +916,9 @@ class getMetricsContext_args(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -961,6 +988,9 @@ class getMetricsContext_result(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -972,5 +1002,3 @@ class getMetricsContext_result(object):
 
   def __ne__(self, other):
     return not (self == other)
-
-

+ 90 - 7
desktop/libs/hadoop/gen-py/hadoop/api/common/ttypes.py

@@ -7,17 +7,18 @@
 from thrift.Thrift import *
 
 from thrift.transport import TTransport
-from thrift.protocol import TBinaryProtocol
+from thrift.protocol import TBinaryProtocol, TProtocol
 try:
   from thrift.protocol import fastbinary
 except:
   fastbinary = None
 
 
+
 class IOException(Exception):
   """
   Generic I/O error
-  
+
   Attributes:
    - msg: Error message.
    - stack: Textual representation of the call stack.
@@ -84,6 +85,9 @@ class IOException(Exception):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __str__(self):
     return repr(self)
@@ -102,7 +106,7 @@ class IOException(Exception):
 class VersionInfo(object):
   """
   Information about the compilation version of this server
-  
+
   Attributes:
    - version
    - revision
@@ -206,6 +210,9 @@ class VersionInfo(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -221,7 +228,7 @@ class VersionInfo(object):
 class StackTraceElement(object):
   """
   A single stack frame in a stack dump
-  
+
   Attributes:
    - className
    - fileName
@@ -324,6 +331,9 @@ class StackTraceElement(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -339,7 +349,7 @@ class StackTraceElement(object):
 class ThreadStackTrace(object):
   """
   Info about a thread with its corresponding stack trace
-  
+
   Attributes:
    - threadName
    - threadStringRepresentation
@@ -427,6 +437,9 @@ class ThreadStackTrace(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -442,7 +455,7 @@ class ThreadStackTrace(object):
 class RuntimeInfo(object):
   """
   Memory available via java.lang.Runtime
-  
+
   Attributes:
    - totalMemory
    - freeMemory
@@ -509,6 +522,9 @@ class RuntimeInfo(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -524,7 +540,7 @@ class RuntimeInfo(object):
 class RequestContext(object):
   """
   Context options for every request.
-  
+
   Attributes:
    - confOptions: This map turns into a Configuration object in the server and
   is currently used to construct a UserGroupInformation to
@@ -579,6 +595,9 @@ class RequestContext(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -668,6 +687,9 @@ class MetricsRecord(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -779,6 +801,9 @@ class MetricsContext(object):
       oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
+    def validate(self):
+      return
+
 
   def __repr__(self):
     L = ['%s=%r' % (key, value)
@@ -791,3 +816,61 @@ class MetricsContext(object):
   def __ne__(self, other):
     return not (self == other)
 
+class ThriftDelegationToken(object):
+  """
+  Attributes:
+   - delegationTokenBytes
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'delegationTokenBytes', None, None, ), # 1
+  )
+
+  def __init__(self, delegationTokenBytes=None,):
+    self.delegationTokenBytes = delegationTokenBytes
+
+  def read(self, iprot):
+    if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
+      fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
+      return
+    iprot.readStructBegin()
+    while True:
+      (fname, ftype, fid) = iprot.readFieldBegin()
+      if ftype == TType.STOP:
+        break
+      if fid == 1:
+        if ftype == TType.STRING:
+          self.delegationTokenBytes = iprot.readString();
+        else:
+          iprot.skip(ftype)
+      else:
+        iprot.skip(ftype)
+      iprot.readFieldEnd()
+    iprot.readStructEnd()
+
+  def write(self, oprot):
+    if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
+      oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
+      return
+    oprot.writeStructBegin('ThriftDelegationToken')
+    if self.delegationTokenBytes != None:
+      oprot.writeFieldBegin('delegationTokenBytes', TType.STRING, 1)
+      oprot.writeString(self.delegationTokenBytes)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+    def validate(self):
+      return
+
+
+  def __repr__(self):
+    L = ['%s=%r' % (key, value)
+      for key, value in self.__dict__.iteritems()]
+    return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
+
+  def __eq__(self, other):
+    return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
+
+  def __ne__(self, other):
+    return not (self == other)

部分文件因为文件数量过多而无法显示