Update after review
This commit is contained in:
parent
3804bfcc60
commit
17930930a7
|
@ -176,11 +176,13 @@ The following are a list of settings (prefixed with `discovery.ec2`) that can fu
|
|||
--
|
||||
The type of host type to use to communicate with other instances. Can be
|
||||
one of `private_ip`, `public_ip`, `private_dns`, `public_dns` or `tag:TAGNAME` where
|
||||
`TAGNAME` is the tag field you defined for your ec2 instance.
|
||||
`TAGNAME` refers to a name of a tag configured for all EC2 instances. Instances which don't
|
||||
have this tag set will be ignored by the discovery process.
|
||||
|
||||
For example if you defined a tag `my-elasticsearch-host` in ec2 and set it to `myhostname1.mydomain.com`, then
|
||||
setting `host_type: tag:my-elasticsearch-host` will tell Discovery Ec2 plugin to read the host name from the
|
||||
`my-elasticsearch-host` tag. In this case, it will be resolved to `myhostname1.mydomain.com`.
|
||||
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html[Read more about EC2 Tags].
|
||||
|
||||
Defaults to `private_ip`.
|
||||
--
|
||||
|
|
|
@ -174,8 +174,9 @@ public interface AwsEc2Service {
|
|||
|
||||
/**
|
||||
* discovery.ec2.host_type: The type of host type to use to communicate with other instances.
|
||||
* Can be one of private_ip, public_ip, private_dns, public_dns or meta:XXXX where
|
||||
* XXXX is the metadata field name we will read the address from. Defaults to private_ip.
|
||||
* Can be one of private_ip, public_ip, private_dns, public_dns or tag:XXXX where
|
||||
* XXXX refers to a name of a tag configured for all EC2 instances. Instances which don't
|
||||
* have this tag set will be ignored by the discovery process. Defaults to private_ip.
|
||||
*/
|
||||
Setting<String> HOST_TYPE_SETTING =
|
||||
new Setting<>("discovery.ec2.host_type", HostType.PRIVATE_IP, Function.identity(), Property.NodeScope);
|
||||
|
|
|
@ -181,7 +181,7 @@ public class AwsEc2UnicastHostsProvider extends AbstractComponent implements Uni
|
|||
TransportAddress[] addresses = transportService.addressesFromString(address, 1);
|
||||
for (int i = 0; i < addresses.length; i++) {
|
||||
logger.trace("adding {}, address {}, transport_address {}", instance.getInstanceId(), address, addresses[i]);
|
||||
discoNodes.add(new DiscoveryNode("#cloud-" + instance.getInstanceId() + "-" + i, addresses[i],
|
||||
discoNodes.add(new DiscoveryNode(instance.getInstanceId(), "#cloud-" + instance.getInstanceId() + "-" + i, addresses[i],
|
||||
emptyMap(), emptySet(), Version.CURRENT.minimumCompatibilityVersion()));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -268,7 +268,7 @@ public class Ec2DiscoveryTests extends ESTestCase {
|
|||
|
||||
for (int node = 0; node < nodes; node++) {
|
||||
addresses[node] = "192.168.0." + (node + 1);
|
||||
poorMansDNS.put("bar_" + node, new TransportAddress(InetAddress.getByName(addresses[node]), 9300));
|
||||
poorMansDNS.put("node" + (node + 1), new TransportAddress(InetAddress.getByName(addresses[node]), 9300));
|
||||
}
|
||||
|
||||
Settings nodeSettings = Settings.builder()
|
||||
|
@ -279,7 +279,7 @@ public class Ec2DiscoveryTests extends ESTestCase {
|
|||
|
||||
for (int node = 0; node < nodes; node++) {
|
||||
List<Tag> tags = new ArrayList<>();
|
||||
tags.add(new Tag("foo", "bar_" + node));
|
||||
tags.add(new Tag("foo", "node" + (node + 1)));
|
||||
tagsList.add(tags);
|
||||
}
|
||||
|
||||
|
@ -287,7 +287,9 @@ public class Ec2DiscoveryTests extends ESTestCase {
|
|||
List<DiscoveryNode> discoveryNodes = buildDynamicNodes(nodeSettings, nodes, tagsList);
|
||||
assertThat(discoveryNodes, hasSize(nodes));
|
||||
for (DiscoveryNode discoveryNode : discoveryNodes) {
|
||||
assertThat(discoveryNode.getHostName(), isOneOf(addresses));
|
||||
TransportAddress address = discoveryNode.getAddress();
|
||||
TransportAddress expected = poorMansDNS.get(discoveryNode.getName());
|
||||
assertEquals(address, expected);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue