@@ -1008,7 +1008,7 @@ private void finishActiveMasterInitialization(MonitoredTask status) throws IOExc
10081008 // initialize load balancer
10091009 this .balancer .setMasterServices (this );
10101010 this .balancer .initialize ();
1011- this .balancer .updateClusterMetrics (getClusterMetricsInternal ());
1011+ this .balancer .updateClusterMetrics (getClusterMetricsWithoutCoprocessor ());
10121012
10131013 // start up all service threads.
10141014 status .setStatus ("Initializing master service threads" );
@@ -1096,7 +1096,7 @@ private void finishActiveMasterInitialization(MonitoredTask status) throws IOExc
10961096 }
10971097
10981098 // set cluster status again after user regions are assigned
1099- this .balancer .updateClusterMetrics (getClusterMetricsInternal ());
1099+ this .balancer .updateClusterMetrics (getClusterMetricsWithoutCoprocessor ());
11001100
11011101 // Start balancer and meta catalog janitor after meta and regions have been assigned.
11021102 status .setStatus ("Starting balancer and catalog janitor" );
@@ -1918,7 +1918,7 @@ public BalanceResponse balance(BalanceRequest request) throws IOException {
19181918 }
19191919
19201920 //Give the balancer the current cluster state.
1921- this .balancer .updateClusterMetrics (getClusterMetricsInternal ());
1921+ this .balancer .updateClusterMetrics (getClusterMetricsWithoutCoprocessor ());
19221922
19231923 List <RegionPlan > plans = this .balancer .balanceCluster (assignments );
19241924
@@ -2726,11 +2726,11 @@ public void checkTableModifiable(final TableName tableName)
27262726 }
27272727 }
27282728
2729- public ClusterMetrics getClusterMetricsInternal () throws InterruptedIOException {
2730- return getClusterMetricsInternal (EnumSet .allOf (Option .class ));
2729+ public ClusterMetrics getClusterMetricsWithoutCoprocessor () throws InterruptedIOException {
2730+ return getClusterMetricsWithoutCoprocessor (EnumSet .allOf (Option .class ));
27312731 }
27322732
2733- public ClusterMetrics getClusterMetricsInternal (EnumSet <Option > options )
2733+ public ClusterMetrics getClusterMetricsWithoutCoprocessor (EnumSet <Option > options )
27342734 throws InterruptedIOException {
27352735 ClusterMetricsBuilder builder = ClusterMetricsBuilder .newBuilder ();
27362736 // given that hbase1 can't submit the request with Option,
@@ -2742,7 +2742,6 @@ public ClusterMetrics getClusterMetricsInternal(EnumSet<Option> options)
27422742 // TASKS and/or LIVE_SERVERS will populate this map, which will be given to the builder if
27432743 // not null after option processing completes.
27442744 Map <ServerName , ServerMetrics > serverMetricsMap = null ;
2745- boolean processedLiveServers = false ;
27462745
27472746 for (Option opt : options ) {
27482747 switch (opt ) {
@@ -2763,28 +2762,16 @@ public ClusterMetrics getClusterMetricsInternal(EnumSet<Option> options)
27632762 .collect (Collectors .toList ()));
27642763 // TASKS is also synonymous with LIVE_SERVERS for now because task information for
27652764 // regionservers is carried in ServerLoad.
2766- // Add entries to serverMetricsMap for all live servers
2767- if (serverManager != null && !processedLiveServers ) {
2768- if (serverMetricsMap == null ) {
2769- serverMetricsMap = new HashMap <>();
2770- }
2771- final Map <ServerName , ServerMetrics > map = serverMetricsMap ;
2772- serverManager .getOnlineServers ().entrySet ()
2773- .forEach (e -> map .put (e .getKey (), e .getValue ()));
2774- processedLiveServers = true ;
2765+ // Add entries to serverMetricsMap for all live servers, if we haven't already done so
2766+ if (serverMetricsMap == null ) {
2767+ serverMetricsMap = getOnlineServers ();
27752768 }
27762769 break ;
27772770 }
27782771 case LIVE_SERVERS : {
2779- // Add entries to serverMetricsMap for all live servers
2780- if (serverManager != null && !processedLiveServers ) {
2781- if (serverMetricsMap == null ) {
2782- serverMetricsMap = new HashMap <>();
2783- }
2784- final Map <ServerName , ServerMetrics > map = serverMetricsMap ;
2785- serverManager .getOnlineServers ().entrySet ()
2786- .forEach (e -> map .put (e .getKey (), e .getValue ()));
2787- processedLiveServers = true ;
2772+ // Add entries to serverMetricsMap for all live servers, if we haven't already done so
2773+ if (serverMetricsMap == null ) {
2774+ serverMetricsMap = getOnlineServers ();
27882775 }
27892776 break ;
27902777 }
@@ -2854,6 +2841,16 @@ public ClusterMetrics getClusterMetricsInternal(EnumSet<Option> options)
28542841 return builder .build ();
28552842 }
28562843
2844+ private Map <ServerName , ServerMetrics > getOnlineServers () {
2845+ if (serverManager != null ) {
2846+ final Map <ServerName , ServerMetrics > map = new HashMap <>();
2847+ serverManager .getOnlineServers ().entrySet ()
2848+ .forEach (e -> map .put (e .getKey (), e .getValue ()));
2849+ return map ;
2850+ }
2851+ return null ;
2852+ }
2853+
28572854 /**
28582855 * @return cluster status
28592856 */
@@ -2865,7 +2862,7 @@ public ClusterMetrics getClusterMetrics(EnumSet<Option> options) throws IOExcept
28652862 if (cpHost != null ) {
28662863 cpHost .preGetClusterMetrics ();
28672864 }
2868- ClusterMetrics status = getClusterMetricsInternal (options );
2865+ ClusterMetrics status = getClusterMetricsWithoutCoprocessor (options );
28692866 if (cpHost != null ) {
28702867 cpHost .postGetClusterMetrics (status );
28712868 }
0 commit comments