HBASE-5755 Region sever looking for master forever with cached stale data
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1311910 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7d1f7b7f37
commit
814616687a
|
@ -1774,8 +1774,9 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler,
|
|||
ServerName masterServerName = null;
|
||||
long previousLogTime = 0;
|
||||
HMasterRegionInterface master = null;
|
||||
boolean refresh = false; // for the first time, use cached data
|
||||
while (keepLooping() && master == null) {
|
||||
masterServerName = this.masterAddressManager.getMasterAddress();
|
||||
masterServerName = this.masterAddressManager.getMasterAddress(refresh);
|
||||
if (masterServerName == null) {
|
||||
if (!keepLooping()) {
|
||||
// give up with no connection.
|
||||
|
@ -1784,6 +1785,7 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler,
|
|||
}
|
||||
LOG.debug("No master found; retry");
|
||||
previousLogTime = System.currentTimeMillis();
|
||||
refresh = true; // let's try pull it from ZK directly
|
||||
|
||||
sleeper.sleep();
|
||||
continue;
|
||||
|
|
|
@ -68,7 +68,19 @@ public class MasterAddressTracker extends ZooKeeperNodeTracker {
|
|||
* @return Server name or null if timed out.
|
||||
*/
|
||||
public ServerName getMasterAddress() {
|
||||
return ZKUtil.znodeContentToServerName(super.getData(false));
|
||||
return getMasterAddress(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the address of the current master if one is available. Returns null
|
||||
* if no current master. If refresh is set, try to load the data from ZK again,
|
||||
* otherwise, cached data will be used.
|
||||
*
|
||||
* @param refresh whether to refresh the data by calling ZK directly.
|
||||
* @return Server name or null if timed out.
|
||||
*/
|
||||
public ServerName getMasterAddress(final boolean refresh) {
|
||||
return ZKUtil.znodeContentToServerName(super.getData(refresh));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue