@@ -492,12 +492,7 @@ public boolean availableBackendsExists() {
492
492
}
493
493
494
494
public boolean containClusterName (String clusterName ) {
495
- rlock .lock ();
496
- try {
497
- return clusterNameToId .containsKey (clusterName );
498
- } finally {
499
- rlock .unlock ();
500
- }
495
+ return clusterNameToId .containsKey (clusterName );
501
496
}
502
497
503
498
@ Override
@@ -550,27 +545,17 @@ public ImmutableMap<Long, Backend> getBackendsByCurrentCluster() throws Analysis
550
545
}
551
546
552
547
public List <Backend > getBackendsByClusterName (final String clusterName ) {
553
- rlock .lock ();
554
- try {
555
- String clusterId = clusterNameToId .getOrDefault (clusterName , "" );
556
- if (clusterId .isEmpty ()) {
557
- return new ArrayList <>();
558
- }
559
- // copy a new List
560
- return new ArrayList <>(clusterIdToBackend .getOrDefault (clusterId , new ArrayList <>()));
561
- } finally {
562
- rlock .unlock ();
548
+ String clusterId = clusterNameToId .getOrDefault (clusterName , "" );
549
+ if (clusterId .isEmpty ()) {
550
+ return new ArrayList <>();
563
551
}
552
+ // copy a new List
553
+ return new ArrayList <>(clusterIdToBackend .getOrDefault (clusterId , new ArrayList <>()));
564
554
}
565
555
566
556
public List <Backend > getBackendsByClusterId (final String clusterId ) {
567
- rlock .lock ();
568
- try {
569
- // copy a new List
570
- return new ArrayList <>(clusterIdToBackend .getOrDefault (clusterId , new ArrayList <>()));
571
- } finally {
572
- rlock .unlock ();
573
- }
557
+ // copy a new List
558
+ return new ArrayList <>(clusterIdToBackend .getOrDefault (clusterId , new ArrayList <>()));
574
559
}
575
560
576
561
public String getClusterNameByBeAddr (String beEndpoint ) {
@@ -588,27 +573,18 @@ public String getClusterNameByBeAddr(String beEndpoint) {
588
573
}
589
574
590
575
public List <String > getCloudClusterIds () {
591
- rlock .lock ();
592
- try {
593
- return new ArrayList <>(clusterIdToBackend .keySet ());
594
- } finally {
595
- rlock .unlock ();
596
- }
576
+ return new ArrayList <>(clusterIdToBackend .keySet ());
597
577
}
598
578
599
579
public String getCloudStatusByName (final String clusterName ) {
600
- rlock .lock ();
601
- try {
602
- String clusterId = clusterNameToId .getOrDefault (clusterName , "" );
603
- if (Strings .isNullOrEmpty (clusterId )) {
604
- // for rename cluster or dropped cluster
605
- LOG .warn ("cant find clusterId by clusteName {}" , clusterName );
606
- return "" ;
607
- }
608
- return getCloudStatusByIdNoLock (clusterId );
609
- } finally {
610
- rlock .unlock ();
580
+ String clusterId = clusterNameToId .getOrDefault (clusterName , "" );
581
+ if (Strings .isNullOrEmpty (clusterId )) {
582
+ // for rename cluster or dropped cluster
583
+ LOG .warn ("cant find clusterId by clusteName {}" , clusterName );
584
+ return "" ;
611
585
}
586
+ // It is safe to return a null/empty status string, the caller handles it properly
587
+ return getCloudStatusByIdNoLock (clusterId );
612
588
}
613
589
614
590
public String getCloudStatusById (final String clusterId ) {
0 commit comments