org.jgroups.util.Util.getIpStackType()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(168)

本文整理了Java中org.jgroups.util.Util.getIpStackType()方法的一些代码示例,展示了Util.getIpStackType()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.getIpStackType()方法的具体详情如下:
包路径:org.jgroups.util.Util
类名称:Util
方法名:getIpStackType

Util.getIpStackType介绍

暂无

代码示例

代码示例来源:origin: wildfly/wildfly

protected void bindToInterfaces(List<NetworkInterface> interfaces, MulticastSocket s, InetAddress mcast_addr) throws IOException {
  SocketAddress tmp_mcast_addr=new InetSocketAddress(mcast_addr, mcast_port);
  for(Iterator it=interfaces.iterator(); it.hasNext();) {
    NetworkInterface i=(NetworkInterface)it.next();
    for(Enumeration en2=i.getInetAddresses(); en2.hasMoreElements();) {
      InetAddress addr=(InetAddress)en2.nextElement();
      if ((Util.getIpStackType() == StackType.IPv4 && addr instanceof Inet4Address)
       || (Util.getIpStackType() == StackType.IPv6 && addr instanceof Inet6Address)) {
        s.joinGroup(tmp_mcast_addr, i);
        log.trace("joined " + tmp_mcast_addr + " on " + i.getName() + " (" + addr + ")");
        break;
      }
    }
  }
}

代码示例来源:origin: wildfly/wildfly

public static InetAddress getLocalhost() throws UnknownHostException {
  return getLocalhost(Util.getIpStackType());
}

代码示例来源:origin: wildfly/wildfly

