Browse Source

[Fix-5468][Common] Fix obtaining IP is incorrect (#5594)

2.0.7-release
Shiwen Cheng 4 years ago committed by GitHub
parent
commit
281b5aea6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      docker/build/conf/dolphinscheduler/common.properties.tpl
  2. 14
      dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java
  3. 9
      dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/NetUtils.java
  4. 3
      dolphinscheduler-common/src/main/resources/common.properties

3
docker/build/conf/dolphinscheduler/common.properties.tpl

@ -78,6 +78,9 @@ datasource.encryption.salt=${DATASOURCE_ENCRYPTION_SALT}
# use sudo or not, if set true, executing user is tenant user and deploy user needs sudo permissions; if set false, executing user is the deploy user and doesn't need sudo permissions # use sudo or not, if set true, executing user is tenant user and deploy user needs sudo permissions; if set false, executing user is the deploy user and doesn't need sudo permissions
sudo.enable=${SUDO_ENABLE} sudo.enable=${SUDO_ENABLE}
# network interface preferred like eth0, default: empty
#dolphin.scheduler.network.interface.preferred=
# network IP gets priority, default: inner outer # network IP gets priority, default: inner outer
#dolphin.scheduler.network.priority.strategy=default #dolphin.scheduler.network.priority.strategy=default

14
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/Constants.java

@ -1029,11 +1029,6 @@ public final class Constants {
*/ */
public static final String SYSTEM_LINE_SEPARATOR = System.getProperty("line.separator"); public static final String SYSTEM_LINE_SEPARATOR = System.getProperty("line.separator");
/**
* net system properties
*/
public static final String DOLPHIN_SCHEDULER_PREFERRED_NETWORK_INTERFACE = "dolphin.scheduler.network.interface.preferred";
public static final String EXCEL_SUFFIX_XLS = ".xls"; public static final String EXCEL_SUFFIX_XLS = ".xls";
@ -1045,9 +1040,14 @@ public final class Constants {
public static final String DATASOURCE_ENCRYPTION_SALT = "datasource.encryption.salt"; public static final String DATASOURCE_ENCRYPTION_SALT = "datasource.encryption.salt";
/** /**
* Network IP gets priority, default inner outer * network interface preferred
*/
public static final String DOLPHIN_SCHEDULER_NETWORK_INTERFACE_PREFERRED = "dolphin.scheduler.network.interface.preferred";
/**
* network IP gets priority, default inner outer
*/ */
public static final String NETWORK_PRIORITY_STRATEGY = "dolphin.scheduler.network.priority.strategy"; public static final String DOLPHIN_SCHEDULER_NETWORK_PRIORITY_STRATEGY = "dolphin.scheduler.network.priority.strategy";
/** /**
* exec shell scripts * exec shell scripts

9
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/NetUtils.java

@ -17,8 +17,6 @@
package org.apache.dolphinscheduler.common.utils; package org.apache.dolphinscheduler.common.utils;
import static org.apache.dolphinscheduler.common.Constants.DOLPHIN_SCHEDULER_PREFERRED_NETWORK_INTERFACE;
import static java.util.Collections.emptyList; import static java.util.Collections.emptyList;
import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.Constants;
@ -130,7 +128,7 @@ public class NetUtils {
Optional<InetAddress> addressOp = toValidAddress(addresses.nextElement()); Optional<InetAddress> addressOp = toValidAddress(addresses.nextElement());
if (addressOp.isPresent()) { if (addressOp.isPresent()) {
try { try {
if (addressOp.get().isReachable(100)) { if (addressOp.get().isReachable(200)) {
LOCAL_ADDRESS = addressOp.get(); LOCAL_ADDRESS = addressOp.get();
return LOCAL_ADDRESS; return LOCAL_ADDRESS;
} }
@ -260,7 +258,8 @@ public class NetUtils {
} }
private static boolean isSpecifyNetworkInterface(NetworkInterface networkInterface) { private static boolean isSpecifyNetworkInterface(NetworkInterface networkInterface) {
String preferredNetworkInterface = System.getProperty(DOLPHIN_SCHEDULER_PREFERRED_NETWORK_INTERFACE); String preferredNetworkInterface = PropertyUtils.getString(Constants.DOLPHIN_SCHEDULER_NETWORK_INTERFACE_PREFERRED,
System.getProperty(Constants.DOLPHIN_SCHEDULER_NETWORK_INTERFACE_PREFERRED));
return Objects.equals(networkInterface.getDisplayName(), preferredNetworkInterface); return Objects.equals(networkInterface.getDisplayName(), preferredNetworkInterface);
} }
@ -268,7 +267,7 @@ public class NetUtils {
if (validNetworkInterfaces.isEmpty()) { if (validNetworkInterfaces.isEmpty()) {
return null; return null;
} }
String networkPriority = PropertyUtils.getString(Constants.NETWORK_PRIORITY_STRATEGY, NETWORK_PRIORITY_DEFAULT); String networkPriority = PropertyUtils.getString(Constants.DOLPHIN_SCHEDULER_NETWORK_PRIORITY_STRATEGY, NETWORK_PRIORITY_DEFAULT);
if (NETWORK_PRIORITY_DEFAULT.equalsIgnoreCase(networkPriority)) { if (NETWORK_PRIORITY_DEFAULT.equalsIgnoreCase(networkPriority)) {
return findAddressByDefaultPolicy(validNetworkInterfaces); return findAddressByDefaultPolicy(validNetworkInterfaces);
} else if (NETWORK_PRIORITY_INNER.equalsIgnoreCase(networkPriority)) { } else if (NETWORK_PRIORITY_INNER.equalsIgnoreCase(networkPriority)) {

3
dolphinscheduler-common/src/main/resources/common.properties

@ -78,6 +78,9 @@ datasource.encryption.salt=!@#$%^&*
# use sudo or not, if set true, executing user is tenant user and deploy user needs sudo permissions; if set false, executing user is the deploy user and doesn't need sudo permissions # use sudo or not, if set true, executing user is tenant user and deploy user needs sudo permissions; if set false, executing user is the deploy user and doesn't need sudo permissions
sudo.enable=true sudo.enable=true
# network interface preferred like eth0, default: empty
#dolphin.scheduler.network.interface.preferred=
# network IP gets priority, default: inner outer # network IP gets priority, default: inner outer
#dolphin.scheduler.network.priority.strategy=default #dolphin.scheduler.network.priority.strategy=default

Loading…
Cancel
Save