From 63d85ec6938f1165a1445cf8d2672dbd4243dc33 Mon Sep 17 00:00:00 2001 From: David Pilato Date: Fri, 27 Feb 2015 11:15:45 +0100 Subject: [PATCH] Update settings filter Update settings filter to match elasticsearch/elasticsearch#9748 Closes #71. --- .../cloud/azure/AzureSettingsFilter.java | 60 ------------------- .../management/AzureComputeServiceImpl.java | 18 +++++- .../storage/AzureStorageServiceImpl.java | 14 ++++- .../azure/AzureSnapshotRestoreITest.java | 3 - 4 files changed, 28 insertions(+), 67 deletions(-) delete mode 100644 src/main/java/org/elasticsearch/cloud/azure/AzureSettingsFilter.java diff --git a/src/main/java/org/elasticsearch/cloud/azure/AzureSettingsFilter.java b/src/main/java/org/elasticsearch/cloud/azure/AzureSettingsFilter.java deleted file mode 100644 index 313e80f..0000000 --- a/src/main/java/org/elasticsearch/cloud/azure/AzureSettingsFilter.java +++ /dev/null @@ -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); - } -} diff --git a/src/main/java/org/elasticsearch/cloud/azure/management/AzureComputeServiceImpl.java b/src/main/java/org/elasticsearch/cloud/azure/management/AzureComputeServiceImpl.java index baad323..5ac8e4d 100644 --- a/src/main/java/org/elasticsearch/cloud/azure/management/AzureComputeServiceImpl.java +++ b/src/main/java/org/elasticsearch/cloud/azure/management/AzureComputeServiceImpl.java @@ -28,7 +28,6 @@ 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; @@ -54,7 +53,22 @@ static final class Azure { @Inject public AzureComputeServiceImpl(Settings settings, SettingsFilter settingsFilter) { super(settings); - settingsFilter.addFilter(new AzureSettingsFilter()); + // Cloud global settings + settingsFilter.addFilter("cloud.azure." + AzureComputeService.Fields.REFRESH); + + // Cloud management API settings + settingsFilter.addFilter("cloud.azure.management." + AzureComputeService.Fields.KEYSTORE_PATH); + settingsFilter.addFilter("cloud.azure.management." + AzureComputeService.Fields.KEYSTORE_PASSWORD); + settingsFilter.addFilter("cloud.azure.management." + AzureComputeService.Fields.KEYSTORE_TYPE); + settingsFilter.addFilter("cloud.azure.management." + AzureComputeService.Fields.SUBSCRIPTION_ID); + settingsFilter.addFilter("cloud.azure.management." + AzureComputeService.Fields.SERVICE_NAME); + + // Deprecated Cloud management API settings + // TODO Remove in 3.0.0 + settingsFilter.addFilter("cloud.azure." + AzureComputeService.Fields.KEYSTORE_DEPRECATED); + settingsFilter.addFilter("cloud.azure." + AzureComputeService.Fields.PASSWORD_DEPRECATED); + settingsFilter.addFilter("cloud.azure." + AzureComputeService.Fields.SUBSCRIPTION_ID_DEPRECATED); + settingsFilter.addFilter("cloud.azure." + AzureComputeService.Fields.SERVICE_NAME_DEPRECATED); String subscriptionId = componentSettings.get(Fields.SUBSCRIPTION_ID, settings.get("cloud.azure." + Fields.SUBSCRIPTION_ID_DEPRECATED)); diff --git a/src/main/java/org/elasticsearch/cloud/azure/storage/AzureStorageServiceImpl.java b/src/main/java/org/elasticsearch/cloud/azure/storage/AzureStorageServiceImpl.java index d7383b6..b0d71e5 100644 --- a/src/main/java/org/elasticsearch/cloud/azure/storage/AzureStorageServiceImpl.java +++ b/src/main/java/org/elasticsearch/cloud/azure/storage/AzureStorageServiceImpl.java @@ -23,7 +23,7 @@ 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.cloud.azure.management.AzureComputeService; import org.elasticsearch.common.blobstore.BlobMetaData; import org.elasticsearch.common.blobstore.support.PlainBlobMetaData; import org.elasticsearch.common.collect.ImmutableMap; @@ -53,7 +53,17 @@ public class AzureStorageServiceImpl extends AbstractLifecycleComponent