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


Java HAUtil.getConfForOtherNodes方法代码示例

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


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

示例1: getRemoteNameNodes

import org.apache.hadoop.hdfs.HAUtil; //导入方法依赖的package包/类
public static List<RemoteNameNodeInfo> getRemoteNameNodes(Configuration conf, String nsId)
    throws IOException {
  // there is only a single NN configured (and no federation) so we don't have any more NNs
  if (nsId == null) {
    return Collections.emptyList();
  }
  List<Configuration> otherNodes = HAUtil.getConfForOtherNodes(conf);
  List<RemoteNameNodeInfo> nns = new ArrayList<RemoteNameNodeInfo>();

  for (Configuration otherNode : otherNodes) {
    String otherNNId = HAUtil.getNameNodeId(otherNode, nsId);
    // don't do any validation here as in some cases, it can be overwritten later
    InetSocketAddress otherIpcAddr = NameNode.getServiceAddress(otherNode, true);


    final String scheme = DFSUtil.getHttpClientScheme(conf);
    URL otherHttpAddr = DFSUtil.getInfoServerWithDefaultHost(otherIpcAddr.getHostName(),
        otherNode, scheme).toURL();

    nns.add(new RemoteNameNodeInfo(otherNode, otherNNId, otherIpcAddr, otherHttpAddr));
  }
  return nns;
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:24,代码来源:RemoteNameNodeInfo.java

示例2: setNameNodeAddresses

import org.apache.hadoop.hdfs.HAUtil; //导入方法依赖的package包/类
/**
 * Determine the address of the NN we are checkpointing
 * as well as our own HTTP address from the configuration.
 * @throws IOException 
 */
private void setNameNodeAddresses(Configuration conf) throws IOException {
  // Look up our own address.
  myNNAddress = getHttpAddress(conf);

  // Look up the active node's address
  List<Configuration> confForActive = HAUtil.getConfForOtherNodes(conf);
  activeNNAddresses = new ArrayList<URL>(confForActive.size());
  for (Configuration activeConf : confForActive) {
    URL activeNNAddress = getHttpAddress(activeConf);

    // sanity check each possible active NN
    Preconditions.checkArgument(checkAddress(activeNNAddress),
        "Bad address for active NN: %s", activeNNAddress);

    activeNNAddresses.add(activeNNAddress);
  }

  // Sanity-check.
  Preconditions.checkArgument(checkAddress(myNNAddress), "Bad address for standby NN: %s",
      myNNAddress);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:27,代码来源:StandbyCheckpointer.java

示例3: isValidRequestor

import org.apache.hadoop.hdfs.HAUtil; //导入方法依赖的package包/类
@VisibleForTesting
static boolean isValidRequestor(ServletContext context, String remoteUser,
    Configuration conf) throws IOException {
  if (remoteUser == null) { // This really shouldn't happen...
    LOG.warn("Received null remoteUser while authorizing access to getImage servlet");
    return false;
  }

  Set<String> validRequestors = new HashSet<String>();

  validRequestors.add(SecurityUtil.getServerPrincipal(conf
      .get(DFSConfigKeys.DFS_NAMENODE_KERBEROS_PRINCIPAL_KEY),
      DFSUtilClient.getNNAddress(conf).getHostName()));
  try {
    validRequestors.add(
        SecurityUtil.getServerPrincipal(conf
            .get(DFSConfigKeys.DFS_SECONDARY_NAMENODE_KERBEROS_PRINCIPAL_KEY),
            SecondaryNameNode.getHttpAddress(conf).getHostName()));
  } catch (Exception e) {
    // Don't halt if SecondaryNameNode principal could not be added.
    LOG.debug("SecondaryNameNode principal could not be added", e);
    String msg = String.format(
      "SecondaryNameNode principal not considered, %s = %s, %s = %s",
      DFSConfigKeys.DFS_SECONDARY_NAMENODE_KERBEROS_PRINCIPAL_KEY,
      conf.get(DFSConfigKeys.DFS_SECONDARY_NAMENODE_KERBEROS_PRINCIPAL_KEY),
      DFSConfigKeys.DFS_NAMENODE_SECONDARY_HTTP_ADDRESS_KEY,
      conf.getTrimmed(DFSConfigKeys.DFS_NAMENODE_SECONDARY_HTTP_ADDRESS_KEY,
        DFSConfigKeys.DFS_NAMENODE_SECONDARY_HTTP_ADDRESS_DEFAULT));
    LOG.warn(msg);
  }

  if (HAUtil.isHAEnabled(conf, DFSUtil.getNamenodeNameServiceId(conf))) {
    List<Configuration> otherNnConfs = HAUtil.getConfForOtherNodes(conf);
    for (Configuration otherNnConf : otherNnConfs) {
      validRequestors.add(SecurityUtil.getServerPrincipal(otherNnConf
              .get(DFSConfigKeys.DFS_NAMENODE_KERBEROS_PRINCIPAL_KEY),
          DFSUtilClient.getNNAddress(otherNnConf).getHostName()));
    }
  }

  for (String v : validRequestors) {
    if (v != null && v.equals(remoteUser)) {
      LOG.info("ImageServlet allowing checkpointer: " + remoteUser);
      return true;
    }
  }

  if (HttpServer2.userHasAdministratorAccess(context, remoteUser)) {
    LOG.info("ImageServlet allowing administrator: " + remoteUser);
    return true;
  }

  LOG.info("ImageServlet rejecting: " + remoteUser);
  return false;
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:56,代码来源:ImageServlet.java


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