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


Java NameNodeInfo类代码示例

本文整理汇总了Java中org.apache.hadoop.hdfs.MiniDFSCluster.NameNodeInfo的典型用法代码示例。如果您正苦于以下问题:Java NameNodeInfo类的具体用法?Java NameNodeInfo怎么用?Java NameNodeInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NameNodeInfo类属于org.apache.hadoop.hdfs.MiniDFSCluster包,在下文中一共展示了NameNodeInfo类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setFederatedHAConfiguration

import org.apache.hadoop.hdfs.MiniDFSCluster.NameNodeInfo; //导入依赖的package包/类
public static void setFederatedHAConfiguration(MiniDFSCluster cluster,
    Configuration conf) {
  Map<String, List<String>> nameservices = Maps.newHashMap();
  for (NameNodeInfo info : cluster.getNameNodeInfos()) {
    Preconditions.checkState(info.nameserviceId != null);
    List<String> nns = nameservices.get(info.nameserviceId);
    if (nns == null) {
      nns = Lists.newArrayList();
      nameservices.put(info.nameserviceId, nns);
    }
    nns.add(info.nnId);

    conf.set(DFSUtil.addKeySuffixes(DFS_NAMENODE_RPC_ADDRESS_KEY,
        info.nameserviceId, info.nnId),
        DFSUtil.createUri(HdfsConstants.HDFS_URI_SCHEME,
        info.nameNode.getNameNodeAddress()).toString());
    conf.set(DFSUtil.addKeySuffixes(DFS_NAMENODE_SERVICE_RPC_ADDRESS_KEY,
        info.nameserviceId, info.nnId),
        DFSUtil.createUri(HdfsConstants.HDFS_URI_SCHEME,
        info.nameNode.getNameNodeAddress()).toString());
  }
  for (Map.Entry<String, List<String>> entry : nameservices.entrySet()) {
    conf.set(DFSUtil.addKeySuffixes(DFS_HA_NAMENODES_KEY_PREFIX,
        entry.getKey()), Joiner.on(",").join(entry.getValue()));
    conf.set(DFS_CLIENT_FAILOVER_PROXY_PROVIDER_KEY_PREFIX + "." + entry
        .getKey(), ConfiguredFailoverProxyProvider.class.getName());
  }
  conf.set(DFSConfigKeys.DFS_NAMESERVICES, Joiner.on(",")
      .join(nameservices.keySet()));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:31,代码来源:DFSTestUtil.java

示例2: setFederatedHAConfiguration

import org.apache.hadoop.hdfs.MiniDFSCluster.NameNodeInfo; //导入依赖的package包/类
public static void setFederatedHAConfiguration(MiniDFSCluster cluster,
    Configuration conf) {
  Map<String, List<String>> nameservices = Maps.newHashMap();
  for (NameNodeInfo info : cluster.getNameNodeInfos()) {
    Preconditions.checkState(info.nameserviceId != null);
    List<String> nns = nameservices.get(info.nameserviceId);
    if (nns == null) {
      nns = Lists.newArrayList();
      nameservices.put(info.nameserviceId, nns);
    }
    nns.add(info.nnId);

    conf.set(DFSUtil.addKeySuffixes(DFS_NAMENODE_RPC_ADDRESS_KEY,
        info.nameserviceId, info.nnId),
        DFSUtil.createUri(HdfsConstants.HDFS_URI_SCHEME,
        info.nameNode.getNameNodeAddress()).toString());
    conf.set(DFSUtil.addKeySuffixes(DFS_NAMENODE_SERVICE_RPC_ADDRESS_KEY,
        info.nameserviceId, info.nnId),
        DFSUtil.createUri(HdfsConstants.HDFS_URI_SCHEME,
        info.nameNode.getNameNodeAddress()).toString());
  }
  for (Map.Entry<String, List<String>> entry : nameservices.entrySet()) {
    conf.set(DFSUtil.addKeySuffixes(DFS_HA_NAMENODES_KEY_PREFIX,
        entry.getKey()), Joiner.on(",").join(entry.getValue()));
    conf.set(HdfsClientConfigKeys.Failover.PROXY_PROVIDER_KEY_PREFIX + "."
        + entry.getKey(), ConfiguredFailoverProxyProvider.class.getName());
  }
  conf.set(DFSConfigKeys.DFS_NAMESERVICES, Joiner.on(",")
      .join(nameservices.keySet()));
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:31,代码来源:DFSTestUtil.java

示例3: testSetUpFederatedCluster

import org.apache.hadoop.hdfs.MiniDFSCluster.NameNodeInfo; //导入依赖的package包/类
@Test
public void testSetUpFederatedCluster() throws Exception {
  Configuration conf = new Configuration();
  MiniDFSCluster  cluster =
          new MiniDFSCluster.Builder(conf).nnTopology(
                  MiniDFSNNTopology.simpleHAFederatedTopology(2))
              .numDataNodes(2)
              .build();
  try {
    cluster.waitActive();
    cluster.transitionToActive(1);
    cluster.transitionToActive(3);
    assertEquals("standby", cluster.getNamesystem(0).getHAState());
    assertEquals("active", cluster.getNamesystem(1).getHAState());
    assertEquals("standby", cluster.getNamesystem(2).getHAState());
    assertEquals("active", cluster.getNamesystem(3).getHAState());

    String ns0nn0 = conf.get(
        DFSUtil.addKeySuffixes(DFS_NAMENODE_HTTP_ADDRESS_KEY, "ns0", "nn0"));
    String ns0nn1 = conf.get(
        DFSUtil.addKeySuffixes(DFS_NAMENODE_HTTP_ADDRESS_KEY, "ns0", "nn1"));
    String ns1nn0 = conf.get(
        DFSUtil.addKeySuffixes(DFS_NAMENODE_HTTP_ADDRESS_KEY, "ns1", "nn0"));
    String ns1nn1 = conf.get(
        DFSUtil.addKeySuffixes(DFS_NAMENODE_HTTP_ADDRESS_KEY, "ns1", "nn1"));

    for(NameNodeInfo nnInfo : cluster.getNameNodeInfos()) {
      assertEquals(ns0nn0, nnInfo.conf.get(
          DFSUtil.addKeySuffixes(
          DFS_NAMENODE_HTTP_ADDRESS_KEY, "ns0", "nn0")));
      assertEquals(ns0nn1, nnInfo.conf.get(
          DFSUtil.addKeySuffixes(
          DFS_NAMENODE_HTTP_ADDRESS_KEY, "ns0", "nn1")));
      assertEquals(ns1nn0, nnInfo.conf.get(
          DFSUtil.addKeySuffixes(
          DFS_NAMENODE_HTTP_ADDRESS_KEY, "ns1", "nn0")));
      assertEquals(ns1nn1, nnInfo.conf.get(
          DFSUtil.addKeySuffixes(
          DFS_NAMENODE_HTTP_ADDRESS_KEY, "ns1", "nn1")));
    }
  } finally {
    MiniDFSCluster.shutdownCluster(cluster);
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:45,代码来源:TestMiniDFSCluster.java


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