• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java TestHdfs类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



TestHdfs类属于org.apache.hadoop.test包,在下文中一共展示了TestHdfs类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testOperationDoAs

import org.apache.hadoop.test.TestHdfs; //导入依赖的package包/类
@Test
@TestDir
@TestJetty
@TestHdfs
public void testOperationDoAs() throws Exception {
  createHttpFSServer();
  UserGroupInformation ugi = UserGroupInformation.createProxyUser(HadoopUsersConfTestHelper.getHadoopUsers()[0],
                                                                  UserGroupInformation.getCurrentUser());
  ugi.doAs(new PrivilegedExceptionAction<Void>() {
    @Override
    public Void run() throws Exception {
      operation(operation);
      return null;
    }
  });
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:BaseTestHttpFSWith.java


示例2: testWithXAttrs

import org.apache.hadoop.test.TestHdfs; //导入依赖的package包/类
/**
 * Ensure that GETXATTRS, SETXATTR, REMOVEXATTR fail.
 */
@Test
@TestDir
@TestJetty
@TestHdfs
public void testWithXAttrs() throws Exception {
  final String name1 = "user.a1";
  final byte[] value1 = new byte[]{0x31, 0x32, 0x33};
  final String dir = "/noXAttr";
  final String path = dir + "/file";
  
  startMiniDFS();
  createHttpFSServer();
  
  FileSystem fs = FileSystem.get(nnConf);
  fs.mkdirs(new Path(dir));
  OutputStream os = fs.create(new Path(path));
  os.write(1);
  os.close();
  
  /* GETXATTRS, SETXATTR, REMOVEXATTR fail */
  getStatus(path, "GETXATTRS");
  putCmd(path, "SETXATTR", TestHttpFSServer.setXAttrParam(name1, value1));
  putCmd(path, "REMOVEXATTR", "xattr.name=" + name1);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:28,代码来源:TestHttpFSServerNoXAttrs.java


示例3: testValidHttpFSAccess

import org.apache.hadoop.test.TestHdfs; //导入依赖的package包/类
@Test
@TestDir
@TestJetty
@TestHdfs
public void testValidHttpFSAccess() throws Exception {
  createHttpFSServer();

  KerberosTestUtils.doAsClient(new Callable<Void>() {
    @Override
    public Void call() throws Exception {
      URL url = new URL(TestJettyHelper.getJettyURL(),
                        "/webhdfs/v1/?op=GETHOMEDIRECTORY");
      AuthenticatedURL aUrl = new AuthenticatedURL();
      AuthenticatedURL.Token aToken = new AuthenticatedURL.Token();
      HttpURLConnection conn = aUrl.openConnection(url, aToken);
      Assert.assertEquals(conn.getResponseCode(), HttpURLConnection.HTTP_OK);
      return null;
    }
  });
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:TestHttpFSWithKerberos.java


示例4: testHdfsAccess

import org.apache.hadoop.test.TestHdfs; //导入依赖的package包/类
@Test
@TestDir
@TestJetty
@TestHdfs
public void testHdfsAccess() throws Exception {
  createHttpFSServer(false);

  String user = HadoopUsersConfTestHelper.getHadoopUsers()[0];
  URL url = new URL(TestJettyHelper.getJettyURL(),
                    MessageFormat.format("/webhdfs/v1/?user.name={0}&op=liststatus", user));
  HttpURLConnection conn = (HttpURLConnection) url.openConnection();
  Assert.assertEquals(conn.getResponseCode(), HttpURLConnection.HTTP_OK);
  BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
  reader.readLine();
  reader.close();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:TestHttpFSServer.java


示例5: testGlobFilter

import org.apache.hadoop.test.TestHdfs; //导入依赖的package包/类
@Test
@TestDir
@TestJetty
@TestHdfs
public void testGlobFilter() throws Exception {
  createHttpFSServer(false);

  FileSystem fs = FileSystem.get(TestHdfsHelper.getHdfsConf());
  fs.mkdirs(new Path("/tmp"));
  fs.create(new Path("/tmp/foo.txt")).close();

  String user = HadoopUsersConfTestHelper.getHadoopUsers()[0];
  URL url = new URL(TestJettyHelper.getJettyURL(),
                    MessageFormat.format("/webhdfs/v1/tmp?user.name={0}&op=liststatus&filter=f*", user));
  HttpURLConnection conn = (HttpURLConnection) url.openConnection();
  Assert.assertEquals(conn.getResponseCode(), HttpURLConnection.HTTP_OK);
  BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
  reader.readLine();
  reader.close();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:TestHttpFSServer.java


示例6: testOpenOffsetLength

import org.apache.hadoop.test.TestHdfs; //导入依赖的package包/类
@Test
@TestDir
@TestJetty
@TestHdfs
public void testOpenOffsetLength() throws Exception {
  createHttpFSServer(false);

  byte[] array = new byte[]{0, 1, 2, 3};
  FileSystem fs = FileSystem.get(TestHdfsHelper.getHdfsConf());
  fs.mkdirs(new Path("/tmp"));
  OutputStream os = fs.create(new Path("/tmp/foo"));
  os.write(array);
  os.close();

  String user = HadoopUsersConfTestHelper.getHadoopUsers()[0];
  URL url = new URL(TestJettyHelper.getJettyURL(),
                    MessageFormat.format("/webhdfs/v1/tmp/foo?user.name={0}&op=open&offset=1&length=2", user));
  HttpURLConnection conn = (HttpURLConnection) url.openConnection();
  Assert.assertEquals(HttpURLConnection.HTTP_OK, conn.getResponseCode());
  InputStream is = conn.getInputStream();
  Assert.assertEquals(1, is.read());
  Assert.assertEquals(2, is.read());
  Assert.assertEquals(-1, is.read());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:TestHttpFSServer.java


示例7: testPutNoOperation

import org.apache.hadoop.test.TestHdfs; //导入依赖的package包/类
@Test
@TestDir
@TestJetty
@TestHdfs
public void testPutNoOperation() throws Exception {
  createHttpFSServer(false);

  String user = HadoopUsersConfTestHelper.getHadoopUsers()[0];
  URL url = new URL(TestJettyHelper.getJettyURL(),
                    MessageFormat.format("/webhdfs/v1/foo?user.name={0}", user));
  HttpURLConnection conn = (HttpURLConnection) url.openConnection();
  conn.setDoInput(true);
  conn.setDoOutput(true);
  conn.setRequestMethod("PUT");
  Assert.assertEquals(conn.getResponseCode(), HttpURLConnection.HTTP_BAD_REQUEST);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:TestHttpFSServer.java


示例8: testOperationDoAs

import org.apache.hadoop.test.TestHdfs; //导入依赖的package包/类
@Test
@TestDir
@TestJetty
@TestHdfs
public void testOperationDoAs() throws Exception {
  createHttpFSServer();
  UserGroupInformation ugi = UserGroupInformation
      .createProxyUser(HadoopUsersConfTestHelper.getHadoopUsers()[0],
          UserGroupInformation.getCurrentUser());
  ugi.doAs(new PrivilegedExceptionAction<Void>() {
    @Override
    public Void run() throws Exception {
      operation(operation);
      return null;
    }
  });
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:18,代码来源:BaseTestHttpFSWith.java


示例9: testValidHttpFSAccess

import org.apache.hadoop.test.TestHdfs; //导入依赖的package包/类
@Test
@TestDir
@TestJetty
@TestHdfs
@Ignore
public void testValidHttpFSAccess() throws Exception {
  createHttpFSServer();

  KerberosTestUtils.doAsClient(new Callable<Void>() {
    @Override
    public Void call() throws Exception {
      URL url = new URL(TestJettyHelper.getJettyURL(),
          "/webhdfs/v1/?op=GETHOMEDIRECTORY");
      AuthenticatedURL aUrl = new AuthenticatedURL();
      AuthenticatedURL.Token aToken = new AuthenticatedURL.Token();
      HttpURLConnection conn = aUrl.openConnection(url, aToken);
      Assert.assertEquals(conn.getResponseCode(), HttpURLConnection.HTTP_OK);
      return null;
    }
  });
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:22,代码来源:TestHttpFSWithKerberos.java


示例10: testHdfsAccess

import org.apache.hadoop.test.TestHdfs; //导入依赖的package包/类
@Test
@TestDir
@TestJetty
@TestHdfs
public void testHdfsAccess() throws Exception {
  createHttpFSServer(false);

  String user = HadoopUsersConfTestHelper.getHadoopUsers()[0];
  URL url = new URL(TestJettyHelper.getJettyURL(),
      MessageFormat.format("/webhdfs/v1/?user.name={0}&op=liststatus", user));
  HttpURLConnection conn = (HttpURLConnection) url.openConnection();
  Assert.assertEquals(conn.getResponseCode(), HttpURLConnection.HTTP_OK);
  BufferedReader reader =
      new BufferedReader(new InputStreamReader(conn.getInputStream()));
  reader.readLine();
  reader.close();
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:18,代码来源:TestHttpFSServer.java


示例11: testGlobFilter

import org.apache.hadoop.test.TestHdfs; //导入依赖的package包/类
@Test
@TestDir
@TestJetty
@TestHdfs
public void testGlobFilter() throws Exception {
  createHttpFSServer(false);

  FileSystem fs = FileSystem.get(TestHdfsHelper.getHdfsConf());
  fs.mkdirs(new Path("/tmp"));
  fs.create(new Path("/tmp/foo.txt")).close();

  String user = HadoopUsersConfTestHelper.getHadoopUsers()[0];
  URL url = new URL(TestJettyHelper.getJettyURL(), MessageFormat
      .format("/webhdfs/v1/tmp?user.name={0}&op=liststatus&filter=f*", user));
  HttpURLConnection conn = (HttpURLConnection) url.openConnection();
  Assert.assertEquals(conn.getResponseCode(), HttpURLConnection.HTTP_OK);
  BufferedReader reader =
      new BufferedReader(new InputStreamReader(conn.getInputStream()));
  reader.readLine();
  reader.close();
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:22,代码来源:TestHttpFSServer.java


示例12: testOpenOffsetLength

import org.apache.hadoop.test.TestHdfs; //导入依赖的package包/类
@Test
@TestDir
@TestJetty
@TestHdfs
public void testOpenOffsetLength() throws Exception {
  createHttpFSServer(false);

  byte[] array = new byte[]{0, 1, 2, 3};
  FileSystem fs = FileSystem.get(TestHdfsHelper.getHdfsConf());
  fs.mkdirs(new Path("/tmp"));
  OutputStream os = fs.create(new Path("/tmp/foo"));
  os.write(array);
  os.close();

  String user = HadoopUsersConfTestHelper.getHadoopUsers()[0];
  URL url = new URL(TestJettyHelper.getJettyURL(), MessageFormat
      .format("/webhdfs/v1/tmp/foo?user.name={0}&op=open&offset=1&length=2",
          user));
  HttpURLConnection conn = (HttpURLConnection) url.openConnection();
  Assert.assertEquals(HttpURLConnection.HTTP_OK, conn.getResponseCode());
  InputStream is = conn.getInputStream();
  Assert.assertEquals(1, is.read());
  Assert.assertEquals(2, is.read());
  Assert.assertEquals(-1, is.read());
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:26,代码来源:TestHttpFSServer.java


示例13: testPutNoOperation

import org.apache.hadoop.test.TestHdfs; //导入依赖的package包/类
@Test
@TestDir
@TestJetty
@TestHdfs
public void testPutNoOperation() throws Exception {
  createHttpFSServer(false);

  String user = HadoopUsersConfTestHelper.getHadoopUsers()[0];
  URL url = new URL(TestJettyHelper.getJettyURL(),
      MessageFormat.format("/webhdfs/v1/foo?user.name={0}", user));
  HttpURLConnection conn = (HttpURLConnection) url.openConnection();
  conn.setDoInput(true);
  conn.setDoOutput(true);
  conn.setRequestMethod("PUT");
  Assert.assertEquals(conn.getResponseCode(),
      HttpURLConnection.HTTP_BAD_REQUEST);
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:18,代码来源:TestHttpFSServer.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java LocalizerStatusProtoOrBuilder类代码示例发布时间:2022-05-22
下一篇:
Java NMTokenProto类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap