Java 类org.apache.hadoop.hdfs.server.namenode.TransferFsImage.HttpGetFailedException 实例源码

项目:aliyun-oss-hadoop-fs    文件:EditLogFileInputStream.java   
@Override
public InputStream getInputStream() throws IOException {
  return SecurityUtil.doAsCurrentUser(
      new PrivilegedExceptionAction<InputStream>() {
        @Override
        public InputStream run() throws IOException {
          HttpURLConnection connection;
          try {
            connection = (HttpURLConnection)
                connectionFactory.openConnection(url, isSpnegoEnabled);
          } catch (AuthenticationException e) {
            throw new IOException(e);
          }

          if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) {
            throw new HttpGetFailedException(
                "Fetch of " + url +
                " failed with status code " + connection.getResponseCode() +
                "\nResponse message:\n" + connection.getResponseMessage(),
                connection);
          }

          String contentLength = connection.getHeaderField(CONTENT_LENGTH);
          if (contentLength != null) {
            advertisedSize = Long.parseLong(contentLength);
            if (advertisedSize <= 0) {
              throw new IOException("Invalid " + CONTENT_LENGTH + " header: " +
                  contentLength);
            }
          } else {
            throw new IOException(CONTENT_LENGTH + " header is not provided " +
                                  "by the server when trying to fetch " + url);
          }

          return connection.getInputStream();
        }
      });
}
项目:big-c    文件:EditLogFileInputStream.java   
@Override
public InputStream getInputStream() throws IOException {
  return SecurityUtil.doAsCurrentUser(
      new PrivilegedExceptionAction<InputStream>() {
        @Override
        public InputStream run() throws IOException {
          HttpURLConnection connection;
          try {
            connection = (HttpURLConnection)
                connectionFactory.openConnection(url, isSpnegoEnabled);
          } catch (AuthenticationException e) {
            throw new IOException(e);
          }

          if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) {
            throw new HttpGetFailedException(
                "Fetch of " + url +
                " failed with status code " + connection.getResponseCode() +
                "\nResponse message:\n" + connection.getResponseMessage(),
                connection);
          }

          String contentLength = connection.getHeaderField(CONTENT_LENGTH);
          if (contentLength != null) {
            advertisedSize = Long.parseLong(contentLength);
            if (advertisedSize <= 0) {
              throw new IOException("Invalid " + CONTENT_LENGTH + " header: " +
                  contentLength);
            }
          } else {
            throw new IOException(CONTENT_LENGTH + " header is not provided " +
                                  "by the server when trying to fetch " + url);
          }

          return connection.getInputStream();
        }
      });
}
项目:hadoop-2.6.0-cdh5.4.3    文件:EditLogFileInputStream.java   
@Override
public InputStream getInputStream() throws IOException {
  return SecurityUtil.doAsCurrentUser(
      new PrivilegedExceptionAction<InputStream>() {
        @Override
        public InputStream run() throws IOException {
          HttpURLConnection connection;
          try {
            connection = (HttpURLConnection)
                connectionFactory.openConnection(url, isSpnegoEnabled);
          } catch (AuthenticationException e) {
            throw new IOException(e);
          }

          if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) {
            throw new HttpGetFailedException(
                "Fetch of " + url +
                " failed with status code " + connection.getResponseCode() +
                "\nResponse message:\n" + connection.getResponseMessage(),
                connection);
          }

          String contentLength = connection.getHeaderField(CONTENT_LENGTH);
          if (contentLength != null) {
            advertisedSize = Long.parseLong(contentLength);
            if (advertisedSize <= 0) {
              throw new IOException("Invalid " + CONTENT_LENGTH + " header: " +
                  contentLength);
            }
          } else {
            throw new IOException(CONTENT_LENGTH + " header is not provided " +
                                  "by the server when trying to fetch " + url);
          }

          return connection.getInputStream();
        }
      });
}
项目:hadoop-plus    文件:EditLogFileInputStream.java   
@Override
public InputStream getInputStream() throws IOException {
  return SecurityUtil.doAsCurrentUser(
      new PrivilegedExceptionAction<InputStream>() {
        @Override
        public InputStream run() throws IOException {
          HttpURLConnection connection = (HttpURLConnection)
              SecurityUtil.openSecureHttpConnection(url);

          if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) {
            throw new HttpGetFailedException(
                "Fetch of " + url +
                " failed with status code " + connection.getResponseCode() +
                "\nResponse message:\n" + connection.getResponseMessage(),
                connection);
          }

          String contentLength = connection.getHeaderField(CONTENT_LENGTH);
          if (contentLength != null) {
            advertisedSize = Long.parseLong(contentLength);
            if (advertisedSize <= 0) {
              throw new IOException("Invalid " + CONTENT_LENGTH + " header: " +
                  contentLength);
            }
          } else {
            throw new IOException(CONTENT_LENGTH + " header is not provided " +
                                  "by the server when trying to fetch " + url);
          }

          return connection.getInputStream();
        }
      });
}
项目:FlexMap    文件:EditLogFileInputStream.java   
@Override
public InputStream getInputStream() throws IOException {
  return SecurityUtil.doAsCurrentUser(
      new PrivilegedExceptionAction<InputStream>() {
        @Override
        public InputStream run() throws IOException {
          HttpURLConnection connection;
          try {
            connection = (HttpURLConnection)
                connectionFactory.openConnection(url, isSpnegoEnabled);
          } catch (AuthenticationException e) {
            throw new IOException(e);
          }

          if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) {
            throw new HttpGetFailedException(
                "Fetch of " + url +
                " failed with status code " + connection.getResponseCode() +
                "\nResponse message:\n" + connection.getResponseMessage(),
                connection);
          }

          String contentLength = connection.getHeaderField(CONTENT_LENGTH);
          if (contentLength != null) {
            advertisedSize = Long.parseLong(contentLength);
            if (advertisedSize <= 0) {
              throw new IOException("Invalid " + CONTENT_LENGTH + " header: " +
                  contentLength);
            }
          } else {
            throw new IOException(CONTENT_LENGTH + " header is not provided " +
                                  "by the server when trying to fetch " + url);
          }

          return connection.getInputStream();
        }
      });
}
项目:hadoop-TCP    文件:EditLogFileInputStream.java   
@Override
public InputStream getInputStream() throws IOException {
  return SecurityUtil.doAsCurrentUser(
      new PrivilegedExceptionAction<InputStream>() {
        @Override
        public InputStream run() throws IOException {
          HttpURLConnection connection = (HttpURLConnection)
              SecurityUtil.openSecureHttpConnection(url);

          if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) {
            throw new HttpGetFailedException(
                "Fetch of " + url +
                " failed with status code " + connection.getResponseCode() +
                "\nResponse message:\n" + connection.getResponseMessage(),
                connection);
          }

          String contentLength = connection.getHeaderField(CONTENT_LENGTH);
          if (contentLength != null) {
            advertisedSize = Long.parseLong(contentLength);
            if (advertisedSize <= 0) {
              throw new IOException("Invalid " + CONTENT_LENGTH + " header: " +
                  contentLength);
            }
          } else {
            throw new IOException(CONTENT_LENGTH + " header is not provided " +
                                  "by the server when trying to fetch " + url);
          }

          return connection.getInputStream();
        }
      });
}
项目:hardfs    文件:EditLogFileInputStream.java   
@Override
public InputStream getInputStream() throws IOException {
  return SecurityUtil.doAsCurrentUser(
      new PrivilegedExceptionAction<InputStream>() {
        @Override
        public InputStream run() throws IOException {
          HttpURLConnection connection = (HttpURLConnection)
              SecurityUtil.openSecureHttpConnection(url);

          if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) {
            throw new HttpGetFailedException(
                "Fetch of " + url +
                " failed with status code " + connection.getResponseCode() +
                "\nResponse message:\n" + connection.getResponseMessage(),
                connection);
          }

          String contentLength = connection.getHeaderField(CONTENT_LENGTH);
          if (contentLength != null) {
            advertisedSize = Long.parseLong(contentLength);
            if (advertisedSize <= 0) {
              throw new IOException("Invalid " + CONTENT_LENGTH + " header: " +
                  contentLength);
            }
          } else {
            throw new IOException(CONTENT_LENGTH + " header is not provided " +
                                  "by the server when trying to fetch " + url);
          }

          return connection.getInputStream();
        }
      });
}
项目:hadoop-on-lustre2    文件:EditLogFileInputStream.java   
@Override
public InputStream getInputStream() throws IOException {
  return SecurityUtil.doAsCurrentUser(
      new PrivilegedExceptionAction<InputStream>() {
        @Override
        public InputStream run() throws IOException {
          HttpURLConnection connection;
          try {
            connection = (HttpURLConnection)
                connectionFactory.openConnection(url, isSpnegoEnabled);
          } catch (AuthenticationException e) {
            throw new IOException(e);
          }

          if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) {
            throw new HttpGetFailedException(
                "Fetch of " + url +
                " failed with status code " + connection.getResponseCode() +
                "\nResponse message:\n" + connection.getResponseMessage(),
                connection);
          }

          String contentLength = connection.getHeaderField(CONTENT_LENGTH);
          if (contentLength != null) {
            advertisedSize = Long.parseLong(contentLength);
            if (advertisedSize <= 0) {
              throw new IOException("Invalid " + CONTENT_LENGTH + " header: " +
                  contentLength);
            }
          } else {
            throw new IOException(CONTENT_LENGTH + " header is not provided " +
                                  "by the server when trying to fetch " + url);
          }

          return connection.getInputStream();
        }
      });
}