Skip to content

[Feature-2574][Server]Specify Network Interface#3186

Merged
qiaozhanwei merged 8 commits intoapache:devfrom
CalvinKirs:#2574
Jul 13, 2020
Merged

[Feature-2574][Server]Specify Network Interface#3186
qiaozhanwei merged 8 commits intoapache:devfrom
CalvinKirs:#2574

Conversation

@CalvinKirs
Copy link
Copy Markdown
Member

What is the purpose of the pull request

This closes #2574

Verify this pull request

This pull request is already covered by existing tests, such as (please describe tests).

This change added tests and can be verified as follows:

  • Manually verified the change by testing locally.

Comment on lines +218 to +221
public static boolean isSpecifyNetworkInterface(NetworkInterface networkInterface) {
String preferredNetworkInterface = System.getProperty(DOLPHIN_SCHEDULER_PREFERRED_NETWORK_INTERFACE);
return Objects.equals(networkInterface.getDisplayName(), preferredNetworkInterface);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

Good job,
Utils should be used as a tool class and it is better not to involve business process.
Is it better to implement this part in the business process class?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Hello, this is exclusive to net, other business is not involved, so I think it is better to achieve here,how do you think?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Hello, this is exclusive to net, other business is not involved, so I think it is better to achieve here,how do you think?

Hi,

I think it is better not to add the isSpecifyNetworkInterface in findNetworkInterface of utils, but I find there is only one call of findNetworkInterface, so I don't think of a better place to add this at present.
I think we can think about the implement scheme again later.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this modify like this, the name is more better.

 private static boolean isSpecifyNetworkInterface(NetworkInterface networkInterface) {
        String preferredNetworkInterface = PropertyUtils.getString(DOLPHIN_SCHEDULER_PREFERRED_NETWORK_INTERFACE);
        logger.info("config name:{}, net work interface: {}, addrs: {}",
                preferredNetworkInterface,  networkInterface, networkInterface.getInterfaceAddresses());
        return Objects.equals(networkInterface.getName(), preferredNetworkInterface) || 
                Objects.equals(networkInterface.getDisplayName(), preferredNetworkInterface);
    }

common.properties add interface config

# Network Interface name
#dolphin.scheduler.network.interface.preferred=eth0

Comment on lines +51 to +52
private static String DOLPHIN_SCHEDULER_PREFERRED_NETWORK_INTERFACE = "dolphin.scheduler.network.interface.preferred";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

Is it better to move DOLPHIN_SCHEDULER_PREFERRED_NETWORK_INTERFACE to Constants.java?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your suggestions, I have completed the changes.

@yangyichao-mango
Copy link
Copy Markdown
Contributor

Hi,

I find you use the function of private static synchronized InetAddress getLocalAddress0(), can you help to explain will it produce the performance issues when call the getLocalAddress0() function.
Thx a lot.

@CalvinKirs
Copy link
Copy Markdown
Member Author

Hi,

I find you use the function of private static synchronized InetAddress getLocalAddress0(), can you help to explain will it produce the performance issues when call the getLocalAddress0() function.
Thx a lot.

There will be no impact here

@CalvinKirs
Copy link
Copy Markdown
Member Author

done.

@sonarqubecloud
Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

68.8% 68.8% Coverage
0.0% 0.0% Duplication

@qiaozhanwei
Copy link
Copy Markdown
Contributor

https://lists.apache.org/thread.html/r3442e2bd785628ad91655f9e5cd79c1b6d33bfa7826e70f6070158d7%40%3Cdev.dolphinscheduler.apache.org%3E

This is mail discuss before,please refer

The conclusion at the time ,InetAddress.getLocalHost().getHostAddress() not support docker host mode
but DS also have a utils at org.apache.dolphinscheduler.remote.utils.IPUtils
But IPUtils also have another problem,for vm machine have many ips,netty is not access

your PR can solve this problem ?

Copy link
Copy Markdown
Contributor

@qiaozhanwei qiaozhanwei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@qiaozhanwei qiaozhanwei merged commit 6f9970b into apache:dev Jul 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]Configurable registration ipaddress

4 participants