Java Code Examples for org.apache.hadoop.fs.FileSystem.addDelegationTokens()

The following are Jave code examples for showing how to use addDelegationTokens() of the org.apache.hadoop.fs.FileSystem class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: hadoop   File:   Source Code and License Vote up 6 votes
 * get delegation token for a specific FS
 * @param fs
 * @param credentials
 * @param p
 * @param conf
 * @throws IOException
static void obtainTokensForNamenodesInternal(FileSystem fs, 
    Credentials credentials, Configuration conf) throws IOException {
  String delegTokenRenewer = Master.getMasterPrincipal(conf);
  if (delegTokenRenewer == null || delegTokenRenewer.length() == 0) {
    throw new IOException(
        "Can't get Master Kerberos principal for use as renewer");
  mergeBinaryTokens(credentials, conf);

  final Token<?> tokens[] = fs.addDelegationTokens(delegTokenRenewer,
  if (tokens != null) {
    for (Token<?> token : tokens) {"Got dt for " + fs.getUri() + "; "+token);
Example 2
Project: hadoop   File:   Source Code and License Vote up 6 votes
private void testDelegationTokenWithFS(Class fileSystemClass)
  throws Exception {
  Configuration conf = new Configuration();
  conf.set("fs.webhdfs.impl", fileSystemClass.getName());
  conf.set("fs.hdfs.impl.disable.cache", "true");
  URI uri = new URI( "webhdfs://" +
  FileSystem fs = FileSystem.get(uri, conf);
  Token<?> tokens[] = fs.addDelegationTokens("foo", null);
  Assert.assertEquals(1, tokens.length);
  fs = FileSystem.get(uri, conf);
  ((DelegationTokenRenewer.Renewable) fs).setDelegationToken(tokens[0]);
  fs.listStatus(new Path("/"));
Example 3
Project: hadoop   File:   Source Code and License Vote up 5 votes
private Token<DelegationTokenIdentifier> getDelegationToken(FileSystem fs,
    String renewer) throws IOException {
  final Token<?> tokens[] = fs.addDelegationTokens(renewer, null);
  assertEquals(1, tokens.length);
  return (Token<DelegationTokenIdentifier>) tokens[0];