@@ -80,8 +80,6 @@ public AzureStorageServiceImpl(Settings settings, Map<String, AzureStorageSettin
8080 // basically can't use the plugin
8181 throw new IllegalArgumentException ("If you want to use an azure repository, you need to define a client configuration." );
8282 }
83-
84-
8583 } else {
8684 this .storageSettings = regularStorageSettings ;
8785 this .deprecatedStorageSettings = new HashMap <>();
@@ -93,22 +91,19 @@ public AzureStorageServiceImpl(Settings settings, Map<String, AzureStorageSettin
9391
9492 // We register all regular azure clients
9593 for (Map .Entry <String , AzureStorageSettings > azureStorageSettingsEntry : this .storageSettings .entrySet ()) {
96- logger . debug ( "registering regular client for account [{}]" , azureStorageSettingsEntry .getKey () );
97- createClient (azureStorageSettingsEntry .getValue ());
94+ final String clientName = azureStorageSettingsEntry .getKey ();
95+ createClient (clientName , azureStorageSettingsEntry .getValue ());
9896 }
9997
10098 // We register all deprecated azure clients
10199 for (Map .Entry <String , AzureStorageSettings > azureStorageSettingsEntry : this .deprecatedStorageSettings .entrySet ()) {
102- logger . debug ( "registering deprecated client for account [{}]" , azureStorageSettingsEntry .getKey () );
103- createClient (azureStorageSettingsEntry .getValue ());
100+ final String clientName = azureStorageSettingsEntry .getKey ();
101+ createClient (clientName , azureStorageSettingsEntry .getValue ());
104102 }
105103 }
106104
107- void createClient (AzureStorageSettings azureStorageSettings ) {
105+ private void createClient (final String clientName , final AzureStorageSettings azureStorageSettings ) {
108106 try {
109- logger .trace ("creating new Azure storage client using account [{}], key [{}], endpoint suffix [{}]" ,
110- azureStorageSettings .getAccount (), azureStorageSettings .getKey (), azureStorageSettings .getEndpointSuffix ());
111-
112107 String storageConnectionString =
113108 "DefaultEndpointsProtocol=https;"
114109 + "AccountName=" + azureStorageSettings .getAccount () + ";"
@@ -127,31 +122,28 @@ void createClient(AzureStorageSettings azureStorageSettings) {
127122 // Register the client
128123 this .clients .put (azureStorageSettings .getAccount (), client );
129124 } catch (Exception e ) {
130- logger .error ("can not create azure storage client: {} " , e . getMessage () );
125+ logger .error (() -> new ParameterizedMessage ( "Can not create azure storage client [{}] " , clientName ), e );
131126 }
132127 }
133128
134129 CloudBlobClient getSelectedClient (String account , LocationMode mode ) {
135- logger .trace ("selecting a client for account [{}], mode [{}]" , account , mode .name ());
136130 AzureStorageSettings azureStorageSettings = this .storageSettings .get (account );
137131 if (azureStorageSettings == null ) {
138132 // We can't find a client that has been registered using regular settings so we try deprecated client
139133 azureStorageSettings = this .deprecatedStorageSettings .get (account );
140134 if (azureStorageSettings == null ) {
141135 // We did not get an account. That's bad.
142136 if (Strings .hasLength (account )) {
143- throw new IllegalArgumentException ("Can not find named azure client [" + account +
144- "]. Check your elasticsearch.yml." );
137+ throw new IllegalArgumentException ("Unable to find Azure client" );
145138 }
146139 throw new IllegalArgumentException ("Can not find primary/secondary client using deprecated settings. " +
147140 "Check your elasticsearch.yml." );
148141 }
149142 }
150143
151144 CloudBlobClient client = this .clients .get (azureStorageSettings .getAccount ());
152-
153145 if (client == null ) {
154- throw new IllegalArgumentException ("Can not find an azure client for account [" + azureStorageSettings . getAccount () + "] " );
146+ throw new IllegalArgumentException ("Can not find an Azure client" );
155147 }
156148
157149 // NOTE: for now, just set the location mode in case it is different;
0 commit comments