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


Java FileSystem.getCanonicalServiceName方法代码示例

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


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

示例1: testGetCanonicalServiceNameWithNonDefaultMountTable

import org.apache.hadoop.fs.FileSystem; //导入方法依赖的package包/类
/**
 * Regression test for HADOOP-8408.
 */
@Test
public void testGetCanonicalServiceNameWithNonDefaultMountTable()
    throws URISyntaxException, IOException {
  
  Configuration conf = new Configuration();
  ConfigUtil.addLink(conf, MOUNT_TABLE_NAME, "/user", new URI("file:///"));
  
  FileSystem viewFs = FileSystem.get(new URI(FsConstants.VIEWFS_SCHEME +
      "://" + MOUNT_TABLE_NAME), conf);
  
  String serviceName = viewFs.getCanonicalServiceName();
  assertNull(serviceName);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:17,代码来源:TestViewFileSystemDelegationTokenSupport.java

示例2: testGetCanonicalServiceNameWithDefaultMountTable

import org.apache.hadoop.fs.FileSystem; //导入方法依赖的package包/类
@Test
public void testGetCanonicalServiceNameWithDefaultMountTable()
    throws URISyntaxException, IOException {
  
  Configuration conf = new Configuration();
  ConfigUtil.addLink(conf, "/user", new URI("file:///"));
  
  FileSystem viewFs = FileSystem.get(FsConstants.VIEWFS_URI, conf);
  
  String serviceName = viewFs.getCanonicalServiceName();
  assertNull(serviceName);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:13,代码来源:TestViewFileSystemDelegationTokenSupport.java

示例3: testDoesntDnsResolveLogicalURI

import org.apache.hadoop.fs.FileSystem; //导入方法依赖的package包/类
/**
 * Test that the client doesn't ever try to DNS-resolve the logical URI.
 * Regression test for HADOOP-9150.
 */
@Test
public void testDoesntDnsResolveLogicalURI() throws Exception {
  FileSystem fs = HATestUtil.configureFailoverFs(cluster, conf);
  NameService spyNS = spyOnNameService();
  String logicalHost = fs.getUri().getHost();
  Path qualifiedRoot = fs.makeQualified(new Path("/"));
  
  // Make a few calls against the filesystem.
  fs.getCanonicalServiceName();
  fs.listStatus(qualifiedRoot);
  
  // Ensure that the logical hostname was never resolved.
  Mockito.verify(spyNS, Mockito.never()).lookupAllHostAddr(Mockito.eq(logicalHost));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:TestDFSClientFailover.java

示例4: isSameHdfs

import org.apache.hadoop.fs.FileSystem; //导入方法依赖的package包/类
/**
 * @param conf the Configuration of HBase
 * @param srcFs
 * @param desFs
 * @return Whether srcFs and desFs are on same hdfs or not
 */
public static boolean isSameHdfs(Configuration conf, FileSystem srcFs, FileSystem desFs) {
  // By getCanonicalServiceName, we could make sure both srcFs and desFs
  // show a unified format which contains scheme, host and port.
  String srcServiceName = srcFs.getCanonicalServiceName();
  String desServiceName = desFs.getCanonicalServiceName();

  if (srcServiceName == null || desServiceName == null) {
    return false;
  }
  if (srcServiceName.equals(desServiceName)) {
    return true;
  }
  if (srcServiceName.startsWith("ha-hdfs") && desServiceName.startsWith("ha-hdfs")) {
    Collection<String> internalNameServices =
        conf.getTrimmedStringCollection("dfs.internal.nameservices");
    if (!internalNameServices.isEmpty()) {
      if (internalNameServices.contains(srcServiceName.split(":")[1])) {
        return true;
      } else {
        return false;
      }
    }
  }
  if (srcFs instanceof DistributedFileSystem && desFs instanceof DistributedFileSystem) {
    //If one serviceName is an HA format while the other is a non-HA format,
    // maybe they refer to the same FileSystem.
    //For example, srcFs is "ha-hdfs://nameservices" and desFs is "hdfs://activeNamenode:port"
    Set<InetSocketAddress> srcAddrs = getNNAddresses((DistributedFileSystem) srcFs, conf);
    Set<InetSocketAddress> desAddrs = getNNAddresses((DistributedFileSystem) desFs, conf);
    if (Sets.intersection(srcAddrs, desAddrs).size() > 0) {
      return true;
    }
  }

  return false;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:43,代码来源:FSHDFSUtils.java


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