本文整理汇总了Java中org.apache.hadoop.mapred.UtilsForTests.setupTC方法的典型用法代码示例。如果您正苦于以下问题:Java UtilsForTests.setupTC方法的具体用法?Java UtilsForTests.setupTC怎么用?Java UtilsForTests.setupTC使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.mapred.UtilsForTests
的用法示例。
在下文中一共展示了UtilsForTests.setupTC方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import org.apache.hadoop.mapred.UtilsForTests; //导入方法依赖的package包/类
@Override
protected void setUp() throws IOException,InterruptedException {
// Prepare the tests' root dir
File TEST_ROOT = new File(TEST_ROOT_DIR);
if (!TEST_ROOT.exists()) {
TEST_ROOT.mkdirs();
}
conf = new Configuration();
conf.set(FileSystem.FS_DEFAULT_NAME_KEY, "file:///");
fs = FileSystem.get(conf);
// This test suite will fail if any ancestor directory of the
// test directory is not world-searchable (ie +x).
// We prefer to fail the test in an obvious manner up front
// during setUp() rather than in a subtle way later.
assertTrue("Test root directory " + TEST_ROOT + " and all of its " +
"parent directories must have a+x permissions",
TrackerDistributedCacheManager.ancestorsHaveExecutePermissions(
fs, new Path(TEST_ROOT.toString()), new HashMap<URI, FileStatus>()));
// Prepare the tests' mapred-local-dir
ROOT_MAPRED_LOCAL_DIR = new File(TEST_ROOT_DIR, "mapred/local");
ROOT_MAPRED_LOCAL_DIR.mkdirs();
String []localDirs = new String[numLocalDirs];
for (int i = 0; i < numLocalDirs; i++) {
File localDir = new File(ROOT_MAPRED_LOCAL_DIR, "0_" + i);
localDirs[i] = localDir.getPath();
localDir.mkdir();
}
conf.setStrings("mapred.local.dir", localDirs);
Class<? extends TaskController> taskControllerClass = conf.getClass(
"mapred.task.tracker.task-controller", DefaultTaskController.class,
TaskController.class);
taskController = (TaskController) ReflectionUtils.newInstance(
taskControllerClass, conf);
// setup permissions for mapred local dir
UtilsForTests.setupTC(taskController, localDirAllocator,
conf.getStrings(JobConf.MAPRED_LOCAL_DIR_PROPERTY));
// Create the temporary cache files to be used in the tests.
firstCacheFile = new Path(TEST_ROOT_DIR, "firstcachefile");
secondCacheFile = new Path(TEST_ROOT_DIR, "secondcachefile");
firstCacheFilePublic = new Path(TEST_ROOT_DIR, "firstcachefileOne");
secondCacheFilePublic = new Path(TEST_ROOT_DIR, "secondcachefileOne");
createPublicTempFile(firstCacheFilePublic);
createPublicTempFile(secondCacheFilePublic);
createPrivateTempFile(firstCacheFile);
createPrivateTempFile(secondCacheFile);
firstCacheDirPublic = new Path(TEST_ROOT_DIR, "firstcachedirPublic");
firstCacheDirPrivate = new Path(TEST_ROOT_DIR, "firstcachedirPrivate");
firstCacheFileInDirPublic = new Path(firstCacheDirPublic, "firstcacheFileinDirPublic.txt");
firstCacheFileInDirPrivate = new Path(firstCacheDirPrivate, "firstcacheFileinDirPrivate.txt");
createPublicTempDir(firstCacheDirPublic);
createPrivateTempDir(firstCacheDirPrivate);
createPublicTempFile(firstCacheFileInDirPublic);
createPrivateTempFile(firstCacheFileInDirPrivate);
}
示例2: refreshConf
import org.apache.hadoop.mapred.UtilsForTests; //导入方法依赖的package包/类
protected void refreshConf(Configuration conf) throws IOException {
taskController.setConf(conf);
UtilsForTests.setupTC(taskController, localDirAllocator,
conf.getStrings(JobConf.MAPRED_LOCAL_DIR_PROPERTY));
}
示例3: setUp
import org.apache.hadoop.mapred.UtilsForTests; //导入方法依赖的package包/类
@Override
protected void setUp() throws IOException,InterruptedException {
// Prepare the tests' root dir
File TEST_ROOT = new File(TEST_ROOT_DIR);
if (!TEST_ROOT.exists()) {
TEST_ROOT.mkdirs();
}
// Prepare the tests' mapred-local-dir
ROOT_MAPRED_LOCAL_DIR = new File(TEST_ROOT_DIR, "mapred/local");
ROOT_MAPRED_LOCAL_DIR.mkdirs();
String []localDirs = new String[numLocalDirs];
for (int i = 0; i < numLocalDirs; i++) {
File localDir = new File(ROOT_MAPRED_LOCAL_DIR, "0_" + i);
localDirs[i] = localDir.getPath();
localDir.mkdir();
}
conf = new Configuration();
conf.setStrings("mapred.local.dir", localDirs);
conf.set(FileSystem.FS_DEFAULT_NAME_KEY, "file:///");
fs = FileSystem.get(conf);
Class<? extends TaskController> taskControllerClass = conf.getClass(
"mapred.task.tracker.task-controller", DefaultTaskController.class,
TaskController.class);
taskController = (TaskController) ReflectionUtils.newInstance(
taskControllerClass, conf);
// setup permissions for mapred local dir
UtilsForTests.setupTC(taskController, localDirAllocator,
conf.getStrings(JobConf.MAPRED_LOCAL_DIR_PROPERTY));
// Create the temporary cache files to be used in the tests.
firstCacheFile = new Path(TEST_ROOT_DIR, "firstcachefile");
secondCacheFile = new Path(TEST_ROOT_DIR, "secondcachefile");
firstCacheFilePublic = new Path(TEST_ROOT_DIR, "firstcachefileOne");
secondCacheFilePublic = new Path(TEST_ROOT_DIR, "secondcachefileOne");
createPublicTempFile(firstCacheFilePublic);
createPublicTempFile(secondCacheFilePublic);
createPrivateTempFile(firstCacheFile);
createPrivateTempFile(secondCacheFile);
firstCacheDirPublic = new Path(TEST_ROOT_DIR, "firstcachedirPublic");
firstCacheDirPrivate = new Path(TEST_ROOT_DIR, "firstcachedirPrivate");
firstCacheFileInDirPublic = new Path(firstCacheDirPublic, "firstcacheFileinDirPublic.txt");
firstCacheFileInDirPrivate = new Path(firstCacheDirPrivate, "firstcacheFileinDirPrivate.txt");
createPublicTempDir(firstCacheDirPublic);
createPrivateTempDir(firstCacheDirPrivate);
createPublicTempFile(firstCacheFileInDirPublic);
createPrivateTempFile(firstCacheFileInDirPrivate);
}