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


Java NetUtils.isLocalAddress方法代码示例

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


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

示例1: getRmClient

import org.apache.hadoop.net.NetUtils; //导入方法依赖的package包/类
private static ApplicationClientProtocol getRmClient(Token<?> token,
    Configuration conf) throws IOException {
  String[] services = token.getService().toString().split(",");
  for (String service : services) {
    InetSocketAddress addr = NetUtils.createSocketAddr(service);
    if (localSecretManager != null) {
      // return null if it's our token
      if (localServiceAddress.getAddress().isAnyLocalAddress()) {
        if (NetUtils.isLocalAddress(addr.getAddress()) &&
            addr.getPort() == localServiceAddress.getPort()) {
          return null;
        }
      } else if (addr.equals(localServiceAddress)) {
        return null;
      }
    }
  }
  return ClientRMProxy.createRMProxy(conf, ApplicationClientProtocol.class);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:RMDelegationTokenIdentifier.java

示例2: isLocalAddress

import org.apache.hadoop.net.NetUtils; //导入方法依赖的package包/类
public static boolean isLocalAddress(InetSocketAddress targetAddr) {
  InetAddress addr = targetAddr.getAddress();
  Boolean cached = localAddrMap.get(addr.getHostAddress());
  if (cached != null) {
    if (LOG.isTraceEnabled()) {
      LOG.trace("Address " + targetAddr +
                (cached ? " is local" : " is not local"));
    }
    return cached;
  }
  
  boolean local = NetUtils.isLocalAddress(addr);

  if (LOG.isTraceEnabled()) {
    LOG.trace("Address " + targetAddr +
              (local ? " is local" : " is not local"));
  }
  localAddrMap.put(addr.getHostAddress(), local);
  return local;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:DFSClient.java

示例3: isLocalAddress

import org.apache.hadoop.net.NetUtils; //导入方法依赖的package包/类
public static boolean isLocalAddress(InetSocketAddress targetAddr) {
  InetAddress addr = targetAddr.getAddress();
  Boolean cached = localAddrMap.get(addr.getHostAddress());
  if (cached != null) {
    LOG.trace("Address {} is {} local", targetAddr, (cached ? "" : "not"));
    return cached;
  }

  boolean local = NetUtils.isLocalAddress(addr);

  LOG.trace("Address {} is {} local", targetAddr, (local ? "" : "not"));
  localAddrMap.put(addr.getHostAddress(), local);
  return local;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:15,代码来源:NuCypherExtUtilClient.java

示例4: getRMHAId

import org.apache.hadoop.net.NetUtils; //导入方法依赖的package包/类
/**
 * @param conf Configuration. Please use verifyAndSetRMHAId to check.
 * @return RM Id on success
 */
public static String getRMHAId(Configuration conf) {
  int found = 0;
  String currentRMId = conf.getTrimmed(YarnConfiguration.RM_HA_ID);
  if(currentRMId == null) {
    for(String rmId : getRMHAIds(conf)) {
      String key = addSuffix(YarnConfiguration.RM_ADDRESS, rmId);
      String addr = conf.get(key);
      if (addr == null) {
        continue;
      }
      InetSocketAddress s;
      try {
        s = NetUtils.createSocketAddr(addr);
      } catch (Exception e) {
        LOG.warn("Exception in creating socket address " + addr, e);
        continue;
      }
      if (!s.isUnresolved() && NetUtils.isLocalAddress(s.getAddress())) {
        currentRMId = rmId.trim();
        found++;
      }
    }
  }
  if (found > 1) { // Only one address must match the local address
    String msg = "The HA Configuration has multiple addresses that match "
        + "local node's address.";
    throw new HadoopIllegalArgumentException(msg);
  }
  return currentRMId;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:35,代码来源:HAUtil.java

示例5: match

import org.apache.hadoop.net.NetUtils; //导入方法依赖的package包/类
@Override
public boolean match(InetSocketAddress s) {
  return NetUtils.isLocalAddress(s.getAddress());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:5,代码来源:DFSUtil.java


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