Search in sources :

Example 16 with FileSystemTestHelper

use of org.apache.hadoop.fs.FileSystemTestHelper in project hadoop by apache.

the class TestEncryptionZonesWithHA method setupCluster.

@Before
public void setupCluster() throws Exception {
    conf = new Configuration();
    conf.setInt(DFSConfigKeys.DFS_HA_TAILEDITS_PERIOD_KEY, 1);
    HAUtil.setAllowStandbyReads(conf, true);
    fsHelper = new FileSystemTestHelper();
    String testRoot = fsHelper.getTestRootDir();
    testRootDir = new File(testRoot).getAbsoluteFile();
    conf.set(CommonConfigurationKeysPublic.HADOOP_SECURITY_KEY_PROVIDER_PATH, JavaKeyStoreProvider.SCHEME_NAME + "://file" + new Path(testRootDir.toString(), "test.jks").toUri());
    cluster = new MiniDFSCluster.Builder(conf).nnTopology(MiniDFSNNTopology.simpleHATopology()).numDataNodes(1).build();
    cluster.waitActive();
    cluster.transitionToActive(0);
    fs = (DistributedFileSystem) HATestUtil.configureFailoverFs(cluster, conf);
    DFSTestUtil.createKey(TEST_KEY, cluster, 0, conf);
    DFSTestUtil.createKey(TEST_KEY, cluster, 1, conf);
    nn0 = cluster.getNameNode(0);
    nn1 = cluster.getNameNode(1);
    dfsAdmin0 = new HdfsAdmin(cluster.getURI(0), conf);
    dfsAdmin1 = new HdfsAdmin(cluster.getURI(1), conf);
    KeyProviderCryptoExtension nn0Provider = cluster.getNameNode(0).getNamesystem().getProvider();
    fs.getClient().setKeyProvider(nn0Provider);
}
Also used : FileSystemTestHelper(org.apache.hadoop.fs.FileSystemTestHelper) Path(org.apache.hadoop.fs.Path) Configuration(org.apache.hadoop.conf.Configuration) HdfsAdmin(org.apache.hadoop.hdfs.client.HdfsAdmin) KeyProviderCryptoExtension(org.apache.hadoop.crypto.key.KeyProviderCryptoExtension) File(java.io.File) Before(org.junit.Before)

Example 17 with FileSystemTestHelper

use of org.apache.hadoop.fs.FileSystemTestHelper in project hadoop by apache.

the class TestReservedRawPaths method setup.

@Before
public void setup() throws Exception {
    conf = new HdfsConfiguration();
    fsHelper = new FileSystemTestHelper();
    // Set up java key store
    String testRoot = fsHelper.getTestRootDir();
    File testRootDir = new File(testRoot).getAbsoluteFile();
    final Path jksPath = new Path(testRootDir.toString(), "test.jks");
    conf.set(CommonConfigurationKeysPublic.HADOOP_SECURITY_KEY_PROVIDER_PATH, JavaKeyStoreProvider.SCHEME_NAME + "://file" + jksPath.toUri());
    cluster = new MiniDFSCluster.Builder(conf).numDataNodes(1).build();
    Logger.getLogger(EncryptionZoneManager.class).setLevel(Level.TRACE);
    fs = cluster.getFileSystem();
    fsWrapper = new FileSystemTestWrapper(cluster.getFileSystem());
    fcWrapper = new FileContextTestWrapper(FileContext.getFileContext(cluster.getURI(), conf));
    dfsAdmin = new HdfsAdmin(cluster.getURI(), conf);
    // Need to set the client's KeyProvider to the NN's for JKS,
    // else the updates do not get flushed properly
    fs.getClient().setKeyProvider(cluster.getNameNode().getNamesystem().getProvider());
    DFSTestUtil.createKey(TEST_KEY, cluster, conf);
}
Also used : FileSystemTestHelper(org.apache.hadoop.fs.FileSystemTestHelper) Path(org.apache.hadoop.fs.Path) INodesInPath(org.apache.hadoop.hdfs.server.namenode.INodesInPath) HdfsAdmin(org.apache.hadoop.hdfs.client.HdfsAdmin) FileSystemTestWrapper(org.apache.hadoop.fs.FileSystemTestWrapper) FileContextTestWrapper(org.apache.hadoop.fs.FileContextTestWrapper) File(java.io.File) EncryptionZoneManager(org.apache.hadoop.hdfs.server.namenode.EncryptionZoneManager) Before(org.junit.Before)

