Example usage for org.apache.hadoop.security.token Token setKind

List of usage examples for org.apache.hadoop.security.token Token setKind

Introduction

In this page you can find the example usage for org.apache.hadoop.security.token Token setKind.

Prototype

@InterfaceAudience.Private
public synchronized void setKind(Text newKind) 

Source Link

Document

Set the token kind.

Usage

From source file:org.apache.tez.common.security.TestTokenCache.java

License:Apache License

private MockFileSystem createFileSystemForServiceName(final String service) throws IOException {
    MockFileSystem mockFs = new MockFileSystem();
    when(mockFs.getCanonicalServiceName()).thenReturn(service);
    when(mockFs.getDelegationToken(any(String.class))).thenAnswer(new Answer<Token<?>>() {
        int unique = 0;

        @Override//from   www. jav a2 s.  c  o  m
        public Token<?> answer(InvocationOnMock invocation) throws Throwable {
            Token<?> token = new Token<TokenIdentifier>();
            token.setService(new Text(service));
            // use unique value so when we restore from token storage, we can
            // tell if it's really the same token
            token.setKind(new Text("token" + unique++));
            return token;
        }
    });
    return mockFs;
}