/** * This utility method tries to connect to the JobManager using the InetAddress returned by * InetAddress.getLocalHost(). The purpose of the utility is to have a final try connecting to * the target address using the LocalHost before using the address returned. * We do a second try because the JM might have been unavailable during the first check. * * @param preliminaryResult The address detected by the heuristic * @return either the preliminaryResult or the address returned by InetAddress.getLocalHost() (if * we are able to connect to targetAddress from there) */ private static InetAddress tryLocalHostBeforeReturning( InetAddress preliminaryResult, SocketAddress targetAddress, boolean logging) throws IOException { InetAddress localhostName = InetAddress.getLocalHost(); if (preliminaryResult.equals(localhostName)) { // preliminary result is equal to the local host name return preliminaryResult; } else if (tryToConnect(localhostName, targetAddress, AddressDetectionState.SLOW_CONNECT.getTimeout(), logging)) { // success, we were able to use local host to connect LOG.debug("Preferring {} (InetAddress.getLocalHost()) for local bind point over previous candidate {}", localhostName, preliminaryResult); return localhostName; } else { // we have to make the preliminary result the final result return preliminaryResult; } }
if (tryToConnect(localhostName, targetAddress, strategy.getTimeout(), logging)) { LOG.debug("Using InetAddress.getLocalHost() immediately for the connecting address"); targetAddress, interfaceAddress); if (tryToConnect(interfaceAddress, targetAddress, strategy.getTimeout(), logging)) { return tryLocalHostBeforeReturning(interfaceAddress, targetAddress, logging); case SLOW_CONNECT: LOG.debug("Trying to connect to {} from local address {} with timeout {}", targetAddress, interfaceAddress, strategy.getTimeout()); if (tryToConnect(interfaceAddress, targetAddress, strategy.getTimeout(), logging)) { return tryLocalHostBeforeReturning(interfaceAddress, targetAddress, logging);
if (tryToConnect(localhostName, targetAddress, strategy.getTimeout(), logging)) { LOG.debug("Using InetAddress.getLocalHost() immediately for the connecting address"); targetAddress, interfaceAddress); if (tryToConnect(interfaceAddress, targetAddress, strategy.getTimeout(), logging)) { return tryLocalHostBeforeReturning(interfaceAddress, targetAddress, logging); case SLOW_CONNECT: LOG.debug("Trying to connect to {} from local address {} with timeout {}", targetAddress, interfaceAddress, strategy.getTimeout()); if (tryToConnect(interfaceAddress, targetAddress, strategy.getTimeout(), logging)) { return tryLocalHostBeforeReturning(interfaceAddress, targetAddress, logging);
if (tryToConnect(localhostName, targetAddress, strategy.getTimeout(), logging)) { LOG.debug("Using InetAddress.getLocalHost() immediately for the connecting address"); targetAddress, interfaceAddress); if (tryToConnect(interfaceAddress, targetAddress, strategy.getTimeout(), logging)) { return tryLocalHostBeforeReturning(interfaceAddress, targetAddress, logging); case SLOW_CONNECT: LOG.debug("Trying to connect to {} from local address {} with timeout {}", targetAddress, interfaceAddress, strategy.getTimeout()); if (tryToConnect(interfaceAddress, targetAddress, strategy.getTimeout(), logging)) { return tryLocalHostBeforeReturning(interfaceAddress, targetAddress, logging);
if (tryToConnect(localhostName, targetAddress, strategy.getTimeout(), logging)) { LOG.debug("Using InetAddress.getLocalHost() immediately for the connecting address"); targetAddress, interfaceAddress); if (tryToConnect(interfaceAddress, targetAddress, strategy.getTimeout(), logging)) { return tryLocalHostBeforeReturning(interfaceAddress, targetAddress, logging); case SLOW_CONNECT: LOG.debug("Trying to connect to {} from local address {} with timeout {}", targetAddress, interfaceAddress, strategy.getTimeout()); if (tryToConnect(interfaceAddress, targetAddress, strategy.getTimeout(), logging)) { return tryLocalHostBeforeReturning(interfaceAddress, targetAddress, logging);
/** * This utility method tries to connect to the JobManager using the InetAddress returned by * InetAddress.getLocalHost(). The purpose of the utility is to have a final try connecting to * the target address using the LocalHost before using the address returned. * We do a second try because the JM might have been unavailable during the first check. * * @param preliminaryResult The address detected by the heuristic * @return either the preliminaryResult or the address returned by InetAddress.getLocalHost() (if * we are able to connect to targetAddress from there) */ private static InetAddress tryLocalHostBeforeReturning( InetAddress preliminaryResult, SocketAddress targetAddress, boolean logging) throws IOException { InetAddress localhostName = InetAddress.getLocalHost(); if (preliminaryResult.equals(localhostName)) { // preliminary result is equal to the local host name return preliminaryResult; } else if (tryToConnect(localhostName, targetAddress, AddressDetectionState.SLOW_CONNECT.getTimeout(), logging)) { // success, we were able to use local host to connect LOG.debug("Preferring {} (InetAddress.getLocalHost()) for local bind point over previous candidate {}", localhostName, preliminaryResult); return localhostName; } else { // we have to make the preliminary result the final result return preliminaryResult; } }
/** * This utility method tries to connect to the JobManager using the InetAddress returned by * InetAddress.getLocalHost(). The purpose of the utility is to have a final try connecting to * the target address using the LocalHost before using the address returned. * We do a second try because the JM might have been unavailable during the first check. * * @param preliminaryResult The address detected by the heuristic * @return either the preliminaryResult or the address returned by InetAddress.getLocalHost() (if * we are able to connect to targetAddress from there) */ private static InetAddress tryLocalHostBeforeReturning( InetAddress preliminaryResult, SocketAddress targetAddress, boolean logging) throws IOException { InetAddress localhostName = InetAddress.getLocalHost(); if (preliminaryResult.equals(localhostName)) { // preliminary result is equal to the local host name return preliminaryResult; } else if (tryToConnect(localhostName, targetAddress, AddressDetectionState.SLOW_CONNECT.getTimeout(), logging)) { // success, we were able to use local host to connect LOG.debug("Preferring {} (InetAddress.getLocalHost()) for local bind point over previous candidate {}", localhostName, preliminaryResult); return localhostName; } else { // we have to make the preliminary result the final result return preliminaryResult; } }
/** * This utility method tries to connect to the JobManager using the InetAddress returned by * InetAddress.getLocalHost(). The purpose of the utility is to have a final try connecting to * the target address using the LocalHost before using the address returned. * We do a second try because the JM might have been unavailable during the first check. * * @param preliminaryResult The address detected by the heuristic * @return either the preliminaryResult or the address returned by InetAddress.getLocalHost() (if * we are able to connect to targetAddress from there) */ private static InetAddress tryLocalHostBeforeReturning( InetAddress preliminaryResult, SocketAddress targetAddress, boolean logging) throws IOException { InetAddress localhostName = InetAddress.getLocalHost(); if (preliminaryResult.equals(localhostName)) { // preliminary result is equal to the local host name return preliminaryResult; } else if (tryToConnect(localhostName, targetAddress, AddressDetectionState.SLOW_CONNECT.getTimeout(), logging)) { // success, we were able to use local host to connect LOG.debug("Preferring {} (InetAddress.getLocalHost()) for local bind point over previous candidate {}", localhostName, preliminaryResult); return localhostName; } else { // we have to make the preliminary result the final result return preliminaryResult; } }