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();
}
}
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();
}
}
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);
}
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());
}
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();
}
Aggregations