当前位置: 首页>>代码示例>>Java>>正文


Java TestDirHelper.getTestDir方法代码示例

本文整理汇总了Java中org.apache.hadoop.test.TestDirHelper.getTestDir方法的典型用法代码示例。如果您正苦于以下问题:Java TestDirHelper.getTestDir方法的具体用法?Java TestDirHelper.getTestDir怎么用?Java TestDirHelper.getTestDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.test.TestDirHelper的用法示例。


在下文中一共展示了TestDirHelper.getTestDir方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: startMiniDFS

import org.apache.hadoop.test.TestDirHelper; //导入方法依赖的package包/类
/**
 * Fire up our own hand-rolled MiniDFSCluster.  We do this here instead
 * of relying on TestHdfsHelper because we don't want to turn on ACL
 * support.
 *
 * @throws Exception
 */
private void startMiniDFS() throws Exception {

  File testDirRoot = TestDirHelper.getTestDir();

  if (System.getProperty("hadoop.log.dir") == null) {
    System.setProperty("hadoop.log.dir",
            new File(testDirRoot, "hadoop-log").getAbsolutePath());
  }
  if (System.getProperty("test.build.data") == null) {
    System.setProperty("test.build.data",
            new File(testDirRoot, "hadoop-data").getAbsolutePath());
  }

  Configuration conf = HadoopUsersConfTestHelper.getBaseConf();
  HadoopUsersConfTestHelper.addUserConf(conf);
  conf.set("fs.hdfs.impl.disable.cache", "true");
  conf.set("dfs.block.access.token.enable", "false");
  conf.set("dfs.permissions", "true");
  conf.set("hadoop.security.authentication", "simple");

  // Explicitly turn off ACL support
  conf.setBoolean(DFSConfigKeys.DFS_NAMENODE_ACLS_ENABLED_KEY, false);

  MiniDFSCluster.Builder builder = new MiniDFSCluster.Builder(conf);
  builder.numDataNodes(2);
  miniDfs = builder.build();
  nnConf = miniDfs.getConfiguration(0);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:36,代码来源:TestHttpFSServerNoACLs.java

示例2: startMiniDFS

import org.apache.hadoop.test.TestDirHelper; //导入方法依赖的package包/类
/**
 * Fire up our own hand-rolled MiniDFSCluster.  We do this here instead
 * of relying on TestHdfsHelper because we don't want to turn on XAttr
 * support.
 *
 * @throws Exception
 */
private void startMiniDFS() throws Exception {

  File testDirRoot = TestDirHelper.getTestDir();

  if (System.getProperty("hadoop.log.dir") == null) {
    System.setProperty("hadoop.log.dir",
            new File(testDirRoot, "hadoop-log").getAbsolutePath());
  }
  if (System.getProperty("test.build.data") == null) {
    System.setProperty("test.build.data",
            new File(testDirRoot, "hadoop-data").getAbsolutePath());
  }

  Configuration conf = HadoopUsersConfTestHelper.getBaseConf();
  HadoopUsersConfTestHelper.addUserConf(conf);
  conf.set("fs.hdfs.impl.disable.cache", "true");
  conf.set("dfs.block.access.token.enable", "false");
  conf.set("dfs.permissions", "true");
  conf.set("hadoop.security.authentication", "simple");

  // Explicitly turn off XAttr support
  conf.setBoolean(DFSConfigKeys.DFS_NAMENODE_XATTRS_ENABLED_KEY, false);

  MiniDFSCluster.Builder builder = new MiniDFSCluster.Builder(conf);
  builder.numDataNodes(2);
  miniDfs = builder.build();
  nnConf = miniDfs.getConfiguration(0);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:36,代码来源:TestHttpFSServerNoXAttrs.java

示例3: initNoHomeDir

import org.apache.hadoop.test.TestDirHelper; //导入方法依赖的package包/类
@Test
@TestException(exception = ServerException.class, msgRegExp = "S01.*")
@TestDir
public void initNoHomeDir() throws Exception {
  File homeDir = new File(TestDirHelper.getTestDir(), "home");
  Configuration conf = new Configuration(false);
  conf.set("server.services", TestService.class.getName());
  Server server = new Server("server", homeDir.getAbsolutePath(), conf);
  server.init();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:11,代码来源:TestServer.java

示例4: initHomeDirNotDir

import org.apache.hadoop.test.TestDirHelper; //导入方法依赖的package包/类
@Test
@TestException(exception = ServerException.class, msgRegExp = "S02.*")
@TestDir
public void initHomeDirNotDir() throws Exception {
  File homeDir = new File(TestDirHelper.getTestDir(), "home");
  new FileOutputStream(homeDir).close();
  Configuration conf = new Configuration(false);
  conf.set("server.services", TestService.class.getName());
  Server server = new Server("server", homeDir.getAbsolutePath(), conf);
  server.init();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:12,代码来源:TestServer.java

示例5: initNoConfigDir

import org.apache.hadoop.test.TestDirHelper; //导入方法依赖的package包/类
@Test
@TestException(exception = ServerException.class, msgRegExp = "S01.*")
@TestDir
public void initNoConfigDir() throws Exception {
  File homeDir = new File(TestDirHelper.getTestDir(), "home");
  assertTrue(homeDir.mkdir());
  assertTrue(new File(homeDir, "log").mkdir());
  assertTrue(new File(homeDir, "temp").mkdir());
  Configuration conf = new Configuration(false);
  conf.set("server.services", TestService.class.getName());
  Server server = new Server("server", homeDir.getAbsolutePath(), conf);
  server.init();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:14,代码来源:TestServer.java

示例6: initConfigDirNotDir

import org.apache.hadoop.test.TestDirHelper; //导入方法依赖的package包/类
@Test
@TestException(exception = ServerException.class, msgRegExp = "S02.*")
@TestDir
public void initConfigDirNotDir() throws Exception {
  File homeDir = new File(TestDirHelper.getTestDir(), "home");
  assertTrue(homeDir.mkdir());
  assertTrue(new File(homeDir, "log").mkdir());
  assertTrue(new File(homeDir, "temp").mkdir());
  File configDir = new File(homeDir, "conf");
  new FileOutputStream(configDir).close();
  Configuration conf = new Configuration(false);
  conf.set("server.services", TestService.class.getName());
  Server server = new Server("server", homeDir.getAbsolutePath(), conf);
  server.init();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:16,代码来源:TestServer.java

示例7: initNoLogDir

import org.apache.hadoop.test.TestDirHelper; //导入方法依赖的package包/类
@Test
@TestException(exception = ServerException.class, msgRegExp = "S01.*")
@TestDir
public void initNoLogDir() throws Exception {
  File homeDir = new File(TestDirHelper.getTestDir(), "home");
  assertTrue(homeDir.mkdir());
  assertTrue(new File(homeDir, "conf").mkdir());
  assertTrue(new File(homeDir, "temp").mkdir());
  Configuration conf = new Configuration(false);
  conf.set("server.services", TestService.class.getName());
  Server server = new Server("server", homeDir.getAbsolutePath(), conf);
  server.init();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:14,代码来源:TestServer.java

示例8: initLogDirNotDir

import org.apache.hadoop.test.TestDirHelper; //导入方法依赖的package包/类
@Test
@TestException(exception = ServerException.class, msgRegExp = "S02.*")
@TestDir
public void initLogDirNotDir() throws Exception {
  File homeDir = new File(TestDirHelper.getTestDir(), "home");
  assertTrue(homeDir.mkdir());
  assertTrue(new File(homeDir, "conf").mkdir());
  assertTrue(new File(homeDir, "temp").mkdir());
  File logDir = new File(homeDir, "log");
  new FileOutputStream(logDir).close();
  Configuration conf = new Configuration(false);
  conf.set("server.services", TestService.class.getName());
  Server server = new Server("server", homeDir.getAbsolutePath(), conf);
  server.init();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:16,代码来源:TestServer.java

示例9: initNoTempDir

import org.apache.hadoop.test.TestDirHelper; //导入方法依赖的package包/类
@Test
@TestException(exception = ServerException.class, msgRegExp = "S01.*")
@TestDir
public void initNoTempDir() throws Exception {
  File homeDir = new File(TestDirHelper.getTestDir(), "home");
  assertTrue(homeDir.mkdir());
  assertTrue(new File(homeDir, "conf").mkdir());
  assertTrue(new File(homeDir, "log").mkdir());
  Configuration conf = new Configuration(false);
  conf.set("server.services", TestService.class.getName());
  Server server = new Server("server", homeDir.getAbsolutePath(), conf);
  server.init();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:14,代码来源:TestServer.java

示例10: initTempDirNotDir

import org.apache.hadoop.test.TestDirHelper; //导入方法依赖的package包/类
@Test
@TestException(exception = ServerException.class, msgRegExp = "S02.*")
@TestDir
public void initTempDirNotDir() throws Exception {
  File homeDir = new File(TestDirHelper.getTestDir(), "home");
  assertTrue(homeDir.mkdir());
  assertTrue(new File(homeDir, "conf").mkdir());
  assertTrue(new File(homeDir, "log").mkdir());
  File tempDir = new File(homeDir, "temp");
  new FileOutputStream(tempDir).close();
  Configuration conf = new Configuration(false);
  conf.set("server.services", TestService.class.getName());
  Server server = new Server("server", homeDir.getAbsolutePath(), conf);
  server.init();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:16,代码来源:TestServer.java

示例11: log4jFile

import org.apache.hadoop.test.TestDirHelper; //导入方法依赖的package包/类
@Test
@TestDir
public void log4jFile() throws Exception {
  InputStream is = Server.getResource("default-log4j.properties");
  OutputStream os = new FileOutputStream(new File(TestDirHelper.getTestDir(), "server-log4j.properties"));
  IOUtils.copyBytes(is, os, 1024, true);
  Configuration conf = new Configuration(false);
  Server server = createServer(conf);
  server.init();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:11,代码来源:TestServer.java

示例12: createHttpFSServer

import org.apache.hadoop.test.TestDirHelper; //导入方法依赖的package包/类
private void createHttpFSServer() throws Exception {
  File homeDir = TestDirHelper.getTestDir();
  Assert.assertTrue(new File(homeDir, "conf").mkdir());
  Assert.assertTrue(new File(homeDir, "log").mkdir());
  Assert.assertTrue(new File(homeDir, "temp").mkdir());
  HttpFSServerWebApp.setHomeDirForCurrentThread(homeDir.getAbsolutePath());

  File secretFile = new File(new File(homeDir, "conf"), "secret");
  Writer w = new FileWriter(secretFile);
  w.write("secret");
  w.close();

  //HDFS configuration
  File hadoopConfDir = new File(new File(homeDir, "conf"), "hadoop-conf");
  hadoopConfDir.mkdirs();
  String fsDefaultName = TestHdfsHelper.getHdfsConf()
    .get(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY);
  Configuration conf = new Configuration(false);
  conf.set(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY, fsDefaultName);
  File hdfsSite = new File(hadoopConfDir, "hdfs-site.xml");
  OutputStream os = new FileOutputStream(hdfsSite);
  conf.writeXml(os);
  os.close();

  conf = new Configuration(false);
  conf.set("httpfs.proxyuser.client.hosts", "*");
  conf.set("httpfs.proxyuser.client.groups", "*");

  conf.set("httpfs.authentication.type", "kerberos");

  conf.set("httpfs.authentication.signature.secret.file",
           secretFile.getAbsolutePath());
  File httpfsSite = new File(new File(homeDir, "conf"), "httpfs-site.xml");
  os = new FileOutputStream(httpfsSite);
  conf.writeXml(os);
  os.close();

  ClassLoader cl = Thread.currentThread().getContextClassLoader();
  URL url = cl.getResource("webapp");
  WebAppContext context = new WebAppContext(url.getPath(), "/webhdfs");
  Server server = TestJettyHelper.getJettyServer();
  server.addHandler(context);
  server.start();
  HttpFSServerWebApp.get().setAuthority(TestJettyHelper.getAuthority());
}
 
开发者ID:yncxcw,项目名称:big-c,代码行数:46,代码来源:TestHttpFSWithKerberos.java

示例13: createHttpFSServer

import org.apache.hadoop.test.TestDirHelper; //导入方法依赖的package包/类
/**
 * Create an HttpFS Server to talk to the MiniDFSCluster we created.
 * @throws Exception
 */
private void createHttpFSServer() throws Exception {
  File homeDir = TestDirHelper.getTestDir();
  Assert.assertTrue(new File(homeDir, "conf").mkdir());
  Assert.assertTrue(new File(homeDir, "log").mkdir());
  Assert.assertTrue(new File(homeDir, "temp").mkdir());
  HttpFSServerWebApp.setHomeDirForCurrentThread(homeDir.getAbsolutePath());

  File secretFile = new File(new File(homeDir, "conf"), "secret");
  Writer w = new FileWriter(secretFile);
  w.write("secret");
  w.close();

  // HDFS configuration
  File hadoopConfDir = new File(new File(homeDir, "conf"), "hadoop-conf");
  if ( !hadoopConfDir.mkdirs() ) {
    throw new IOException();
  }

  String fsDefaultName =
          nnConf.get(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY);
  Configuration conf = new Configuration(false);
  conf.set(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY, fsDefaultName);

  // Explicitly turn off ACLs, just in case the default becomes true later
  conf.setBoolean(DFSConfigKeys.DFS_NAMENODE_ACLS_ENABLED_KEY, false);

  File hdfsSite = new File(hadoopConfDir, "hdfs-site.xml");
  OutputStream os = new FileOutputStream(hdfsSite);
  conf.writeXml(os);
  os.close();

  // HTTPFS configuration
  conf = new Configuration(false);
  conf.set("httpfs.hadoop.config.dir", hadoopConfDir.toString());
  conf.set("httpfs.proxyuser." +
                  HadoopUsersConfTestHelper.getHadoopProxyUser() + ".groups",
          HadoopUsersConfTestHelper.getHadoopProxyUserGroups());
  conf.set("httpfs.proxyuser." +
                  HadoopUsersConfTestHelper.getHadoopProxyUser() + ".hosts",
          HadoopUsersConfTestHelper.getHadoopProxyUserHosts());
  conf.set("httpfs.authentication.signature.secret.file",
          secretFile.getAbsolutePath());

  File httpfsSite = new File(new File(homeDir, "conf"), "httpfs-site.xml");
  os = new FileOutputStream(httpfsSite);
  conf.writeXml(os);
  os.close();

  ClassLoader cl = Thread.currentThread().getContextClassLoader();
  URL url = cl.getResource("webapp");
  if ( url == null ) {
    throw new IOException();
  }
  WebAppContext context = new WebAppContext(url.getPath(), "/webhdfs");
  Server server = TestJettyHelper.getJettyServer();
  server.addHandler(context);
  server.start();
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:63,代码来源:TestHttpFSServerNoACLs.java

示例14: createHttpFSServer

import org.apache.hadoop.test.TestDirHelper; //导入方法依赖的package包/类
private void createHttpFSServer(boolean addDelegationTokenAuthHandler)
  throws Exception {
  File homeDir = TestDirHelper.getTestDir();
  Assert.assertTrue(new File(homeDir, "conf").mkdir());
  Assert.assertTrue(new File(homeDir, "log").mkdir());
  Assert.assertTrue(new File(homeDir, "temp").mkdir());
  HttpFSServerWebApp.setHomeDirForCurrentThread(homeDir.getAbsolutePath());

  File secretFile = new File(new File(homeDir, "conf"), "secret");
  Writer w = new FileWriter(secretFile);
  w.write("secret");
  w.close();

  //HDFS configuration
  File hadoopConfDir = new File(new File(homeDir, "conf"), "hadoop-conf");
  hadoopConfDir.mkdirs();
  String fsDefaultName = TestHdfsHelper.getHdfsConf().get(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY);
  Configuration conf = new Configuration(false);
  conf.set(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY, fsDefaultName);
  conf.setBoolean(DFSConfigKeys.DFS_NAMENODE_ACLS_ENABLED_KEY, true);
  conf.setBoolean(DFSConfigKeys.DFS_NAMENODE_XATTRS_ENABLED_KEY, true);
  File hdfsSite = new File(hadoopConfDir, "hdfs-site.xml");
  OutputStream os = new FileOutputStream(hdfsSite);
  conf.writeXml(os);
  os.close();

  //HTTPFS configuration
  conf = new Configuration(false);
  if (addDelegationTokenAuthHandler) {
   conf.set("httpfs.authentication.type",
            HttpFSKerberosAuthenticationHandlerForTesting.class.getName());
  }
  conf.set("httpfs.services.ext", MockGroups.class.getName());
  conf.set("httpfs.admin.group", HadoopUsersConfTestHelper.
    getHadoopUserGroups(HadoopUsersConfTestHelper.getHadoopUsers()[0])[0]);
  conf.set("httpfs.proxyuser." + HadoopUsersConfTestHelper.getHadoopProxyUser() + ".groups",
           HadoopUsersConfTestHelper.getHadoopProxyUserGroups());
  conf.set("httpfs.proxyuser." + HadoopUsersConfTestHelper.getHadoopProxyUser() + ".hosts",
           HadoopUsersConfTestHelper.getHadoopProxyUserHosts());
  conf.set("httpfs.authentication.signature.secret.file", secretFile.getAbsolutePath());
  conf.set("httpfs.hadoop.config.dir", hadoopConfDir.toString());
  File httpfsSite = new File(new File(homeDir, "conf"), "httpfs-site.xml");
  os = new FileOutputStream(httpfsSite);
  conf.writeXml(os);
  os.close();

  ClassLoader cl = Thread.currentThread().getContextClassLoader();
  URL url = cl.getResource("webapp");
  WebAppContext context = new WebAppContext(url.getPath(), "/webhdfs");
  Server server = TestJettyHelper.getJettyServer();
  server.addHandler(context);
  server.start();
  if (addDelegationTokenAuthHandler) {
    HttpFSServerWebApp.get().setAuthority(TestJettyHelper.getAuthority());
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:57,代码来源:TestHttpFSServer.java


注:本文中的org.apache.hadoop.test.TestDirHelper.getTestDir方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。