本文整理汇总了Java中org.apache.hadoop.test.TestDirHelper类的典型用法代码示例。如果您正苦于以下问题:Java TestDirHelper类的具体用法?Java TestDirHelper怎么用?Java TestDirHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TestDirHelper类属于org.apache.hadoop.test包,在下文中一共展示了TestDirHelper类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: lifecycle
import org.apache.hadoop.test.TestDirHelper; //导入依赖的package包/类
@Test
@TestDir
public void lifecycle() throws Exception {
String dir = TestDirHelper.getTestDir().getAbsolutePath();
System.setProperty("TestServerWebApp1.home.dir", dir);
System.setProperty("TestServerWebApp1.config.dir", dir);
System.setProperty("TestServerWebApp1.log.dir", dir);
System.setProperty("TestServerWebApp1.temp.dir", dir);
ServerWebApp server = new ServerWebApp("TestServerWebApp1") {
};
assertEquals(server.getStatus(), Server.Status.UNDEF);
server.contextInitialized(null);
assertEquals(server.getStatus(), Server.Status.NORMAL);
server.contextDestroyed(null);
assertEquals(server.getStatus(), Server.Status.SHUTDOWN);
}
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:TestServerWebApp.java
示例2: testResolveAuthority
import org.apache.hadoop.test.TestDirHelper; //导入依赖的package包/类
@Test
@TestDir
public void testResolveAuthority() throws Exception {
String dir = TestDirHelper.getTestDir().getAbsolutePath();
System.setProperty("TestServerWebApp3.home.dir", dir);
System.setProperty("TestServerWebApp3.config.dir", dir);
System.setProperty("TestServerWebApp3.log.dir", dir);
System.setProperty("TestServerWebApp3.temp.dir", dir);
System.setProperty("testserverwebapp3.http.hostname", "localhost");
System.setProperty("testserverwebapp3.http.port", "14000");
ServerWebApp server = new ServerWebApp("TestServerWebApp3") {
};
InetSocketAddress address = server.resolveAuthority();
Assert.assertEquals("localhost", address.getHostName());
Assert.assertEquals(14000, address.getPort());
}
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:TestServerWebApp.java
示例3: noKerberosKeytabProperty
import org.apache.hadoop.test.TestDirHelper; //导入依赖的package包/类
@Test
@TestException(exception = ServiceException.class, msgRegExp = "H01.*")
@TestDir
public void noKerberosKeytabProperty() throws Exception {
String dir = TestDirHelper.getTestDir().getAbsolutePath();
String services = StringUtils.join(",",
Arrays.asList(InstrumentationService.class.getName(),
SchedulerService.class.getName(),
FileSystemAccessService.class.getName()));
Configuration conf = new Configuration(false);
conf.set("server.services", services);
conf.set("server.hadoop.authentication.type", "kerberos");
conf.set("server.hadoop.authentication.kerberos.keytab", " ");
Server server = new Server("server", dir, dir, dir, dir, conf);
server.init();
}
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:TestFileSystemAccessService.java
示例4: noKerberosPrincipalProperty
import org.apache.hadoop.test.TestDirHelper; //导入依赖的package包/类
@Test
@TestException(exception = ServiceException.class, msgRegExp = "H01.*")
@TestDir
public void noKerberosPrincipalProperty() throws Exception {
String dir = TestDirHelper.getTestDir().getAbsolutePath();
String services = StringUtils.join(",",
Arrays.asList(InstrumentationService.class.getName(),
SchedulerService.class.getName(),
FileSystemAccessService.class.getName()));
Configuration conf = new Configuration(false);
conf.set("server.services", services);
conf.set("server.hadoop.authentication.type", "kerberos");
conf.set("server.hadoop.authentication.kerberos.keytab", "/tmp/foo");
conf.set("server.hadoop.authentication.kerberos.principal", " ");
Server server = new Server("server", dir, dir, dir, dir, conf);
server.init();
}
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:TestFileSystemAccessService.java
示例5: kerberosInitializationFailure
import org.apache.hadoop.test.TestDirHelper; //导入依赖的package包/类
@Test
@TestException(exception = ServiceException.class, msgRegExp = "H02.*")
@TestDir
public void kerberosInitializationFailure() throws Exception {
String dir = TestDirHelper.getTestDir().getAbsolutePath();
String services = StringUtils.join(",",
Arrays.asList(InstrumentationService.class.getName(),
SchedulerService.class.getName(),
FileSystemAccessService.class.getName()));
Configuration conf = new Configuration(false);
conf.set("server.services", services);
conf.set("server.hadoop.authentication.type", "kerberos");
conf.set("server.hadoop.authentication.kerberos.keytab", "/tmp/foo");
conf.set("server.hadoop.authentication.kerberos.principal", "[email protected]");
Server server = new Server("server", dir, dir, dir, dir, conf);
server.init();
}
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:TestFileSystemAccessService.java
示例6: serviceHadoopConf
import org.apache.hadoop.test.TestDirHelper; //导入依赖的package包/类
@Test
@TestDir
public void serviceHadoopConf() throws Exception {
String dir = TestDirHelper.getTestDir().getAbsolutePath();
String services = StringUtils.join(",",
Arrays.asList(InstrumentationService.class.getName(),
SchedulerService.class.getName(),
FileSystemAccessService.class.getName()));
Configuration conf = new Configuration(false);
conf.set("server.services", services);
Server server = new Server("server", dir, dir, dir, dir, conf);
server.init();
FileSystemAccessService fsAccess = (FileSystemAccessService) server.get(FileSystemAccess.class);
Assert.assertEquals(fsAccess.serviceHadoopConf.get("foo"), "FOO");
server.destroy();
}
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:TestFileSystemAccessService.java
示例7: NameNodeNotinWhitelists
import org.apache.hadoop.test.TestDirHelper; //导入依赖的package包/类
@Test
@TestException(exception = FileSystemAccessException.class, msgRegExp = "H05.*")
@TestDir
public void NameNodeNotinWhitelists() throws Exception {
String dir = TestDirHelper.getTestDir().getAbsolutePath();
String services = StringUtils.join(",",
Arrays.asList(InstrumentationService.class.getName(),
SchedulerService.class.getName(),
FileSystemAccessService.class.getName()));
Configuration conf = new Configuration(false);
conf.set("server.services", services);
conf.set("server.hadoop.name.node.whitelist", "NN");
Server server = new Server("server", dir, dir, dir, dir, conf);
server.init();
FileSystemAccessService fsAccess = (FileSystemAccessService) server.get(FileSystemAccess.class);
fsAccess.validateNamenode("NNx");
}
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:TestFileSystemAccessService.java
示例8: loadingSysPropConfig
import org.apache.hadoop.test.TestDirHelper; //导入依赖的package包/类
@Test
@TestDir
public void loadingSysPropConfig() throws Exception {
try {
System.setProperty("testserver.a", "sysprop");
String dir = TestDirHelper.getTestDir().getAbsolutePath();
File configFile = new File(dir, "testserver-site.xml");
Writer w = new FileWriter(configFile);
w.write("<configuration><property><name>testserver.a</name><value>site</value></property></configuration>");
w.close();
Server server = new Server("testserver", dir, dir, dir, dir);
server.init();
assertEquals(server.getConfig().get("testserver.a"), "sysprop");
} finally {
System.getProperties().remove("testserver.a");
}
}
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:TestServer.java
示例9: 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
示例10: 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
示例11: failedInit
import org.apache.hadoop.test.TestDirHelper; //导入依赖的package包/类
@Test(expected = RuntimeException.class)
@TestDir
public void failedInit() throws Exception {
String dir = TestDirHelper.getTestDir().getAbsolutePath();
System.setProperty("TestServerWebApp2.home.dir", dir);
System.setProperty("TestServerWebApp2.config.dir", dir);
System.setProperty("TestServerWebApp2.log.dir", dir);
System.setProperty("TestServerWebApp2.temp.dir", dir);
System.setProperty("testserverwebapp2.services", "FOO");
ServerWebApp server = new ServerWebApp("TestServerWebApp2") {
};
server.contextInitialized(null);
}
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:TestServerWebApp.java
示例12: createHadoopConf
import org.apache.hadoop.test.TestDirHelper; //导入依赖的package包/类
private void createHadoopConf(Configuration hadoopConf) throws Exception {
String dir = TestDirHelper.getTestDir().getAbsolutePath();
File hdfsSite = new File(dir, "hdfs-site.xml");
OutputStream os = new FileOutputStream(hdfsSite);
hadoopConf.writeXml(os);
os.close();
}
开发者ID:naver,项目名称:hadoop,代码行数:8,代码来源:TestFileSystemAccessService.java
示例13: simpleSecurity
import org.apache.hadoop.test.TestDirHelper; //导入依赖的package包/类
@Test
@TestDir
public void simpleSecurity() throws Exception {
String dir = TestDirHelper.getTestDir().getAbsolutePath();
String services = StringUtils.join(",",
Arrays.asList(InstrumentationService.class.getName(),
SchedulerService.class.getName(),
FileSystemAccessService.class.getName()));
Configuration conf = new Configuration(false);
conf.set("server.services", services);
Server server = new Server("server", dir, dir, dir, dir, conf);
server.init();
Assert.assertNotNull(server.get(FileSystemAccess.class));
server.destroy();
}
开发者ID:naver,项目名称:hadoop,代码行数:16,代码来源:TestFileSystemAccessService.java
示例14: invalidSecurity
import org.apache.hadoop.test.TestDirHelper; //导入依赖的package包/类
@Test
@TestException(exception = ServiceException.class, msgRegExp = "H09.*")
@TestDir
public void invalidSecurity() throws Exception {
String dir = TestDirHelper.getTestDir().getAbsolutePath();
String services = StringUtils.join(",",
Arrays.asList(InstrumentationService.class.getName(),
SchedulerService.class.getName(),
FileSystemAccessService.class.getName()));
Configuration conf = new Configuration(false);
conf.set("server.services", services);
conf.set("server.hadoop.authentication.type", "foo");
Server server = new Server("server", dir, dir, dir, dir, conf);
server.init();
}
开发者ID:naver,项目名称:hadoop,代码行数:16,代码来源:TestFileSystemAccessService.java
示例15: serviceHadoopConfCustomDir
import org.apache.hadoop.test.TestDirHelper; //导入依赖的package包/类
@Test
@TestDir
public void serviceHadoopConfCustomDir() throws Exception {
String dir = TestDirHelper.getTestDir().getAbsolutePath();
String hadoopConfDir = new File(dir, "confx").getAbsolutePath();
new File(hadoopConfDir).mkdirs();
String services = StringUtils.join(",",
Arrays.asList(InstrumentationService.class.getName(),
SchedulerService.class.getName(),
FileSystemAccessService.class.getName()));
Configuration conf = new Configuration(false);
conf.set("server.services", services);
conf.set("server.hadoop.config.dir", hadoopConfDir);
File hdfsSite = new File(hadoopConfDir, "hdfs-site.xml");
OutputStream os = new FileOutputStream(hdfsSite);
Configuration hadoopConf = new Configuration(false);
hadoopConf.set("foo", "BAR");
hadoopConf.writeXml(os);
os.close();
Server server = new Server("server", dir, dir, dir, dir, conf);
server.init();
FileSystemAccessService fsAccess = (FileSystemAccessService) server.get(FileSystemAccess.class);
Assert.assertEquals(fsAccess.serviceHadoopConf.get("foo"), "BAR");
server.destroy();
}
开发者ID:naver,项目名称:hadoop,代码行数:28,代码来源:TestFileSystemAccessService.java
示例16: fileSystemExecutorNoNameNode
import org.apache.hadoop.test.TestDirHelper; //导入依赖的package包/类
@Test
@TestException(exception = FileSystemAccessException.class, msgRegExp = "H06.*")
@TestDir
@TestHdfs
public void fileSystemExecutorNoNameNode() throws Exception {
String dir = TestDirHelper.getTestDir().getAbsolutePath();
String services = StringUtils.join(",",
Arrays.asList(InstrumentationService.class.getName(),
SchedulerService.class.getName(),
FileSystemAccessService.class.getName()));
Configuration hadoopConf = new Configuration(false);
hadoopConf.set(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY, TestHdfsHelper.getHdfsConf().get(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY));
createHadoopConf(hadoopConf);
Configuration conf = new Configuration(false);
conf.set("server.services", services);
Server server = new Server("server", dir, dir, dir, dir, conf);
server.init();
FileSystemAccess fsAccess = server.get(FileSystemAccess.class);
Configuration hdfsConf = fsAccess.getFileSystemConfiguration();
hdfsConf.set(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY, "");
fsAccess.execute("u", hdfsConf, new FileSystemAccess.FileSystemExecutor<Void>() {
@Override
public Void execute(FileSystem fs) throws IOException {
return null;
}
});
}
开发者ID:naver,项目名称:hadoop,代码行数:30,代码来源:TestFileSystemAccessService.java
示例17: service
import org.apache.hadoop.test.TestDirHelper; //导入依赖的package包/类
@Test
@TestDir
public void service() throws Exception {
String dir = TestDirHelper.getTestDir().getAbsolutePath();
Configuration conf = new Configuration(false);
conf.set("server.services", StringUtils.join(",", Arrays.asList(GroupsService.class.getName())));
Server server = new Server("server", dir, dir, dir, dir, conf);
server.init();
Groups groups = server.get(Groups.class);
assertNotNull(groups);
List<String> g = groups.getGroups(System.getProperty("user.name"));
assertNotSame(g.size(), 0);
server.destroy();
}
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:TestGroupsService.java
示例18: invalidGroupsMapping
import org.apache.hadoop.test.TestDirHelper; //导入依赖的package包/类
@Test(expected = RuntimeException.class)
@TestDir
public void invalidGroupsMapping() throws Exception {
String dir = TestDirHelper.getTestDir().getAbsolutePath();
Configuration conf = new Configuration(false);
conf.set("server.services", StringUtils.join(",", Arrays.asList(GroupsService.class.getName())));
conf.set("server.groups.hadoop.security.group.mapping", String.class.getName());
Server server = new Server("server", dir, dir, dir, dir, conf);
server.init();
}
开发者ID:naver,项目名称:hadoop,代码行数:11,代码来源:TestGroupsService.java
示例19: service
import org.apache.hadoop.test.TestDirHelper; //导入依赖的package包/类
@Test
@TestDir
public void service() throws Exception {
String dir = TestDirHelper.getTestDir().getAbsolutePath();
Configuration conf = new Configuration(false);
conf.set("server.services", StringUtils.join(",", Arrays.asList(InstrumentationService.class.getName(),
SchedulerService.class.getName())));
Server server = new Server("server", dir, dir, dir, dir, conf);
server.init();
assertNotNull(server.get(Scheduler.class));
server.destroy();
}
开发者ID:naver,项目名称:hadoop,代码行数:13,代码来源:TestSchedulerService.java
示例20: sampling
import org.apache.hadoop.test.TestDirHelper; //导入依赖的package包/类
@Test
@TestDir
@SuppressWarnings("unchecked")
public void sampling() throws Exception {
String dir = TestDirHelper.getTestDir().getAbsolutePath();
String services = StringUtils.join(",", Arrays.asList(InstrumentationService.class.getName(),
SchedulerService.class.getName()));
Configuration conf = new Configuration(false);
conf.set("server.services", services);
Server server = new Server("server", dir, dir, dir, dir, conf);
server.init();
Instrumentation instrumentation = server.get(Instrumentation.class);
final AtomicInteger count = new AtomicInteger();
Instrumentation.Variable<Long> varToSample = new Instrumentation.Variable<Long>() {
@Override
public Long getValue() {
return (long) count.incrementAndGet();
}
};
instrumentation.addSampler("g", "s", 10, varToSample);
sleep(2000);
int i = count.get();
assertTrue(i > 0);
Map<String, Map<String, ?>> snapshot = instrumentation.getSnapshot();
Map<String, Map<String, Object>> samplers = (Map<String, Map<String, Object>>) snapshot.get("samplers");
InstrumentationService.Sampler sampler = (InstrumentationService.Sampler) samplers.get("g").get("s");
assertTrue(sampler.getRate() > 0);
server.destroy();
}
开发者ID:naver,项目名称:hadoop,代码行数:35,代码来源:TestInstrumentationService.java
注:本文中的org.apache.hadoop.test.TestDirHelper类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论