Search in sources :

Example 16 with Text

use of org.apache.hadoop.io.Text in project hadoop by apache.

the class TestFileSystemTokens method testFsWithNestedDuplicatesChildren.

@Test
public void testFsWithNestedDuplicatesChildren() throws Exception {
    Credentials credentials = new Credentials();
    Text service1 = new Text("singleTokenFs1");
    Text service2 = new Text("singleTokenFs2");
    Text service4 = new Text("singleTokenFs4");
    Text multiService = new Text("multiTokenFs");
    Token<?> token2 = mock(Token.class);
    credentials.addToken(service2, token2);
    MockFileSystem fs1 = createFileSystemForServiceName(service1);
    MockFileSystem fs1B = createFileSystemForServiceName(service1);
    MockFileSystem fs2 = createFileSystemForServiceName(service2);
    MockFileSystem fs3 = createFileSystemForServiceName(null);
    MockFileSystem fs4 = createFileSystemForServiceName(service4);
    // now let's get dirty!  ensure dup tokens aren't fetched even when
    // repeated and dupped in a nested fs.  fs4 is a real test of the drill
    // down: multi-filter-multi-filter-filter-fs4.
    MockFileSystem multiFs = createFileSystemForServiceName(multiService, fs1, fs1B, fs2, fs2, new FilterFileSystem(fs3), new FilterFileSystem(new FilterFileSystem(fs4)));
    MockFileSystem superMultiFs = createFileSystemForServiceName(null, fs1, fs1B, fs1, new FilterFileSystem(fs3), new FilterFileSystem(multiFs));
    superMultiFs.addDelegationTokens(renewer, credentials);
    // does not have its own token
    verifyTokenFetch(superMultiFs, false);
    // has its own token
    verifyTokenFetch(multiFs, true);
    verifyTokenFetch(fs1, true);
    // we had added its token to credentials
    verifyTokenFetch(fs2, false);
    // has no tokens
    verifyTokenFetch(fs3, false);
    verifyTokenFetch(fs4, true);
    //fs1+fs2+fs4+multifs (fs3=0)
    assertEquals(4, credentials.numberOfTokens());
    assertNotNull(credentials.getToken(service1));
    assertNotNull(credentials.getToken(service2));
    assertSame(token2, credentials.getToken(service2));
    assertNotNull(credentials.getToken(multiService));
    assertNotNull(credentials.getToken(service4));
}
Also used : Text(org.apache.hadoop.io.Text) Credentials(org.apache.hadoop.security.Credentials) MockFileSystem(org.apache.hadoop.fs.FileSystemTestHelper.MockFileSystem) Test(org.junit.Test)

Example 17 with Text

use of org.apache.hadoop.io.Text in project hadoop by apache.

the class TestFileSystemTokens method testFsWithChildTokens.

@Test
public void testFsWithChildTokens() throws Exception {
    Credentials credentials = new Credentials();
    Text service1 = new Text("singleTokenFs1");
    Text service2 = new Text("singleTokenFs2");
    MockFileSystem fs1 = createFileSystemForServiceName(service1);
    MockFileSystem fs2 = createFileSystemForServiceName(service2);
    MockFileSystem fs3 = createFileSystemForServiceName(null);
    MockFileSystem multiFs = createFileSystemForServiceName(null, fs1, fs2, fs3);
    multiFs.addDelegationTokens(renewer, credentials);
    // has no tokens of own, only child tokens
    verifyTokenFetch(multiFs, false);
    verifyTokenFetch(fs1, true);
    verifyTokenFetch(fs2, true);
    verifyTokenFetch(fs3, false);
    assertEquals(2, credentials.numberOfTokens());
    assertNotNull(credentials.getToken(service1));
    assertNotNull(credentials.getToken(service2));
}
Also used : Text(org.apache.hadoop.io.Text) Credentials(org.apache.hadoop.security.Credentials) MockFileSystem(org.apache.hadoop.fs.FileSystemTestHelper.MockFileSystem) Test(org.junit.Test)

Example 18 with Text

use of org.apache.hadoop.io.Text in project hadoop by apache.

the class TestFileSystemTokens method testFsWithMyOwnExistsAndChildTokens.

