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


Java URI.getAuthority方法代码示例

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


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

示例1: testHarUriWithHaUriWithNoPort

import java.net.URI; //导入方法依赖的package包/类
/**
 * Test that the HarFileSystem works with underlying HDFS URIs that have no
 * port specified, as is often the case with an HA setup.
 */
@Test
public void testHarUriWithHaUriWithNoPort() throws Exception {
  Configuration conf = new HdfsConfiguration();
  MiniDFSCluster cluster = null;
  try {
    cluster = new MiniDFSCluster.Builder(conf)
        .numDataNodes(1)
        .nnTopology(MiniDFSNNTopology.simpleHATopology())
        .build();
    cluster.transitionToActive(0);
    HATestUtil.setFailoverConfigurations(cluster, conf);
    
    createEmptyHarArchive(HATestUtil.configureFailoverFs(cluster, conf),
        TEST_HAR_PATH);
    
    URI failoverUri = FileSystem.getDefaultUri(conf);
    Path p = new Path("har://hdfs-" + failoverUri.getAuthority() + TEST_HAR_PATH);
    p.getFileSystem(conf);
  } finally {
    cluster.shutdown();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:TestHarFileSystemWithHA.java

示例2: getNNAddress

import java.net.URI; //导入方法依赖的package包/类
/**
 * @return address of file system
 */
public static InetSocketAddress getNNAddress(URI filesystemURI) {
  String authority = filesystemURI.getAuthority();
  if (authority == null) {
    throw new IllegalArgumentException(String.format(
        "Invalid URI for NameNode address (check %s): %s has no authority.",
        FileSystem.FS_DEFAULT_NAME_KEY, filesystemURI.toString()));
  }
  if (!HdfsConstants.HDFS_URI_SCHEME.equalsIgnoreCase(
      filesystemURI.getScheme())) {
    throw new IllegalArgumentException(String.format(
        "Invalid URI for NameNode address (check %s): " +
            "%s is not of scheme '%s'.", FileSystem.FS_DEFAULT_NAME_KEY,
        filesystemURI.toString(), HdfsConstants.HDFS_URI_SCHEME));
  }
  return getNNAddress(authority);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:20,代码来源:NuCypherExtUtilClient.java

示例3: getPath

import java.net.URI; //导入方法依赖的package包/类
@Override
public Path getPath(URI uri) {
    checkPermission();
    if (!uri.getScheme().equalsIgnoreCase(getScheme())) {
        throw new IllegalArgumentException("URI does not match this provider");
    }
    if (uri.getAuthority() != null) {
        throw new IllegalArgumentException("Authority component present");
    }
    if (uri.getQuery() != null) {
        throw new IllegalArgumentException("Query component present");
    }
    if (uri.getFragment() != null) {
        throw new IllegalArgumentException("Fragment component present");
    }
    String path = uri.getPath();
    if (path == null || path.charAt(0) != '/') {
        throw new IllegalArgumentException("Invalid path component");
    }
    return getTheFileSystem().getPath(path);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:JrtFileSystemProvider.java

示例4: ViewFs

import java.net.URI; //导入方法依赖的package包/类
/**
 * This constructor has the signature needed by
 * {@link AbstractFileSystem#createFileSystem(URI, Configuration)}.
 * 
 * @param theUri which must be that of ViewFs
 * @param conf
 * @throws IOException
 * @throws URISyntaxException 
 */
ViewFs(final URI theUri, final Configuration conf) throws IOException,
    URISyntaxException {
  super(theUri, FsConstants.VIEWFS_SCHEME, false, -1);
  creationTime = Time.now();
  ugi = UserGroupInformation.getCurrentUser();
  config = conf;
  // Now build  client side view (i.e. client side mount table) from config.
  String authority = theUri.getAuthority();
  fsState = new InodeTree<AbstractFileSystem>(conf, authority) {

    @Override
    protected
    AbstractFileSystem getTargetFileSystem(final URI uri)
      throws URISyntaxException, UnsupportedFileSystemException {
        String pathString = uri.getPath();
        if (pathString.isEmpty()) {
          pathString = "/";
        }
        return new ChRootedFs(
            AbstractFileSystem.createFileSystem(uri, config),
            new Path(pathString));
    }

    @Override
    protected
    AbstractFileSystem getTargetFileSystem(
        final INodeDir<AbstractFileSystem> dir) throws URISyntaxException {
      return new InternalDirOfViewFs(dir, creationTime, ugi, getUri());
    }

    @Override
    protected
    AbstractFileSystem getTargetFileSystem(URI[] mergeFsURIList)
        throws URISyntaxException, UnsupportedFileSystemException {
      throw new UnsupportedFileSystemException("mergefs not implemented yet");
      // return MergeFs.createMergeFs(mergeFsURIList, config);
    }
  };
}
 
开发者ID:naver,项目名称:hadoop,代码行数:49,代码来源:ViewFs.java

示例5: insertBaseElement

import java.net.URI; //导入方法依赖的package包/类
/**
 * Insert "base" node so that style sheets, images, and other relative resources load properly.
 * 
 * @param sourceBuilder {@link StringBuilder} object used to build page source
 * @param driver web driver object
 * @return the [sourceBuilder] object
 */
private static StringBuilder insertBaseElement(StringBuilder sourceBuilder, WebDriver driver) {
    int offset = sourceBuilder.indexOf("<head>") + 6;
    
    // if no head found
    if (offset < 6) {
        return sourceBuilder;
    }
    
    int closing = sourceBuilder.indexOf("</head>", offset);
    String substr = sourceBuilder.substring(offset, closing);
    
    // if base already exists
    if (substr.contains("<base ")) {
        return sourceBuilder;
    }
    
    URI uri = URI.create(driver.getCurrentUrl());
    
    String path = uri.getPath();
    int endIndex = path.lastIndexOf('/') + 1;
    String root = path.substring(0, endIndex);
    
    String authority = uri.getAuthority();
    if (authority != null) {
        root = authority + root;
    }
    
    sourceBuilder.insert(offset, "\">\n")
            .insert(offset, root)
            .insert(offset, "://")
            .insert(offset, uri.getScheme())
            .insert(offset, "<base href=\"")
            .insert(offset, "\n<!-- Inserted by Selenium Foundation -->\n");
    
    return sourceBuilder;
}
 
开发者ID:Nordstrom,项目名称:Selenium-Foundation,代码行数:44,代码来源:PageSourceUtils.java

示例6: getBaseUri

import java.net.URI; //导入方法依赖的package包/类
private static URI getBaseUri(URI uri) {
  String scheme = uri.getScheme();
  String authority = uri.getAuthority();
  String baseUriString = scheme + "://";
  if (authority != null) {
    baseUriString = baseUriString + authority;
  } else {
    baseUriString = baseUriString + "/";
  }
  return URI.create(baseUriString);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:12,代码来源:AbstractFileSystem.java

示例7: checkUri

import java.net.URI; //导入方法依赖的package包/类
private void checkUri(URI uri) {
    if (!uri.getScheme().equalsIgnoreCase(getScheme()))
        throw new IllegalArgumentException("URI does not match this provider");
    if (uri.getAuthority() != null)
        throw new IllegalArgumentException("Authority component present");
    if (uri.getPath() == null)
        throw new IllegalArgumentException("Path component is undefined");
    if (!uri.getPath().equals("/"))
        throw new IllegalArgumentException("Path component should be '/'");
    if (uri.getQuery() != null)
        throw new IllegalArgumentException("Query component present");
    if (uri.getFragment() != null)
        throw new IllegalArgumentException("Fragment component present");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:15,代码来源:WindowsFileSystemProvider.java

示例8: parseURL

import java.net.URI; //导入方法依赖的package包/类
@Override
protected void parseURL(URL location, String spec, int start, int limit) {
    _scheme = spec.substring(0, spec.indexOf("://"));

    URI    specURI = _getSpecURI(spec);
    String host = specURI.getHost();
    int    port = specURI.getPort();
    String authority = specURI.getAuthority();
    String userInfo = specURI.getUserInfo();
    String path = specURI.getPath();
    String query = specURI.getQuery();
    
    setURL(location, _scheme, host, port, authority, userInfo, path, query, null);
}
 
开发者ID:Datatellit,项目名称:xlight_android_native,代码行数:15,代码来源:SseURLStreamHandlerImpl.java

示例9: newNameResolver

import java.net.URI; //导入方法依赖的package包/类
@Nullable
@Override
public NameResolver newNameResolver(URI targetUri, Attributes params) {
    if (scheme.equals(targetUri.getScheme())) {
        final String authority = targetUri.getAuthority();

        return new NameResolver() {
            @Override
            public String getServiceAuthority() {
                return authority;
            }

            @Override
            public void start(NameResolver.Listener listener) {
                try {
                    listener.onAddresses(
                            Collections.singletonList(new EquivalentAddressGroup(staticAddress)),
                            Attributes.EMPTY
                    );
                } catch (Throwable e) {
                    listener.onError(Status.UNKNOWN);
                }
            }

            @Override
            public void shutdown() {

            }
        };
    } else {
        return null;
    }
}
 
开发者ID:salesforce,项目名称:grpc-java-contrib,代码行数:34,代码来源:StaticResolver.java

示例10: Key

import java.net.URI; //导入方法依赖的package包/类
Key(URI uri, Configuration conf, long unique) throws IOException {
  scheme = uri.getScheme()==null ?
      "" : StringUtils.toLowerCase(uri.getScheme());
  authority = uri.getAuthority()==null ?
      "" : StringUtils.toLowerCase(uri.getAuthority());
  this.unique = unique;
  
  this.ugi = UserGroupInformation.getCurrentUser();
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:10,代码来源:FileSystem.java

示例11: expandAsGlob

import java.net.URI; //导入方法依赖的package包/类
/**
 * Expand the given path as a glob pattern.  Non-existent paths do not
 * throw an exception because creation commands like touch and mkdir need
 * to create them.  The "stat" field will be null if the path does not
 * exist.
 * @param pattern the pattern to expand as a glob
 * @param conf the hadoop configuration
 * @return list of {@link PathData} objects.  if the pattern is not a glob,
 * and does not exist, the list will contain a single PathData with a null
 * stat 
 * @throws IOException anything else goes wrong...
 */
public static PathData[] expandAsGlob(String pattern, Configuration conf)
throws IOException {
  Path globPath = new Path(pattern);
  FileSystem fs = globPath.getFileSystem(conf);    
  FileStatus[] stats = fs.globStatus(globPath);
  PathData[] items = null;
  
  if (stats == null) {
    // remove any quoting in the glob pattern
    pattern = pattern.replaceAll("\\\\(.)", "$1");
    // not a glob & file not found, so add the path with a null stat
    items = new PathData[]{ new PathData(fs, pattern, null) };
  } else {
    // figure out what type of glob path was given, will convert globbed
    // paths to match the type to preserve relativity
    PathType globType;
    URI globUri = globPath.toUri();
    if (globUri.getScheme() != null) {
      globType = PathType.HAS_SCHEME;
    } else if (!globUri.getPath().isEmpty() &&
               new Path(globUri.getPath()).isAbsolute()) {
      globType = PathType.SCHEMELESS_ABSOLUTE;
    } else {
      globType = PathType.RELATIVE;
    }

    // convert stats to PathData
    items = new PathData[stats.length];
    int i=0;
    for (FileStatus stat : stats) {
      URI matchUri = stat.getPath().toUri();
      String globMatch = null;
      switch (globType) {
        case HAS_SCHEME: // use as-is, but remove authority if necessary
          if (globUri.getAuthority() == null) {
            matchUri = removeAuthority(matchUri);
          }
          globMatch = uriToString(matchUri, false);
          break;
        case SCHEMELESS_ABSOLUTE: // take just the uri's path
          globMatch = matchUri.getPath();
          break;
        case RELATIVE: // make it relative to the current working dir
          URI cwdUri = fs.getWorkingDirectory().toUri();
          globMatch = relativize(cwdUri, matchUri, stat.isDirectory());
          break;
      }
      items[i++] = new PathData(fs, globMatch, stat);
    }
  }
  Arrays.sort(items);
  return items;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:66,代码来源:PathData.java

示例12: isSameFS

import java.net.URI; //导入方法依赖的package包/类
/**
 * Are qualSrc and qualDst of the same file system?
 * @param qualPath1 - fully qualified path
 * @param qualPath2 - fully qualified path
 * @return
 */
private static boolean isSameFS(Path qualPath1, Path qualPath2) {
  URI srcUri = qualPath1.toUri();
  URI dstUri = qualPath2.toUri();
  return (srcUri.getScheme().equals(dstUri.getScheme()) && 
      !(srcUri.getAuthority() != null && dstUri.getAuthority() != null && srcUri
      .getAuthority().equals(dstUri.getAuthority())));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:14,代码来源:FileContext.java

示例13: pathPrefixLength

import java.net.URI; //导入方法依赖的package包/类
static int pathPrefixLength(final URI uri) {
    final String ssp = uri.getSchemeSpecificPart();
    final String a = uri.getAuthority();
    final int al = null == a ? 0 : 2 + a.length();
    final int pl = Paths.prefixLength(ssp, SEPARATOR_CHAR, true) - al;
    return pl >= 0 ? pl : Paths.prefixLength(uri.getPath(), SEPARATOR_CHAR, false);
}
 
开发者ID:christian-schlichtherle,项目名称:truevfs,代码行数:8,代码来源:TUriHelper.java

示例14: fromUri

import java.net.URI; //导入方法依赖的package包/类
/**
 * Converts given URI to a Path
 */
static WindowsPath fromUri(WindowsFileSystem fs, URI uri) {
    if (!uri.isAbsolute())
        throw new IllegalArgumentException("URI is not absolute");
    if (uri.isOpaque())
        throw new IllegalArgumentException("URI is not hierarchical");
    String scheme = uri.getScheme();
    if ((scheme == null) || !scheme.equalsIgnoreCase("file"))
        throw new IllegalArgumentException("URI scheme is not \"file\"");
    if (uri.getFragment() != null)
        throw new IllegalArgumentException("URI has a fragment component");
    if (uri.getQuery() != null)
        throw new IllegalArgumentException("URI has a query component");
    String path = uri.getPath();
    if (path.equals(""))
        throw new IllegalArgumentException("URI path component is empty");

    // UNC
    String auth = uri.getAuthority();
    if (auth != null && !auth.equals("")) {
        String host = uri.getHost();
        if (host == null)
            throw new IllegalArgumentException("URI authority component has undefined host");
        if (uri.getUserInfo() != null)
            throw new IllegalArgumentException("URI authority component has user-info");
        if (uri.getPort() != -1)
            throw new IllegalArgumentException("URI authority component has port number");

        // IPv6 literal
        // 1. drop enclosing brackets
        // 2. replace ":" with "-"
        // 3. replace "%" with "s" (zone/scopeID delimiter)
        // 4. Append .ivp6-literal.net
        if (host.startsWith("[")) {
            host = host.substring(1, host.length()-1)
                       .replace(':', '-')
                       .replace('%', 's');
            host += IPV6_LITERAL_SUFFIX;
        }

        // reconstitute the UNC
        path = "\\\\" + host + path;
    } else {
        if ((path.length() > 2) && (path.charAt(2) == ':')) {
            // "/c:/foo" --> "c:/foo"
            path = path.substring(1);
        }
    }
    return WindowsPath.parse(fs, path);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:53,代码来源:WindowsUriSupport.java

示例15: joinURI

import java.net.URI; //导入方法依赖的package包/类
private static String joinURI(String baseURI, String relativeURI) throws URISyntaxException {
    String bscheme = null;
    String bauthority = null;
    String bpath = "";
    String bquery = null;

    // pre-parse the baseURI
    if (baseURI != null) {
        if (baseURI.endsWith("..")) {
            baseURI = baseURI + "/";
        }
        URI base = new URI(baseURI);
        bscheme = base.getScheme();
        bauthority = base.getAuthority();
        bpath = base.getPath();
        bquery = base.getQuery();
    }

    URI r = new URI(relativeURI);
    String rscheme = r.getScheme();
    String rauthority = r.getAuthority();
    String rpath = r.getPath();
    String rquery = r.getQuery();

    String tscheme, tauthority, tpath, tquery;
    if (rscheme != null && rscheme.equals(bscheme)) {
        rscheme = null;
    }
    if (rscheme != null) {
        tscheme = rscheme;
        tauthority = rauthority;
        tpath = removeDotSegments(rpath);
        tquery = rquery;
    } else {
        if (rauthority != null) {
            tauthority = rauthority;
            tpath = removeDotSegments(rpath);
            tquery = rquery;
        } else {
            if (rpath.length() == 0) {
                tpath = bpath;
                if (rquery != null) {
                    tquery = rquery;
                } else {
                    tquery = bquery;
                }
            } else {
                if (rpath.startsWith("/")) {
                    tpath = removeDotSegments(rpath);
                } else {
                    if (bauthority != null && bpath.length() == 0) {
                        tpath = "/" + rpath;
                    } else {
                        int last = bpath.lastIndexOf('/');
                        if (last == -1) {
                            tpath = rpath;
                        } else {
                            tpath = bpath.substring(0, last+1) + rpath;
                        }
                    }
                    tpath = removeDotSegments(tpath);
                }
                tquery = rquery;
            }
            tauthority = bauthority;
        }
        tscheme = bscheme;
    }
    return new URI(tscheme, tauthority, tpath, tquery, null).toString();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:71,代码来源:Canonicalizer11.java


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