• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java NameNodeInfo类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GetApplicationsRequestProtoOrBuilder类代码示例发布时间:2022-05-22
下一篇:
Java Cell类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap