This method checks for designated role, according to local IP addresses and configuration passed into method

@param voidConfiguration
@param localIPs
@return
760057
protected Pair<NodeRole, String> getRole(@NonNull VoidConfiguration voidConfiguration,
                    @NonNull Collection<String> localIPs) {
        NodeRole result = NodeRole.CLIENT;

        for (String ip : voidConfiguration.getShardAddresses()) {
            String cleansed = ip.replaceAll(":.*", "");
            if (localIPs.contains(cleansed))
                return Pair.create(NodeRole.SHARD, ip);
        }

        if (voidConfiguration.getBackupAddresses() != null)
            for (String ip : voidConfiguration.getBackupAddresses()) {
                String cleansed = ip.replaceAll(":.*", "");
                if (localIPs.contains(cleansed))
                    return Pair.create(NodeRole.BACKUP, ip);
            }


        String sparkIp = null;


        if (sparkIp == null && voidConfiguration.getNetworkMask() != null) {
            NetworkOrganizer organizer = new NetworkOrganizer(voidConfiguration.getNetworkMask());
            sparkIp = organizer.getMatchingAddress();
        }

        // last resort here...
        if (sparkIp == null)
            sparkIp = System.getenv(ND4JEnvironmentVars.DL4J_VOID_IP);


        log.info("Got [{}] as sparkIp", sparkIp);
        if (sparkIp == null)
            throw new ND4JIllegalStateException("Can't get IP address for UDP communcation");

        // local IP from pair is used for shard only, so we don't care
        return Pair.create(result, sparkIp + ":" + voidConfiguration.getUnicastControllerPort());
    }
1193576
public static boolean isValidLocalIP(InetAddress ip) throws SocketException   {
        String ipStr = ip.getHostAddress();
        
        Iterator ips = getAllIPAddresses().iterator();
        while (ips.hasNext()) {
            InetAddress ip2 = (InetAddress) ips.next();
            if (ip2.getHostAddress().equals(ipStr)) {
                return true;
            }
        }
        
        return false;
    }
1143505
@Override
  public InetSocketAddress ipLocal()
  {
    SocketChannel s = _channel;
    
    if (s != null) {
      try {
        return (InetSocketAddress) s.getLocalAddress();
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
    }
    else {
      return null;
    }
  }
251727
public void setDnsIpAddresses(java.util.Collection<String> dnsIpAddresses) {
        if (dnsIpAddresses == null) {
            this.dnsIpAddresses = null;
            return;
        }

        this.dnsIpAddresses = new com.amazonaws.internal.SdkInternalList<String>(dnsIpAddresses);
    }
1071316
public void setIpV6Addresses(java.util.Collection<String> ipV6Addresses) {
        if (ipV6Addresses == null) {
            this.ipV6Addresses = null;
            return;
        }

        this.ipV6Addresses = new java.util.ArrayList<String>(ipV6Addresses);
    }
860594
@Override
    public final void setDefaultLocalAddresses(List<? extends SocketAddress> localAddresses) {
        if (localAddresses == null) {
            throw new NullPointerException("localAddresses");
        }
        setDefaultLocalAddresses((Iterable<? extends SocketAddress>) localAddresses);
    }
408838
private boolean isLocalIpAddress(InetAddress addr) {
    if (addr.isAnyLocalAddress() || addr.isLoopbackAddress())
      return true;
    try {
      return NetworkInterface.getByInetAddress(addr) != null;
    } catch (SocketException e) {
      return false;
    }
  }
519506
public void setResourceAwsEc2InstanceIpV4Addresses(java.util.Collection<IpFilter> resourceAwsEc2InstanceIpV4Addresses) {
        if (resourceAwsEc2InstanceIpV4Addresses == null) {
            this.resourceAwsEc2InstanceIpV4Addresses = null;
            return;
        }

        this.resourceAwsEc2InstanceIpV4Addresses = new java.util.ArrayList<IpFilter>(resourceAwsEc2InstanceIpV4Addresses);
    }
312800
public void setInboundPermissions(java.util.Collection<IpPermission> inboundPermissions) {
        if (inboundPermissions == null) {
            this.inboundPermissions = null;
            return;
        }

        this.inboundPermissions = new java.util.ArrayList<IpPermission>(inboundPermissions);
    }
982448
public void setVpnConnections(java.util.Collection<VpnConnection> vpnConnections) {
        if (vpnConnections == null) {
            this.vpnConnections = null;
            return;
        }

        this.vpnConnections = new com.amazonaws.internal.SdkInternalList<VpnConnection>(vpnConnections);
    }
470647
@Nullable
    public static String determineIpAddress() throws SocketException {
        SocketException caughtException = null;
        for (final Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces(); networkInterfaces.hasMoreElements();) {
            try {
                final NetworkInterface nextInterface = networkInterfaces.nextElement();
                if (! nextInterface.isLoopback() && ! nextInterface.isVirtual() && ! nextInterface.isPointToPoint()) {
                    for (final Enumeration<InetAddress> addresses = nextInterface.getInetAddresses(); addresses.hasMoreElements(); ) {
                        final InetAddress inetAddress = addresses.nextElement();
                        final byte[] address = inetAddress.getAddress();
                        if ((address.length == 4) //  we don't need no steenking IPv6
                                && ((address[0] != 127) || (address[1] != 0))) {    //  don't want localhost IP
                            return inetAddress.getHostAddress();
                        }
                    }
                }
            } catch (SocketException ex) {
                // We're not going to extract an IP address from this interface, so move on to the next one.
                // If we find a qualifying interface, we won't care that some other interface gave us problems.
                // If we don't find one, this exception might be informative.
                caughtException = ex;
            }
        }

        if (caughtException != null) {
            throw caughtException;
        }
        return null;
    }
1220462
public void setIpv6Addresses(java.util.Collection<ScheduledInstancesIpv6Address> ipv6Addresses) {
        if (ipv6Addresses == null) {
            this.ipv6Addresses = null;
            return;
        }

        this.ipv6Addresses = new com.amazonaws.internal.SdkInternalList<ScheduledInstancesIpv6Address>(ipv6Addresses);
    }
1298216
public final B serverAddresses(Iterable<InetSocketAddress> serverAddresses) {
        requireNonNull(serverAddresses, "serverAddresses");
        final DnsServerAddresses addrs = DnsServerAddresses.sequential(serverAddresses);
        serverAddressStreamProvider = hostname -> addrs.stream();
        return self();
    }
536412
public void setDhcpConfigurations(java.util.Collection<DhcpConfiguration> dhcpConfigurations) {
        if (dhcpConfigurations == null) {
            this.dhcpConfigurations = null;
            return;
        }

        this.dhcpConfigurations = new com.amazonaws.internal.SdkInternalList<DhcpConfiguration>(dhcpConfigurations);
    }
746168
protected void configureFoursquareClient(final Collection<BaseClient> properties) {
        val foursquare = pac4jProperties.getFoursquare();
        if (StringUtils.isNotBlank(foursquare.getId()) && StringUtils.isNotBlank(foursquare.getSecret())) {
            val client = new FoursquareClient(foursquare.getId(), foursquare.getSecret());
            configureClient(client, foursquare);

            LOGGER.debug("Created client [{}] with identifier [{}]", client.getName(), client.getKey());
            properties.add(client);
        }
    }
1082959
@Override
  public InetSocketAddress ipLocal()
  {
    Socket s = getSocket();
    
    if (s != null) {
      return (InetSocketAddress) s.getLocalSocketAddress();
    }
    else {
      return null;
    }
  }
108755
public void setIpV4Addresses(java.util.Collection<String> ipV4Addresses) {
        if (ipV4Addresses == null) {
            this.ipV4Addresses = null;
            return;
        }

        this.ipV4Addresses = new java.util.ArrayList<String>(ipV4Addresses);
    }