5151import org .apache .hadoop .hbase .client .AsyncClusterConnection ;
5252import org .apache .hadoop .hbase .client .AsyncRegionServerAdmin ;
5353import org .apache .hadoop .hbase .client .RegionInfo ;
54- import org .apache .hadoop .hbase .executor .EventHandler ;
55- import org .apache .hadoop .hbase .executor .EventType ;
5654import org .apache .hadoop .hbase .ipc .RemoteWithExtrasException ;
5755import org .apache .hadoop .hbase .master .assignment .RegionStates ;
5856import org .apache .hadoop .hbase .master .procedure .ServerCrashProcedure ;
5957import org .apache .hadoop .hbase .monitoring .MonitoredTask ;
6058import org .apache .hadoop .hbase .procedure2 .Procedure ;
61- import org .apache .hadoop .hbase .shaded .protobuf .generated .AdminProtos ;
6259import org .apache .hadoop .hbase .util .Bytes ;
6360import org .apache .hadoop .hbase .util .CommonFSUtils ;
6461import org .apache .hadoop .hbase .util .EnvironmentEdgeManager ;
6562import org .apache .hadoop .hbase .util .FutureUtils ;
66- import org .apache .hadoop .hbase .util .RetryCounter ;
67- import org .apache .hadoop .hbase .util .RetryCounterFactory ;
6863import org .apache .hadoop .hbase .zookeeper .ZKUtil ;
6964import org .apache .hadoop .hbase .zookeeper .ZKWatcher ;
7065import org .apache .hadoop .hbase .zookeeper .ZNodePaths ;
@@ -177,8 +172,6 @@ public class ServerManager {
177172 private final long maxSkew ;
178173 private final long warningSkew ;
179174
180- private final RetryCounterFactory pingRetryCounterFactory ;
181-
182175 /** Listeners that are called on server events. */
183176 private List <ServerListener > listeners = new CopyOnWriteArrayList <>();
184177
@@ -192,11 +185,6 @@ public ServerManager(final MasterServices master) {
192185 warningSkew = c .getLong ("hbase.master.warningclockskew" , 10000 );
193186 persistFlushedSequenceId = c .getBoolean (PERSIST_FLUSHEDSEQUENCEID ,
194187 PERSIST_FLUSHEDSEQUENCEID_DEFAULT );
195- int pingMaxAttempts = Math .max (1 , master .getConfiguration ().getInt (
196- "hbase.master.maximum.ping.server.attempts" , 10 ));
197- int pingSleepInterval = Math .max (1 , master .getConfiguration ().getInt (
198- "hbase.master.ping.server.retry.sleep.interval" , 100 ));
199- this .pingRetryCounterFactory = new RetryCounterFactory (pingMaxAttempts , pingSleepInterval );
200188 }
201189
202190 /**
@@ -239,43 +227,9 @@ ServerName regionServerStartup(RegionServerStartupRequest request, int versionNu
239227 ServerName sn = ServerName .valueOf (hostname , request .getPort (), request .getServerStartCode ());
240228 checkClockSkew (sn , request .getServerCurrentTime ());
241229 checkIsDead (sn , "STARTUP" );
242- master .getExecutorService ().submit (new RegionServerStartupHandler (sn ,
243- ServerMetricsBuilder .of (sn , versionNumber , version )));
244230 return sn ;
245231 }
246232
247- class RegionServerStartupHandler extends EventHandler {
248- final ServerName serverName ;
249- final ServerMetrics serverMetrics ;
250- final int timeout ;
251-
252- RegionServerStartupHandler (final ServerName serverName , final ServerMetrics sm ) {
253- super (master , EventType .M_RS_ONLINE );
254- this .serverName = serverName ;
255- this .serverMetrics = sm ;
256- this .timeout = server .getConfiguration ().getInt (
257- HConstants .HBASE_RPC_READ_TIMEOUT_KEY , HConstants .DEFAULT_HBASE_RPC_TIMEOUT );
258- }
259- @ Override
260- public void process () throws IOException {
261- long startTime = EnvironmentEdgeManager .currentTime ();
262- while ((EnvironmentEdgeManager .currentTime () - startTime ) < timeout ) {
263- if (isServerReachable (this .serverName )) {
264- if (!checkAndRecordNewServer (this .serverName , this .serverMetrics )) {
265- LOG .warn ("THIS SHOULD NOT HAPPEN, RegionServerStartup"
266- + " could not record the server: " + this .serverName );
267- }
268- break ;
269- }
270- try {
271- Thread .sleep (100 );
272- } catch (InterruptedException ie ) {
273- LOG .debug ("Caught interrupted exception while waiting for regionserver to online" , ie );
274- }
275- }
276- }
277- }
278-
279233 /**
280234 * Updates last flushed sequence Ids for the regions on server sn
281235 * @param sn
@@ -874,45 +828,6 @@ public void waitForRegionServers(MonitoredTask status) throws InterruptedExcepti
874828 " master is " + (this .master .isStopped () ? "stopped." : "running" ));
875829 }
876830
877- /**
878- * Check if a region server is reachable and has the expected start code
879- */
880- public boolean isServerReachable (ServerName server ) {
881- if (server == null ) throw new NullPointerException ("Passed server is null" );
882-
883- RetryCounter retryCounter = pingRetryCounterFactory .create ();
884- while (retryCounter .shouldRetry ()) {
885- synchronized (this .onlineServers ) {
886- if (this .deadservers .isDeadServer (server )) {
887- return false ;
888- }
889- }
890- try {
891- AsyncRegionServerAdmin admin = master .getAsyncClusterConnection ()
892- .getRegionServerAdmin (server );
893- if (admin != null ) {
894- AdminProtos .ServerInfo info = FutureUtils .get (
895- admin .getServerInfo (RequestConverter .buildGetServerInfoRequest ())
896- ).getServerInfo ();
897- return info != null && info .hasServerName ()
898- && server .getStartcode () == info .getServerName ().getStartCode ();
899- }
900- } catch (IOException ioe ) {
901- if (LOG .isDebugEnabled ()) {
902- LOG .debug ("Couldn't reach " + server + ", try=" + retryCounter .getAttemptTimes () + " of "
903- + retryCounter .getMaxAttempts (), ioe );
904- }
905- try {
906- retryCounter .sleepUntilNextRetry ();
907- } catch (InterruptedException ie ) {
908- Thread .currentThread ().interrupt ();
909- break ;
910- }
911- }
912- }
913- return false ;
914- }
915-
916831 private String getStrForMax (final int max ) {
917832 return max == Integer .MAX_VALUE ? "NO_LIMIT" : Integer .toString (max );
918833 }
0 commit comments