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


Java TestJettyHelper.getJettyURL方法代码示例

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


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

示例1: testHdfsAccess

import org.apache.hadoop.test.TestJettyHelper; //导入方法依赖的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

示例2: testGlobFilter

import org.apache.hadoop.test.TestJettyHelper; //导入方法依赖的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

示例3: createWithHttp

import org.apache.hadoop.test.TestJettyHelper; //导入方法依赖的package包/类
/**
 * Talks to the http interface to create a file.
 *
 * @param filename The file to create
 * @param perms The permission field, if any (may be null)
 * @throws Exception
 */
private void createWithHttp ( String filename, String perms )
        throws Exception {
  String user = HadoopUsersConfTestHelper.getHadoopUsers()[0];
  // Remove leading / from filename
  if ( filename.charAt(0) == '/' ) {
    filename = filename.substring(1);
  }
  String pathOps;
  if ( perms == null ) {
    pathOps = MessageFormat.format(
            "/webhdfs/v1/{0}?user.name={1}&op=CREATE",
            filename, user);
  } else {
    pathOps = MessageFormat.format(
            "/webhdfs/v1/{0}?user.name={1}&permission={2}&op=CREATE",
            filename, user, perms);
  }
  URL url = new URL(TestJettyHelper.getJettyURL(), pathOps);
  HttpURLConnection conn = (HttpURLConnection) url.openConnection();
  conn.addRequestProperty("Content-Type", "application/octet-stream");
  conn.setRequestMethod("PUT");
  conn.connect();
  Assert.assertEquals(HttpURLConnection.HTTP_CREATED, conn.getResponseCode());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:32,代码来源:TestHttpFSServer.java

示例4: getStatus

import org.apache.hadoop.test.TestJettyHelper; //导入方法依赖的package包/类
/**
 * Talks to the http interface to get the json output of a *STATUS command
 * on the given file.
 *
 * @param filename The file to query.
 * @param command Either GETFILESTATUS, LISTSTATUS, or ACLSTATUS
 * @return A string containing the JSON output describing the file.
 * @throws Exception
 */
private String getStatus(String filename, String command)
        throws Exception {
  String user = HadoopUsersConfTestHelper.getHadoopUsers()[0];
  // Remove leading / from filename
  if ( filename.charAt(0) == '/' ) {
    filename = filename.substring(1);
  }
  String pathOps = MessageFormat.format(
          "/webhdfs/v1/{0}?user.name={1}&op={2}",
          filename, user, command);
  URL url = new URL(TestJettyHelper.getJettyURL(), pathOps);
  HttpURLConnection conn = (HttpURLConnection) url.openConnection();
  conn.connect();
  Assert.assertEquals(HttpURLConnection.HTTP_OK, conn.getResponseCode());

  BufferedReader reader =
          new BufferedReader(new InputStreamReader(conn.getInputStream()));

  return reader.readLine();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:30,代码来源:TestHttpFSServer.java

示例5: putCmd

import org.apache.hadoop.test.TestJettyHelper; //导入方法依赖的package包/类
/**
 * General-purpose http PUT command to the httpfs server.
 * @param filename The file to operate upon
 * @param command The command to perform (SETACL, etc)
 * @param params Parameters, like "aclspec=..."
 */
private void putCmd(String filename, String command,
                    String params) throws Exception {
  String user = HadoopUsersConfTestHelper.getHadoopUsers()[0];
  // Remove leading / from filename
  if ( filename.charAt(0) == '/' ) {
    filename = filename.substring(1);
  }
  String pathOps = MessageFormat.format(
          "/webhdfs/v1/{0}?user.name={1}{2}{3}&op={4}",
          filename, user, (params == null) ? "" : "&",
          (params == null) ? "" : params, command);
  URL url = new URL(TestJettyHelper.getJettyURL(), pathOps);
  HttpURLConnection conn = (HttpURLConnection) url.openConnection();
  conn.setRequestMethod("PUT");
  conn.connect();
  Assert.assertEquals(HttpURLConnection.HTTP_OK, conn.getResponseCode());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:TestHttpFSServer.java

示例6: testOpenOffsetLength

import org.apache.hadoop.test.TestJettyHelper; //导入方法依赖的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.TestJettyHelper; //导入方法依赖的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: getStatus

import org.apache.hadoop.test.TestJettyHelper; //导入方法依赖的package包/类
/**
 * Talks to the http interface to get the json output of a *STATUS command
 * on the given file.
 *
 * @param filename The file to query.
 * @param command Either GETXATTRS, SETXATTR, or REMOVEXATTR
 * @throws Exception
 */
private void getStatus(String filename, String command)
        throws Exception {
  String user = HadoopUsersConfTestHelper.getHadoopUsers()[0];
  // Remove leading / from filename
  if ( filename.charAt(0) == '/' ) {
    filename = filename.substring(1);
  }
  String pathOps = MessageFormat.format(
          "/webhdfs/v1/{0}?user.name={1}&op={2}",
          filename, user, command);
  URL url = new URL(TestJettyHelper.getJettyURL(), pathOps);
  HttpURLConnection conn = (HttpURLConnection) url.openConnection();
  conn.connect();
  int resp = conn.getResponseCode();
  BufferedReader reader;
  Assert.assertEquals(HttpURLConnection.HTTP_INTERNAL_ERROR, resp);
  reader = new BufferedReader(new InputStreamReader(conn.getErrorStream()));
  String res = reader.readLine();
  Assert.assertTrue(res.contains("RemoteException"));
  Assert.assertTrue(res.contains("XAttr"));
  Assert.assertTrue(res.contains("rejected"));
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:31,代码来源:TestHttpFSServerNoXAttrs.java

示例9: putCmd

import org.apache.hadoop.test.TestJettyHelper; //导入方法依赖的package包/类
/**
 * General-purpose http PUT command to the httpfs server.
 * @param filename The file to operate upon
 * @param command The command to perform (SETXATTR, etc)
 * @param params Parameters
 */
private void putCmd(String filename, String command,
                    String params) throws Exception {
  String user = HadoopUsersConfTestHelper.getHadoopUsers()[0];
  // Remove leading / from filename
  if ( filename.charAt(0) == '/' ) {
    filename = filename.substring(1);
  }
  String pathOps = MessageFormat.format(
          "/webhdfs/v1/{0}?user.name={1}{2}{3}&op={4}",
          filename, user, (params == null) ? "" : "&",
          (params == null) ? "" : params, command);
  URL url = new URL(TestJettyHelper.getJettyURL(), pathOps);
  HttpURLConnection conn = (HttpURLConnection) url.openConnection();
  conn.setRequestMethod("PUT");
  conn.connect();
  int resp = conn.getResponseCode();
  Assert.assertEquals(HttpURLConnection.HTTP_INTERNAL_ERROR, resp);
  BufferedReader reader;
  reader = new BufferedReader(new InputStreamReader(conn.getErrorStream()));
  String err = reader.readLine();
  Assert.assertTrue(err.contains("RemoteException"));
  Assert.assertTrue(err.contains("XAttr"));
  Assert.assertTrue(err.contains("rejected"));
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:31,代码来源:TestHttpFSServerNoXAttrs.java

示例10: testOpenOffsetLength

import org.apache.hadoop.test.TestJettyHelper; //导入方法依赖的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

示例11: testHdfsAccess

import org.apache.hadoop.test.TestJettyHelper; //导入方法依赖的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

示例12: testGlobFilter

import org.apache.hadoop.test.TestJettyHelper; //导入方法依赖的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

示例13: testPutNoOperation

import org.apache.hadoop.test.TestJettyHelper; //导入方法依赖的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

示例14: testInvalidadHttpFSAccess

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

  URL url = new URL(TestJettyHelper.getJettyURL(),
                    "/webhdfs/v1/?op=GETHOMEDIRECTORY");
  HttpURLConnection conn = (HttpURLConnection) url.openConnection();
  Assert.assertEquals(conn.getResponseCode(),
                      HttpURLConnection.HTTP_UNAUTHORIZED);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:14,代码来源:TestHttpFSWithKerberos.java

示例15: putCmd

import org.apache.hadoop.test.TestJettyHelper; //导入方法依赖的package包/类
/**
 * General-purpose http PUT command to the httpfs server.
 * @param filename The file to operate upon
 * @param command The command to perform (SETACL, etc)
 * @param params Parameters, like "aclspec=..."
 */
private void putCmd(String filename, String command,
                    String params, boolean expectOK) throws Exception {
  String user = HadoopUsersConfTestHelper.getHadoopUsers()[0];
  // Remove leading / from filename
  if ( filename.charAt(0) == '/' ) {
    filename = filename.substring(1);
  }
  String pathOps = MessageFormat.format(
          "/webhdfs/v1/{0}?user.name={1}{2}{3}&op={4}",
          filename, user, (params == null) ? "" : "&",
          (params == null) ? "" : params, command);
  URL url = new URL(TestJettyHelper.getJettyURL(), pathOps);
  HttpURLConnection conn = (HttpURLConnection) url.openConnection();
  conn.setRequestMethod("PUT");
  conn.connect();
  int resp = conn.getResponseCode();
  if ( expectOK ) {
    Assert.assertEquals(HttpURLConnection.HTTP_OK, resp);
  } else {
    Assert.assertEquals(HttpURLConnection.HTTP_INTERNAL_ERROR, resp);
    BufferedReader reader;
    reader = new BufferedReader(new InputStreamReader(conn.getErrorStream()));
    String err = reader.readLine();
    Assert.assertTrue(err.contains("AclException"));
    Assert.assertTrue(err.contains("Support for ACLs has been disabled"));
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:34,代码来源:TestHttpFSServerNoACLs.java


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