Update settings filter and remove component settings from AbstractComponent
Update settings filter to match elasticsearch/elasticsearch#9748 Remove component settings from AbstractComponent as seen in elasticsearch/elasticsearch#9919 Closes #71. Closes #72.
This commit is contained in:
parent
b7c44087cf
commit
cd7b8d4840
30
README.md
30
README.md
|
@ -64,13 +64,13 @@ How to start (short story)
|
|||
Azure credential API settings
|
||||
-----------------------------
|
||||
|
||||
The following are a list of settings (prefixed with `cloud.azure.management`) that can further control the discovery:
|
||||
The following are a list of settings that can further control the credential API:
|
||||
|
||||
* `keystore.path`: /path/to/keystore
|
||||
* `keystore.type`: `pkcs12`, `jceks` or `jks`. Defaults to `pkcs12`.
|
||||
* `keystore.password`: your_password for the keystore
|
||||
* `subscription.id`: your_azure_subscription_id
|
||||
* `cloud.service.name`: your_azure_cloud_service_name
|
||||
* `cloud.azure.management.keystore.path`: /path/to/keystore
|
||||
* `cloud.azure.management.keystore.type`: `pkcs12`, `jceks` or `jks`. Defaults to `pkcs12`.
|
||||
* `cloud.azure.management.keystore.password`: your_password for the keystore
|
||||
* `cloud.azure.management.subscription.id`: your_azure_subscription_id
|
||||
* `cloud.azure.management.cloud.service.name`: your_azure_cloud_service_name
|
||||
|
||||
Note that in previous versions, it was:
|
||||
|
||||
|
@ -86,16 +86,16 @@ cloud:
|
|||
Advanced settings
|
||||
-----------------
|
||||
|
||||
The following are a list of settings (prefixed with `discovery.azure`) that can further control the discovery:
|
||||
The following are a list of settings that can further control the discovery:
|
||||
|
||||
* `host.type`: either `public_ip` or `private_ip` (default). Azure discovery will use the one you set to ping
|
||||
* `discovery.azure.host.type`: either `public_ip` or `private_ip` (default). Azure discovery will use the one you set to ping
|
||||
other nodes. This feature was not documented before but was existing under `cloud.azure.host_type`.
|
||||
* `endpoint.name`: when using `public_ip` this setting is used to identify the endpoint name used to forward requests
|
||||
* `discovery.azure.endpoint.name`: when using `public_ip` this setting is used to identify the endpoint name used to forward requests
|
||||
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).
|
||||
* `discovery.azure.deployment.name`: deployment name if any. Defaults to the value set with `cloud.azure.management.cloud.service.name`.
|
||||
* `discovery.azure.deployment.slot`: either `staging` or `production` (default).
|
||||
|
||||
For example:
|
||||
|
||||
|
@ -476,10 +476,10 @@ Example using Java:
|
|||
|
||||
```java
|
||||
client.admin().cluster().preparePutRepository("my_backup3")
|
||||
.setType("azure").setSettings(ImmutableSettings.settingsBuilder()
|
||||
.put(AzureStorageService.Fields.CONTAINER, "backup_container")
|
||||
.put(AzureStorageService.Fields.CHUNK_SIZE, new ByteSizeValue(32, ByteSizeUnit.MB))
|
||||
).get();
|
||||
.setType("azure").setSettings(ImmutableSettings.settingsBuilder()
|
||||
.put(Storage.CONTAINER, "backup_container")
|
||||
.put(Storage.CHUNK_SIZE, new ByteSizeValue(32, ByteSizeUnit.MB))
|
||||
).get();
|
||||
```
|
||||
|
||||
Repository validation rules
|
||||
|
|
|
@ -20,10 +20,13 @@
|
|||
package org.elasticsearch.cloud.azure;
|
||||
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.cloud.azure.storage.AzureStorageService;
|
||||
import org.elasticsearch.cloud.azure.storage.AzureStorageServiceImpl;
|
||||
import org.elasticsearch.cloud.azure.management.AzureComputeService;
|
||||
import org.elasticsearch.cloud.azure.management.AzureComputeService.Discovery;
|
||||
import org.elasticsearch.cloud.azure.management.AzureComputeService.Management;
|
||||
import org.elasticsearch.cloud.azure.management.AzureComputeServiceImpl;
|
||||
import org.elasticsearch.cloud.azure.storage.AzureStorageService;
|
||||
import org.elasticsearch.cloud.azure.storage.AzureStorageService.Storage;
|
||||
import org.elasticsearch.cloud.azure.storage.AzureStorageServiceImpl;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.inject.AbstractModule;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
|
@ -63,7 +66,7 @@ public class AzureModule extends AbstractModule {
|
|||
if (isDiscoveryReady(settings, logger)) {
|
||||
logger.debug("starting azure discovery service");
|
||||
bind(AzureComputeService.class)
|
||||
.to(settings.getAsClass("cloud.azure.api.impl", AzureComputeServiceImpl.class))
|
||||
.to(settings.getAsClass(Management.API_IMPLEMENTATION, AzureComputeServiceImpl.class))
|
||||
.asEagerSingleton();
|
||||
}
|
||||
|
||||
|
@ -71,7 +74,7 @@ public class AzureModule extends AbstractModule {
|
|||
if (isSnapshotReady(settings, logger)) {
|
||||
logger.debug("starting azure repository service");
|
||||
bind(AzureStorageService.class)
|
||||
.to(settings.getAsClass("repositories.azure.api.impl", AzureStorageServiceImpl.class))
|
||||
.to(settings.getAsClass(Storage.API_IMPLEMENTATION, AzureStorageServiceImpl.class))
|
||||
.asEagerSingleton();
|
||||
}
|
||||
}
|
||||
|
@ -102,22 +105,22 @@ public class AzureModule extends AbstractModule {
|
|||
}
|
||||
|
||||
if ( // We check new parameters
|
||||
(isPropertyMissing(settings, "cloud.azure.management." + AzureComputeService.Fields.SUBSCRIPTION_ID) ||
|
||||
isPropertyMissing(settings, "cloud.azure.management." + AzureComputeService.Fields.SERVICE_NAME) ||
|
||||
isPropertyMissing(settings, "cloud.azure.management." + AzureComputeService.Fields.KEYSTORE_PATH) ||
|
||||
isPropertyMissing(settings, "cloud.azure.management." + AzureComputeService.Fields.KEYSTORE_PASSWORD))
|
||||
(isPropertyMissing(settings, Management.SUBSCRIPTION_ID) ||
|
||||
isPropertyMissing(settings, Management.SERVICE_NAME) ||
|
||||
isPropertyMissing(settings, Management.KEYSTORE_PATH) ||
|
||||
isPropertyMissing(settings, Management.KEYSTORE_PASSWORD))
|
||||
// We check deprecated
|
||||
&& (isPropertyMissing(settings, "cloud.azure." + AzureComputeService.Fields.SUBSCRIPTION_ID_DEPRECATED) ||
|
||||
isPropertyMissing(settings, "cloud.azure." + AzureComputeService.Fields.SERVICE_NAME_DEPRECATED) ||
|
||||
isPropertyMissing(settings, "cloud.azure." + AzureComputeService.Fields.KEYSTORE_DEPRECATED) ||
|
||||
isPropertyMissing(settings, "cloud.azure." + AzureComputeService.Fields.PASSWORD_DEPRECATED))
|
||||
&& (isPropertyMissing(settings, Management.SUBSCRIPTION_ID_DEPRECATED) ||
|
||||
isPropertyMissing(settings, Management.SERVICE_NAME_DEPRECATED) ||
|
||||
isPropertyMissing(settings, Management.KEYSTORE_DEPRECATED) ||
|
||||
isPropertyMissing(settings, Management.PASSWORD_DEPRECATED))
|
||||
) {
|
||||
logger.debug("one or more azure discovery settings are missing. " +
|
||||
"Check elasticsearch.yml file and `cloud.azure.management`. Should have [{}], [{}], [{}] and [{}].",
|
||||
AzureComputeService.Fields.SUBSCRIPTION_ID,
|
||||
AzureComputeService.Fields.SERVICE_NAME,
|
||||
AzureComputeService.Fields.KEYSTORE_PATH,
|
||||
AzureComputeService.Fields.KEYSTORE_PASSWORD);
|
||||
"Check elasticsearch.yml file. Should have [{}], [{}], [{}] and [{}].",
|
||||
Management.SUBSCRIPTION_ID,
|
||||
Management.SERVICE_NAME,
|
||||
Management.KEYSTORE_PATH,
|
||||
Management.KEYSTORE_PASSWORD);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -137,13 +140,13 @@ public class AzureModule extends AbstractModule {
|
|||
return false;
|
||||
}
|
||||
|
||||
if ((isPropertyMissing(settings, "cloud.azure.storage." + AzureStorageService.Fields.ACCOUNT) ||
|
||||
isPropertyMissing(settings, "cloud.azure.storage." + AzureStorageService.Fields.KEY)) &&
|
||||
(isPropertyMissing(settings, "cloud.azure." + AzureStorageService.Fields.ACCOUNT_DEPRECATED) ||
|
||||
isPropertyMissing(settings, "cloud.azure." + AzureStorageService.Fields.KEY_DEPRECATED))) {
|
||||
logger.debug("azure repository is not set [using cloud.azure.storage.{}] and [cloud.azure.storage.{}] properties",
|
||||
AzureStorageService.Fields.ACCOUNT,
|
||||
AzureStorageService.Fields.KEY);
|
||||
if ((isPropertyMissing(settings, Storage.ACCOUNT) ||
|
||||
isPropertyMissing(settings, Storage.KEY)) &&
|
||||
(isPropertyMissing(settings, Storage.ACCOUNT_DEPRECATED) ||
|
||||
isPropertyMissing(settings, Storage.KEY_DEPRECATED))) {
|
||||
logger.debug("azure repository is not set using [{}] and [{}] properties",
|
||||
Storage.ACCOUNT,
|
||||
Storage.KEY);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -171,24 +174,16 @@ public class AzureModule extends AbstractModule {
|
|||
public static void checkDeprecated(Settings settings, ESLogger logger) {
|
||||
// Cloud services are disabled
|
||||
if (isCloudReady(settings)) {
|
||||
checkDeprecatedSettings(settings, "cloud.azure." + AzureStorageService.Fields.ACCOUNT_DEPRECATED,
|
||||
"cloud.azure.storage." + AzureStorageService.Fields.ACCOUNT, logger);
|
||||
checkDeprecatedSettings(settings, "cloud.azure." + AzureStorageService.Fields.KEY_DEPRECATED,
|
||||
"cloud.azure.storage." + AzureStorageService.Fields.KEY, logger);
|
||||
checkDeprecatedSettings(settings, Storage.ACCOUNT_DEPRECATED, Storage.ACCOUNT, logger);
|
||||
checkDeprecatedSettings(settings, Storage.KEY_DEPRECATED, Storage.KEY, logger);
|
||||
|
||||
// TODO Remove in 3.0.0
|
||||
checkDeprecatedSettings(settings, "cloud.azure." + AzureComputeService.Fields.KEYSTORE_DEPRECATED,
|
||||
"cloud.azure.management." + AzureComputeService.Fields.KEYSTORE_PATH, logger);
|
||||
checkDeprecatedSettings(settings, "cloud.azure." + AzureComputeService.Fields.PASSWORD_DEPRECATED,
|
||||
"cloud.azure.management." + AzureComputeService.Fields.KEYSTORE_PASSWORD, logger);
|
||||
checkDeprecatedSettings(settings, "cloud.azure." + AzureComputeService.Fields.SERVICE_NAME_DEPRECATED,
|
||||
"cloud.azure.management." + AzureComputeService.Fields.SERVICE_NAME, logger);
|
||||
checkDeprecatedSettings(settings, "cloud.azure." + AzureComputeService.Fields.SUBSCRIPTION_ID_DEPRECATED,
|
||||
"cloud.azure.management." + AzureComputeService.Fields.SUBSCRIPTION_ID, logger);
|
||||
checkDeprecatedSettings(settings, "cloud.azure." + AzureComputeService.Fields.HOST_TYPE_DEPRECATED,
|
||||
"discovery.azure." + AzureComputeService.Fields.HOST_TYPE, logger);
|
||||
checkDeprecatedSettings(settings, "cloud.azure." + AzureComputeService.Fields.PORT_NAME_DEPRECATED,
|
||||
"discovery.azure." + AzureComputeService.Fields.ENDPOINT_NAME, logger);
|
||||
checkDeprecatedSettings(settings, Management.KEYSTORE_DEPRECATED, Management.KEYSTORE_PATH, logger);
|
||||
checkDeprecatedSettings(settings, Management.PASSWORD_DEPRECATED, Management.KEYSTORE_PASSWORD, logger);
|
||||
checkDeprecatedSettings(settings, Management.SERVICE_NAME_DEPRECATED, Management.SERVICE_NAME, logger);
|
||||
checkDeprecatedSettings(settings, Management.SUBSCRIPTION_ID_DEPRECATED, Management.SUBSCRIPTION_ID, logger);
|
||||
checkDeprecatedSettings(settings, Discovery.HOST_TYPE_DEPRECATED, Discovery.HOST_TYPE, logger);
|
||||
checkDeprecatedSettings(settings, Discovery.PORT_NAME_DEPRECATED, Discovery.ENDPOINT_NAME, logger);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you 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.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.cloud.azure;
|
||||
|
||||
import org.elasticsearch.cloud.azure.management.AzureComputeService;
|
||||
import org.elasticsearch.cloud.azure.storage.AzureStorageService;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.common.settings.SettingsFilter;
|
||||
|
||||
/**
|
||||
* Filtering cloud.azure.* settings
|
||||
*/
|
||||
public class AzureSettingsFilter implements SettingsFilter.Filter {
|
||||
|
||||
@Override
|
||||
public void filter(ImmutableSettings.Builder settings) {
|
||||
// Cloud global settings
|
||||
settings.remove("cloud.azure." + AzureComputeService.Fields.REFRESH);
|
||||
|
||||
// Cloud management API settings
|
||||
settings.remove("cloud.azure.management." + AzureComputeService.Fields.KEYSTORE_PATH);
|
||||
settings.remove("cloud.azure.management." + AzureComputeService.Fields.KEYSTORE_PASSWORD);
|
||||
settings.remove("cloud.azure.management." + AzureComputeService.Fields.KEYSTORE_TYPE);
|
||||
settings.remove("cloud.azure.management." + AzureComputeService.Fields.SUBSCRIPTION_ID);
|
||||
settings.remove("cloud.azure.management." + AzureComputeService.Fields.SERVICE_NAME);
|
||||
|
||||
// Deprecated Cloud management API settings
|
||||
// TODO Remove in 3.0.0
|
||||
settings.remove("cloud.azure." + AzureComputeService.Fields.KEYSTORE_DEPRECATED);
|
||||
settings.remove("cloud.azure." + AzureComputeService.Fields.PASSWORD_DEPRECATED);
|
||||
settings.remove("cloud.azure." + AzureComputeService.Fields.SUBSCRIPTION_ID_DEPRECATED);
|
||||
settings.remove("cloud.azure." + AzureComputeService.Fields.SERVICE_NAME_DEPRECATED);
|
||||
|
||||
// Cloud storage API settings
|
||||
settings.remove("cloud.azure.storage." + AzureStorageService.Fields.ACCOUNT);
|
||||
settings.remove("cloud.azure.storage." + AzureStorageService.Fields.KEY);
|
||||
|
||||
// Deprecated Cloud storage API settings
|
||||
// TODO Remove in 3.0.0
|
||||
settings.remove("cloud.azure." + AzureStorageService.Fields.ACCOUNT_DEPRECATED);
|
||||
settings.remove("cloud.azure." + AzureStorageService.Fields.KEY_DEPRECATED);
|
||||
}
|
||||
}
|
|
@ -29,10 +29,12 @@ import org.elasticsearch.common.inject.Inject;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.repositories.RepositoryName;
|
||||
import org.elasticsearch.repositories.RepositorySettings;
|
||||
import org.elasticsearch.repositories.azure.AzureRepository;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import static org.elasticsearch.cloud.azure.storage.AzureStorageService.Storage.CONTAINER;
|
||||
import static org.elasticsearch.repositories.azure.AzureRepository.CONTAINER_DEFAULT;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -48,8 +50,7 @@ public class AzureBlobStore extends AbstractComponent implements BlobStore {
|
|||
AzureStorageService client) throws URISyntaxException, StorageException {
|
||||
super(settings);
|
||||
this.client = client;
|
||||
this.container = repositorySettings.settings().get(AzureStorageService.Fields.CONTAINER,
|
||||
componentSettings.get(AzureStorageService.Fields.CONTAINER, AzureRepository.CONTAINER_DEFAULT));
|
||||
this.container = repositorySettings.settings().get("container", settings.get(CONTAINER, CONTAINER_DEFAULT));
|
||||
this.repositoryName = name.getName();
|
||||
}
|
||||
|
||||
|
|
|
@ -26,36 +26,43 @@ import com.microsoft.windowsazure.management.compute.models.HostedServiceGetDeta
|
|||
*/
|
||||
public interface AzureComputeService {
|
||||
|
||||
static public final class Fields {
|
||||
static public final class Management {
|
||||
// Deprecated azure management cloud settings
|
||||
@Deprecated
|
||||
public static final String SUBSCRIPTION_ID_DEPRECATED = "subscription_id";
|
||||
public static final String SUBSCRIPTION_ID_DEPRECATED = "cloud.azure.subscription_id";
|
||||
@Deprecated
|
||||
public static final String SERVICE_NAME_DEPRECATED = "service_name";
|
||||
public static final String SERVICE_NAME_DEPRECATED = "cloud.azure.service_name";
|
||||
@Deprecated
|
||||
public static final String KEYSTORE_DEPRECATED = "keystore";
|
||||
public static final String KEYSTORE_DEPRECATED = "cloud.azure.keystore";
|
||||
@Deprecated
|
||||
public static final String PASSWORD_DEPRECATED = "password";
|
||||
@Deprecated
|
||||
public static final String PORT_NAME_DEPRECATED = "port_name";
|
||||
@Deprecated
|
||||
public static final String HOST_TYPE_DEPRECATED = "host_type";
|
||||
public static final String PASSWORD_DEPRECATED = "cloud.azure.password";
|
||||
|
||||
public static final String SUBSCRIPTION_ID = "subscription.id";
|
||||
public static final String SERVICE_NAME = "cloud.service.name";
|
||||
public static final String API_IMPLEMENTATION = "cloud.azure.management.api.impl";
|
||||
|
||||
public static final String SUBSCRIPTION_ID = "cloud.azure.management.subscription.id";
|
||||
public static final String SERVICE_NAME = "cloud.azure.management.cloud.service.name";
|
||||
|
||||
// Keystore settings
|
||||
public static final String KEYSTORE_PATH = "keystore.path";
|
||||
public static final String KEYSTORE_PASSWORD = "keystore.password";
|
||||
public static final String KEYSTORE_TYPE = "keystore.type";
|
||||
|
||||
public static final String REFRESH = "refresh_interval";
|
||||
|
||||
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 static final String KEYSTORE_PATH = "cloud.azure.management.keystore.path";
|
||||
public static final String KEYSTORE_PASSWORD = "cloud.azure.management.keystore.password";
|
||||
public static final String KEYSTORE_TYPE = "cloud.azure.management.keystore.type";
|
||||
}
|
||||
|
||||
static public final class Discovery {
|
||||
// Deprecated azure discovery cloud settings
|
||||
@Deprecated
|
||||
public static final String PORT_NAME_DEPRECATED = "cloud.azure.port_name";
|
||||
@Deprecated
|
||||
public static final String HOST_TYPE_DEPRECATED = "cloud.azure.host_type";
|
||||
@Deprecated
|
||||
public static final String REFRESH_DEPRECATED = "cloud.azure.refresh_interval";
|
||||
|
||||
public static final String REFRESH = "discovery.azure.refresh_interval";
|
||||
|
||||
public static final String HOST_TYPE = "discovery.azure.host.type";
|
||||
public static final String ENDPOINT_NAME = "discovery.azure.endpoint.name";
|
||||
public static final String DEPLOYMENT_NAME = "discovery.azure.deployment.name";
|
||||
public static final String DEPLOYMENT_SLOT = "discovery.azure.deployment.slot";
|
||||
}
|
||||
public HostedServiceGetDetailedResponse getServiceDetails();
|
||||
}
|
||||
|
|
|
@ -28,16 +28,16 @@ import com.microsoft.windowsazure.management.configuration.ManagementConfigurati
|
|||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.cloud.azure.AzureServiceDisableException;
|
||||
import org.elasticsearch.cloud.azure.AzureServiceRemoteException;
|
||||
import org.elasticsearch.cloud.azure.AzureSettingsFilter;
|
||||
import org.elasticsearch.common.component.AbstractLifecycleComponent;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.settings.SettingsFilter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import static org.elasticsearch.cloud.azure.management.AzureComputeService.Management.*;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -52,21 +52,19 @@ public class AzureComputeServiceImpl extends AbstractLifecycleComponent<AzureCom
|
|||
private final String serviceName;
|
||||
|
||||
@Inject
|
||||
public AzureComputeServiceImpl(Settings settings, SettingsFilter settingsFilter) {
|
||||
public AzureComputeServiceImpl(Settings settings) {
|
||||
super(settings);
|
||||
settingsFilter.addFilter(new AzureSettingsFilter());
|
||||
String subscriptionId = settings.get(SUBSCRIPTION_ID, settings.get(SUBSCRIPTION_ID_DEPRECATED));
|
||||
|
||||
String subscriptionId = componentSettings.get(Fields.SUBSCRIPTION_ID, settings.get("cloud.azure." + Fields.SUBSCRIPTION_ID_DEPRECATED));
|
||||
|
||||
serviceName = componentSettings.get(Fields.SERVICE_NAME, settings.get("cloud.azure." + Fields.SERVICE_NAME_DEPRECATED));
|
||||
String keystorePath = componentSettings.get(Fields.KEYSTORE_PATH, settings.get("cloud.azure." + Fields.KEYSTORE_DEPRECATED));
|
||||
String keystorePassword = componentSettings.get(Fields.KEYSTORE_PASSWORD, settings.get("cloud.azure." + Fields.PASSWORD_DEPRECATED));
|
||||
String strKeyStoreType = componentSettings.get(Fields.KEYSTORE_TYPE, KeyStoreType.pkcs12.name());
|
||||
serviceName = settings.get(Management.SERVICE_NAME, settings.get(Management.SERVICE_NAME_DEPRECATED));
|
||||
String keystorePath = settings.get(KEYSTORE_PATH, settings.get(KEYSTORE_DEPRECATED));
|
||||
String keystorePassword = settings.get(KEYSTORE_PASSWORD, settings.get(PASSWORD_DEPRECATED));
|
||||
String strKeyStoreType = settings.get(KEYSTORE_TYPE, KeyStoreType.pkcs12.name());
|
||||
KeyStoreType tmpKeyStoreType = KeyStoreType.pkcs12;
|
||||
try {
|
||||
tmpKeyStoreType = KeyStoreType.fromString(strKeyStoreType);
|
||||
} catch (Exception e) {
|
||||
logger.warn("wrong value for [{}]: [{}]. falling back to [{}]...", Fields.KEYSTORE_TYPE,
|
||||
logger.warn("wrong value for [{}]: [{}]. falling back to [{}]...", KEYSTORE_TYPE,
|
||||
strKeyStoreType, KeyStoreType.pkcs12.name());
|
||||
}
|
||||
KeyStoreType keystoreType = tmpKeyStoreType;
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you 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.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.cloud.azure.management;
|
||||
|
||||
import org.elasticsearch.common.component.AbstractComponent;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.settings.SettingsFilter;
|
||||
|
||||
import static org.elasticsearch.cloud.azure.management.AzureComputeService.Management.*;
|
||||
|
||||
public class AzureComputeSettingsFilter extends AbstractComponent {
|
||||
|
||||
@Inject
|
||||
protected AzureComputeSettingsFilter(Settings settings, SettingsFilter settingsFilter) {
|
||||
super(settings);
|
||||
// Cloud management API settings we need to hide
|
||||
settingsFilter.addFilter(KEYSTORE_PATH);
|
||||
settingsFilter.addFilter(KEYSTORE_PASSWORD);
|
||||
settingsFilter.addFilter(KEYSTORE_TYPE);
|
||||
settingsFilter.addFilter(SUBSCRIPTION_ID);
|
||||
|
||||
// Deprecated Cloud management API settings we need to hide
|
||||
// TODO Remove in 3.0.0
|
||||
settingsFilter.addFilter(KEYSTORE_DEPRECATED);
|
||||
settingsFilter.addFilter(PASSWORD_DEPRECATED);
|
||||
settingsFilter.addFilter(SUBSCRIPTION_ID_DEPRECATED);
|
||||
}
|
||||
}
|
|
@ -32,17 +32,19 @@ import java.net.URISyntaxException;
|
|||
* @see AzureStorageServiceImpl for Azure REST API implementation
|
||||
*/
|
||||
public interface AzureStorageService {
|
||||
static public final class Fields {
|
||||
static public final class Storage {
|
||||
@Deprecated
|
||||
public static final String ACCOUNT_DEPRECATED = "storage_account";
|
||||
public static final String ACCOUNT_DEPRECATED = "cloud.azure.storage_account";
|
||||
@Deprecated
|
||||
public static final String KEY_DEPRECATED = "storage_key";
|
||||
public static final String ACCOUNT = "account";
|
||||
public static final String KEY = "key";
|
||||
public static final String CONTAINER = "container";
|
||||
public static final String BASE_PATH = "base_path";
|
||||
public static final String CHUNK_SIZE = "chunk_size";
|
||||
public static final String COMPRESS = "compress";
|
||||
public static final String KEY_DEPRECATED = "cloud.azure.storage_key";
|
||||
|
||||
public static final String API_IMPLEMENTATION = "cloud.azure.storage.api.impl";
|
||||
public static final String ACCOUNT = "cloud.azure.storage.account";
|
||||
public static final String KEY = "cloud.azure.storage.key";
|
||||
public static final String CONTAINER = "repositories.azure.container";
|
||||
public static final String BASE_PATH = "repositories.azure.base_path";
|
||||
public static final String CHUNK_SIZE = "repositories.azure.chunk_size";
|
||||
public static final String COMPRESS = "repositories.azure.compress";
|
||||
}
|
||||
|
||||
boolean doesContainerExist(String container);
|
||||
|
|
|
@ -23,14 +23,12 @@ import com.microsoft.azure.storage.CloudStorageAccount;
|
|||
import com.microsoft.azure.storage.StorageException;
|
||||
import com.microsoft.azure.storage.blob.*;
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.cloud.azure.AzureSettingsFilter;
|
||||
import org.elasticsearch.common.blobstore.BlobMetaData;
|
||||
import org.elasticsearch.common.blobstore.support.PlainBlobMetaData;
|
||||
import org.elasticsearch.common.collect.ImmutableMap;
|
||||
import org.elasticsearch.common.component.AbstractLifecycleComponent;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.settings.SettingsFilter;
|
||||
import org.elasticsearch.repositories.RepositoryException;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
@ -38,6 +36,8 @@ import java.io.OutputStream;
|
|||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import static org.elasticsearch.cloud.azure.storage.AzureStorageService.Storage.*;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -51,13 +51,11 @@ public class AzureStorageServiceImpl extends AbstractLifecycleComponent<AzureSto
|
|||
private CloudBlobClient client;
|
||||
|
||||
@Inject
|
||||
public AzureStorageServiceImpl(Settings settings, SettingsFilter settingsFilter) {
|
||||
public AzureStorageServiceImpl(Settings settings) {
|
||||
super(settings);
|
||||
settingsFilter.addFilter(new AzureSettingsFilter());
|
||||
|
||||
// We try to load storage API settings from `repositories.azure.`
|
||||
account = componentSettings.get(Fields.ACCOUNT, settings.get("cloud.azure." + Fields.ACCOUNT_DEPRECATED));
|
||||
key = componentSettings.get(Fields.KEY, settings.get("cloud.azure." + Fields.KEY_DEPRECATED));
|
||||
// We try to load storage API settings from `cloud.azure.`
|
||||
account = settings.get(ACCOUNT, settings.get(ACCOUNT_DEPRECATED));
|
||||
key = settings.get(KEY, settings.get(KEY_DEPRECATED));
|
||||
blob = "http://" + account + ".blob.core.windows.net/";
|
||||
|
||||
try {
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you 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.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.cloud.azure.storage;
|
||||
|
||||
import org.elasticsearch.common.component.AbstractComponent;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.settings.SettingsFilter;
|
||||
|
||||
import static org.elasticsearch.cloud.azure.storage.AzureStorageService.Storage.*;
|
||||
|
||||
public class AzureStorageSettingsFilter extends AbstractComponent {
|
||||
|
||||
@Inject
|
||||
protected AzureStorageSettingsFilter(Settings settings, SettingsFilter settingsFilter) {
|
||||
super(settings);
|
||||
// Cloud storage API settings needed to be hidden
|
||||
settingsFilter.addFilter(ACCOUNT);
|
||||
settingsFilter.addFilter(KEY);
|
||||
|
||||
// Deprecated Cloud storage API settings needed to be hidden
|
||||
// TODO Remove in 3.0.0
|
||||
settingsFilter.addFilter(ACCOUNT_DEPRECATED);
|
||||
settingsFilter.addFilter(KEY_DEPRECATED);
|
||||
}
|
||||
}
|
|
@ -21,7 +21,6 @@ package org.elasticsearch.discovery.azure;
|
|||
|
||||
import org.elasticsearch.cluster.ClusterName;
|
||||
import org.elasticsearch.cluster.ClusterService;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNodeService;
|
||||
import org.elasticsearch.cluster.settings.DynamicSettings;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
@ -43,9 +42,8 @@ public class AzureDiscovery extends ZenDiscovery {
|
|||
@Inject
|
||||
public AzureDiscovery(Settings settings, ClusterName clusterName, ThreadPool threadPool, TransportService transportService,
|
||||
ClusterService clusterService, NodeSettingsService nodeSettingsService, ZenPingService pingService,
|
||||
DiscoveryNodeService discoveryNodeService,
|
||||
DiscoverySettings discoverySettings, ElectMasterService electMasterService, DynamicSettings dynamicSettings) {
|
||||
super(settings, clusterName, threadPool, transportService, clusterService, nodeSettingsService,
|
||||
discoveryNodeService, pingService, electMasterService, discoverySettings, dynamicSettings);
|
||||
pingService, electMasterService, discoverySettings, dynamicSettings);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package org.elasticsearch.discovery.azure;
|
||||
|
||||
import org.elasticsearch.cloud.azure.AzureModule;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.cloud.azure.management.AzureComputeSettingsFilter;
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
import org.elasticsearch.common.logging.Loggers;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
@ -35,7 +35,6 @@ public class AzureDiscoveryModule extends ZenDiscoveryModule {
|
|||
protected final ESLogger logger;
|
||||
private Settings settings;
|
||||
|
||||
@Inject
|
||||
public AzureDiscoveryModule(Settings settings) {
|
||||
super();
|
||||
this.logger = Loggers.getLogger(getClass(), settings);
|
||||
|
@ -47,6 +46,7 @@ public class AzureDiscoveryModule extends ZenDiscoveryModule {
|
|||
|
||||
@Override
|
||||
protected void bindDiscovery() {
|
||||
bind(AzureComputeSettingsFilter.class).asEagerSingleton();
|
||||
if (AzureModule.isDiscoveryReady(settings, logger)) {
|
||||
bind(Discovery.class).to(AzureDiscovery.class).asEagerSingleton();
|
||||
} else {
|
||||
|
|
|
@ -24,7 +24,8 @@ import org.elasticsearch.Version;
|
|||
import org.elasticsearch.cloud.azure.AzureServiceDisableException;
|
||||
import org.elasticsearch.cloud.azure.AzureServiceRemoteException;
|
||||
import org.elasticsearch.cloud.azure.management.AzureComputeService;
|
||||
import org.elasticsearch.cloud.azure.management.AzureComputeService.Fields;
|
||||
import org.elasticsearch.cloud.azure.management.AzureComputeService.Discovery;
|
||||
import org.elasticsearch.cloud.azure.management.AzureComputeService.Management;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.common.collect.Lists;
|
||||
import org.elasticsearch.common.component.AbstractComponent;
|
||||
|
@ -111,38 +112,40 @@ public class AzureUnicastHostsProvider extends AbstractComponent implements Unic
|
|||
this.networkService = networkService;
|
||||
this.version = version;
|
||||
|
||||
this.refreshInterval = componentSettings.getAsTime(Fields.REFRESH,
|
||||
settings.getAsTime("cloud.azure." + Fields.REFRESH, TimeValue.timeValueSeconds(0)));
|
||||
this.refreshInterval = settings.getAsTime(Discovery.REFRESH, settings.getAsTime(Discovery.REFRESH_DEPRECATED,
|
||||
TimeValue.timeValueSeconds(0)));
|
||||
|
||||
String strHostType = componentSettings.get(Fields.HOST_TYPE,
|
||||
settings.get("cloud.azure." + Fields.HOST_TYPE_DEPRECATED, HostType.PRIVATE_IP.name())).toUpperCase();
|
||||
String strHostType = settings.get(Discovery.HOST_TYPE, settings.get(Discovery.HOST_TYPE_DEPRECATED,
|
||||
HostType.PRIVATE_IP.name())).toUpperCase();
|
||||
HostType tmpHostType = HostType.fromString(strHostType);
|
||||
if (tmpHostType == null) {
|
||||
logger.warn("wrong value for [{}]: [{}]. falling back to [{}]...", Fields.HOST_TYPE,
|
||||
logger.warn("wrong value for [{}]: [{}]. falling back to [{}]...", Discovery.HOST_TYPE,
|
||||
strHostType, HostType.PRIVATE_IP.name().toLowerCase());
|
||||
tmpHostType = HostType.PRIVATE_IP;
|
||||
}
|
||||
this.hostType = tmpHostType;
|
||||
|
||||
// TODO Remove in 3.0.0
|
||||
String portName = settings.get("cloud.azure." + Fields.PORT_NAME_DEPRECATED);
|
||||
String portName = settings.get(Discovery.PORT_NAME_DEPRECATED);
|
||||
if (portName != null) {
|
||||
logger.warn("setting [{}] has been deprecated. please replace with [{}].", Fields.PORT_NAME_DEPRECATED, Fields.ENDPOINT_NAME);
|
||||
logger.warn("setting [{}] has been deprecated. please replace with [{}].", Discovery.PORT_NAME_DEPRECATED,
|
||||
Discovery.ENDPOINT_NAME);
|
||||
this.publicEndpointName = portName;
|
||||
} else {
|
||||
this.publicEndpointName = componentSettings.get(Fields.ENDPOINT_NAME, "elasticsearch");
|
||||
this.publicEndpointName = settings.get(Discovery.ENDPOINT_NAME, "elasticsearch");
|
||||
}
|
||||
|
||||
this.deploymentName = componentSettings.get(Fields.DEPLOYMENT_NAME,
|
||||
settings.get("cloud.azure.management." + Fields.SERVICE_NAME,
|
||||
settings.get("cloud.azure." + Fields.SERVICE_NAME_DEPRECATED)));
|
||||
// Deployment name could be set with discovery.azure.deployment.name
|
||||
// Default to cloud.azure.management.cloud.service.name
|
||||
this.deploymentName = settings.get(Discovery.DEPLOYMENT_NAME,
|
||||
settings.get(Management.SERVICE_NAME, settings.get(Management.SERVICE_NAME_DEPRECATED)));
|
||||
|
||||
// Reading deployment_slot
|
||||
String strDeployment = componentSettings.get(Fields.DEPLOYMENT_SLOT, Deployment.PRODUCTION.deployment);
|
||||
String strDeployment = settings.get(Discovery.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);
|
||||
logger.warn("wrong value for [{}]: [{}]. falling back to [{}]...", Discovery.DEPLOYMENT_SLOT, strDeployment,
|
||||
Deployment.PRODUCTION.deployment);
|
||||
tmpDeployment = Deployment.PRODUCTION;
|
||||
}
|
||||
this.deploymentSlot = tmpDeployment.slot;
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
package org.elasticsearch.repositories.azure;
|
||||
|
||||
import com.microsoft.azure.storage.StorageException;
|
||||
import org.elasticsearch.cloud.azure.storage.AzureStorageService;
|
||||
import org.elasticsearch.cloud.azure.blobstore.AzureBlobStore;
|
||||
import org.elasticsearch.cloud.azure.storage.AzureStorageService.Storage;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.cluster.metadata.SnapshotId;
|
||||
import org.elasticsearch.common.Strings;
|
||||
|
@ -57,6 +57,13 @@ public class AzureRepository extends BlobStoreRepository {
|
|||
public final static String TYPE = "azure";
|
||||
public final static String CONTAINER_DEFAULT = "elasticsearch-snapshots";
|
||||
|
||||
static public final class Repository {
|
||||
public static final String CONTAINER = "container";
|
||||
public static final String CHUNK_SIZE = "chunk_size";
|
||||
public static final String COMPRESS = "compress";
|
||||
public static final String BASE_PATH = "base_path";
|
||||
}
|
||||
|
||||
private final AzureBlobStore blobStore;
|
||||
|
||||
private final BlobPath basePath;
|
||||
|
@ -71,21 +78,21 @@ public class AzureRepository extends BlobStoreRepository {
|
|||
AzureBlobStore azureBlobStore) throws IOException, URISyntaxException, StorageException {
|
||||
super(name.getName(), repositorySettings, indexShardRepository);
|
||||
|
||||
String container = repositorySettings.settings().get(AzureStorageService.Fields.CONTAINER,
|
||||
componentSettings.get(AzureStorageService.Fields.CONTAINER, CONTAINER_DEFAULT));
|
||||
String container = repositorySettings.settings().get(Repository.CONTAINER,
|
||||
settings.get(Storage.CONTAINER, CONTAINER_DEFAULT));
|
||||
|
||||
this.blobStore = azureBlobStore;
|
||||
this.chunkSize = repositorySettings.settings().getAsBytesSize(AzureStorageService.Fields.CHUNK_SIZE,
|
||||
componentSettings.getAsBytesSize(AzureStorageService.Fields.CHUNK_SIZE, new ByteSizeValue(64, ByteSizeUnit.MB)));
|
||||
this.chunkSize = repositorySettings.settings().getAsBytesSize(Repository.CHUNK_SIZE,
|
||||
settings.getAsBytesSize(Storage.CHUNK_SIZE, new ByteSizeValue(64, ByteSizeUnit.MB)));
|
||||
|
||||
if (this.chunkSize.getMb() > 64) {
|
||||
logger.warn("azure repository does not support yet size > 64mb. Fall back to 64mb.");
|
||||
this.chunkSize = new ByteSizeValue(64, ByteSizeUnit.MB);
|
||||
}
|
||||
|
||||
this.compress = repositorySettings.settings().getAsBoolean(AzureStorageService.Fields.COMPRESS,
|
||||
componentSettings.getAsBoolean(AzureStorageService.Fields.COMPRESS, false));
|
||||
String basePath = repositorySettings.settings().get(AzureStorageService.Fields.BASE_PATH, null);
|
||||
this.compress = repositorySettings.settings().getAsBoolean(Repository.COMPRESS,
|
||||
settings.getAsBoolean(Storage.COMPRESS, false));
|
||||
String basePath = repositorySettings.settings().get(Repository.BASE_PATH, null);
|
||||
|
||||
if (Strings.hasLength(basePath)) {
|
||||
// Remove starting / if any
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
package org.elasticsearch.repositories.azure;
|
||||
|
||||
import org.elasticsearch.cloud.azure.AzureModule;
|
||||
import org.elasticsearch.cloud.azure.storage.AzureStorageSettingsFilter;
|
||||
import org.elasticsearch.common.inject.AbstractModule;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.logging.ESLogger;
|
||||
import org.elasticsearch.common.logging.Loggers;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
@ -37,7 +37,6 @@ public class AzureRepositoryModule extends AbstractModule {
|
|||
protected final ESLogger logger;
|
||||
private Settings settings;
|
||||
|
||||
@Inject
|
||||
public AzureRepositoryModule(Settings settings) {
|
||||
super();
|
||||
this.logger = Loggers.getLogger(getClass(), settings);
|
||||
|
@ -49,6 +48,7 @@ public class AzureRepositoryModule extends AbstractModule {
|
|||
*/
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(AzureStorageSettingsFilter.class).asEagerSingleton();
|
||||
if (AzureModule.isSnapshotReady(settings, logger)) {
|
||||
bind(Repository.class).to(AzureRepository.class).asEagerSingleton();
|
||||
bind(IndexShardRepository.class).to(BlobStoreIndexShardRepository.class).asEagerSingleton();
|
||||
|
|
|
@ -57,7 +57,7 @@ public abstract class AbstractAzureTest extends ElasticsearchIntegrationTest {
|
|||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
return ImmutableSettings.builder()
|
||||
.put(super.nodeSettings(nodeOrdinal))
|
||||
.put("plugins." + PluginsService.LOAD_PLUGIN_FROM_CLASSPATH, true)
|
||||
.put(PluginsService.LOAD_PLUGIN_FROM_CLASSPATH, true)
|
||||
.put(readSettingsFromFile())
|
||||
.build();
|
||||
}
|
||||
|
|
|
@ -21,6 +21,8 @@ package org.elasticsearch.discovery.azure;
|
|||
|
||||
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse;
|
||||
import org.elasticsearch.cloud.azure.management.AzureComputeService;
|
||||
import org.elasticsearch.cloud.azure.management.AzureComputeService.Discovery;
|
||||
import org.elasticsearch.cloud.azure.management.AzureComputeService.Management;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.plugins.PluginsService;
|
||||
|
@ -39,7 +41,7 @@ public abstract class AbstractAzureComputeServiceTest extends ElasticsearchInteg
|
|||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
ImmutableSettings.Builder settings = ImmutableSettings.builder()
|
||||
.put(super.nodeSettings(nodeOrdinal))
|
||||
.put("plugins." + PluginsService.LOAD_PLUGIN_FROM_CLASSPATH, true);
|
||||
.put(PluginsService.LOAD_PLUGIN_FROM_CLASSPATH, true);
|
||||
return settings.build();
|
||||
}
|
||||
|
||||
|
@ -53,16 +55,26 @@ public abstract class AbstractAzureComputeServiceTest extends ElasticsearchInteg
|
|||
protected Settings settingsBuilder() {
|
||||
ImmutableSettings.Builder builder = ImmutableSettings.settingsBuilder()
|
||||
.put("discovery.type", "azure")
|
||||
.put("cloud.azure.api.impl", mock)
|
||||
// We add a fake subscription_id to start mock compute service
|
||||
.put("cloud.azure.subscription_id", "fake")
|
||||
.put("cloud.azure.refresh_interval", "5s")
|
||||
.put("cloud.azure.keystore", "dummy")
|
||||
.put("cloud.azure.password", "dummy")
|
||||
.put("cloud.azure.service_name", "dummy")
|
||||
.put(Management.API_IMPLEMENTATION, mock)
|
||||
// We need the network to make the mock working
|
||||
.put("node.mode", "network");
|
||||
|
||||
// We add a fake subscription_id to start mock compute service
|
||||
if (rarely()) {
|
||||
// We use sometime deprecated settings in tests
|
||||
builder.put(Management.SUBSCRIPTION_ID_DEPRECATED, "fake")
|
||||
.put(Discovery.REFRESH_DEPRECATED, "5s")
|
||||
.put(Management.KEYSTORE_DEPRECATED, "dummy")
|
||||
.put(Management.PASSWORD_DEPRECATED, "dummy")
|
||||
.put(Management.SERVICE_NAME_DEPRECATED, "dummy");
|
||||
} else {
|
||||
builder.put(Management.SUBSCRIPTION_ID, "fake")
|
||||
.put(Discovery.REFRESH, "5s")
|
||||
.put(Management.KEYSTORE_PATH, "dummy")
|
||||
.put(Management.KEYSTORE_PASSWORD, "dummy")
|
||||
.put(Management.SERVICE_NAME, "dummy");
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
|
||||
package org.elasticsearch.discovery.azure;
|
||||
|
||||
import org.elasticsearch.cloud.azure.management.AzureComputeService.Discovery;
|
||||
import org.elasticsearch.cloud.azure.management.AzureComputeService.Management;
|
||||
import org.elasticsearch.cloud.azure.management.AzureComputeServiceSimpleMock;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.test.ElasticsearchIntegrationTest;
|
||||
|
@ -39,8 +41,8 @@ public class AzureSimpleTest extends AbstractAzureComputeServiceTest {
|
|||
@Test
|
||||
public void one_node_should_run_using_private_ip() {
|
||||
ImmutableSettings.Builder settings = ImmutableSettings.settingsBuilder()
|
||||
.put("cloud.azure.service_name", "dummy")
|
||||
.put("cloud.azure.host_type", "private_ip")
|
||||
.put(Management.SERVICE_NAME, "dummy")
|
||||
.put(Discovery.HOST_TYPE, "private_ip")
|
||||
.put(super.settingsBuilder());
|
||||
|
||||
logger.info("--> start one node");
|
||||
|
@ -54,8 +56,8 @@ public class AzureSimpleTest extends AbstractAzureComputeServiceTest {
|
|||
@Test
|
||||
public void one_node_should_run_using_public_ip() {
|
||||
ImmutableSettings.Builder settings = ImmutableSettings.settingsBuilder()
|
||||
.put("cloud.azure.service_name", "dummy")
|
||||
.put("cloud.azure.host_type", "public_ip")
|
||||
.put(Management.SERVICE_NAME, "dummy")
|
||||
.put(Discovery.HOST_TYPE, "public_ip")
|
||||
.put(super.settingsBuilder());
|
||||
|
||||
logger.info("--> start one node");
|
||||
|
@ -69,8 +71,8 @@ public class AzureSimpleTest extends AbstractAzureComputeServiceTest {
|
|||
@Test
|
||||
public void one_node_should_run_using_wrong_settings() {
|
||||
ImmutableSettings.Builder settings = ImmutableSettings.settingsBuilder()
|
||||
.put("cloud.azure.service_name", "dummy")
|
||||
.put("cloud.azure.host_type", "do_not_exist")
|
||||
.put(Management.SERVICE_NAME, "dummy")
|
||||
.put(Discovery.HOST_TYPE, "do_not_exist")
|
||||
.put(super.settingsBuilder());
|
||||
|
||||
logger.info("--> start one node");
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
|
||||
package org.elasticsearch.discovery.azure;
|
||||
|
||||
import org.elasticsearch.cloud.azure.management.AzureComputeService.Discovery;
|
||||
import org.elasticsearch.cloud.azure.management.AzureComputeService.Management;
|
||||
import org.elasticsearch.cloud.azure.management.AzureComputeServiceTwoNodesMock;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.test.ElasticsearchIntegrationTest;
|
||||
|
@ -39,8 +41,8 @@ public class AzureTwoStartedNodesTest extends AbstractAzureComputeServiceTest {
|
|||
@Test
|
||||
public void two_nodes_should_run_using_private_ip() {
|
||||
ImmutableSettings.Builder settings = ImmutableSettings.settingsBuilder()
|
||||
.put("cloud.azure.service_name", "dummy")
|
||||
.put("cloud.azure.host_type", "private_ip")
|
||||
.put(Management.SERVICE_NAME, "dummy")
|
||||
.put(Discovery.HOST_TYPE, "private_ip")
|
||||
.put(super.settingsBuilder());
|
||||
|
||||
logger.info("--> start first node");
|
||||
|
@ -58,8 +60,8 @@ public class AzureTwoStartedNodesTest extends AbstractAzureComputeServiceTest {
|
|||
@Test
|
||||
public void two_nodes_should_run_using_public_ip() {
|
||||
ImmutableSettings.Builder settings = ImmutableSettings.settingsBuilder()
|
||||
.put("cloud.azure.service_name", "dummy")
|
||||
.put("cloud.azure.host_type", "public_ip")
|
||||
.put(Management.SERVICE_NAME, "dummy")
|
||||
.put(Discovery.HOST_TYPE, "public_ip")
|
||||
.put(super.settingsBuilder());
|
||||
|
||||
logger.info("--> start first node");
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.repositories.azure;
|
|||
import com.microsoft.azure.storage.StorageException;
|
||||
import org.elasticsearch.cloud.azure.AbstractAzureTest;
|
||||
import org.elasticsearch.cloud.azure.storage.AzureStorageService;
|
||||
import org.elasticsearch.cloud.azure.storage.AzureStorageService.Storage;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
@ -65,17 +66,17 @@ public abstract class AbstractAzureRepositoryServiceTest extends AbstractAzureTe
|
|||
@Override
|
||||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
ImmutableSettings.Builder builder = ImmutableSettings.settingsBuilder()
|
||||
.put("plugins." + PluginsService.LOAD_PLUGIN_FROM_CLASSPATH, true)
|
||||
.put("repositories.azure.api.impl", mock)
|
||||
.put("repositories.azure.container", "snapshots");
|
||||
.put(PluginsService.LOAD_PLUGIN_FROM_CLASSPATH, true)
|
||||
.put(Storage.API_IMPLEMENTATION, mock)
|
||||
.put(Storage.CONTAINER, "snapshots");
|
||||
|
||||
// We use sometime deprecated settings in tests
|
||||
if (rarely()) {
|
||||
builder.put("cloud.azure." + AzureStorageService.Fields.ACCOUNT_DEPRECATED, "mock_azure_account")
|
||||
.put("cloud.azure." + AzureStorageService.Fields.KEY_DEPRECATED, "mock_azure_key");
|
||||
builder.put(Storage.ACCOUNT_DEPRECATED, "mock_azure_account")
|
||||
.put(Storage.KEY_DEPRECATED, "mock_azure_key");
|
||||
} else {
|
||||
builder.put("cloud.azure.storage." + AzureStorageService.Fields.ACCOUNT, "mock_azure_account")
|
||||
.put("cloud.azure.storage." + AzureStorageService.Fields.KEY, "mock_azure_key");
|
||||
builder.put(Storage.ACCOUNT, "mock_azure_account")
|
||||
.put(Storage.KEY, "mock_azure_key");
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
|
|
|
@ -27,17 +27,17 @@ import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotR
|
|||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.client.ClusterAdminClient;
|
||||
import org.elasticsearch.cloud.azure.AbstractAzureTest;
|
||||
import org.elasticsearch.cloud.azure.AzureSettingsFilter;
|
||||
import org.elasticsearch.cloud.azure.storage.AzureStorageService;
|
||||
import org.elasticsearch.cloud.azure.storage.AzureStorageService.Storage;
|
||||
import org.elasticsearch.cloud.azure.storage.AzureStorageServiceImpl;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.base.Predicate;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.settings.SettingsFilter;
|
||||
import org.elasticsearch.repositories.RepositoryMissingException;
|
||||
import org.elasticsearch.repositories.RepositoryVerificationException;
|
||||
import org.elasticsearch.repositories.azure.AzureRepository.Repository;
|
||||
import org.elasticsearch.snapshots.SnapshotMissingException;
|
||||
import org.elasticsearch.snapshots.SnapshotState;
|
||||
import org.elasticsearch.test.ElasticsearchIntegrationTest;
|
||||
|
@ -109,9 +109,9 @@ public class AzureSnapshotRestoreITest extends AbstractAzureTest {
|
|||
logger.info("--> creating azure repository with path [{}]", getRepositoryPath());
|
||||
PutRepositoryResponse putRepositoryResponse = client.admin().cluster().preparePutRepository("test-repo")
|
||||
.setType("azure").setSettings(ImmutableSettings.settingsBuilder()
|
||||
.put(AzureStorageService.Fields.CONTAINER, getContainerName())
|
||||
.put(AzureStorageService.Fields.BASE_PATH, getRepositoryPath())
|
||||
.put(AzureStorageService.Fields.CHUNK_SIZE, randomIntBetween(1000, 10000))
|
||||
.put(Storage.CONTAINER, getContainerName())
|
||||
.put(Storage.BASE_PATH, getRepositoryPath())
|
||||
.put(Storage.CHUNK_SIZE, randomIntBetween(1000, 10000))
|
||||
).get();
|
||||
assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true));
|
||||
|
||||
|
@ -182,16 +182,16 @@ public class AzureSnapshotRestoreITest extends AbstractAzureTest {
|
|||
logger.info("--> creating azure repository with path [{}]", getRepositoryPath());
|
||||
PutRepositoryResponse putRepositoryResponse1 = client.admin().cluster().preparePutRepository("test-repo1")
|
||||
.setType("azure").setSettings(ImmutableSettings.settingsBuilder()
|
||||
.put(AzureStorageService.Fields.CONTAINER, getContainerName().concat("-1"))
|
||||
.put(AzureStorageService.Fields.BASE_PATH, getRepositoryPath())
|
||||
.put(AzureStorageService.Fields.CHUNK_SIZE, randomIntBetween(1000, 10000))
|
||||
.put(Repository.CONTAINER, getContainerName().concat("-1"))
|
||||
.put(Repository.BASE_PATH, getRepositoryPath())
|
||||
.put(Repository.CHUNK_SIZE, randomIntBetween(1000, 10000))
|
||||
).get();
|
||||
assertThat(putRepositoryResponse1.isAcknowledged(), equalTo(true));
|
||||
PutRepositoryResponse putRepositoryResponse2 = client.admin().cluster().preparePutRepository("test-repo2")
|
||||
.setType("azure").setSettings(ImmutableSettings.settingsBuilder()
|
||||
.put(AzureStorageService.Fields.CONTAINER, getContainerName().concat("-2"))
|
||||
.put(AzureStorageService.Fields.BASE_PATH, getRepositoryPath())
|
||||
.put(AzureStorageService.Fields.CHUNK_SIZE, randomIntBetween(1000, 10000))
|
||||
.put(Repository.CONTAINER, getContainerName().concat("-2"))
|
||||
.put(Repository.BASE_PATH, getRepositoryPath())
|
||||
.put(Repository.CHUNK_SIZE, randomIntBetween(1000, 10000))
|
||||
).get();
|
||||
assertThat(putRepositoryResponse2.isAcknowledged(), equalTo(true));
|
||||
|
||||
|
@ -262,7 +262,7 @@ public class AzureSnapshotRestoreITest extends AbstractAzureTest {
|
|||
logger.info("--> creating azure repository without any path");
|
||||
PutRepositoryResponse putRepositoryResponse = client.preparePutRepository("test-repo").setType("azure")
|
||||
.setSettings(ImmutableSettings.settingsBuilder()
|
||||
.put(AzureStorageService.Fields.CONTAINER, getContainerName())
|
||||
.put(Repository.CONTAINER, getContainerName())
|
||||
).get();
|
||||
assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true));
|
||||
|
||||
|
@ -283,8 +283,8 @@ public class AzureSnapshotRestoreITest extends AbstractAzureTest {
|
|||
logger.info("--> creating azure repository path [{}]", getRepositoryPath());
|
||||
putRepositoryResponse = client.preparePutRepository("test-repo").setType("azure")
|
||||
.setSettings(ImmutableSettings.settingsBuilder()
|
||||
.put(AzureStorageService.Fields.CONTAINER, getContainerName())
|
||||
.put(AzureStorageService.Fields.BASE_PATH, getRepositoryPath())
|
||||
.put(Repository.CONTAINER, getContainerName())
|
||||
.put(Repository.BASE_PATH, getRepositoryPath())
|
||||
).get();
|
||||
assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true));
|
||||
|
||||
|
@ -310,7 +310,7 @@ public class AzureSnapshotRestoreITest extends AbstractAzureTest {
|
|||
logger.info("--> creating azure repository without any path");
|
||||
PutRepositoryResponse putRepositoryResponse = client.preparePutRepository("test-repo").setType("azure")
|
||||
.setSettings(ImmutableSettings.settingsBuilder()
|
||||
.put(AzureStorageService.Fields.CONTAINER, getContainerName())
|
||||
.put(Repository.CONTAINER, getContainerName())
|
||||
).get();
|
||||
assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true));
|
||||
|
||||
|
@ -360,9 +360,9 @@ public class AzureSnapshotRestoreITest extends AbstractAzureTest {
|
|||
try {
|
||||
PutRepositoryResponse putRepositoryResponse = client().admin().cluster().preparePutRepository("test-repo")
|
||||
.setType("azure").setSettings(ImmutableSettings.settingsBuilder()
|
||||
.put(AzureStorageService.Fields.CONTAINER, container)
|
||||
.put(AzureStorageService.Fields.BASE_PATH, getRepositoryPath())
|
||||
.put(AzureStorageService.Fields.CHUNK_SIZE, randomIntBetween(1000, 10000))
|
||||
.put(Repository.CONTAINER, container)
|
||||
.put(Repository.BASE_PATH, getRepositoryPath())
|
||||
.put(Repository.CHUNK_SIZE, randomIntBetween(1000, 10000))
|
||||
).get();
|
||||
client().admin().cluster().prepareDeleteRepository("test-repo").get();
|
||||
try {
|
||||
|
@ -392,9 +392,9 @@ public class AzureSnapshotRestoreITest extends AbstractAzureTest {
|
|||
logger.info("--> creating azure repository with path [{}]", getRepositoryPath());
|
||||
PutRepositoryResponse putRepositoryResponse = client.admin().cluster().preparePutRepository("test-repo")
|
||||
.setType("azure").setSettings(ImmutableSettings.settingsBuilder()
|
||||
.put(AzureStorageService.Fields.CONTAINER, getContainerName())
|
||||
.put(AzureStorageService.Fields.BASE_PATH, getRepositoryPath())
|
||||
.put(AzureStorageService.Fields.CHUNK_SIZE, randomIntBetween(1000, 10000))
|
||||
.put(Repository.CONTAINER, getContainerName())
|
||||
.put(Repository.BASE_PATH, getRepositoryPath())
|
||||
.put(Repository.CHUNK_SIZE, randomIntBetween(1000, 10000))
|
||||
).get();
|
||||
assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true));
|
||||
|
||||
|
@ -440,7 +440,7 @@ public class AzureSnapshotRestoreITest extends AbstractAzureTest {
|
|||
try {
|
||||
client.preparePutRepository("test-repo").setType("azure")
|
||||
.setSettings(ImmutableSettings.settingsBuilder()
|
||||
.put(AzureStorageService.Fields.CONTAINER, container)
|
||||
.put(Repository.CONTAINER, container)
|
||||
).get();
|
||||
fail("we should get a RepositoryVerificationException");
|
||||
} catch (RepositoryVerificationException e) {
|
||||
|
@ -470,10 +470,7 @@ public class AzureSnapshotRestoreITest extends AbstractAzureTest {
|
|||
*/
|
||||
public static void cleanRepositoryFiles(String... containers) throws StorageException, URISyntaxException {
|
||||
Settings settings = readSettingsFromFile();
|
||||
SettingsFilter settingsFilter = new SettingsFilter(settings);
|
||||
settingsFilter.addFilter(new AzureSettingsFilter());
|
||||
|
||||
AzureStorageService client = new AzureStorageServiceImpl(settings, settingsFilter);
|
||||
AzureStorageService client = new AzureStorageServiceImpl(settings);
|
||||
for (String container : containers) {
|
||||
client.removeContainer(container);
|
||||
}
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
# Licensed to Elasticsearch under one or more contributor
|
||||
# license agreements. See the NOTICE file distributed with this work for additional
|
||||
# information regarding copyright ownership. ElasticSearch licenses this file to you
|
||||
# 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.
|
||||
#
|
||||
# Azure discovery allows to use Azure API in order to perform discovery.
|
||||
#
|
||||
# You have to install the cloud-azure plugin for enabling the Azure discovery.
|
||||
#
|
||||
# See <http://elasticsearch.org/guide/reference/modules/discovery/azure.html>
|
||||
# for more information.
|
||||
#
|
||||
# See <https://github.com/elasticsearch/elasticsearch-cloud-azure/>
|
||||
# for a step-by-step tutorial.
|
||||
#
|
||||
# cloud:
|
||||
# azure:
|
||||
# keystore: FULLPATH-TO-YOUR-KEYSTORE
|
||||
# password: YOUR-PASSWORD
|
||||
# subscription_id: YOUR-AZURE-SUBSCRIPTION-ID
|
||||
# service_name: YOUR-AZURE-SERVICE-NAME
|
||||
# storage_account: "YOUR-AZURE-STORAGE-NAME"
|
||||
# storage_key: "YOUR-AZURE-STORAGE-KEY"
|
||||
#
|
||||
# discovery:
|
||||
# type: azure
|
||||
#
|
||||
# repositories:
|
||||
# azure:
|
||||
# container: "NAME-OF-CONTAINER-USED-FOR-SNAPSHOTS" #optional default to "elasticsearch-snapshots"
|
||||
# base_path: "path/to/snapshots" #optional default to empty
|
||||
# concurrent_streams: 5 #optional default to 5
|
||||
# chunk_size: 64mb #optional default to "64mb"
|
||||
# compress: false #optional default to false
|
Loading…
Reference in New Issue