@@ -72,14 +72,12 @@ public class ConfigUtil {
72
72
private boolean propertyFileCacheEnabled = true ;
73
73
private boolean overrideSystemProperties = true ;
74
74
private boolean propertyKubernetesCacheEnabled = false ;
75
- private int propertyKubernetesMaxWritePods = 3 ;
76
75
private boolean clientMonitorEnabled = false ;
77
76
private boolean clientMonitorJmxEnabled = false ;
78
77
private String monitorExternalType = "" ;
79
78
private long monitorExternalExportPeriod = 10 ;
80
79
private int monitorExceptionQueueSize = 25 ;
81
80
82
-
83
81
public ConfigUtil () {
84
82
warnLogRateLimiter = RateLimiter .create (0.017 ); // 1 warning log output per minute
85
83
initRefreshInterval ();
@@ -95,7 +93,6 @@ public ConfigUtil() {
95
93
initPropertyFileCacheEnabled ();
96
94
initOverrideSystemProperties ();
97
95
initPropertyKubernetesCacheEnabled ();
98
- initPropertyKubernetesMaxWritePods ();
99
96
initClientMonitorEnabled ();
100
97
initClientMonitorJmxEnabled ();
101
98
initClientMonitorExternalType ();
@@ -393,44 +390,31 @@ private String getDeprecatedCustomizedCacheRoot() {
393
390
}
394
391
395
392
public String getK8sNamespace () {
396
- return getK8sConfigProperties (ApolloClientSystemConsts .APOLLO_CACHE_KUBERNETES_NAMESPACE ,
397
- ApolloClientSystemConsts .APOLLO_CACHE_KUBERNETES_NAMESPACE_ENVIRONMENT_VARIABLES ,
398
- ConfigConsts .KUBERNETES_CACHE_CONFIG_MAP_NAMESPACE_DEFAULT );
399
- }
393
+ String k8sNamespace = getCacheKubernetesNamespace ();
400
394
401
- private void initPropertyKubernetesMaxWritePods () {
402
- String propertyKubernetesMaxWritePodsStr = getK8sConfigProperties (ApolloClientSystemConsts .APOLLO_CACHE_KUBERNETES_MAX_WRITE_PODS ,
403
- ApolloClientSystemConsts .APOLLO_CACHE_KUBERNETES_MAX_WRITE_PODS_ENVIRONMENT_VARIABLES ,
404
- String .valueOf (propertyKubernetesMaxWritePods ));
405
- if (!Strings .isNullOrEmpty (propertyKubernetesMaxWritePodsStr )) {
406
- try {
407
- propertyKubernetesMaxWritePods = Integer .parseInt (propertyKubernetesMaxWritePodsStr );
408
- } catch (Throwable ex ) {
409
- logger .error ("Config for {} is invalid: {}" ,
410
- ApolloClientSystemConsts .APOLLO_CACHE_KUBERNETES_NAMESPACE , propertyKubernetesMaxWritePodsStr );
411
- }
395
+ if (!Strings .isNullOrEmpty (k8sNamespace )) {
396
+ return k8sNamespace ;
412
397
}
398
+
399
+ return ConfigConsts .KUBERNETES_CACHE_CONFIG_MAP_NAMESPACE_DEFAULT ;
413
400
}
414
401
415
- private String getK8sConfigProperties ( String key , String environmentKey , String defaultValue ) {
402
+ private String getCacheKubernetesNamespace ( ) {
416
403
// 1. Get from System Property
417
- String k8sNamespace = System .getProperty (key );
404
+ String k8sNamespace = System .getProperty (ApolloClientSystemConsts . APOLLO_CACHE_KUBERNETES_NAMESPACE );
418
405
if (Strings .isNullOrEmpty (k8sNamespace )) {
419
406
// 2. Get from OS environment variable
420
- k8sNamespace = System .getenv (environmentKey );
407
+ k8sNamespace = System .getenv (ApolloClientSystemConsts . APOLLO_CACHE_KUBERNETES_NAMESPACE_ENVIRONMENT_VARIABLES );
421
408
}
422
409
if (Strings .isNullOrEmpty (k8sNamespace )) {
423
410
// 3. Get from server.properties
424
- k8sNamespace = Foundation .server ().getProperty (key , null );
411
+ k8sNamespace = Foundation .server ().getProperty (ApolloClientSystemConsts . APOLLO_CACHE_KUBERNETES_NAMESPACE , null );
425
412
}
426
413
if (Strings .isNullOrEmpty (k8sNamespace )) {
427
414
// 4. Get from app.properties
428
- k8sNamespace = Foundation .app ().getProperty (key , null );
429
- }
430
- if (!Strings .isNullOrEmpty (k8sNamespace )) {
431
- return k8sNamespace ;
415
+ k8sNamespace = Foundation .app ().getProperty (ApolloClientSystemConsts .APOLLO_CACHE_KUBERNETES_NAMESPACE , null );
432
416
}
433
- return defaultValue ;
417
+ return k8sNamespace ;
434
418
}
435
419
436
420
public boolean isInLocalMode () {
@@ -540,10 +524,6 @@ public boolean isPropertyKubernetesCacheEnabled() {
540
524
return propertyKubernetesCacheEnabled ;
541
525
}
542
526
543
- public int getPropertyKubernetesMaxWritePods () {
544
- return propertyKubernetesMaxWritePods ;
545
- }
546
-
547
527
public boolean isOverrideSystemProperties () {
548
528
return overrideSystemProperties ;
549
529
}
@@ -637,7 +617,7 @@ private void initClientMonitorExceptionQueueSize() {
637
617
public int getMonitorExceptionQueueSize () {
638
618
return monitorExceptionQueueSize ;
639
619
}
640
-
620
+
641
621
private boolean getPropertyBoolean (String propertyName , String envName , boolean defaultVal ) {
642
622
String enablePropertyNamesCache = System .getProperty (propertyName );
643
623
if (Strings .isNullOrEmpty (enablePropertyNamesCache )) {
0 commit comments