@@ -479,40 +479,36 @@ public String getName() {
479
479
480
480
void onCircuitBreakerRuleChanged (ServiceKey serviceKey ) {
481
481
circuitBreakerRuleDictionary .onServiceChanged (serviceKey );
482
- synchronized (countersCache ) {
483
- LOG .info ("onCircuitBreakerRuleChanged: clear service {} from ResourceCounters" , serviceKey );
484
- for (Map .Entry <Level , Cache <Resource , Optional <ResourceCounters >>> entry : countersCache .entrySet ()) {
485
- Cache <Resource , Optional <ResourceCounters >> cacheValue = entry .getValue ();
486
- for (Resource resource : cacheValue .asMap ().keySet ()) {
487
- if (Objects .equals (resource .getService (), serviceKey )) {
488
- cacheValue .invalidate (resource );
489
- }
482
+ LOG .info ("onCircuitBreakerRuleChanged: clear service {} from ResourceCounters" , serviceKey );
483
+ for (Map .Entry <Level , Cache <Resource , Optional <ResourceCounters >>> entry : countersCache .entrySet ()) {
484
+ Cache <Resource , Optional <ResourceCounters >> cacheValue = entry .getValue ();
485
+ for (Resource resource : cacheValue .asMap ().keySet ()) {
486
+ if (Objects .equals (resource .getService (), serviceKey )) {
487
+ cacheValue .invalidate (resource );
490
488
}
491
489
}
492
- HealthCheckContainer healthCheckContainer = healthCheckCache . get ( serviceKey );
493
- if ( null != healthCheckContainer ) {
494
- for ( Map . Entry < Resource , ResourceWrap > entry : resourceMapping . entrySet () ) {
495
- Resource resource = entry . getKey ();
496
- if ( Objects . equals ( resource . getService (), serviceKey )) {
497
- LOG . info ( "onCircuitBreakerRuleChanged: clear resource {} from healthCheckContainer" , resource );
498
- healthCheckContainer . removeResource ( resource );
499
- }
490
+ }
491
+ HealthCheckContainer healthCheckContainer = healthCheckCache . get ( serviceKey );
492
+ if ( null != healthCheckContainer ) {
493
+ for ( Map . Entry < Resource , ResourceWrap > entry : resourceMapping . entrySet ()) {
494
+ Resource resource = entry . getKey ();
495
+ if ( Objects . equals ( resource . getService (), serviceKey )) {
496
+ LOG . info ( "onCircuitBreakerRuleChanged: clear resource {} from healthCheckContainer" , resource );
497
+ healthCheckContainer . removeResource ( resource );
500
498
}
501
499
}
502
500
}
503
501
}
504
502
505
503
void onCircuitBreakerRuleAdded (ServiceKey serviceKey ) {
506
504
circuitBreakerRuleDictionary .onServiceChanged (serviceKey );
507
- synchronized (countersCache ) {
508
- LOG .info ("onCircuitBreakerRuleChanged: clear service {} from ResourceCounters" , serviceKey );
509
- for (Map .Entry <Level , Cache <Resource , Optional <ResourceCounters >>> entry : countersCache .entrySet ()) {
510
- Cache <Resource , Optional <ResourceCounters >> cacheValue = entry .getValue ();
511
- for (Map .Entry <Resource , Optional <ResourceCounters >> entryCache : cacheValue .asMap ().entrySet ()) {
512
- Resource resource = entryCache .getKey ();
513
- if (Objects .equals (resource .getService (), serviceKey ) && !entryCache .getValue ().isPresent ()) {
514
- cacheValue .invalidate (resource );
515
- }
505
+ LOG .info ("onCircuitBreakerRuleAdded: clear service {} from ResourceCounters" , serviceKey );
506
+ for (Map .Entry <Level , Cache <Resource , Optional <ResourceCounters >>> entry : countersCache .entrySet ()) {
507
+ Cache <Resource , Optional <ResourceCounters >> cacheValue = entry .getValue ();
508
+ for (Map .Entry <Resource , Optional <ResourceCounters >> entryCache : cacheValue .asMap ().entrySet ()) {
509
+ Resource resource = entryCache .getKey ();
510
+ if (Objects .equals (resource .getService (), serviceKey ) && !entryCache .getValue ().isPresent ()) {
511
+ cacheValue .invalidate (resource );
516
512
}
517
513
}
518
514
}
@@ -533,19 +529,17 @@ public HealthCheckContainer apply(ServiceKey serviceKey, HealthCheckContainer he
533
529
return null ;
534
530
}
535
531
});
536
- synchronized (countersCache ) {
537
- for (Map .Entry <Level , Cache <Resource , Optional <ResourceCounters >>> entry : countersCache .entrySet ()) {
538
- Cache <Resource , Optional <ResourceCounters >> cacheValue = entry .getValue ();
539
- for (Map .Entry <Resource , Optional <ResourceCounters >> entryCache : cacheValue .asMap ().entrySet ()) {
540
- Resource resource = entryCache .getKey ();
541
- if (Objects .equals (resource .getService (), svcKey )) {
542
- if (entryCache .getValue ().isPresent ()) {
543
- LOG .info ("onFaultDetectRuleChanged: ResourceCounters {} setReloadFaultDetect true" , svcKey );
544
- ResourceCounters resourceCounters = entryCache .getValue ().get ();
545
- resourceCounters .setReloadFaultDetect (true );
546
- }
547
-
532
+ for (Map .Entry <Level , Cache <Resource , Optional <ResourceCounters >>> entry : countersCache .entrySet ()) {
533
+ Cache <Resource , Optional <ResourceCounters >> cacheValue = entry .getValue ();
534
+ for (Map .Entry <Resource , Optional <ResourceCounters >> entryCache : cacheValue .asMap ().entrySet ()) {
535
+ Resource resource = entryCache .getKey ();
536
+ if (Objects .equals (resource .getService (), svcKey )) {
537
+ if (entryCache .getValue ().isPresent ()) {
538
+ LOG .info ("onFaultDetectRuleChanged: ResourceCounters {} setReloadFaultDetect true" , svcKey );
539
+ ResourceCounters resourceCounters = entryCache .getValue ().get ();
540
+ resourceCounters .setReloadFaultDetect (true );
548
541
}
542
+
549
543
}
550
544
}
551
545
}
0 commit comments