Example 18 with FileSystemTestHelper

use of org.apache.hadoop.fs.FileSystemTestHelper in project hadoop by apache.

the class TestTrashWithEncryptionZones method setup.

@Before
public void setup() throws Exception {
    conf = new HdfsConfiguration();
    fsHelper = new FileSystemTestHelper();
    // Set up java key store
    String testRoot = fsHelper.getTestRootDir();
    testRootDir = new File(testRoot).getAbsoluteFile();
    conf.set(CommonConfigurationKeysPublic.HADOOP_SECURITY_KEY_PROVIDER_PATH, getKeyProviderURI());
    conf.setBoolean(DFSConfigKeys.DFS_NAMENODE_DELEGATION_TOKEN_ALWAYS_USE_KEY, true);
    // Lower the batch size for testing
    conf.setInt(DFSConfigKeys.DFS_NAMENODE_LIST_ENCRYPTION_ZONES_NUM_RESPONSES, 2);
    cluster = new MiniDFSCluster.Builder(conf).numDataNodes(1).build();
    org.apache.log4j.Logger.getLogger(EncryptionZoneManager.class).setLevel(Level.TRACE);
    fs = cluster.getFileSystem();
    fsWrapper = new FileSystemTestWrapper(fs);
    dfsAdmin = new HdfsAdmin(cluster.getURI(), conf);
    setProvider();
    // Create a test key
    DFSTestUtil.createKey(TEST_KEY, cluster, conf);
    clientConf = new Configuration(conf);
    clientConf.setLong(FS_TRASH_INTERVAL_KEY, 1);
    shell = new FsShell(clientConf);
}
Also used : FileSystemTestHelper(org.apache.hadoop.fs.FileSystemTestHelper) FsShell(org.apache.hadoop.fs.FsShell) Configuration(org.apache.hadoop.conf.Configuration) HdfsAdmin(org.apache.hadoop.hdfs.client.HdfsAdmin) FileSystemTestWrapper(org.apache.hadoop.fs.FileSystemTestWrapper) File(java.io.File) EncryptionZoneManager(org.apache.hadoop.hdfs.server.namenode.EncryptionZoneManager) Before(org.junit.Before)

Aggregations

FileSystemTestHelper (org.apache.hadoop.fs.FileSystemTestHelper)18 File (java.io.File)12 Configuration (org.apache.hadoop.conf.Configuration)9 Path (org.apache.hadoop.fs.Path)9 Before (org.junit.Before)9 HdfsAdmin (org.apache.hadoop.hdfs.client.HdfsAdmin)6 FileSystemTestWrapper (org.apache.hadoop.fs.FileSystemTestWrapper)4 MiniDFSCluster (org.apache.hadoop.hdfs.MiniDFSCluster)4 Test (org.junit.Test)4 HdfsConfiguration (org.apache.hadoop.hdfs.HdfsConfiguration)3 EncryptionZoneManager (org.apache.hadoop.hdfs.server.namenode.EncryptionZoneManager)3 FileContextTestWrapper (org.apache.hadoop.fs.FileContextTestWrapper)2 DistributedFileSystem (org.apache.hadoop.hdfs.DistributedFileSystem)2 BeforeClass (org.junit.BeforeClass)2 FileOutputStream (java.io.FileOutputStream)1 RandomAccessFile (java.io.RandomAccessFile)1 SocketTimeoutException (java.net.SocketTimeoutException)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1