StackType ip_version=Util.getIpStackType();
for(Enumeration addresses=intf.getInetAddresses(); addresses.hasMoreElements(); ) {
  InetAddress addr=(InetAddress)addresses.nextElement();

代码示例来源:origin: wildfly/wildfly

public static void setDefaultValues(List<Protocol> protocols) throws Exception {
  if(protocols == null)
    return;
  // check InetAddress related features of stack
  Collection<InetAddress> addrs=getInetAddresses(protocols);
  StackType ip_version=Util.getIpStackType(); // 0 = n/a, 4 = IPv4, 6 = IPv6
  if(!addrs.isEmpty()) {
    // check that all user-supplied InetAddresses have a consistent version:
    // 1. If an addr is IPv6 and we have an IPv4 stack --> FAIL
    // 2. If an address is an IPv4 class D (multicast) address and the stack is IPv6: FAIL
    // Else pass
    for(InetAddress addr : addrs) {
      if(addr instanceof Inet6Address && ip_version == StackType.IPv4)
        throw new IllegalArgumentException("found IPv6 address " + addr + " in an IPv4 stack");
      if(addr instanceof Inet4Address && addr.isMulticastAddress() && ip_version == StackType.IPv6)
        throw new Exception("found IPv4 multicast address " + addr + " in an IPv6 stack");
    }
  }
  // process default values
  setDefaultValues(protocols, ip_version);
}

代码示例来源:origin: wildfly/wildfly

protected static InetAddress convertBindAddress(String value) throws Exception {
  InetAddress retval=null;
  Util.AddressScope addr_scope=null;
  try {
    addr_scope=Util.AddressScope.valueOf(value.toUpperCase());
  }
  catch(Throwable ignored) {
  }
  if(addr_scope != null)
    retval=Util.getAddress(addr_scope);
  else {
    if(value.startsWith("match"))
      retval=Util.getAddressByPatternMatch(value);
    else if(value.startsWith("custom:"))
      retval=getAddressByCustomCode(value.substring("custom:".length()));
    else
      retval=InetAddress.getByName(value);
  }
  if(retval instanceof Inet4Address && retval.isMulticastAddress() && Util.getIpStackType() == StackType.IPv6) {
    String tmp=prefix + value;
    retval=InetAddress.getByName(tmp);
    return retval;
  }
  return retval;
}

代码示例来源:origin: wildfly/wildfly

StackType stack_type=Util.getIpStackType();
boolean ipv6=stack_type == StackType.IPv6;
InetAddress addr=InetAddress.getByName(ipv6? DEFAULT_DIAG_ADDR_IPv6 : DEFAULT_DIAG_ADDR);

代码示例来源:origin: wildfly/wildfly

StackType ip_version=getIpStackType();

代码示例来源:origin: wildfly/wildfly

Collection<InetAddress> addrs=getAddresses(inetAddressMap);
StackType ip_version=Util.getIpStackType();

代码示例来源:origin: org.jboss.eap/wildfly-client-all

protected void bindToInterfaces(List<NetworkInterface> interfaces, MulticastSocket s, InetAddress mcast_addr) throws IOException {
  SocketAddress tmp_mcast_addr=new InetSocketAddress(mcast_addr, mcast_port);
  for(Iterator it=interfaces.iterator(); it.hasNext();) {
    NetworkInterface i=(NetworkInterface)it.next();
    for(Enumeration en2=i.getInetAddresses(); en2.hasMoreElements();) {
      InetAddress addr=(InetAddress)en2.nextElement();
      if ((Util.getIpStackType() == StackType.IPv4 && addr instanceof Inet4Address)
       || (Util.getIpStackType() == StackType.IPv6 && addr instanceof Inet6Address)) {
        s.joinGroup(tmp_mcast_addr, i);
        log.trace("joined " + tmp_mcast_addr + " on " + i.getName() + " (" + addr + ")");
        break;
      }
    }
  }
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

public static InetAddress getLocalhost() throws UnknownHostException {
  return getLocalhost(Util.getIpStackType());
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

StackType ip_version=Util.getIpStackType();
for(Enumeration addresses=intf.getInetAddresses(); addresses.hasMoreElements(); ) {
  InetAddress addr=(InetAddress)addresses.nextElement();

代码示例来源:origin: org.jboss.eap/wildfly-client-all

public static void setDefaultValues(List<Protocol> protocols) throws Exception {
  if(protocols == null)
    return;
  // check InetAddress related features of stack
  Collection<InetAddress> addrs=getInetAddresses(protocols);
  StackType ip_version=Util.getIpStackType(); // 0 = n/a, 4 = IPv4, 6 = IPv6
  if(!addrs.isEmpty()) {
    // check that all user-supplied InetAddresses have a consistent version:
    // 1. If an addr is IPv6 and we have an IPv4 stack --> FAIL
    // 2. If an address is an IPv4 class D (multicast) address and the stack is IPv6: FAIL
    // Else pass
    for(InetAddress addr : addrs) {
      if(addr instanceof Inet6Address && ip_version == StackType.IPv4)
        throw new IllegalArgumentException("found IPv6 address " + addr + " in an IPv4 stack");
      if(addr instanceof Inet4Address && addr.isMulticastAddress() && ip_version == StackType.IPv6)
        throw new Exception("found IPv4 multicast address " + addr + " in an IPv6 stack");
    }
  }
  // process default values
  setDefaultValues(protocols, ip_version);
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

StackType ip_version=getIpStackType();

代码示例来源:origin: org.jboss.eap/wildfly-client-all

protected static InetAddress convertBindAddress(String value) throws Exception {
  InetAddress retval=null;
  Util.AddressScope addr_scope=null;
  try {
    addr_scope=Util.AddressScope.valueOf(value.toUpperCase());
  }
  catch(Throwable ex) {
  }
  if(addr_scope != null)
    retval=Util.getAddress(addr_scope);
  else {
    if(value.startsWith("match"))
      retval=Util.getAddressByPatternMatch(value);
    else if(value.startsWith("custom:"))
      retval=getAddressByCustomCode(value.substring("custom:".length()));
    else
      retval=InetAddress.getByName(value);
  }
  if(retval instanceof Inet4Address && retval.isMulticastAddress() && Util.getIpStackType() == StackType.IPv6) {
    String tmp=prefix + value;
    retval=InetAddress.getByName(tmp);
    return retval;
  }
  return retval;
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

StackType stack_type=Util.getIpStackType();
boolean ipv6=stack_type == StackType.IPv6;
InetAddress addr=InetAddress.getByName(ipv6? DEFAULT_DIAG_ADDR_IPv6 : DEFAULT_DIAG_ADDR);

代码示例来源:origin: org.jboss.eap/wildfly-client-all

Collection<InetAddress> addrs=getAddresses(inetAddressMap);
StackType ip_version=Util.getIpStackType(); // 0 = n/a, 4 = IPv4, 6 = IPv6

相关文章

Util类方法