protected void handleReportForDutyResponse(final RegionServerStartupResponse c)
    throws IOException {
    try {
      boolean updateRootDir = false;
      for (NameStringPair e : c.getMapEntriesList()) {
        String key = e.getName();
        // The hostname the master sees us as.
        if (key.equals(HConstants.KEY_FOR_HOSTNAME_SEEN_BY_MASTER)) {
          String hostnameFromMasterPOV = e.getValue();
          this.serverName = ServerName.valueOf(hostnameFromMasterPOV,
            rpcServices.getSocketAddress().getPort(), this.startcode);
          String expectedHostName = rpcServices.getSocketAddress().getHostName();
          // if Master use-ip is enabled, RegionServer use-ip will be enabled by default even if it
          // is set to disable. so we will use the ip of the RegionServer to compare with the
          // hostname passed by the Master, see HBASE-27304 for details.
          if (
            StringUtils.isBlank(useThisHostnameInstead) && getActiveMaster().isPresent()
              && InetAddresses.isInetAddress(getActiveMaster().get().getHostname())
          ) {
            expectedHostName = rpcServices.getSocketAddress().getAddress().getHostAddress();
          }
          boolean isHostnameConsist = StringUtils.isBlank(useThisHostnameInstead)
            ? hostnameFromMasterPOV.equals(expectedHostName)
            : hostnameFromMasterPOV.equals(useThisHostnameInstead);
          if (!isHostnameConsist) {
            String msg = "Master passed us a different hostname to use; was="
              + (StringUtils.isBlank(useThisHostnameInstead)
                ? expectedHostName
                : this.useThisHostnameInstead)
              + ", but now=" + hostnameFromMasterPOV;
            LOG.error(msg);
            throw new IOException(msg);
          }
          continue;
        }

        String value = e.getValue();
        if (key.equals(HConstants.HBASE_DIR)) {
          if (value != null && !value.equals(conf.get(HConstants.HBASE_DIR))) {
            updateRootDir = true;
          }
        }

        if (LOG.isDebugEnabled()) {
          LOG.debug("Config from master: " + key + "=" + value);
        }
        this.conf.set(key, value);
      }
      // Set our ephemeral znode up in zookeeper now we have a name.
      createMyEphemeralNode();

      if (updateRootDir) {
        // initialize file system by the config fs.defaultFS and hbase.rootdir from master
        initializeFileSystem();
      }

      // hack! Maps DFSClient => RegionServer for logs. HDFS made this
      // config param for task trackers, but we can piggyback off of it.
      if (this.conf.get("mapreduce.task.attempt.id") == null) {
        this.conf.set("mapreduce.task.attempt.id", "hb_rs_" + this.serverName.toString());
      }

      // Save it in a file, this will allow to see if we crash
      ZNodeClearer.writeMyEphemeralNodeOnDisk(getMyEphemeralNodePath());

      // This call sets up an initialized replication and WAL. Later we start it up.
      setupWALAndReplication();
      // Init in here rather than in constructor after thread name has been set
      final MetricsTable metricsTable =
        new MetricsTable(new MetricsTableWrapperAggregateImpl(this));
      this.metricsRegionServerImpl = new MetricsRegionServerWrapperImpl(this);
      this.metricsRegionServer =
        new MetricsRegionServer(metricsRegionServerImpl, conf, metricsTable);
      // Now that we have a metrics source, start the pause monitor
      this.pauseMonitor = new JvmPauseMonitor(conf, getMetrics().getMetricsSource());
      pauseMonitor.start();

      // There is a rare case where we do NOT want services to start. Check config.
      if (getConfiguration().getBoolean("hbase.regionserver.workers", true)) {
        startServices();
      }
      // In here we start up the replication Service. Above we initialized it. TODO. Reconcile.
      // or make sense of it.
      startReplicationService();

      // Set up ZK
      LOG.info("Serving as " + this.serverName + ", RpcServer on " + rpcServices.getSocketAddress()
        + ", sessionid=0x"
        + Long.toHexString(this.zooKeeper.getRecoverableZooKeeper().getSessionId()));

      // Wake up anyone waiting for this server to online
      synchronized (online) {
        online.set(true);
        online.notifyAll();
      }
    } catch (Throwable e) {
      stop("Failed initialization");
      throw convertThrowableToIOE(cleanup(e, "Failed init"), "Region server startup failed");
    } finally {
      sleeper.skipSleepCycle();
    }
  }
Run init. Sets up wal and starts up all server threads.
@param c Extra configuration.
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java