Explorar o código

Make Hue job submission work even if it's talking to a secure cluster.

Aaron T. Myers %!s(int64=15) %!d(string=hai) anos
pai
achega
94352d8c05
Modificáronse 21 ficheiros con 1207 adicións e 437 borrados
  1. 9 0
      apps/jobsub/src/jobsub/java/src/org/apache/hadoop/security/JobClientTrace.aj
  2. 2 4
      apps/jobsub/src/jobsub/java/src/org/apache/hadoop/security/UgiFixer.aj
  3. 21 1
      apps/jobsub/src/jobsub/server.py
  4. 56 0
      desktop/libs/hadoop/gen-py/hadoop/api/common/ttypes.py
  5. 1 1
      desktop/libs/hadoop/gen-py/hadoop/api/hdfs/Namenode-remote
  6. 6 2
      desktop/libs/hadoop/gen-py/hadoop/api/hdfs/Namenode.py
  7. 0 56
      desktop/libs/hadoop/gen-py/hadoop/api/hdfs/ttypes.py
  8. 7 0
      desktop/libs/hadoop/gen-py/hadoop/api/jobtracker/Jobtracker-remote
  9. 207 0
      desktop/libs/hadoop/gen-py/hadoop/api/jobtracker/Jobtracker.py
  10. 17 11
      desktop/libs/hadoop/java/gen-java/org/apache/hadoop/thriftfs/api/Namenode.java
  11. 0 314
      desktop/libs/hadoop/java/gen-java/org/apache/hadoop/thriftfs/api/ThriftHdfsDelegationToken.java
  12. 782 0
      desktop/libs/hadoop/java/gen-java/org/apache/hadoop/thriftfs/jobtracker/api/Jobtracker.java
  13. 4 0
      desktop/libs/hadoop/java/if/common.thrift
  14. 4 5
      desktop/libs/hadoop/java/if/hdfs.thrift
  15. 25 22
      desktop/libs/hadoop/java/if/jobtracker.thrift
  16. 25 0
      desktop/libs/hadoop/java/src/java/org/apache/hadoop/mapred/ThriftJobTrackerPlugin.java
  17. 5 18
      desktop/libs/hadoop/java/src/java/org/apache/hadoop/thriftfs/NamenodePlugin.java
  18. 26 0
      desktop/libs/hadoop/java/src/java/org/apache/hadoop/thriftfs/ThriftUtils.java
  19. 2 1
      desktop/libs/hadoop/src/hadoop/cluster.py
  20. 1 1
      desktop/libs/hadoop/src/hadoop/fs/hadoopfs.py
  21. 7 1
      desktop/libs/hadoop/src/hadoop/job_tracker.py

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

@@ -15,7 +15,9 @@
 // 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;
 
@@ -32,4 +34,11 @@ public aspect JobClientTrace {
     JobClientTracer.getInstance().submittedJob(ret);
     return ret;
   }
+
+  void around(Configuration conf, Credentials credentials):
+    call(void JobClient.readTokensFromFiles(Configuration, Credentials)) && args(conf, credentials) {
+    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 - 4
apps/jobsub/src/jobsub/java/src/org/apache/hadoop/security/UgiFixer.aj

@@ -90,10 +90,8 @@ public aspect UgiFixer {
   AppConfigurationEntry[] around(String appName):
     getAppConfigurationEntry(appName) {
       if (!appName.equals("hadoop-simple")) {
-        LOG.warn("getAppConfigurationEntry() called for auth method other than simple: " + appName);
-        return proceed(appName);
-      } else {
-        return JOBSUB_CONF;
+        LOG.warn("getAppConfigurationEntry() called for auth method other than simple, returning JOBSUB_CONF anyway: " + appName);
       }
+      return JOBSUB_CONF;
     }
 }

+ 21 - 1
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__)
@@ -231,7 +232,24 @@ class PlanRunner(object):
       '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

+ 56 - 0
desktop/libs/hadoop/gen-py/hadoop/api/common/ttypes.py

@@ -791,3 +791,59 @@ 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 __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)
+

+ 1 - 1
desktop/libs/hadoop/gen-py/hadoop/api/hdfs/Namenode-remote

@@ -43,7 +43,7 @@ if len(sys.argv) <= 1 or sys.argv[1] == '--help':
   print '  void utime(RequestContext ctx, string path, i64 atime, i64 mtime)'
   print '  void datanodeUp(string name, string storage, i32 thriftPort)'
   print '  void datanodeDown(string name, string storage, i32 thriftPort)'
-  print '  ThriftHdfsDelegationToken getDelegationToken(RequestContext ctx, string renewer)'
+  print '  ThriftDelegationToken getDelegationToken(RequestContext ctx, string renewer)'
   print ''
   sys.exit(0)
 

+ 6 - 2
desktop/libs/hadoop/gen-py/hadoop/api/hdfs/Namenode.py

@@ -302,6 +302,8 @@ class Iface(hadoop.api.common.HadoopServiceBase.Iface):
 
   def getDelegationToken(self, ctx, renewer):
     """
+    Get an HDFS delegation token.
+    
     Parameters:
      - ctx
      - renewer
@@ -1154,6 +1156,8 @@ class Client(hadoop.api.common.HadoopServiceBase.Client, Iface):
 
   def getDelegationToken(self, ctx, renewer):
     """
+    Get an HDFS delegation token.
+    
     Parameters:
      - ctx
      - renewer
@@ -4808,7 +4812,7 @@ class getDelegationToken_result(object):
   """
 
   thrift_spec = (
-    (0, TType.STRUCT, 'success', (ThriftHdfsDelegationToken, ThriftHdfsDelegationToken.thrift_spec), None, ), # 0
+    (0, TType.STRUCT, 'success', (hadoop.api.common.ttypes.ThriftDelegationToken, hadoop.api.common.ttypes.ThriftDelegationToken.thrift_spec), None, ), # 0
     (1, TType.STRUCT, 'err', (hadoop.api.common.ttypes.IOException, hadoop.api.common.ttypes.IOException.thrift_spec), None, ), # 1
   )
 
@@ -4827,7 +4831,7 @@ class getDelegationToken_result(object):
         break
       if fid == 0:
         if ftype == TType.STRUCT:
-          self.success = ThriftHdfsDelegationToken()
+          self.success = hadoop.api.common.ttypes.ThriftDelegationToken()
           self.success.read(iprot)
         else:
           iprot.skip(ftype)

+ 0 - 56
desktop/libs/hadoop/gen-py/hadoop/api/hdfs/ttypes.py

@@ -903,62 +903,6 @@ class DFSHealthReport(object):
   def __ne__(self, other):
     return not (self == other)
 
-class ThriftHdfsDelegationToken(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('ThriftHdfsDelegationToken')
-    if self.delegationTokenBytes != None:
-      oprot.writeFieldBegin('delegationTokenBytes', TType.STRING, 1)
-      oprot.writeString(self.delegationTokenBytes)
-      oprot.writeFieldEnd()
-    oprot.writeFieldStop()
-    oprot.writeStructEnd()
-
-  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)
-
 class QuotaException(Exception):
   """
   Quota-related error

+ 7 - 0
desktop/libs/hadoop/gen-py/hadoop/api/jobtracker/Jobtracker-remote

@@ -44,6 +44,7 @@ if len(sys.argv) <= 1 or sys.argv[1] == '--help':
   print '  void killJob(RequestContext ctx, ThriftJobID jobID)'
   print '  void killTaskAttempt(RequestContext ctx, ThriftTaskAttemptID attemptID)'
   print '  void setJobPriority(RequestContext ctx, ThriftJobID jobID, ThriftJobPriority priority)'
+  print '  ThriftDelegationToken getDelegationToken(RequestContext ctx, string renewer)'
   print ''
   sys.exit(0)
 
@@ -230,4 +231,10 @@ elif cmd == 'setJobPriority':
     sys.exit(1)
   pp.pprint(client.setJobPriority(eval(args[0]),eval(args[1]),eval(args[2]),))
 
+elif cmd == 'getDelegationToken':
+  if len(args) != 2:
+    print 'getDelegationToken requires 2 args'
+    sys.exit(1)
+  pp.pprint(client.getDelegationToken(eval(args[0]),args[1],))
+
 transport.close()

