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


Java DataNode.refreshNamenodes方法代码示例

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


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

示例1: addNameNode

import org.apache.hadoop.hdfs.server.datanode.DataNode; //导入方法依赖的package包/类
/**
 * Add a namenode to a federated cluster and start it. Configuration of
 * datanodes in the cluster is refreshed to register with the new namenode.
 * 
 * @return newly started namenode
 */
public NameNode addNameNode(Configuration conf, int namenodePort)
    throws IOException {
  if(!federation)
    throw new IOException("cannot add namenode to non-federated cluster");

  int nnIndex = nameNodes.length;
  int numNameNodes = nameNodes.length + 1;
  NameNodeInfo[] newlist = new NameNodeInfo[numNameNodes];
  System.arraycopy(nameNodes, 0, newlist, 0, nameNodes.length);
  nameNodes = newlist;
  String nameserviceId = NAMESERVICE_ID_PREFIX + (nnIndex + 1);
  
  String nameserviceIds = conf.get(DFS_NAMESERVICES);
  nameserviceIds += "," + nameserviceId;
  conf.set(DFS_NAMESERVICES, nameserviceIds);

  String nnId = null;
  initNameNodeAddress(conf, nameserviceId,
      new NNConf(nnId).setIpcPort(namenodePort));
  initNameNodeConf(conf, nameserviceId, nnId, true, true, nnIndex);
  createNameNode(nnIndex, conf, numDataNodes, true, null, null,
      nameserviceId, nnId);

  // Refresh datanodes with the newly started namenode
  for (DataNodeProperties dn : dataNodes) {
    DataNode datanode = dn.datanode;
    datanode.refreshNamenodes(conf);
  }

  // Wait for new namenode to get registrations from all the datanodes
  waitActive(nnIndex);
  return nameNodes[nnIndex].nameNode;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:40,代码来源:MiniDFSCluster.java

示例2: addNameNode

import org.apache.hadoop.hdfs.server.datanode.DataNode; //导入方法依赖的package包/类
/**
 * Add a namenode to a federated cluster and start it. Configuration of
 * datanodes in the cluster is refreshed to register with the new namenode.
 * 
 * @return newly started namenode
 */
public void addNameNode(Configuration conf, int namenodePort)
    throws IOException {
  if(!federation)
    throw new IOException("cannot add namenode to non-federated cluster");

  int nameServiceIndex = namenodes.keys().size();
  String nameserviceId = NAMESERVICE_ID_PREFIX + (namenodes.keys().size() + 1);

  String nameserviceIds = conf.get(DFS_NAMESERVICES);
  nameserviceIds += "," + nameserviceId;
  conf.set(DFS_NAMESERVICES, nameserviceIds);

  String nnId = null;
  initNameNodeAddress(conf, nameserviceId,
      new NNConf(nnId).setIpcPort(namenodePort));
  // figure out the current number of NNs
  NameNodeInfo[] infos = this.getNameNodeInfos(nameserviceId);
  int nnIndex = infos == null ? 0 : infos.length;
  initNameNodeConf(conf, nameserviceId, nameServiceIndex, nnId, true, true, nnIndex);
  createNameNode(conf, true, null, null, nameserviceId, nnId);

  // Refresh datanodes with the newly started namenode
  for (DataNodeProperties dn : dataNodes) {
    DataNode datanode = dn.datanode;
    datanode.refreshNamenodes(conf);
  }

  // Wait for new namenode to get registrations from all the datanodes
  waitActive(nnIndex);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:37,代码来源:MiniDFSCluster.java


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