@Test
public void testFsWithMyOwnExistsAndChildTokens() throws Exception {
    Credentials credentials = new Credentials();
    Text service1 = new Text("singleTokenFs1");
    Text service2 = new Text("singleTokenFs2");
    Text myService = new Text("multiTokenFs");
    Token<?> token = mock(Token.class);
    credentials.addToken(myService, token);
    MockFileSystem fs1 = createFileSystemForServiceName(service1);
    MockFileSystem fs2 = createFileSystemForServiceName(service2);
    MockFileSystem multiFs = createFileSystemForServiceName(myService, fs1, fs2);
    multiFs.addDelegationTokens(renewer, credentials);
    // we had added its token to credentials
    verifyTokenFetch(multiFs, false);
    verifyTokenFetch(fs1, true);
    verifyTokenFetch(fs2, true);
    assertEquals(3, credentials.numberOfTokens());
    assertSame(token, credentials.getToken(myService));
    assertNotNull(credentials.getToken(service1));
    assertNotNull(credentials.getToken(service2));
}
Also used : Text(org.apache.hadoop.io.Text) Credentials(org.apache.hadoop.security.Credentials) MockFileSystem(org.apache.hadoop.fs.FileSystemTestHelper.MockFileSystem) Test(org.junit.Test)

Example 19 with Text

use of org.apache.hadoop.io.Text in project hadoop by apache.

the class TestFileSystemTokens method testFsWithTokenExists.

@Test
public void testFsWithTokenExists() throws Exception {
    Credentials credentials = new Credentials();
    Text service = new Text("singleTokenFs");
    MockFileSystem fs = createFileSystemForServiceName(service);
    Token<?> token = mock(Token.class);
    credentials.addToken(service, token);
    fs.addDelegationTokens(renewer, credentials);
    verifyTokenFetch(fs, false);
    assertEquals(1, credentials.numberOfTokens());
    assertSame(token, credentials.getToken(service));
}
Also used : Text(org.apache.hadoop.io.Text) Credentials(org.apache.hadoop.security.Credentials) MockFileSystem(org.apache.hadoop.fs.FileSystemTestHelper.MockFileSystem) Test(org.junit.Test)

Example 20 with Text

use of org.apache.hadoop.io.Text in project hadoop by apache.

the class TestFileSystemTokens method testFsWithDuplicateChildren.

@Test
public void testFsWithDuplicateChildren() throws Exception {
    Credentials credentials = new Credentials();
    Text service = new Text("singleTokenFs1");
    MockFileSystem fs = createFileSystemForServiceName(service);
    MockFileSystem multiFs = createFileSystemForServiceName(null, fs, new FilterFileSystem(fs));
    multiFs.addDelegationTokens(renewer, credentials);
    verifyTokenFetch(multiFs, false);
    verifyTokenFetch(fs, true);
    assertEquals(1, credentials.numberOfTokens());
    assertNotNull(credentials.getToken(service));
}
Also used : Text(org.apache.hadoop.io.Text) Credentials(org.apache.hadoop.security.Credentials) MockFileSystem(org.apache.hadoop.fs.FileSystemTestHelper.MockFileSystem) Test(org.junit.Test)

Aggregations

Text (org.apache.hadoop.io.Text)1012 Test (org.junit.Test)397 Path (org.apache.hadoop.fs.Path)180 Configuration (org.apache.hadoop.conf.Configuration)169 LongWritable (org.apache.hadoop.io.LongWritable)141 IOException (java.io.IOException)139 IntWritable (org.apache.hadoop.io.IntWritable)115 FileSystem (org.apache.hadoop.fs.FileSystem)109 ArrayList (java.util.ArrayList)100 Token (org.apache.hadoop.security.token.Token)94 ObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector)86 BytesWritable (org.apache.hadoop.io.BytesWritable)73 SequenceFile (org.apache.hadoop.io.SequenceFile)68 Credentials (org.apache.hadoop.security.Credentials)63 DeferredObject (org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredObject)54 DeferredJavaObject (org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredJavaObject)53 JobConf (org.apache.hadoop.mapred.JobConf)50 FloatWritable (org.apache.hadoop.io.FloatWritable)46 BooleanWritable (org.apache.hadoop.io.BooleanWritable)45 DoubleWritable (org.apache.hadoop.hive.serde2.io.DoubleWritable)42