Add keystore.type, deployment.name and deployment.slot settings for discovery
We can now support two new options: * `deployment.name`: deployment name if any. Defaults to the value set with `cloud.azure.cloud.service.name`. * `deployment.slot`: either `staging` or `production` (default). (cherry picked from commit 6d7ee49) (cherry picked from commit 10beb68)
This commit is contained in:
parent
85ac406f63
commit
ff0547f04d
16
README.md
16
README.md
|
@ -93,7 +93,23 @@ other nodes. This feature was not documented before but was existing under `clou
|
|||
to elasticsearch (aka transport port name). Defaults to `elasticsearch`. In Azure management console, you could define
|
||||
an endpoint `elasticsearch` forwarding for example requests on public IP on port 8100 to the virtual machine on port 9300.
|
||||
This feature was not documented before but was existing under `cloud.azure.port_name`.
|
||||
* `deployment.name`: deployment name if any. Defaults to the value set with `cloud.azure.management.cloud.service.name`.
|
||||
* `deployment.slot`: either `staging` or `production` (default).
|
||||
|
||||
For example:
|
||||
|
||||
```
|
||||
discovery:
|
||||
type: azure
|
||||
azure:
|
||||
host:
|
||||
type: private_ip
|
||||
endpoint:
|
||||
name: elasticsearch
|
||||
deployment:
|
||||
name: your_azure_cloud_service_name
|
||||
slot: production
|
||||
```
|
||||
|
||||
How to start (long story)
|
||||
--------------------------
|
||||
|
|
|
@ -53,6 +53,8 @@ public interface AzureComputeService {
|
|||
|
||||
public static final String HOST_TYPE = "host.type";
|
||||
public static final String ENDPOINT_NAME = "endpoint.name";
|
||||
public static final String DEPLOYMENT_NAME = "deployment.name";
|
||||
public static final String DEPLOYMENT_SLOT = "deployment.slot";
|
||||
}
|
||||
|
||||
public HostedServiceGetDetailedResponse getServiceDetails();
|
||||
|
|
|
@ -46,10 +46,46 @@ import java.util.List;
|
|||
public class AzureUnicastHostsProvider extends AbstractComponent implements UnicastHostsProvider {
|
||||
|
||||
public static enum HostType {
|
||||
PRIVATE_IP,
|
||||
PUBLIC_IP
|
||||
PRIVATE_IP("private_ip"),
|
||||
PUBLIC_IP("public_ip");
|
||||
|
||||
private String type ;
|
||||
|
||||
private HostType(String type) {
|
||||
this.type = type ;
|
||||
}
|
||||
|
||||
public static HostType fromString(String type) {
|
||||
for (HostType hostType : values()) {
|
||||
if (hostType.type.equalsIgnoreCase(type)) {
|
||||
return hostType;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static enum Deployment {
|
||||
PRODUCTION("production", DeploymentSlot.Production),
|
||||
STAGING("staging", DeploymentSlot.Staging);
|
||||
|
||||
private String deployment;
|
||||
private DeploymentSlot slot;
|
||||
|
||||
private Deployment(String deployment, DeploymentSlot slot) {
|
||||
this.deployment = deployment;
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
public static Deployment fromString(String string) {
|
||||
for (Deployment deployment : values()) {
|
||||
if (deployment.deployment.equalsIgnoreCase(string)) {
|
||||
return deployment;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private final AzureComputeService azureComputeService;
|
||||
private TransportService transportService;
|
||||
|
@ -78,12 +114,10 @@ public class AzureUnicastHostsProvider extends AbstractComponent implements Unic
|
|||
this.refreshInterval = componentSettings.getAsTime(Fields.REFRESH,
|
||||
settings.getAsTime("cloud.azure." + Fields.REFRESH, TimeValue.timeValueSeconds(0)));
|
||||
|
||||
HostType tmpHostType;
|
||||
String strHostType = componentSettings.get(Fields.HOST_TYPE,
|
||||
settings.get("cloud.azure." + Fields.HOST_TYPE_DEPRECATED, HostType.PRIVATE_IP.name())).toUpperCase();
|
||||
try {
|
||||
tmpHostType = HostType.valueOf(strHostType);
|
||||
} catch (IllegalArgumentException e) {
|
||||
HostType tmpHostType = HostType.fromString(strHostType);
|
||||
if (tmpHostType == null) {
|
||||
logger.warn("wrong value for [{}]: [{}]. falling back to [{}]...", Fields.HOST_TYPE,
|
||||
strHostType, HostType.PRIVATE_IP.name().toLowerCase());
|
||||
tmpHostType = HostType.PRIVATE_IP;
|
||||
|
@ -99,8 +133,19 @@ public class AzureUnicastHostsProvider extends AbstractComponent implements Unic
|
|||
this.publicEndpointName = componentSettings.get(Fields.ENDPOINT_NAME, "elasticsearch");
|
||||
}
|
||||
|
||||
this.deploymentName = componentSettings.get(Fields.SERVICE_NAME, settings.get("cloud.azure." + Fields.SERVICE_NAME_DEPRECATED));
|
||||
this.deploymentSlot = DeploymentSlot.Production;
|
||||
this.deploymentName = componentSettings.get(Fields.DEPLOYMENT_NAME,
|
||||
settings.get("cloud.azure.management." + Fields.SERVICE_NAME,
|
||||
settings.get("cloud.azure." + Fields.SERVICE_NAME_DEPRECATED)));
|
||||
|
||||
// Reading deployment_slot
|
||||
String strDeployment = componentSettings.get(Fields.DEPLOYMENT_SLOT, Deployment.PRODUCTION.deployment);
|
||||
Deployment tmpDeployment = Deployment.fromString(strDeployment);
|
||||
if (tmpDeployment == null) {
|
||||
logger.warn("wrong value for [{}]: [{}]. falling back to [{}]...", Fields.DEPLOYMENT_SLOT,
|
||||
strDeployment, Deployment.PRODUCTION.deployment);
|
||||
tmpDeployment = Deployment.PRODUCTION;
|
||||
}
|
||||
this.deploymentSlot = tmpDeployment.slot;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue