1818package org .apache .servicecomb .config .center .client ;
1919
2020import java .io .IOException ;
21+ import java .util .ArrayList ;
2122import java .util .HashMap ;
23+ import java .util .List ;
2224import java .util .Map ;
2325
2426import org .apache .commons .lang3 .StringUtils ;
3335import org .apache .servicecomb .http .client .utils .ServiceCombServiceAvailableUtils ;
3436import org .slf4j .Logger ;
3537import org .slf4j .LoggerFactory ;
38+ import org .springframework .util .CollectionUtils ;
3639
3740import com .fasterxml .jackson .core .type .TypeReference ;
3841import com .google .common .eventbus .EventBus ;
@@ -56,6 +59,8 @@ public class ConfigCenterClient implements ConfigCenterOperation {
5659
5760 private final ConfigCenterAddressManager addressManager ;
5861
62+ private final Map <String , List <String >> dimensionConfigNames = new HashMap <>();
63+
5964 public ConfigCenterClient (ConfigCenterAddressManager addressManager , HttpTransport httpTransport ) {
6065 this .addressManager = addressManager ;
6166 this .httpTransport = httpTransport ;
@@ -95,18 +100,24 @@ public QueryConfigurationsResponse queryConfigurations(QueryConfigurationsReques
95100
96101 if (allConfigMap .get (APPLICATION_CONFIG ) != null ) {
97102 configurations .putAll (allConfigMap .get (APPLICATION_CONFIG ));
103+ logConfigurationNames (APPLICATION_CONFIG , allConfigMap .get (APPLICATION_CONFIG ));
98104 }
99105
100106 if (allConfigMap .get (buildDimensionsInfo (request , false )) != null ) {
101107 configurations .putAll (allConfigMap .get (buildDimensionsInfo (request , false )));
108+ logConfigurationNames (buildDimensionsInfo (request , false ),
109+ allConfigMap .get (buildDimensionsInfo (request , false )));
102110 }
103111
104112 if (allConfigMap .get (buildDarkLaunchDimensionsInfo (request )) != null ) {
105113 configurations .putAll (allConfigMap .get (buildDarkLaunchDimensionsInfo (request )));
114+ logConfigurationNames (buildDarkLaunchDimensionsInfo (request ),
115+ allConfigMap .get (buildDarkLaunchDimensionsInfo (request )));
106116 }
107117
108118 if (allConfigMap .get (dimensionsInfo ) != null ) {
109119 configurations .putAll (allConfigMap .get (dimensionsInfo ));
120+ logConfigurationNames (dimensionsInfo , allConfigMap .get (dimensionsInfo ));
110121 }
111122 queryConfigurationsResponse .setConfigurations (configurations );
112123 queryConfigurationsResponse .setChanged (true );
@@ -140,6 +151,38 @@ public QueryConfigurationsResponse queryConfigurations(QueryConfigurationsReques
140151 }
141152 }
142153
154+ /**
155+ * Only the name of the new configuration item is printed.
156+ * No log is printed when the configuration content is updated.
157+ *
158+ * @param dimension dimension
159+ * @param configs configs
160+ */
161+ private void logConfigurationNames (String dimension , Map <String , Object > configs ) {
162+ if (CollectionUtils .isEmpty (configs )) {
163+ return ;
164+ }
165+ List <String > configNames = dimensionConfigNames .get (dimension );
166+ if (configNames == null ) {
167+ configNames = new ArrayList <>();
168+ }
169+ StringBuilder names = new StringBuilder ();
170+ for (String key : configs .keySet ()) {
171+ if (configNames .contains (key )) {
172+ continue ;
173+ }
174+ names .append (key ).append ("," );
175+ configNames .add (key );
176+ }
177+ if (names .isEmpty ()) {
178+ return ;
179+ }
180+ dimensionConfigNames .put (dimension , configNames );
181+ String fileNames = names .substring (0 , names .length () - 1 );
182+ LOGGER .info ("pulling dimension [{}] configurations success, get config names: [{}]." ,
183+ dimension , fileNames );
184+ }
185+
143186 @ Override
144187 public void checkAddressAvailable (String address ) {
145188 ServiceCombServiceAvailableUtils .checkAddressAvailable (addressManager , address , httpTransport , ADDRESS_CHECK_PATH );
0 commit comments