+ 207 - 0
desktop/libs/hadoop/gen-py/hadoop/api/jobtracker/Jobtracker.py

@@ -246,6 +246,16 @@ class Iface(hadoop.api.common.HadoopServiceBase.Iface):
     """
     pass
 
+  def getDelegationToken(self, ctx, renewer):
+    """
+    Get an MR delegation token.
+    
+    Parameters:
+     - ctx
+     - renewer
+    """
+    pass
+
 
 class Client(hadoop.api.common.HadoopServiceBase.Client, Iface):
   """
@@ -1052,6 +1062,42 @@ class Client(hadoop.api.common.HadoopServiceBase.Client, Iface):
       raise result.jne
     return
 
+  def getDelegationToken(self, ctx, renewer):
+    """
+    Get an MR delegation token.
+    
+    Parameters:
+     - ctx
+     - renewer
+    """
+    self.send_getDelegationToken(ctx, renewer)
+    return self.recv_getDelegationToken()
+
+  def send_getDelegationToken(self, ctx, renewer):
+    self._oprot.writeMessageBegin('getDelegationToken', TMessageType.CALL, self._seqid)
+    args = getDelegationToken_args()
+    args.ctx = ctx
+    args.renewer = renewer
+    args.write(self._oprot)
+    self._oprot.writeMessageEnd()
+    self._oprot.trans.flush()
+
+  def recv_getDelegationToken(self, ):
+    (fname, mtype, rseqid) = self._iprot.readMessageBegin()
+    if mtype == TMessageType.EXCEPTION:
+      x = TApplicationException()
+      x.read(self._iprot)
+      self._iprot.readMessageEnd()
+      raise x
+    result = getDelegationToken_result()
+    result.read(self._iprot)
+    self._iprot.readMessageEnd()
+    if result.success != None:
+      return result.success
+    if result.err != None:
+      raise result.err
+    raise TApplicationException(TApplicationException.MISSING_RESULT, "getDelegationToken failed: unknown result");
+
 
 class Processor(hadoop.api.common.HadoopServiceBase.Processor, Iface, TProcessor):
   def __init__(self, handler):
@@ -1079,6 +1125,7 @@ class Processor(hadoop.api.common.HadoopServiceBase.Processor, Iface, TProcessor
     self._processMap["killJob"] = Processor.process_killJob
     self._processMap["killTaskAttempt"] = Processor.process_killTaskAttempt
     self._processMap["setJobPriority"] = Processor.process_setJobPriority
+    self._processMap["getDelegationToken"] = Processor.process_getDelegationToken
 
   def process(self, iprot, oprot):
     (name, type, seqid) = iprot.readMessageBegin()
@@ -1391,6 +1438,20 @@ class Processor(hadoop.api.common.HadoopServiceBase.Processor, Iface, TProcessor
     oprot.writeMessageEnd()
     oprot.trans.flush()
 
+  def process_getDelegationToken(self, seqid, iprot, oprot):
+    args = getDelegationToken_args()
+    args.read(iprot)
+    iprot.readMessageEnd()
+    result = getDelegationToken_result()
+    try:
+      result.success = self._handler.getDelegationToken(args.ctx, args.renewer)
+    except hadoop.api.common.ttypes.IOException, err:
+      result.err = err
+    oprot.writeMessageBegin("getDelegationToken", TMessageType.REPLY, seqid)
+    result.write(oprot)
+    oprot.writeMessageEnd()
+    oprot.trans.flush()
+
 
 # HELPER FUNCTIONS AND STRUCTURES
 
@@ -4562,4 +4623,150 @@ class setJobPriority_result(object):
   def __ne__(self, other):
     return not (self == other)
 
+class getDelegationToken_args(object):
+  """
+  Attributes:
+   - ctx
+   - renewer
+  """
+
+  thrift_spec = (
+    None, # 0
+    (1, TType.STRING, 'renewer', None, None, ), # 1
+    None, # 2
+    None, # 3
+    None, # 4
+    None, # 5
+    None, # 6
+    None, # 7
+    None, # 8
+    None, # 9
+    (10, TType.STRUCT, 'ctx', (hadoop.api.common.ttypes.RequestContext, hadoop.api.common.ttypes.RequestContext.thrift_spec), None, ), # 10
+  )
+
+  def __init__(self, ctx=None, renewer=None,):
+    self.ctx = ctx
+    self.renewer = renewer
+
+  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 == 10:
+        if ftype == TType.STRUCT:
+          self.ctx = hadoop.api.common.ttypes.RequestContext()
+          self.ctx.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 1:
+        if ftype == TType.STRING:
+          self.renewer = 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('getDelegationToken_args')
+    if self.renewer != None:
+      oprot.writeFieldBegin('renewer', TType.STRING, 1)
+      oprot.writeString(self.renewer)
+      oprot.writeFieldEnd()
+    if self.ctx != None:
+      oprot.writeFieldBegin('ctx', TType.STRUCT, 10)
+      self.ctx.write(oprot)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  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)
+
+class getDelegationToken_result(object):
+  """
+  Attributes:
+   - success
+   - err
+  """
+
+  thrift_spec = (
+    (0, TType.STRUCT, 'success', (hadoop.api.common.ttypes.ThriftDelegationToken, hadoop.api.common.ttypes.ThriftDelegationToken.thrift_spec), None, ), # 0
+    (1, TType.STRUCT, 'err', (hadoop.api.common.ttypes.IOException, hadoop.api.common.ttypes.IOException.thrift_spec), None, ), # 1
+  )
+
+  def __init__(self, success=None, err=None,):
+    self.success = success
+    self.err = err
+
+  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 == 0:
+        if ftype == TType.STRUCT:
+          self.success = hadoop.api.common.ttypes.ThriftDelegationToken()
+          self.success.read(iprot)
+        else:
+          iprot.skip(ftype)
+      elif fid == 1:
+        if ftype == TType.STRUCT:
+          self.err = hadoop.api.common.ttypes.IOException()
+          self.err.read(iprot)
+        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('getDelegationToken_result')
+    if self.success != None:
+      oprot.writeFieldBegin('success', TType.STRUCT, 0)
+      self.success.write(oprot)
+      oprot.writeFieldEnd()
+    if self.err != None:
+      oprot.writeFieldBegin('err', TType.STRUCT, 1)
+      self.err.write(oprot)
+      oprot.writeFieldEnd()
+    oprot.writeFieldStop()
+    oprot.writeStructEnd()
+
+  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)
+
 

+ 17 - 11
desktop/libs/hadoop/java/gen-java/org/apache/hadoop/thriftfs/api/Namenode.java

@@ -283,7 +283,13 @@ public class Namenode {
      */
     public void datanodeDown(String name, String storage, int thriftPort) throws TException;
 
-    public ThriftHdfsDelegationToken getDelegationToken(org.apache.hadoop.thriftfs.api.RequestContext ctx, String renewer) throws org.apache.hadoop.thriftfs.api.IOException, TException;
+    /**
+     * Get an HDFS delegation token.
+     * 
+     * @param ctx
+     * @param renewer
+     */
+    public org.apache.hadoop.thriftfs.api.ThriftDelegationToken getDelegationToken(org.apache.hadoop.thriftfs.api.RequestContext ctx, String renewer) throws org.apache.hadoop.thriftfs.api.IOException, TException;
 
   }
 
@@ -1083,7 +1089,7 @@ public class Namenode {
       return;
     }
 
