Remove deprecated azure settings

This commit is contained in:
Nik Everett 2016-01-08 13:13:14 -05:00
parent 98fdb39d3d
commit 6250f4dbaa
4 changed files with 38 additions and 73 deletions

View File

@ -21,6 +21,7 @@ package org.elasticsearch.cloud.azure.storage;
import com.microsoft.azure.storage.LocationMode;
import com.microsoft.azure.storage.StorageException;
import org.elasticsearch.common.blobstore.BlobMetaData;
import java.io.InputStream;
@ -36,10 +37,6 @@ public interface AzureStorageService {
final class Storage {
public static final String PREFIX = "cloud.azure.storage.";
@Deprecated
public static final String ACCOUNT_DEPRECATED = "cloud.azure.storage.account";
@Deprecated
public static final String KEY_DEPRECATED = "cloud.azure.storage.key";
public static final String TIMEOUT = "cloud.azure.storage.timeout";

View File

@ -19,9 +19,6 @@
package org.elasticsearch.cloud.azure.storage;
import java.util.HashMap;
import java.util.Map;
import org.elasticsearch.cloud.azure.storage.AzureStorageService.Storage;
import org.elasticsearch.common.collect.Tuple;
import org.elasticsearch.common.logging.ESLogger;
@ -31,6 +28,9 @@ import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.repositories.RepositorySettings;
import java.util.HashMap;
import java.util.Map;
public class AzureStorageSettings {
private static ESLogger logger = ESLoggerFactory.getLogger(AzureStorageSettings.class.getName());
@ -78,22 +78,12 @@ public class AzureStorageSettings {
* @param settings settings to parse
* @return A tuple with v1 = primary storage and v2 = secondary storage
*/
@SuppressWarnings("deprecation") // Supports deprecated settings
public static Tuple<AzureStorageSettings, Map<String, AzureStorageSettings>> parse(Settings settings) {
AzureStorageSettings primaryStorage = null;
Map<String, AzureStorageSettings> secondaryStorage = new HashMap<>();
// We check for deprecated settings
String account = settings.get(Storage.ACCOUNT_DEPRECATED);
String key = settings.get(Storage.KEY_DEPRECATED);
TimeValue globalTimeout = settings.getAsTime(Storage.TIMEOUT, TimeValue.timeValueMinutes(5));
if (account != null) {
logger.warn("[{}] and [{}] have been deprecated. Use now [{}xxx.account] and [{}xxx.key] where xxx is any name",
Storage.ACCOUNT_DEPRECATED, Storage.KEY_DEPRECATED, Storage.PREFIX, Storage.PREFIX);
primaryStorage = new AzureStorageSettings(null, account, key, globalTimeout);
} else {
Settings storageSettings = settings.getByPrefix(Storage.PREFIX);
if (storageSettings != null) {
Map<String, Object> asMap = storageSettings.getAsStructuredMap();
@ -130,7 +120,6 @@ public class AzureStorageSettings {
secondaryStorage.remove(fallback.getKey());
}
}
}
return Tuple.tuple(primaryStorage, secondaryStorage);
}

View File

@ -19,8 +19,8 @@
package org.elasticsearch.cloud.azure;
import java.net.URISyntaxException;
import java.util.Collection;
import com.microsoft.azure.storage.LocationMode;
import com.microsoft.azure.storage.StorageException;
import org.elasticsearch.cloud.azure.storage.AzureStorageService;
import org.elasticsearch.cloud.azure.storage.AzureStorageService.Storage;
@ -34,8 +34,8 @@ import org.elasticsearch.test.store.MockFSDirectoryService;
import org.junit.After;
import org.junit.Before;
import com.microsoft.azure.storage.LocationMode;
import com.microsoft.azure.storage.StorageException;
import java.net.URISyntaxException;
import java.util.Collection;
public abstract class AbstractAzureRepositoryServiceTestCase extends AbstractAzureTestCase {
@ -77,15 +77,9 @@ public abstract class AbstractAzureRepositoryServiceTestCase extends AbstractAzu
}
@Override
@SuppressWarnings("deprecation") // Supports deprecated settings for testing backwards compatibility
protected Settings nodeSettings(int nodeOrdinal) {
Settings.Builder builder = Settings.settingsBuilder()
.put(Storage.CONTAINER, "snapshots");
// We use sometime deprecated settings in tests
builder.put(Storage.ACCOUNT_DEPRECATED, "mock_azure_account")
.put(Storage.KEY_DEPRECATED, "mock_azure_key");
return builder.build();
}

View File

@ -19,14 +19,13 @@
package org.elasticsearch.repositories.azure;
import java.util.Map;
import org.apache.lucene.util.LuceneTestCase;
import org.elasticsearch.cloud.azure.storage.AzureStorageService.Storage;
import org.elasticsearch.cloud.azure.storage.AzureStorageSettings;
import org.elasticsearch.common.collect.Tuple;
import org.elasticsearch.common.settings.Settings;
import java.util.Map;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
@ -66,20 +65,6 @@ public class AzureSettingsParserTest extends LuceneTestCase {
assertThat(tuple.v2().keySet(), hasSize(0));
}
public void testDeprecatedSettings() {
@SuppressWarnings("deprecation")
Settings settings = Settings.builder()
.put(Storage.ACCOUNT_DEPRECATED, "myaccount1")
.put(Storage.KEY_DEPRECATED, "mykey1")
.build();
Tuple<AzureStorageSettings, Map<String, AzureStorageSettings>> tuple = AzureStorageSettings.parse(settings);
assertThat(tuple.v1(), notNullValue());
assertThat(tuple.v1().getAccount(), is("myaccount1"));
assertThat(tuple.v1().getKey(), is("mykey1"));
assertThat(tuple.v2().keySet(), hasSize(0));
}
public void testParseTwoSettingsNoDefault() {
Settings settings = Settings.builder()
.put("cloud.azure.storage.azure1.account", "myaccount1")