當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。