mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-25 06:16:40 +00:00
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
|
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.
|
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`.
|
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)
|
How to start (long story)
|
||||||
--------------------------
|
--------------------------
|
||||||
|
@ -53,6 +53,8 @@ public interface AzureComputeService {
|
|||||||
|
|
||||||
public static final String HOST_TYPE = "host.type";
|
public static final String HOST_TYPE = "host.type";
|
||||||
public static final String ENDPOINT_NAME = "endpoint.name";
|
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();
|
public HostedServiceGetDetailedResponse getServiceDetails();
|
||||||
|
@ -46,10 +46,46 @@ import java.util.List;
|
|||||||
public class AzureUnicastHostsProvider extends AbstractComponent implements UnicastHostsProvider {
|
public class AzureUnicastHostsProvider extends AbstractComponent implements UnicastHostsProvider {
|
||||||
|
|
||||||
public static enum HostType {
|
public static enum HostType {
|
||||||
PRIVATE_IP,
|
PRIVATE_IP("private_ip"),
|
||||||
PUBLIC_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 final AzureComputeService azureComputeService;
|
||||||
private TransportService transportService;
|
private TransportService transportService;
|
||||||
@ -78,12 +114,10 @@ public class AzureUnicastHostsProvider extends AbstractComponent implements Unic
|
|||||||
this.refreshInterval = componentSettings.getAsTime(Fields.REFRESH,
|
this.refreshInterval = componentSettings.getAsTime(Fields.REFRESH,
|
||||||
settings.getAsTime("cloud.azure." + Fields.REFRESH, TimeValue.timeValueSeconds(0)));
|
settings.getAsTime("cloud.azure." + Fields.REFRESH, TimeValue.timeValueSeconds(0)));
|
||||||
|
|
||||||
HostType tmpHostType;
|
|
||||||
String strHostType = componentSettings.get(Fields.HOST_TYPE,
|
String strHostType = componentSettings.get(Fields.HOST_TYPE,
|
||||||
settings.get("cloud.azure." + Fields.HOST_TYPE_DEPRECATED, HostType.PRIVATE_IP.name())).toUpperCase();
|
settings.get("cloud.azure." + Fields.HOST_TYPE_DEPRECATED, HostType.PRIVATE_IP.name())).toUpperCase();
|
||||||
try {
|
HostType tmpHostType = HostType.fromString(strHostType);
|
||||||
tmpHostType = HostType.valueOf(strHostType);
|
if (tmpHostType == null) {
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
logger.warn("wrong value for [{}]: [{}]. falling back to [{}]...", Fields.HOST_TYPE,
|
logger.warn("wrong value for [{}]: [{}]. falling back to [{}]...", Fields.HOST_TYPE,
|
||||||
strHostType, HostType.PRIVATE_IP.name().toLowerCase());
|
strHostType, HostType.PRIVATE_IP.name().toLowerCase());
|
||||||
tmpHostType = HostType.PRIVATE_IP;
|
tmpHostType = HostType.PRIVATE_IP;
|
||||||
@ -99,8 +133,19 @@ public class AzureUnicastHostsProvider extends AbstractComponent implements Unic
|
|||||||
this.publicEndpointName = componentSettings.get(Fields.ENDPOINT_NAME, "elasticsearch");
|
this.publicEndpointName = componentSettings.get(Fields.ENDPOINT_NAME, "elasticsearch");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.deploymentName = componentSettings.get(Fields.SERVICE_NAME, settings.get("cloud.azure." + Fields.SERVICE_NAME_DEPRECATED));
|
this.deploymentName = componentSettings.get(Fields.DEPLOYMENT_NAME,
|
||||||
this.deploymentSlot = DeploymentSlot.Production;
|
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…
x
Reference in New Issue
Block a user