From 662f3c7ba50ff8ec13d86171bcfc61fd3da9deed Mon Sep 17 00:00:00 2001 From: Timmo Verlaan Date: Mon, 29 Jan 2018 21:27:22 +0100 Subject: epmd: allow alternative to dns resolving for nodename This makes it possible to create a custom integration with a key-value store for example. The key would then point to the actual address. You would have to write your own epmd module to make use of that feature. --- erts/doc/src/Makefile | 1 + erts/doc/src/alt_disco.xml | 93 +++++++++++++++++++++++++++++++ erts/doc/src/part.xml | 1 + erts/emulator/test/distribution_SUITE.erl | 7 ++- 4 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 erts/doc/src/alt_disco.xml (limited to 'erts') diff --git a/erts/doc/src/Makefile b/erts/doc/src/Makefile index 5fa8b0673a..96cc4413a9 100644 --- a/erts/doc/src/Makefile +++ b/erts/doc/src/Makefile @@ -74,6 +74,7 @@ XML_CHAPTER_FILES = \ match_spec.xml \ crash_dump.xml \ alt_dist.xml \ + alt_disco.xml \ driver.xml \ absform.xml \ inet_cfg.xml \ diff --git a/erts/doc/src/alt_disco.xml b/erts/doc/src/alt_disco.xml new file mode 100644 index 0000000000..d04221b9b3 --- /dev/null +++ b/erts/doc/src/alt_disco.xml @@ -0,0 +1,93 @@ + + + + +
+ + 20182018 + Ericsson AB. All Rights Reserved. + + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + + How to Implement an Alternative Service Discovery for Erlang Distribution + + Timmo Verlaan + + + + + 2018-04-25 + PA1 + alt_disco.xml +
+

+ This section describes how to implement an alternative discovery mechanism + for Erlang distribution. Discovery is normally done using DNS and the + Erlang Port Mapper Daemon (EPMD) for port discovery. +

+ +

+ Support for alternative service discovery mechanisms was added in Erlang/OTP + 21. +

+ + +
+ Introduction +

To implement your own service discovery module you have to write your own + EPMD module. The EPMD module is + responsible for providing the location of another node. The distribution + modules (inet_tcp_dist/inet_tls_dist) call the EPMD module to + get the IP address and port of the other node. The EPMD module that is part + of Erlang/OTP will resolve the hostname using DNS and uses the EPMD unix + process to get the port of another node. The EPMD unix process does this by + connecting to the other node on a well-known port, port 4369.

+
+ +
+ Discovery module +

The discovery module needs to implement the same API as the regular + EPMD module. However, instead of + communicating with EPMD you can connect to any service to find out + connection details of other nodes. A discovery module is enabled + by setting -epmd_module + when starting erlang. The discovery module must implement the following + callbacks:

+ + + start_link/0 + Start any processes needed by the discovery module. + names/1 + Return node names held by the registrar for the given host. + register_node/2 + Register the given node name with the registrar. + port_please/3 + Return the distribution port used by the given node. + + +

The discovery module may implement the following callback:

+ + + address_please/3 +

Return the address of the given node. + If not implemented, + inet:gethostbyname/1 will be used instead

+

This callback may also return the port of the given node. In that case + port_please/3 + may be omitted.

+
+
+
diff --git a/erts/doc/src/part.xml b/erts/doc/src/part.xml index d583b873a0..fc39cb30e6 100644 --- a/erts/doc/src/part.xml +++ b/erts/doc/src/part.xml @@ -37,6 +37,7 @@ + diff --git a/erts/emulator/test/distribution_SUITE.erl b/erts/emulator/test/distribution_SUITE.erl index e40d346e10..b8b84e91a0 100644 --- a/erts/emulator/test/distribution_SUITE.erl +++ b/erts/emulator/test/distribution_SUITE.erl @@ -73,7 +73,7 @@ dist_evil_parallel_receiver/0]). %% epmd_module exports --export([start_link/0, register_node/2, register_node/3, port_please/2]). +-export([start_link/0, register_node/2, register_node/3, port_please/2, address_please/3]). suite() -> [{ct_hooks,[ts_install_cth]}, @@ -2086,6 +2086,11 @@ port_please(_Name, _Ip) -> {port, Port, Version} end. +address_please(_Name, _Address, _AddressFamily) -> + %% Use localhost. + IP = {127,0,0,1}, + {ok, IP}. + %%% Utilities timestamp() -> -- cgit v1.2.3