Code example for URI

Methods: getHost, getScheme, getUserInfo

0
  /** 
   * @throws IllegalArgumentException if credentials for S3 cannot be 
   * determined. 
   */ 
  public void initialize(URI uri, Configuration conf) {
    if (uri.getHost() == null) {
      throw new IllegalArgumentException("Invalid hostname in URI " + uri);
    } 
     
    String userInfo = uri.getUserInfo();
    if (userInfo != null) {
      int index = userInfo.indexOf(':');
      if (index != -1) {
        accessKey = userInfo.substring(0, index);
        secretAccessKey = userInfo.substring(index + 1);
      } else { 
        accessKey = userInfo;
      } 
    } 
     
    String scheme = uri.getScheme();
    String accessKeyProperty = String.format("fs.%s.awsAccessKeyId", scheme);
    String secretAccessKeyProperty =
      String.format("fs.%s.awsSecretAccessKey", scheme);
    if (accessKey == null) {
      accessKey = conf.get(accessKeyProperty);