Search in sources :

Example 81 with BeforeClass

use of org.junit.BeforeClass in project hadoop by apache.

the class TestOfflineImageViewerForContentSummary method createOriginalFSImage.

/**
   * Create a populated namespace for later testing. Save its contents to a
   * data structure and store its fsimage location. We only want to generate
   * the fsimage file once and use it for multiple tests.
   */
@BeforeClass
public static void createOriginalFSImage() throws IOException {
    MiniDFSCluster cluster = null;
    Configuration conf = new Configuration();
    try {
        cluster = new MiniDFSCluster.Builder(conf).build();
        cluster.waitActive();
        DistributedFileSystem hdfs = cluster.getFileSystem();
        Path parentDir = new Path("/parentDir");
        Path childDir1 = new Path(parentDir, "childDir1");
        Path childDir2 = new Path(parentDir, "childDir2");
        Path dirForLinks = new Path("/dirForLinks");
        hdfs.mkdirs(parentDir);
        hdfs.mkdirs(childDir1);
        hdfs.mkdirs(childDir2);
        hdfs.mkdirs(dirForLinks);
        hdfs.setQuota(parentDir, 10, 1024 * 1024 * 1024);
        Path file1OnParentDir = new Path(parentDir, "file1");
        try (FSDataOutputStream o = hdfs.create(file1OnParentDir)) {
            o.write("123".getBytes());
        }
        try (FSDataOutputStream o = hdfs.create(new Path(parentDir, "file2"))) {
            o.write("1234".getBytes());
        }
        try (FSDataOutputStream o = hdfs.create(new Path(childDir1, "file3"))) {
            o.write("123".getBytes());
        }
        try (FSDataOutputStream o = hdfs.create(new Path(parentDir, "file4"))) {
            o.write("123".getBytes());
        }
        Path link1 = new Path("/link1");
        Path link2 = new Path("/dirForLinks/linkfordir1");
        hdfs.createSymlink(new Path("/parentDir/file4"), link1, true);
        summaryFromDFS = hdfs.getContentSummary(parentDir);
        emptyDirSummaryFromDFS = hdfs.getContentSummary(childDir2);
        fileSummaryFromDFS = hdfs.getContentSummary(file1OnParentDir);
        symLinkSummaryFromDFS = hdfs.getContentSummary(link1);
        hdfs.createSymlink(childDir1, link2, true);
        symLinkSummaryForDirContainsFromDFS = hdfs.getContentSummary(new Path("/dirForLinks"));
        // Write results to the fsimage file
        hdfs.setSafeMode(HdfsConstants.SafeModeAction.SAFEMODE_ENTER, false);
        hdfs.saveNamespace();
        // Determine the location of the fsimage file
        originalFsimage = FSImageTestUtil.findLatestImageFile(FSImageTestUtil.getFSImage(cluster.getNameNode()).getStorage().getStorageDir(0));
        if (originalFsimage == null) {
            throw new RuntimeException("Didn't generate or can't find fsimage");
        }
        LOG.debug("original FS image file is " + originalFsimage);
    } finally {
        if (cluster != null)
            cluster.shutdown();
    }
}
Also used : Path(org.apache.hadoop.fs.Path) MiniDFSCluster(org.apache.hadoop.hdfs.MiniDFSCluster) Configuration(org.apache.hadoop.conf.Configuration) FSDataOutputStream(org.apache.hadoop.fs.FSDataOutputStream) DistributedFileSystem(org.apache.hadoop.hdfs.DistributedFileSystem) BeforeClass(org.junit.BeforeClass)

Example 82 with BeforeClass

use of org.junit.BeforeClass in project hadoop by apache.

the class TestOfflineImageViewerForXAttr method createOriginalFSImage.

/**
   * Create a populated namespace for later testing. Save its contents to a data
   * structure and store its fsimage location. We only want to generate the
   * fsimage file once and use it for multiple tests.
   */
