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


Java InetSocketAddress.isUnresolved方法代码示例

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


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

示例1: getAddressesForNameserviceId

import java.net.InetSocketAddress; //导入方法依赖的package包/类
static Map<String, InetSocketAddress> getAddressesForNameserviceId(
    Configuration conf, String nsId, String defaultValue, String... keys) {
  Collection<String> nnIds = getNameNodeIds(conf, nsId);
  Map<String, InetSocketAddress> ret = Maps.newHashMap();
  for (String nnId : emptyAsSingletonNull(nnIds)) {
    String suffix = concatSuffixes(nsId, nnId);
    String address = getConfValue(defaultValue, suffix, conf, keys);
    if (address != null) {
      InetSocketAddress isa = NetUtils.createSocketAddr(address);
      if (isa.isUnresolved()) {
        LOG.warn("Namenode for {} remains unresolved for ID {}. Check your "
            + "hdfs-site.xml file to ensure namenodes are configured "
            + "properly.", nsId, nnId);
      }
      ret.put(nnId, isa);
    }
  }
  return ret;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:20,代码来源:NuCypherExtUtilClient.java

示例2: getAddressesForNameserviceId

import java.net.InetSocketAddress; //导入方法依赖的package包/类
private static Map<String, InetSocketAddress> getAddressesForNameserviceId(
    Configuration conf, String nsId, String defaultValue,
    String... keys) {
  Collection<String> nnIds = getNameNodeIds(conf, nsId);
  Map<String, InetSocketAddress> ret = Maps.newHashMap();
  for (String nnId : emptyAsSingletonNull(nnIds)) {
    String suffix = concatSuffixes(nsId, nnId);
    String address = getConfValue(defaultValue, suffix, conf, keys);
    if (address != null) {
      InetSocketAddress isa = NetUtils.createSocketAddr(address);
      if (isa.isUnresolved()) {
        LOG.warn("Namenode for " + nsId +
                 " remains unresolved for ID " + nnId +
                 ".  Check your hdfs-site.xml file to " +
                 "ensure namenodes are configured properly.");
      }
      ret.put(nnId, isa);
    }
  }
  return ret;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:DFSUtil.java

示例3: parseEntry

import java.net.InetSocketAddress; //导入方法依赖的package包/类
@VisibleForTesting
static InetSocketAddress parseEntry(String type, String fn, String line) {
  try {
    URI uri = new URI("dummy", line, null, null, null);
    int port = uri.getPort() == -1 ? 0 : uri.getPort();
    InetSocketAddress addr = new InetSocketAddress(uri.getHost(), port);
    if (addr.isUnresolved()) {
      LOG.warn(String.format("Failed to resolve address `%s` in `%s`. " +
              "Ignoring in the %s list.", line, fn, type));
      return null;
    }
    return addr;
  } catch (URISyntaxException e) {
    LOG.warn(String.format("Failed to parse `%s` in `%s`. " + "Ignoring in " +
            "the %s list.", line, fn, type));
  }
  return null;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:HostFileManager.java

示例4: importContact

import java.net.InetSocketAddress; //导入方法依赖的package包/类
DistributedDatabaseContact
importContact(
	DHTPluginContact		contact,
	int						network )

	throws DistributedDatabaseException
{
	InetSocketAddress address = contact.getAddress();

	if ( address.isUnresolved()){

		return( ddb.importContact( contact.exportToMap()));

	}else{

		return( 
			ddb.importContact( 
				address, 
				DHTTransportUDP.PROTOCOL_VERSION_MIN_AZ, 
				network==DHT.NW_AZ_CVS?DistributedDatabase.DHT_AZ_CVS:DistributedDatabase.DHT_AZ_MAIN ));
	}
}
 
开发者ID:BiglySoftware,项目名称:BiglyBT,代码行数:23,代码来源:RelatedContentSearcher.java

示例5: refresh

import java.net.InetSocketAddress; //导入方法依赖的package包/类
public static void refresh(Configuration conf){
  Collection<String> tempServers = new HashSet<String>();
  // trusted proxy servers such as http proxies
  for (String host : conf.getTrimmedStrings(CONF_HADOOP_PROXYSERVERS)) {
    InetSocketAddress addr = new InetSocketAddress(host, 0);
    if (!addr.isUnresolved()) {
      tempServers.add(addr.getAddress().getHostAddress());
    }
  }
  proxyServers = tempServers;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:12,代码来源:ProxyServers.java

示例6: buildTokenService

import java.net.InetSocketAddress; //导入方法依赖的package包/类
/**
 * Construct the service key for a token
 * @param addr InetSocketAddress of remote connection with a token
 * @return "ip:port" or "host:port" depending on the value of
 *          hadoop.security.token.service.use_ip
 */
public static Text buildTokenService(InetSocketAddress addr) {
  String host = null;
  if (useIpForTokenService) {
    if (addr.isUnresolved()) { // host has no ip address
      throw new IllegalArgumentException(
          new UnknownHostException(addr.getHostName())
      );
    }
    host = addr.getAddress().getHostAddress();
  } else {
    host = StringUtils.toLowerCase(addr.getHostName());
  }
  return new Text(host + ":" + addr.getPort());
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:21,代码来源:SecurityUtil.java

示例7: lookup

import java.net.InetSocketAddress; //导入方法依赖的package包/类
protected void lookup ()
{
    fireState ( State.LOOKUP );

    // performing lookup
    final InetSocketAddress address = new InetSocketAddress ( this.address.getHostString (), this.address.getPort () );
    if ( address.isUnresolved () )
    {
        final UnresolvedAddressException e = new UnresolvedAddressException ();
        handleDisconnected ( e );
    }

    synchronized ( this )
    {
        if ( this.executor == null )
        {
            // we got disposed, do nothing
            return;
        }
        this.executor.execute ( new Runnable () {

            @Override
            public void run ()
            {
                createClient ( address );
            }
        } );
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:30,代码来源:AutoConnectClient.java

示例8: createTunnelByConfig

import java.net.InetSocketAddress; //导入方法依赖的package包/类
public static Tunnel createTunnelByConfig(InetSocketAddress destAddress,Selector selector) throws Exception {
	if(destAddress.isUnresolved()){
		Config config=ProxyConfig.Instance.getDefaultTunnelConfig(destAddress);
		if(config instanceof HttpConnectConfig){
			return new HttpConnectTunnel((HttpConnectConfig)config,selector);
		}else if(config instanceof ShadowsocksConfig){
			return new ShadowsocksTunnel((ShadowsocksConfig)config,selector); 
		} 
		throw new Exception("The config is unknow.");
	}else {
		return new RawTunnel(destAddress, selector);
	}
}
 
开发者ID:w22ee,项目名称:onekey-proxy-android,代码行数:14,代码来源:TunnelFactory.java

示例9: createTunnelByConfig

import java.net.InetSocketAddress; //导入方法依赖的package包/类
public static Tunnel createTunnelByConfig(InetSocketAddress destAddress, Selector selector) throws Exception {
    if (destAddress.isUnresolved()) {
        Config config = ProxyConfig.Instance.getDefaultTunnelConfig(destAddress);
        if (config instanceof HttpConnectConfig) {
            return new HttpConnectTunnel((HttpConnectConfig) config, selector);
        } else if (config instanceof ShadowsocksConfig) {
            return new ShadowsocksTunnel((ShadowsocksConfig) config, selector);
        }
        throw new Exception("The config is unknow.");
    } else {
        return new RawTunnel(destAddress, selector);
    }
}
 
开发者ID:IronMan001,项目名称:ss-android,代码行数:14,代码来源:TunnelFactory.java

示例10: getHost

import java.net.InetSocketAddress; //导入方法依赖的package包/类
private String getHost(final InetSocketAddress isa) {

        //@@@ Will this work with literal IPv6 addresses, or do we
        //@@@ need to wrap these in [] for the string representation?
        //@@@ Having it in this method at least allows for easy workarounds.
       return isa.isUnresolved() ?
            isa.getHostName() : isa.getAddress().getHostAddress();

    }
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:10,代码来源:SystemDefaultRoutePlanner.java

示例11: getRMHAId

import java.net.InetSocketAddress; //导入方法依赖的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

示例12: encodeProxyRequestPacket

import java.net.InetSocketAddress; //导入方法依赖的package包/类
/**
 * Encodes the proxy authorization request packet.
 * 
 * @param request the socks proxy request data
 * @return the encoded buffer
 * @throws UnsupportedEncodingException if request's hostname charset 
 * can't be converted to ASCII. 
 */
private IoBuffer encodeProxyRequestPacket(final SocksProxyRequest request) throws UnsupportedEncodingException {
    int len = 6;
    InetSocketAddress adr = request.getEndpointAddress();
    byte addressType = 0;
    byte[] host = null;

    if (adr != null && !adr.isUnresolved()) {
        if (adr.getAddress() instanceof Inet6Address) {
            len += 16;
            addressType = SocksProxyConstants.IPV6_ADDRESS_TYPE;
        } else if (adr.getAddress() instanceof Inet4Address) {
            len += 4;
            addressType = SocksProxyConstants.IPV4_ADDRESS_TYPE;
        }
    } else {
        host = request.getHost() != null ? request.getHost().getBytes("ASCII") : null;

        if (host != null) {
            len += 1 + host.length;
            addressType = SocksProxyConstants.DOMAIN_NAME_ADDRESS_TYPE;
        } else {
            throw new IllegalArgumentException("SocksProxyRequest object " + "has no suitable endpoint information");
        }
    }

    IoBuffer buf = IoBuffer.allocate(len);

    buf.put(request.getProtocolVersion());
    buf.put(request.getCommandCode());
    buf.put((byte) 0x00); // Reserved
    buf.put(addressType);

    if (host == null) {
        buf.put(request.getIpAddress());
    } else {
        buf.put((byte) host.length);
        buf.put(host);
    }

    buf.put(request.getPort());

    return buf;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:52,代码来源:Socks5LogicHandler.java

示例13: getSuffixIDs

import java.net.InetSocketAddress; //导入方法依赖的package包/类
/**
 * Returns nameservice Id and namenode Id when the local host matches the
 * configuration parameter {@code addressKey}.<nameservice Id>.<namenode Id>
 * 
 * @param conf Configuration
 * @param addressKey configuration key corresponding to the address.
 * @param knownNsId only look at configs for the given nameservice, if not-null
 * @param knownNNId only look at configs for the given namenode, if not null
 * @param matcher matching criteria for matching the address
 * @return Array with nameservice Id and namenode Id on success. First element
 *         in the array is nameservice Id and second element is namenode Id.
 *         Null value indicates that the configuration does not have the the
 *         Id.
 * @throws HadoopIllegalArgumentException on error
 */
static String[] getSuffixIDs(final Configuration conf, final String addressKey,
    String knownNsId, String knownNNId,
    final AddressMatcher matcher) {
  String nameserviceId = null;
  String namenodeId = null;
  int found = 0;
  
  Collection<String> nsIds = getNameServiceIds(conf);
  for (String nsId : emptyAsSingletonNull(nsIds)) {
    if (knownNsId != null && !knownNsId.equals(nsId)) {
      continue;
    }
    
    Collection<String> nnIds = getNameNodeIds(conf, nsId);
    for (String nnId : emptyAsSingletonNull(nnIds)) {
      if (LOG.isTraceEnabled()) {
        LOG.trace(String.format("addressKey: %s nsId: %s nnId: %s",
            addressKey, nsId, nnId));
      }
      if (knownNNId != null && !knownNNId.equals(nnId)) {
        continue;
      }
      String key = addKeySuffixes(addressKey, nsId, nnId);
      String addr = conf.get(key);
      if (addr == null) {
        continue;
      }
      InetSocketAddress s = null;
      try {
        s = NetUtils.createSocketAddr(addr);
      } catch (Exception e) {
        LOG.warn("Exception in creating socket address " + addr, e);
        continue;
      }
      if (!s.isUnresolved() && matcher.match(s)) {
        nameserviceId = nsId;
        namenodeId = nnId;
        found++;
      }
    }
  }
  if (found > 1) { // Only one address must match the local address
    String msg = "Configuration has multiple addresses that match "
        + "local node's address. Please configure the system with "
        + DFS_NAMESERVICE_ID + " and "
        + DFS_HA_NAMENODE_ID_KEY;
    throw new HadoopIllegalArgumentException(msg);
  }
  return new String[] { nameserviceId, namenodeId };
}
 
开发者ID:naver,项目名称:hadoop,代码行数:66,代码来源:DFSUtil.java

示例14: main

import java.net.InetSocketAddress; //导入方法依赖的package包/类
public static void main(String[] args) {
    InetSocketAddress a = InetSocketAddress.createUnresolved("unresolved", 1234);
    if (!a.isUnresolved())
        throw new RuntimeException("Address is not flagged as 'unresolved'");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:6,代码来源:CreateUnresolved.java

示例15: getHost

import java.net.InetSocketAddress; //导入方法依赖的package包/类
/**
 * Obtains a host from an {@link InetSocketAddress}.
 *
 * @param isa       the socket address
 *
 * @return  a host string, either as a symbolic name or
 *          as a literal IP address string
 * <br/>
 * (TODO: determine format for IPv6 addresses, with or without [brackets])
 */
protected String getHost(InetSocketAddress isa) {

    //@@@ Will this work with literal IPv6 addresses, or do we
    //@@@ need to wrap these in [] for the string representation?
    //@@@ Having it in this method at least allows for easy workarounds.
   return isa.isUnresolved() ?
        isa.getHostName() : isa.getAddress().getHostAddress();

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:ProxySelectorRoutePlanner.java


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