-    public ThriftHdfsDelegationToken getDelegationToken(org.apache.hadoop.thriftfs.api.RequestContext ctx, String renewer) throws org.apache.hadoop.thriftfs.api.IOException, TException
+    public org.apache.hadoop.thriftfs.api.ThriftDelegationToken getDelegationToken(org.apache.hadoop.thriftfs.api.RequestContext ctx, String renewer) throws org.apache.hadoop.thriftfs.api.IOException, TException
     {
       send_getDelegationToken(ctx, renewer);
       return recv_getDelegationToken();
@@ -1100,7 +1106,7 @@ public class Namenode {
       oprot_.getTransport().flush();
     }
 
-    public ThriftHdfsDelegationToken recv_getDelegationToken() throws org.apache.hadoop.thriftfs.api.IOException, TException
+    public org.apache.hadoop.thriftfs.api.ThriftDelegationToken recv_getDelegationToken() throws org.apache.hadoop.thriftfs.api.IOException, TException
     {
       TMessage msg = iprot_.readMessageBegin();
       if (msg.type == TMessageType.EXCEPTION) {
@@ -17986,7 +17992,7 @@ public class Namenode {
     private static final TField SUCCESS_FIELD_DESC = new TField("success", TType.STRUCT, (short)0);
     private static final TField ERR_FIELD_DESC = new TField("err", TType.STRUCT, (short)1);
 
-    public ThriftHdfsDelegationToken success;
+    public org.apache.hadoop.thriftfs.api.ThriftDelegationToken success;
     public org.apache.hadoop.thriftfs.api.IOException err;
 
     /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
@@ -18049,7 +18055,7 @@ public class Namenode {
 
     public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
       put(_Fields.SUCCESS, new FieldMetaData("success", TFieldRequirementType.DEFAULT, 
-          new StructMetaData(TType.STRUCT, ThriftHdfsDelegationToken.class)));
+          new StructMetaData(TType.STRUCT, org.apache.hadoop.thriftfs.api.ThriftDelegationToken.class)));
       put(_Fields.ERR, new FieldMetaData("err", TFieldRequirementType.DEFAULT, 
           new FieldValueMetaData(TType.STRUCT)));
     }});