@BeforeClass
public static void createOriginalFSImage() throws IOException {
    MiniDFSCluster cluster = null;
    Configuration conf = new Configuration();
    try {
        cluster = new MiniDFSCluster.Builder(conf).build();
        cluster.waitActive();
        DistributedFileSystem hdfs = cluster.getFileSystem();
        // Create a name space with XAttributes
        Path dir = new Path("/dir1");
        hdfs.mkdirs(dir);
        hdfs.setXAttr(dir, "user.attr1", "value1".getBytes());
        hdfs.setXAttr(dir, "user.attr2", "value2".getBytes());
        // Write results to the fsimage file
        hdfs.setSafeMode(HdfsConstants.SafeModeAction.SAFEMODE_ENTER, false);
        hdfs.saveNamespace();
        List<XAttr> attributes = new ArrayList<XAttr>();
        attributes.add(XAttrHelper.buildXAttr("user.attr1", "value1".getBytes()));
        attr1JSon = JsonUtil.toJsonString(attributes, null);
        attributes.add(XAttrHelper.buildXAttr("user.attr2", "value2".getBytes()));
        // Determine the location of the fsimage file
        originalFsimage = FSImageTestUtil.findLatestImageFile(FSImageTestUtil.getFSImage(cluster.getNameNode()).getStorage().getStorageDir(0));
        if (originalFsimage == null) {
            throw new RuntimeException("Didn't generate or can't find fsimage");
        }
        LOG.debug("original FS image file is " + originalFsimage);
    } finally {
        if (cluster != null)
            cluster.shutdown();
    }
}
Also used : Path(org.apache.hadoop.fs.Path) MiniDFSCluster(org.apache.hadoop.hdfs.MiniDFSCluster) Configuration(org.apache.hadoop.conf.Configuration) ArrayList(java.util.ArrayList) DistributedFileSystem(org.apache.hadoop.hdfs.DistributedFileSystem) XAttr(org.apache.hadoop.fs.XAttr) BeforeClass(org.junit.BeforeClass)

Example 83 with BeforeClass

use of org.junit.BeforeClass in project hadoop by apache.

the class FoldedTreeSetTest method setUpClass.

@BeforeClass
public static void setUpClass() {
    long seed = System.nanoTime();
    System.out.println("This run uses the random seed " + seed);
    srand = new Random(seed);
}
Also used : Random(java.util.Random) BeforeClass(org.junit.BeforeClass)

Example 84 with BeforeClass

use of org.junit.BeforeClass in project hadoop by apache.

the class TestZStandardCompressorDecompressor method beforeClass.

@BeforeClass
public static void beforeClass() throws Exception {
    CONFIGURATION.setInt(IO_FILE_BUFFER_SIZE_KEY, 1024 * 64);
    uncompressedFile = new File(TestZStandardCompressorDecompressor.class.getResource("/zstd/test_file.txt").toURI());
    compressedFile = new File(TestZStandardCompressorDecompressor.class.getResource("/zstd/test_file.txt.zst").toURI());
}
Also used : File(java.io.File) BeforeClass(org.junit.BeforeClass)

Example 85 with BeforeClass

use of org.junit.BeforeClass in project flink by apache.

the class AutoParallelismITCase method setupCluster.

@BeforeClass
public static void setupCluster() {
    Configuration config = new Configuration();
    config.setInteger(ConfigConstants.LOCAL_NUMBER_TASK_MANAGER, NUM_TM);
    config.setInteger(ConfigConstants.TASK_MANAGER_NUM_TASK_SLOTS, SLOTS_PER_TM);
    cluster = new LocalFlinkMiniCluster(config, false);
    cluster.start();
}
Also used : Configuration(org.apache.flink.configuration.Configuration) LocalFlinkMiniCluster(org.apache.flink.runtime.minicluster.LocalFlinkMiniCluster) BeforeClass(org.junit.BeforeClass)

Aggregations

BeforeClass (org.junit.BeforeClass)2813 File (java.io.File)388 Configuration (org.apache.hadoop.conf.Configuration)287 IOException (java.io.IOException)128 Connection (java.sql.Connection)126 Properties (java.util.Properties)108 Reader (java.io.Reader)99 SqlSessionFactoryBuilder (org.apache.ibatis.session.SqlSessionFactoryBuilder)98 Provisioning (com.zimbra.cs.account.Provisioning)93 ScriptRunner (org.apache.ibatis.jdbc.ScriptRunner)91 HiveConf (org.apache.hadoop.hive.conf.HiveConf)86 MockProvisioning (com.zimbra.cs.account.MockProvisioning)77 Path (org.apache.hadoop.fs.Path)75 URI (java.net.URI)73 HashMap (java.util.HashMap)70 URL (java.net.URL)63 SqlSession (org.apache.ibatis.session.SqlSession)62 MiniDFSCluster (org.apache.hadoop.hdfs.MiniDFSCluster)61 Injector (com.google.inject.Injector)57 CConfiguration (co.cask.cdap.common.conf.CConfiguration)56