@@ -18062,7 +18068,7 @@ public class Namenode {
     }
 
     public getDelegationToken_result(
-      ThriftHdfsDelegationToken success,
+      org.apache.hadoop.thriftfs.api.ThriftDelegationToken success,
       org.apache.hadoop.thriftfs.api.IOException err)
     {
       this();
@@ -18075,7 +18081,7 @@ public class Namenode {
      */
     public getDelegationToken_result(getDelegationToken_result other) {
       if (other.isSetSuccess()) {
-        this.success = new ThriftHdfsDelegationToken(other.success);
+        this.success = new org.apache.hadoop.thriftfs.api.ThriftDelegationToken(other.success);
       }
       if (other.isSetErr()) {
         this.err = new org.apache.hadoop.thriftfs.api.IOException(other.err);
@@ -18091,11 +18097,11 @@ public class Namenode {
       return new getDelegationToken_result(this);
     }
 
-    public ThriftHdfsDelegationToken getSuccess() {
+    public org.apache.hadoop.thriftfs.api.ThriftDelegationToken getSuccess() {
       return this.success;
     }
 
-    public getDelegationToken_result setSuccess(ThriftHdfsDelegationToken success) {
+    public getDelegationToken_result setSuccess(org.apache.hadoop.thriftfs.api.ThriftDelegationToken success) {
       this.success = success;
       return this;
     }
@@ -18145,7 +18151,7 @@ public class Namenode {
         if (value == null) {
           unsetSuccess();
         } else {
-          setSuccess((ThriftHdfsDelegationToken)value);
+          setSuccess((org.apache.hadoop.thriftfs.api.ThriftDelegationToken)value);
         }
         break;
 
@@ -18277,7 +18283,7 @@ public class Namenode {
           switch (fieldId) {
             case SUCCESS:
               if (field.type == TType.STRUCT) {
-                this.success = new ThriftHdfsDelegationToken();
+                this.success = new org.apache.hadoop.thriftfs.api.ThriftDelegationToken();
                 this.success.read(iprot);
               } else { 
                 TProtocolUtil.skip(iprot, field.type);

+ 0 - 314
desktop/libs/hadoop/java/gen-java/org/apache/hadoop/thriftfs/api/ThriftHdfsDelegationToken.java

@@ -1,314 +0,0 @@
-/**
- * Autogenerated by Thrift
- *
- * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
- */
-package org.apache.hadoop.thriftfs.api;
-
-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 java.util.BitSet;
-import java.util.Arrays;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.thrift.*;
-import org.apache.thrift.meta_data.*;
-import org.apache.thrift.protocol.*;
-
-public class ThriftHdfsDelegationToken implements TBase<ThriftHdfsDelegationToken._Fields>, java.io.Serializable, Cloneable, Comparable<ThriftHdfsDelegationToken> {
-  private static final TStruct STRUCT_DESC = new TStruct("ThriftHdfsDelegationToken");
-
-  private static final TField DELEGATION_TOKEN_BYTES_FIELD_DESC = new TField("delegationTokenBytes", TType.STRING, (short)1);
-
-  public byte[] delegationTokenBytes;
-
-  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
-  public enum _Fields implements TFieldIdEnum {
-    DELEGATION_TOKEN_BYTES((short)1, "delegationTokenBytes");
-
-    private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
-    private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
-
-    static {
-      for (_Fields field : EnumSet.allOf(_Fields.class)) {
-        byId.put((int)field._thriftId, field);
-        byName.put(field.getFieldName(), field);
-      }
-    }
-
-    /**
-     * Find the _Fields constant that matches fieldId, or null if its not found.
-     */
-    public static _Fields findByThriftId(int fieldId) {
-      return byId.get(fieldId);
-    }
-
-    /**
-     * 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;
-    }
-  }
-
-  // isset id assignments
-
-  public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
-    put(_Fields.DELEGATION_TOKEN_BYTES, new FieldMetaData("delegationTokenBytes", TFieldRequirementType.DEFAULT, 
-        new FieldValueMetaData(TType.STRING)));
-  }});
-
-  static {
-    FieldMetaData.addStructMetaDataMap(ThriftHdfsDelegationToken.class, metaDataMap);
-  }
-
-  public ThriftHdfsDelegationToken() {
-  }
-
-  public ThriftHdfsDelegationToken(
-    byte[] delegationTokenBytes)
-  {
-    this();
-    this.delegationTokenBytes = delegationTokenBytes;
-  }
-
-  /**
-   * Performs a deep copy on <i>other</i>.
-   */
-  public ThriftHdfsDelegationToken(ThriftHdfsDelegationToken other) {
-    if (other.isSetDelegationTokenBytes()) {
-      this.delegationTokenBytes = new byte[other.delegationTokenBytes.length];
-      System.arraycopy(other.delegationTokenBytes, 0, delegationTokenBytes, 0, other.delegationTokenBytes.length);
-    }
-  }
-
-  public ThriftHdfsDelegationToken deepCopy() {
-    return new ThriftHdfsDelegationToken(this);
-  }
-
-  @Deprecated
-  public ThriftHdfsDelegationToken clone() {
-    return new ThriftHdfsDelegationToken(this);
-  }
-
-  public byte[] getDelegationTokenBytes() {
-    return this.delegationTokenBytes;
-  }
-
-  public ThriftHdfsDelegationToken setDelegationTokenBytes(byte[] delegationTokenBytes) {
-    this.delegationTokenBytes = delegationTokenBytes;
-    return this;
-  }
-
-  public void unsetDelegationTokenBytes() {
-    this.delegationTokenBytes = null;
-  }
-
-  /** Returns true if field delegationTokenBytes is set (has been asigned a value) and false otherwise */
-  public boolean isSetDelegationTokenBytes() {
-    return this.delegationTokenBytes != null;
-  }
-
-  public void setDelegationTokenBytesIsSet(boolean value) {
-    if (!value) {
-      this.delegationTokenBytes = null;
-    }
-  }
-
-  public void setFieldValue(_Fields field, Object value) {
-    switch (field) {
-    case DELEGATION_TOKEN_BYTES:
-      if (value == null) {
-        unsetDelegationTokenBytes();
-      } else {
-        setDelegationTokenBytes((byte[])value);
-      }
-      break;
-
-    }
-  }
-
-  public void setFieldValue(int fieldID, Object value) {
-    setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
-  }
-
-  public Object getFieldValue(_Fields field) {
-    switch (field) {
-    case DELEGATION_TOKEN_BYTES:
-      return getDelegationTokenBytes();
-
-    }
-    throw new IllegalStateException();
-  }
-
-  public Object getFieldValue(int fieldId) {
-    return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
-  }
-
-  /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
-  public boolean isSet(_Fields field) {
-    switch (field) {
-    case DELEGATION_TOKEN_BYTES:
-      return isSetDelegationTokenBytes();
-    }
-    throw new IllegalStateException();
-  }
-
-  public boolean isSet(int fieldID) {
-    return isSet(_Fields.findByThriftIdOrThrow(fieldID));
-  }
-
-  @Override
-  public boolean equals(Object that) {
-    if (that == null)
-      return false;
-    if (that instanceof ThriftHdfsDelegationToken)
-      return this.equals((ThriftHdfsDelegationToken)that);
-    return false;
-  }
-
-  public boolean equals(ThriftHdfsDelegationToken that) {
-    if (that == null)
-      return false;
-
-    boolean this_present_delegationTokenBytes = true && this.isSetDelegationTokenBytes();
-    boolean that_present_delegationTokenBytes = true && that.isSetDelegationTokenBytes();
-    if (this_present_delegationTokenBytes || that_present_delegationTokenBytes) {
-      if (!(this_present_delegationTokenBytes && that_present_delegationTokenBytes))
-        return false;
-      if (!java.util.Arrays.equals(this.delegationTokenBytes, that.delegationTokenBytes))
-        return false;
-    }
-
-    return true;
-  }
-
-  @Override
-  public int hashCode() {
-    return 0;
-  }
-
-  public int compareTo(ThriftHdfsDelegationToken other) {
-    if (!getClass().equals(other.getClass())) {
-      return getClass().getName().compareTo(other.getClass().getName());
-    }
-
-    int lastComparison = 0;
-    ThriftHdfsDelegationToken typedOther = (ThriftHdfsDelegationToken)other;
-
-    lastComparison = Boolean.valueOf(isSetDelegationTokenBytes()).compareTo(isSetDelegationTokenBytes());
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    lastComparison = TBaseHelper.compareTo(delegationTokenBytes, typedOther.delegationTokenBytes);
-    if (lastComparison != 0) {
-      return lastComparison;
-    }
-    return 0;
-  }
-
-  public void read(TProtocol iprot) throws TException {
-    TField field;
-    iprot.readStructBegin();
-    while (true)
-    {
-      field = iprot.readFieldBegin();
-      if (field.type == TType.STOP) { 
-        break;
-      }
-      _Fields fieldId = _Fields.findByThriftId(field.id);
-      if (fieldId == null) {
-        TProtocolUtil.skip(iprot, field.type);
-      } else {
-        switch (fieldId) {
-          case DELEGATION_TOKEN_BYTES:
-            if (field.type == TType.STRING) {
-              this.delegationTokenBytes = iprot.readBinary();
-            } else { 
-              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.delegationTokenBytes != null) {
-      oprot.writeFieldBegin(DELEGATION_TOKEN_BYTES_FIELD_DESC);
-      oprot.writeBinary(this.delegationTokenBytes);
-      oprot.writeFieldEnd();
-    }
-    oprot.writeFieldStop();
-    oprot.writeStructEnd();
-  }
-
-  @Override
-  public String toString() {
-    StringBuilder sb = new StringBuilder("ThriftHdfsDelegationToken(");
-    boolean first = true;
-
-    sb.append("delegationTokenBytes:");
-    if (this.delegationTokenBytes == null) {
-      sb.append("null");
-    } else {
-        int __delegationTokenBytes_size = Math.min(this.delegationTokenBytes.length, 128);
-        for (int i = 0; i < __delegationTokenBytes_size; i++) {
-          if (i != 0) sb.append(" ");
-          sb.append(Integer.toHexString(this.delegationTokenBytes[i]).length() > 1 ? Integer.toHexString(this.delegationTokenBytes[i]).substring(Integer.toHexString(this.delegationTokenBytes[i]).length() - 2).toUpperCase() : "0" + Integer.toHexString(this.delegationTokenBytes[i]).toUpperCase());
-        }
-        if (this.delegationTokenBytes.length > 128) sb.append(" ...");
-    }
-    first = false;
-    sb.append(")");
-    return sb.toString();
-  }
-
-  public void validate() throws TException {
-    // check for required fields
-  }
-
-}
-

+ 782 - 0
desktop/libs/hadoop/java/gen-java/org/apache/hadoop/thriftfs/jobtracker/api/Jobtracker.java

@@ -210,6 +210,14 @@ public class Jobtracker {
      */
     public void setJobPriority(org.apache.hadoop.thriftfs.api.RequestContext ctx, ThriftJobID jobID, ThriftJobPriority priority) throws org.apache.hadoop.thriftfs.api.IOException, JobNotFoundException, TException;
 
+    /**
+     * Get an MR delegation token.
+     * 
+     * @param ctx
+     * @param renewer
+     */
+    public org.apache.hadoop.thriftfs.api.ThriftDelegationToken getDelegationToken(org.apache.hadoop.thriftfs.api.RequestContext ctx, String renewer) throws org.apache.hadoop.thriftfs.api.IOException, TException;
+
   }
 
   public static class Client extends org.apache.hadoop.thriftfs.api.HadoopServiceBase.Client implements Iface {
@@ -1038,6 +1046,43 @@ public class Jobtracker {
       return;
     }
 
+    public org.apache.hadoop.thriftfs.api.ThriftDelegationToken getDelegationToken(org.apache.hadoop.thriftfs.api.RequestContext ctx, String renewer) throws org.apache.hadoop.thriftfs.api.IOException, TException
+    {
+      send_getDelegationToken(ctx, renewer);
+      return recv_getDelegationToken();
+    }
+
+    public void send_getDelegationToken(org.apache.hadoop.thriftfs.api.RequestContext ctx, String renewer) throws TException
+    {
+      oprot_.writeMessageBegin(new TMessage("getDelegationToken", TMessageType.CALL, seqid_));
+      getDelegationToken_args args = new getDelegationToken_args();
+      args.ctx = ctx;
+      args.renewer = renewer;
+      args.write(oprot_);
+      oprot_.writeMessageEnd();
+      oprot_.getTransport().flush();
+    }
+
+    public org.apache.hadoop.thriftfs.api.ThriftDelegationToken recv_getDelegationToken() throws org.apache.hadoop.thriftfs.api.IOException, TException
+    {
+      TMessage msg = iprot_.readMessageBegin();
+      if (msg.type == TMessageType.EXCEPTION) {
+        TApplicationException x = TApplicationException.read(iprot_);
+        iprot_.readMessageEnd();
+        throw x;
+      }
+      getDelegationToken_result result = new getDelegationToken_result();
+      result.read(iprot_);
+      iprot_.readMessageEnd();
+      if (result.isSetSuccess()) {
+        return result.success;
+      }
+      if (result.err != null) {
+        throw result.err;
+      }
+      throw new TApplicationException(TApplicationException.MISSING_RESULT, "getDelegationToken failed: unknown result");
+    }
+
   }
   public static class Processor extends org.apache.hadoop.thriftfs.api.HadoopServiceBase.Processor implements TProcessor {
     private static final Logger LOGGER = LoggerFactory.getLogger(Processor.class.getName());
@@ -1068,6 +1113,7 @@ public class Jobtracker {
       processMap_.put("killJob", new killJob());
       processMap_.put("killTaskAttempt", new killTaskAttempt());
       processMap_.put("setJobPriority", new setJobPriority());
+      processMap_.put("getDelegationToken", new getDelegationToken());
     }
 
     private Iface iface_;
@@ -1601,6 +1647,34 @@ public class Jobtracker {
 
     }
 
+    private class getDelegationToken implements ProcessFunction {
+      public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
+      {
+        getDelegationToken_args args = new getDelegationToken_args();
+        args.read(iprot);
+        iprot.readMessageEnd();
+        getDelegationToken_result result = new getDelegationToken_result();
+        try {
+          result.success = iface_.getDelegationToken(args.ctx, args.renewer);
+        } catch (org.apache.hadoop.thriftfs.api.IOException err) {
+          result.err = err;
+        } catch (Throwable th) {
+          LOGGER.error("Internal error processing getDelegationToken", th);
+          TApplicationException x = new TApplicationException(TApplicationException.INTERNAL_ERROR, "Internal error processing getDelegationToken");
+          oprot.writeMessageBegin(new TMessage("getDelegationToken", TMessageType.EXCEPTION, seqid));
+          x.write(oprot);
+          oprot.writeMessageEnd();
+          oprot.getTransport().flush();
+          return;
+        }
+        oprot.writeMessageBegin(new TMessage("getDelegationToken", TMessageType.REPLY, seqid));
+        result.write(oprot);
+        oprot.writeMessageEnd();
+        oprot.getTransport().flush();
+      }
+
+    }
+
   }
 
   public static class getJobTrackerName_args implements TBase<getJobTrackerName_args._Fields>, java.io.Serializable, Cloneable   {
@@ -16363,4 +16437,712 @@ public class Jobtracker {
 
   }
 
+  public static class getDelegationToken_args implements TBase<getDelegationToken_args._Fields>, java.io.Serializable, Cloneable   {
+    private static final TStruct STRUCT_DESC = new TStruct("getDelegationToken_args");
+
+    private static final TField CTX_FIELD_DESC = new TField("ctx", TType.STRUCT, (short)10);
+    private static final TField RENEWER_FIELD_DESC = new TField("renewer", TType.STRING, (short)1);
+
+    public org.apache.hadoop.thriftfs.api.RequestContext ctx;
+    public String renewer;
+
+    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+    public enum _Fields implements TFieldIdEnum {
+      CTX((short)10, "ctx"),
+      RENEWER((short)1, "renewer");
+
+      private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
+      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+      static {
+        for (_Fields field : EnumSet.allOf(_Fields.class)) {
+          byId.put((int)field._thriftId, field);
+          byName.put(field.getFieldName(), field);
+        }
+      }
+
+      /**
+       * Find the _Fields constant that matches fieldId, or null if its not found.
+       */
+      public static _Fields findByThriftId(int fieldId) {
+        return byId.get(fieldId);
+      }
+
+      /**
+       * 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;
+      }
+    }
+
+    // isset id assignments
+
+    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
+      put(_Fields.CTX, new FieldMetaData("ctx", TFieldRequirementType.DEFAULT, 
+          new StructMetaData(TType.STRUCT, org.apache.hadoop.thriftfs.api.RequestContext.class)));
+      put(_Fields.RENEWER, new FieldMetaData("renewer", TFieldRequirementType.DEFAULT, 
+          new FieldValueMetaData(TType.STRING)));
+    }});
+
+    static {
+      FieldMetaData.addStructMetaDataMap(getDelegationToken_args.class, metaDataMap);
+    }
+
+    public getDelegationToken_args() {
+    }
+
+    public getDelegationToken_args(
+      org.apache.hadoop.thriftfs.api.RequestContext ctx,
+      String renewer)
+    {
+      this();
+      this.ctx = ctx;
+      this.renewer = renewer;
+    }
+
+    /**
+     * Performs a deep copy on <i>other</i>.
+     */
+    public getDelegationToken_args(getDelegationToken_args other) {
+      if (other.isSetCtx()) {
+        this.ctx = new org.apache.hadoop.thriftfs.api.RequestContext(other.ctx);
+      }
+      if (other.isSetRenewer()) {
+        this.renewer = other.renewer;
+      }
+    }
+
+    public getDelegationToken_args deepCopy() {
+      return new getDelegationToken_args(this);
+    }
+
+    @Deprecated
+    public getDelegationToken_args clone() {
+      return new getDelegationToken_args(this);
+    }
+
+    public org.apache.hadoop.thriftfs.api.RequestContext getCtx() {
+      return this.ctx;
+    }
+
+    public getDelegationToken_args setCtx(org.apache.hadoop.thriftfs.api.RequestContext ctx) {
+      this.ctx = ctx;
+      return this;
+    }
+
+    public void unsetCtx() {
+      this.ctx = null;
+    }
+
+    /** Returns true if field ctx is set (has been asigned a value) and false otherwise */
+    public boolean isSetCtx() {
+      return this.ctx != null;
+    }
+
+    public void setCtxIsSet(boolean value) {
+      if (!value) {
+        this.ctx = null;
+      }
+    }
+
+    public String getRenewer() {
+      return this.renewer;
+    }
+
+    public getDelegationToken_args setRenewer(String renewer) {
+      this.renewer = renewer;
+      return this;
+    }
+
+    public void unsetRenewer() {
+      this.renewer = null;
+    }
+
+    /** Returns true if field renewer is set (has been asigned a value) and false otherwise */
+    public boolean isSetRenewer() {
+      return this.renewer != null;
+    }
+
+    public void setRenewerIsSet(boolean value) {
+      if (!value) {
+        this.renewer = null;
+      }
+    }
+
+    public void setFieldValue(_Fields field, Object value) {
+      switch (field) {
+      case CTX:
+        if (value == null) {
+          unsetCtx();
+        } else {
+          setCtx((org.apache.hadoop.thriftfs.api.RequestContext)value);
+        }
+        break;
+
+      case RENEWER:
+        if (value == null) {
+          unsetRenewer();
+        } else {
+          setRenewer((String)value);
+        }
+        break;
+
+      }
+    }
+
+    public void setFieldValue(int fieldID, Object value) {
+      setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
+    }
+
+    public Object getFieldValue(_Fields field) {
+      switch (field) {
+      case CTX:
+        return getCtx();
+
+      case RENEWER:
+        return getRenewer();
+
+      }
+      throw new IllegalStateException();
+    }
+
+    public Object getFieldValue(int fieldId) {
+      return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
+    }
+
+    /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
+    public boolean isSet(_Fields field) {
+      switch (field) {
+      case CTX:
+        return isSetCtx();
+      case RENEWER:
+        return isSetRenewer();
+      }
+      throw new IllegalStateException();
+    }
+
+    public boolean isSet(int fieldID) {
+      return isSet(_Fields.findByThriftIdOrThrow(fieldID));
+    }
+
+    @Override
+    public boolean equals(Object that) {
+      if (that == null)
+        return false;
+      if (that instanceof getDelegationToken_args)
+        return this.equals((getDelegationToken_args)that);
+      return false;
+    }
+
+    public boolean equals(getDelegationToken_args that) {
+      if (that == null)
+        return false;
+
+      boolean this_present_ctx = true && this.isSetCtx();
+      boolean that_present_ctx = true && that.isSetCtx();
+      if (this_present_ctx || that_present_ctx) {
+        if (!(this_present_ctx && that_present_ctx))
+          return false;
+        if (!this.ctx.equals(that.ctx))
+          return false;
+      }
+
+      boolean this_present_renewer = true && this.isSetRenewer();
+      boolean that_present_renewer = true && that.isSetRenewer();
+      if (this_present_renewer || that_present_renewer) {
+        if (!(this_present_renewer && that_present_renewer))
+          return false;
+        if (!this.renewer.equals(that.renewer))
+          return false;
+      }
+
+      return true;
+    }
+
+    @Override
+    public int hashCode() {
+      return 0;
+    }
+
+    public void read(TProtocol iprot) throws TException {
+      TField field;
+      iprot.readStructBegin();
+      while (true)
+      {
+        field = iprot.readFieldBegin();
+        if (field.type == TType.STOP) { 
+          break;
+        }
+        _Fields fieldId = _Fields.findByThriftId(field.id);
+        if (fieldId == null) {
+          TProtocolUtil.skip(iprot, field.type);
+        } else {
+          switch (fieldId) {
+            case CTX:
+              if (field.type == TType.STRUCT) {
+                this.ctx = new org.apache.hadoop.thriftfs.api.RequestContext();
+                this.ctx.read(iprot);
+              } else { 
+                TProtocolUtil.skip(iprot, field.type);
+              }
+              break;
+            case RENEWER:
+              if (field.type == TType.STRING) {
+                this.renewer = iprot.readString();
+              } else { 
+                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.renewer != null) {
+        oprot.writeFieldBegin(RENEWER_FIELD_DESC);
+        oprot.writeString(this.renewer);
+        oprot.writeFieldEnd();
+      }
+      if (this.ctx != null) {
+        oprot.writeFieldBegin(CTX_FIELD_DESC);
+        this.ctx.write(oprot);
+        oprot.writeFieldEnd();
+      }
+      oprot.writeFieldStop();
+      oprot.writeStructEnd();
+    }
+
+    @Override
+    public String toString() {
+      StringBuilder sb = new StringBuilder("getDelegationToken_args(");
+      boolean first = true;
+
+      sb.append("ctx:");
+      if (this.ctx == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.ctx);
+      }
+      first = false;
+      if (!first) sb.append(", ");
+      sb.append("renewer:");
+      if (this.renewer == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.renewer);
+      }
+      first = false;
+      sb.append(")");
+      return sb.toString();
+    }
+
+    public void validate() throws TException {
+      // check for required fields
+    }
+
+  }
+
+  public static class getDelegationToken_result implements TBase<getDelegationToken_result._Fields>, java.io.Serializable, Cloneable, Comparable<getDelegationToken_result>   {
+    private static final TStruct STRUCT_DESC = new TStruct("getDelegationToken_result");
+
+    private static final TField SUCCESS_FIELD_DESC = new TField("success", TType.STRUCT, (short)0);
+    private static final TField ERR_FIELD_DESC = new TField("err", TType.STRUCT, (short)1);
+
+    public org.apache.hadoop.thriftfs.api.ThriftDelegationToken success;
+    public org.apache.hadoop.thriftfs.api.IOException err;
+
+    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
+    public enum _Fields implements TFieldIdEnum {
+      SUCCESS((short)0, "success"),
+      ERR((short)1, "err");
+
+      private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
+      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
+
+      static {
+        for (_Fields field : EnumSet.allOf(_Fields.class)) {
+          byId.put((int)field._thriftId, field);
+          byName.put(field.getFieldName(), field);
+        }
+      }
+
+      /**
+       * Find the _Fields constant that matches fieldId, or null if its not found.
+       */
+      public static _Fields findByThriftId(int fieldId) {
+        return byId.get(fieldId);
+      }
+
+      /**
+       * 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;
+      }
+    }
+
+    // isset id assignments
+
+    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
+      put(_Fields.SUCCESS, new FieldMetaData("success", TFieldRequirementType.DEFAULT, 
+          new StructMetaData(TType.STRUCT, org.apache.hadoop.thriftfs.api.ThriftDelegationToken.class)));
+      put(_Fields.ERR, new FieldMetaData("err", TFieldRequirementType.DEFAULT, 
+          new FieldValueMetaData(TType.STRUCT)));
+    }});
+
+    static {
+      FieldMetaData.addStructMetaDataMap(getDelegationToken_result.class, metaDataMap);
+    }
+
+    public getDelegationToken_result() {
+    }
+
+    public getDelegationToken_result(
+      org.apache.hadoop.thriftfs.api.ThriftDelegationToken success,
+      org.apache.hadoop.thriftfs.api.IOException err)
+    {
+      this();
+      this.success = success;
+      this.err = err;
+    }
+
+    /**
+     * Performs a deep copy on <i>other</i>.
+     */
+    public getDelegationToken_result(getDelegationToken_result other) {
+      if (other.isSetSuccess()) {
+        this.success = new org.apache.hadoop.thriftfs.api.ThriftDelegationToken(other.success);
+      }
+      if (other.isSetErr()) {
+        this.err = new org.apache.hadoop.thriftfs.api.IOException(other.err);
+      }
+    }
+
+    public getDelegationToken_result deepCopy() {
+      return new getDelegationToken_result(this);
+    }
+
+    @Deprecated
+    public getDelegationToken_result clone() {
+      return new getDelegationToken_result(this);
+    }
+
+    public org.apache.hadoop.thriftfs.api.ThriftDelegationToken getSuccess() {
+      return this.success;
+    }
+
+    public getDelegationToken_result setSuccess(org.apache.hadoop.thriftfs.api.ThriftDelegationToken success) {
+      this.success = success;
+      return this;
+    }
+
+    public void unsetSuccess() {
+      this.success = null;
+    }
+
+    /** Returns true if field success is set (has been asigned a value) and false otherwise */
+    public boolean isSetSuccess() {
+      return this.success != null;
+    }
+
+    public void setSuccessIsSet(boolean value) {
+      if (!value) {
+        this.success = null;
+      }
+    }
+
+    public org.apache.hadoop.thriftfs.api.IOException getErr() {
+      return this.err;
+    }
+
+    public getDelegationToken_result setErr(org.apache.hadoop.thriftfs.api.IOException err) {
+      this.err = err;
+      return this;
+    }
+
+    public void unsetErr() {
+      this.err = null;
+    }
+
+    /** Returns true if field err is set (has been asigned a value) and false otherwise */
+    public boolean isSetErr() {
+      return this.err != null;
+    }
+
+    public void setErrIsSet(boolean value) {
+      if (!value) {
+        this.err = null;
+      }
+    }
+
+    public void setFieldValue(_Fields field, Object value) {
+      switch (field) {
+      case SUCCESS:
+        if (value == null) {
+          unsetSuccess();
+        } else {
+          setSuccess((org.apache.hadoop.thriftfs.api.ThriftDelegationToken)value);
+        }
+        break;
+
+      case ERR:
+        if (value == null) {
+          unsetErr();
+        } else {
+          setErr((org.apache.hadoop.thriftfs.api.IOException)value);
+        }
+        break;
+
+      }
+    }
+
+    public void setFieldValue(int fieldID, Object value) {
+      setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
+    }
+
+    public Object getFieldValue(_Fields field) {
+      switch (field) {
+      case SUCCESS:
+        return getSuccess();
+
+      case ERR:
+        return getErr();
+
+      }
+      throw new IllegalStateException();
+    }
+
+    public Object getFieldValue(int fieldId) {
+      return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
+    }
+
+    /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
+    public boolean isSet(_Fields field) {
+      switch (field) {
+      case SUCCESS:
+        return isSetSuccess();
+      case ERR:
+        return isSetErr();
+      }
+      throw new IllegalStateException();
+    }
+
+    public boolean isSet(int fieldID) {
+      return isSet(_Fields.findByThriftIdOrThrow(fieldID));
+    }
+
+    @Override
+    public boolean equals(Object that) {
+      if (that == null)
+        return false;
+      if (that instanceof getDelegationToken_result)
+        return this.equals((getDelegationToken_result)that);
+      return false;
+    }
+
+    public boolean equals(getDelegationToken_result that) {
+      if (that == null)
+        return false;
+
+      boolean this_present_success = true && this.isSetSuccess();
+      boolean that_present_success = true && that.isSetSuccess();
+      if (this_present_success || that_present_success) {
+        if (!(this_present_success && that_present_success))
+          return false;
+        if (!this.success.equals(that.success))
+          return false;
+      }
+
+      boolean this_present_err = true && this.isSetErr();
+      boolean that_present_err = true && that.isSetErr();
+      if (this_present_err || that_present_err) {
+        if (!(this_present_err && that_present_err))
+          return false;
+        if (!this.err.equals(that.err))
+          return false;
+      }
+
+      return true;
+    }
+
+    @Override
+    public int hashCode() {
+      return 0;
+    }
+
+    public int compareTo(getDelegationToken_result other) {
+      if (!getClass().equals(other.getClass())) {
+        return getClass().getName().compareTo(other.getClass().getName());
+      }
+
+      int lastComparison = 0;
+      getDelegationToken_result typedOther = (getDelegationToken_result)other;
+
+      lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(isSetSuccess());
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+      lastComparison = TBaseHelper.compareTo(success, typedOther.success);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+      lastComparison = Boolean.valueOf(isSetErr()).compareTo(isSetErr());
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+      lastComparison = TBaseHelper.compareTo(err, typedOther.err);
+      if (lastComparison != 0) {
+        return lastComparison;
+      }
+      return 0;
+    }
+
+    public void read(TProtocol iprot) throws TException {
+      TField field;
+      iprot.readStructBegin();
+      while (true)
+      {
+        field = iprot.readFieldBegin();
+        if (field.type == TType.STOP) { 
+          break;
+        }
+        _Fields fieldId = _Fields.findByThriftId(field.id);
+        if (fieldId == null) {
+          TProtocolUtil.skip(iprot, field.type);
+        } else {
+          switch (fieldId) {
+            case SUCCESS:
+              if (field.type == TType.STRUCT) {
+                this.success = new org.apache.hadoop.thriftfs.api.ThriftDelegationToken();
+                this.success.read(iprot);
+              } else { 
+                TProtocolUtil.skip(iprot, field.type);
+              }
+              break;
+            case ERR:
+              if (field.type == TType.STRUCT) {
+                this.err = new org.apache.hadoop.thriftfs.api.IOException();
+                this.err.read(iprot);
+              } else { 
+                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 {
+      oprot.writeStructBegin(STRUCT_DESC);
+
+      if (this.isSetSuccess()) {
+        oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
+        this.success.write(oprot);
+        oprot.writeFieldEnd();
+      } else if (this.isSetErr()) {
+        oprot.writeFieldBegin(ERR_FIELD_DESC);
+        this.err.write(oprot);
+        oprot.writeFieldEnd();
+      }
+      oprot.writeFieldStop();
+      oprot.writeStructEnd();
+    }
+
+    @Override
+    public String toString() {
+      StringBuilder sb = new StringBuilder("getDelegationToken_result(");
+      boolean first = true;
+
+      sb.append("success:");
+      if (this.success == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.success);
+      }
+      first = false;
+      if (!first) sb.append(", ");
+      sb.append("err:");
+      if (this.err == null) {
+        sb.append("null");
+      } else {
+        sb.append(this.err);
+      }
+      first = false;
+      sb.append(")");
+      return sb.toString();
+    }
+
+    public void validate() throws TException {
+      // check for required fields
+    }
+
+  }
+
 }

+ 4 - 0
desktop/libs/hadoop/java/if/common.thrift

@@ -112,6 +112,10 @@ struct MetricsContext {
   4: map<string, list<MetricsRecord>> records
 }
 
+struct ThriftDelegationToken {
+  1: binary delegationTokenBytes
+}
+
 service HadoopServiceBase {
   /** Return the version information for this server */
   VersionInfo getVersionInfo(10:RequestContext ctx);

+ 4 - 5
desktop/libs/hadoop/java/if/hdfs.thrift

@@ -236,10 +236,6 @@ struct DFSHealthReport {
   8: i32 httpPort
 }
 
-struct ThriftHdfsDelegationToken {
-  1: binary delegationTokenBytes
-}
-
 /** Quota-related error */
 exception QuotaException {
   /** Error message. */
@@ -490,7 +486,10 @@ service Namenode extends common.HadoopServiceBase {
                     /** Thrift port of the datanode */
                     3:  i32 thriftPort),
 
-  ThriftHdfsDelegationToken getDelegationToken(10:common.RequestContext ctx, 1:string renewer) throws(1: common.IOException err)
+  /**
+   * Get an HDFS delegation token.
+   */
+  common.ThriftDelegationToken getDelegationToken(10:common.RequestContext ctx, 1:string renewer) throws(1: common.IOException err)
 }
 
 /** Encapsulates a block data transfer with its CRC */

+ 25 - 22
desktop/libs/hadoop/java/if/jobtracker.thrift

@@ -448,28 +448,31 @@ service Jobtracker extends common.HadoopServiceBase {
 	ThriftTaskTrackerStatus getTracker(10: common.RequestContext ctx, 1: string name)
 	          throws(1: TaskTrackerNotFoundException tne),
 
-        /** Get the current time in ms according to the JT */
-        i64 getCurrentTime(10: common.RequestContext ctx),
-
-        /** Get the xml for a job's configuration, serialised from the local filesystem on the JT */
-        string getJobConfXML(10: common.RequestContext ctx, 1: ThriftJobID jobID)
-                  throws(1: common.IOException err),
-
-	/** Kill a job */
-        void killJob(10: common.RequestContext ctx, 1: ThriftJobID jobID)
-                                   throws(1: common.IOException err, 2: JobNotFoundException jne),
-
-        /** Kill a task attempt */
-        void killTaskAttempt(10: common.RequestContext ctx, 1: ThriftTaskAttemptID attemptID)
-                                         throws(1: common.IOException err,
-                                                2: TaskAttemptNotFoundException tne,
-                                                3: JobNotFoundException jne),
-
-        /** Set a job's priority */
-        void setJobPriority(10: common.RequestContext ctx,
-                            1: ThriftJobID jobID,
-                            2: ThriftJobPriority priority)
-            throws(1: common.IOException err, 2: JobNotFoundException jne),
+  /** Get the current time in ms according to the JT */
+  i64 getCurrentTime(10: common.RequestContext ctx),
+
+  /** Get the xml for a job's configuration, serialised from the local filesystem on the JT */
+  string getJobConfXML(10: common.RequestContext ctx, 1: ThriftJobID jobID)
+            throws(1: common.IOException err),
+
+  /** Kill a job */
+  void killJob(10: common.RequestContext ctx, 1: ThriftJobID jobID)
+                             throws(1: common.IOException err, 2: JobNotFoundException jne),
+
+  /** Kill a task attempt */
+  void killTaskAttempt(10: common.RequestContext ctx, 1: ThriftTaskAttemptID attemptID)
+                                   throws(1: common.IOException err,
+                                          2: TaskAttemptNotFoundException tne,
+                                          3: JobNotFoundException jne),
+
+  /** Set a job's priority */
+  void setJobPriority(10: common.RequestContext ctx,
+                      1: ThriftJobID jobID,
+                      2: ThriftJobPriority priority)
+      throws(1: common.IOException err, 2: JobNotFoundException jne),
+
+  /** Get an MR delegation token. */
+  common.ThriftDelegationToken getDelegationToken(10:common.RequestContext ctx, 1:string renewer) throws(1: common.IOException err)
 }
 
 

+ 25 - 0
desktop/libs/hadoop/java/src/java/org/apache/hadoop/mapred/ThriftJobTrackerPlugin.java

@@ -21,6 +21,7 @@ package org.apache.hadoop.mapred;
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileReader;
+import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.security.PrivilegedAction;
 import java.security.PrivilegedExceptionAction;
@@ -38,18 +39,25 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configurable;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.mapreduce.security.token.delegation.DelegationTokenIdentifier;
+import org.apache.hadoop.io.DataOutputBuffer;
+import org.apache.hadoop.io.Text;
 import org.apache.hadoop.mapred.Counters.Counter;
 import org.apache.hadoop.mapred.Counters.Group;
 import org.apache.hadoop.mapred.JobTracker.State;
 import org.apache.hadoop.mapred.TaskStatus.Phase;
 import org.apache.hadoop.mapreduce.TaskType;
 import org.apache.hadoop.net.NetUtils;
+import org.apache.hadoop.security.Credentials;
+import org.apache.hadoop.security.UserGroupInformation;
+import org.apache.hadoop.security.token.Token;
 import org.apache.hadoop.thriftfs.ThriftHandlerBase;
 import org.apache.hadoop.thriftfs.ThriftPluginServer;
 import org.apache.hadoop.thriftfs.ThriftServerContext;
 import org.apache.hadoop.thriftfs.ThriftUtils;
 import org.apache.hadoop.thriftfs.api.IOException;
 import org.apache.hadoop.thriftfs.api.RequestContext;
+import org.apache.hadoop.thriftfs.api.ThriftDelegationToken;
 import org.apache.hadoop.thriftfs.jobtracker.api.JobTrackerState;
 import org.apache.hadoop.thriftfs.jobtracker.api.Jobtracker;
 import org.apache.hadoop.thriftfs.jobtracker.api.ThriftClusterStatus;
@@ -1217,6 +1225,23 @@ public class ThriftJobTrackerPlugin extends JobTrackerPlugin implements Configur
               }
             });
         }
+
+        @Override
+        public ThriftDelegationToken getDelegationToken(RequestContext ctx, final String renewer)
+            throws IOException, TException {
+          return assumeUserContextAndExecute(ctx, new PrivilegedExceptionAction<ThriftDelegationToken>() {
+            public ThriftDelegationToken run() throws java.io.IOException {
+              Token<DelegationTokenIdentifier> delegationToken;
+              try {
+                delegationToken = jobTracker.getDelegationToken(new Text(renewer));
+              } catch (InterruptedException e) {
+                throw new java.io.IOException(e);
+              }
+
+              return ThriftUtils.toThrift(delegationToken, JobTracker.getAddress(conf));
+            }
+          });
+        }
     }
 
     /** Implementation of configurable interface */

+ 5 - 18
desktop/libs/hadoop/java/src/java/org/apache/hadoop/thriftfs/NamenodePlugin.java

@@ -56,7 +56,7 @@ import org.apache.hadoop.thriftfs.api.IOException;
 import org.apache.hadoop.thriftfs.api.Namenode;
 import org.apache.hadoop.thriftfs.api.RequestContext;
 import org.apache.hadoop.thriftfs.api.Stat;
-import org.apache.hadoop.thriftfs.api.ThriftHdfsDelegationToken;
+import org.apache.hadoop.thriftfs.api.ThriftDelegationToken;
 import org.apache.thrift.TException;
 import org.apache.thrift.TProcessor;
 import org.apache.thrift.TProcessorFactory;
@@ -411,25 +411,12 @@ public class NamenodePlugin extends org.apache.hadoop.hdfs.server.namenode.Namen
     }
 
     @Override
-    public ThriftHdfsDelegationToken getDelegationToken(RequestContext ctx, final String renewer) throws IOException,
+    public ThriftDelegationToken getDelegationToken(RequestContext ctx, final String renewer) throws IOException,
         TException {
-      return assumeUserContextAndExecute(ctx, new PrivilegedExceptionAction<ThriftHdfsDelegationToken>() {
-        public ThriftHdfsDelegationToken run() throws java.io.IOException {
-          UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
+      return assumeUserContextAndExecute(ctx, new PrivilegedExceptionAction<ThriftDelegationToken>() {
+        public ThriftDelegationToken run() throws java.io.IOException {
           Token<DelegationTokenIdentifier> delegationToken = namenode.getDelegationToken(new Text(renewer));
-
-          InetSocketAddress address = namenode.getNameNodeAddress();
-          String nnAddress = InetAddress.getByName(address.getHostName()).getHostAddress() + ":" + address.getPort();
-          delegationToken.setService(new Text(nnAddress));
-
-          DataOutputBuffer out = new DataOutputBuffer();
-          Credentials ts = new Credentials();
-          ts.addToken(new Text(ugi.getShortUserName()), delegationToken);
-          ts.writeTokenStorageToStream(out);
-
-          byte[] tokenData = new byte[out.getLength()];
-          System.arraycopy(out.getData(), 0, tokenData, 0, tokenData.length);
-          return new ThriftHdfsDelegationToken(tokenData);
+          return ThriftUtils.toThrift(delegationToken, namenode.getNameNodeAddress());
         }
       });
     }

+ 26 - 0
desktop/libs/hadoop/java/src/java/org/apache/hadoop/thriftfs/ThriftUtils.java

@@ -17,7 +17,9 @@
  */
 package org.apache.hadoop.thriftfs;
 
+import java.net.InetAddress;
 import java.net.InetSocketAddress;
+import java.net.UnknownHostException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -27,8 +29,15 @@ import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hdfs.protocol.DatanodeID;
 import org.apache.hadoop.hdfs.protocol.LocatedBlock;
+import org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier;
 import org.apache.hadoop.hdfs.server.namenode.NameNode;
+import org.apache.hadoop.io.DataOutputBuffer;
+import org.apache.hadoop.io.Text;
 import org.apache.hadoop.net.NetUtils;
+import org.apache.hadoop.security.Credentials;
+import org.apache.hadoop.security.UserGroupInformation;
+import org.apache.hadoop.security.token.Token;
+import org.apache.hadoop.security.token.delegation.AbstractDelegationTokenIdentifier;
 import org.apache.hadoop.thriftfs.api.Block;
 import org.apache.hadoop.thriftfs.api.Constants;
 import org.apache.hadoop.thriftfs.api.ContentSummary;
@@ -36,6 +45,7 @@ import org.apache.hadoop.thriftfs.api.DatanodeInfo;
 import org.apache.hadoop.thriftfs.api.DatanodeState;
 import org.apache.hadoop.thriftfs.api.IOException;
 import org.apache.hadoop.thriftfs.api.Namenode;
+import org.apache.hadoop.thriftfs.api.ThriftDelegationToken;
 import org.apache.thrift.protocol.TBinaryProtocol;
 import org.apache.thrift.protocol.TProtocol;
 import org.apache.thrift.transport.TSocket;
@@ -189,4 +199,20 @@ public class ThriftUtils {
     TProtocol p = new TBinaryProtocol(t);
     return new Namenode.Client(p);
   }
+
+  public static ThriftDelegationToken toThrift(Token<? extends AbstractDelegationTokenIdentifier> delegationToken,
+      InetSocketAddress address) throws java.io.IOException {
+    String serviceAddress = InetAddress.getByName(address.getHostName()).getHostAddress() + ":"
+        + address.getPort();
+    delegationToken.setService(new Text(serviceAddress));
+
+    DataOutputBuffer out = new DataOutputBuffer();
+    Credentials ts = new Credentials();
+    ts.addToken(new Text(serviceAddress), delegationToken);
+    ts.writeTokenStorageToStream(out);
+
+    byte[] tokenData = new byte[out.getLength()];
+    System.arraycopy(out.getData(), 0, tokenData, 0, tokenData.length);
+    return new ThriftDelegationToken(tokenData);
+  }
 }

+ 2 - 1
desktop/libs/hadoop/src/hadoop/cluster.py

@@ -45,7 +45,8 @@ def _make_filesystem(identifier):
 def _make_mrcluster(identifier):
   cluster_conf = conf.MR_CLUSTERS[identifier]
   return LiveJobTracker(cluster_conf.JT_HOST.get(),
-                        cluster_conf.JT_THRIFT_PORT.get())
+                        cluster_conf.JT_THRIFT_PORT.get(),
+                        cluster_conf.SECURITY_ENABLED.get())
 
 FS_CACHE = None
 def get_hdfs(identifier="default"):

+ 1 - 1
desktop/libs/hadoop/src/hadoop/fs/hadoopfs.py

@@ -556,7 +556,7 @@ class HadoopFileSystem(object):
   def get_delegation_token(self):
     # TODO(atm): The second argument here should really be the Hue kerberos
     # principal, which doesn't exist yet. Todd's working on that.
-    return self.nn_client.getDelegationToken(self.request_context, '')
+    return self.nn_client.getDelegationToken(self.request_context, 'hadoop')
 
   def _connect_dn(self, node):
     sock = TSocket.TSocket(node.host, node.thriftPort)

+ 7 - 1
desktop/libs/hadoop/src/hadoop/job_tracker.py

@@ -63,13 +63,14 @@ class LiveJobTracker(object):
   In particular, if Thrift returns None for anything, this will throw.
   """
 
-  def __init__(self, host, thrift_port):
+  def __init__(self, host, thrift_port, security_enabled=False):
     self.client = thrift_util.get_client(
       Jobtracker.Client, host, thrift_port,
       service_name="Hadoop MR JobTracker HUE Plugin",
       timeout_seconds=JT_THRIFT_TIMEOUT)
     self.host = host
     self.thrift_port = thrift_port
+    self.security_enabled = security_enabled
     # We allow a single LiveJobTracker to be used across multiple
     # threads by restricting the stateful components to a thread
     # thread-local.
@@ -364,3 +365,8 @@ class LiveJobTracker(object):
     Set a job's priority
     """
     return self.client.setJobPriority(self.thread_local.request_context, jobid, priority)
+
+  def get_delegation_token(self):
+    # TODO(atm): The second argument here should really be the Hue kerberos
+    # principal, which doesn't exist yet. Todd's working on that.
+    return self.client.getDelegationToken(self.thread_local.request_context, 'hadoop')