HBASE-2293 CME in RegionManager#isMetaServer
git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@919708 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
83258ba826
commit
6eab8932c8
|
@ -225,6 +225,7 @@ Release 0.21.0 - Unreleased
|
||||||
half-written hfile (Ruslan Salyakhov via Stack)
|
half-written hfile (Ruslan Salyakhov via Stack)
|
||||||
HBASE-2281 Hbase shell does not work when started from the build dir
|
HBASE-2281 Hbase shell does not work when started from the build dir
|
||||||
(Alexey Kovyrin via Stack)
|
(Alexey Kovyrin via Stack)
|
||||||
|
HBASE-2293 CME in RegionManager#isMetaServer
|
||||||
|
|
||||||
IMPROVEMENTS
|
IMPROVEMENTS
|
||||||
HBASE-1760 Cleanup TODOs in HTable
|
HBASE-1760 Cleanup TODOs in HTable
|
||||||
|
|
|
@ -330,7 +330,9 @@ public class RegionManager implements HConstants {
|
||||||
String regionName = rs.getRegionInfo().getRegionNameAsString();
|
String regionName = rs.getRegionInfo().getRegionNameAsString();
|
||||||
LOG.info("Assigning region " + regionName + " to " + sinfo.getServerName());
|
LOG.info("Assigning region " + regionName + " to " + sinfo.getServerName());
|
||||||
rs.setPendingOpen(sinfo.getServerName());
|
rs.setPendingOpen(sinfo.getServerName());
|
||||||
this.regionsInTransition.put(regionName, rs);
|
synchronized (this.regionsInTransition) {
|
||||||
|
this.regionsInTransition.put(regionName, rs);
|
||||||
|
}
|
||||||
|
|
||||||
returnMsgs.add(new HMsg(HMsg.Type.MSG_REGION_OPEN, rs.getRegionInfo()));
|
returnMsgs.add(new HMsg(HMsg.Type.MSG_REGION_OPEN, rs.getRegionInfo()));
|
||||||
}
|
}
|
||||||
|
@ -378,9 +380,11 @@ public class RegionManager implements HConstants {
|
||||||
Set<RegionState> regionsToAssign = new HashSet<RegionState>();
|
Set<RegionState> regionsToAssign = new HashSet<RegionState>();
|
||||||
|
|
||||||
boolean isMetaServer = isMetaServer(addr);
|
boolean isMetaServer = isMetaServer(addr);
|
||||||
|
RegionState rootState = null;
|
||||||
// Handle if root is unassigned... only assign root if root is offline.
|
// Handle if root is unassigned... only assign root if root is offline.
|
||||||
RegionState rootState = regionsInTransition.get(HRegionInfo.ROOT_REGIONINFO.getRegionNameAsString());
|
synchronized (this.regionsInTransition) {
|
||||||
|
rootState = regionsInTransition.get(HRegionInfo.ROOT_REGIONINFO.getRegionNameAsString());
|
||||||
|
}
|
||||||
if (rootState != null && rootState.isUnassigned()) {
|
if (rootState != null && rootState.isUnassigned()) {
|
||||||
// make sure root isnt assigned here first.
|
// make sure root isnt assigned here first.
|
||||||
// if so return 'empty list'
|
// if so return 'empty list'
|
||||||
|
@ -400,8 +404,7 @@ public class RegionManager implements HConstants {
|
||||||
if (reassigningMetas && isMetaOrRoot && !isSingleServer) {
|
if (reassigningMetas && isMetaOrRoot && !isSingleServer) {
|
||||||
return regionsToAssign; // dont assign anything to this server.
|
return regionsToAssign; // dont assign anything to this server.
|
||||||
}
|
}
|
||||||
|
synchronized (this.regionsInTransition) {
|
||||||
synchronized(regionsInTransition) {
|
|
||||||
for (RegionState s: regionsInTransition.values()) {
|
for (RegionState s: regionsInTransition.values()) {
|
||||||
HRegionInfo i = s.getRegionInfo();
|
HRegionInfo i = s.getRegionInfo();
|
||||||
if (i == null) {
|
if (i == null) {
|
||||||
|
@ -836,13 +839,15 @@ public class RegionManager implements HConstants {
|
||||||
* @return true if server is transitioning the ROOT table
|
* @return true if server is transitioning the ROOT table
|
||||||
*/
|
*/
|
||||||
public boolean isRootServerCandidate(final String server) {
|
public boolean isRootServerCandidate(final String server) {
|
||||||
for (RegionState s : regionsInTransition.values()) {
|
synchronized (this.regionsInTransition) {
|
||||||
if (s.getRegionInfo().isRootRegion()
|
for (RegionState s : regionsInTransition.values()) {
|
||||||
&& !s.isUnassigned()
|
if (s.getRegionInfo().isRootRegion()
|
||||||
&& s.getServerName() != null
|
&& !s.isUnassigned()
|
||||||
&& s.getServerName().equals(server)) {
|
&& s.getServerName() != null
|
||||||
// Has an outstanding root region to be assigned.
|
&& s.getServerName().equals(server)) {
|
||||||
return true;
|
// Has an outstanding root region to be assigned.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -855,13 +860,15 @@ public class RegionManager implements HConstants {
|
||||||
* @return if this server was transitioning a META table then a not null HRegionInfo pointing to it
|
* @return if this server was transitioning a META table then a not null HRegionInfo pointing to it
|
||||||
*/
|
*/
|
||||||
public HRegionInfo getMetaServerRegionInfo(final String server) {
|
public HRegionInfo getMetaServerRegionInfo(final String server) {
|
||||||
for (RegionState s : regionsInTransition.values()) {
|
synchronized (this.regionsInTransition) {
|
||||||
if (s.getRegionInfo().isMetaRegion()
|
for (RegionState s : regionsInTransition.values()) {
|
||||||
&& !s.isUnassigned()
|
if (s.getRegionInfo().isMetaRegion()
|
||||||
&& s.getServerName() != null
|
&& !s.isUnassigned()
|
||||||
&& s.getServerName().equals(server)) {
|
&& s.getServerName() != null
|
||||||
// Has an outstanding meta region to be assigned.
|
&& s.getServerName().equals(server)) {
|
||||||
return s.getRegionInfo();
|
// Has an outstanding meta region to be assigned.
|
||||||
|
return s.getRegionInfo();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -910,7 +917,9 @@ public class RegionManager implements HConstants {
|
||||||
* @param info
|
* @param info
|
||||||
*/
|
*/
|
||||||
public void removeRegion(HRegionInfo info) {
|
public void removeRegion(HRegionInfo info) {
|
||||||
this.regionsInTransition.remove(info.getRegionNameAsString());
|
synchronized (this.regionsInTransition) {
|
||||||
|
this.regionsInTransition.remove(info.getRegionNameAsString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -918,7 +927,9 @@ public class RegionManager implements HConstants {
|
||||||
* @return true if the named region is in a transition state
|
* @return true if the named region is in a transition state
|
||||||
*/
|
*/
|
||||||
public boolean regionIsInTransition(String regionName) {
|
public boolean regionIsInTransition(String regionName) {
|
||||||
return regionsInTransition.containsKey(regionName);
|
synchronized (this.regionsInTransition) {
|
||||||
|
return regionsInTransition.containsKey(regionName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -926,9 +937,11 @@ public class RegionManager implements HConstants {
|
||||||
* @return true if the region is unassigned, pendingOpen or open
|
* @return true if the region is unassigned, pendingOpen or open
|
||||||
*/
|
*/
|
||||||
public boolean regionIsOpening(String regionName) {
|
public boolean regionIsOpening(String regionName) {
|
||||||
RegionState state = regionsInTransition.get(regionName);
|
synchronized (this.regionsInTransition) {
|
||||||
if (state != null) {
|
RegionState state = regionsInTransition.get(regionName);
|
||||||
return state.isOpening();
|
if (state != null) {
|
||||||
|
return state.isOpening();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -939,15 +952,16 @@ public class RegionManager implements HConstants {
|
||||||
* @param force if true mark region unassigned whatever its current state
|
* @param force if true mark region unassigned whatever its current state
|
||||||
*/
|
*/
|
||||||
public void setUnassigned(HRegionInfo info, boolean force) {
|
public void setUnassigned(HRegionInfo info, boolean force) {
|
||||||
|
RegionState s = null;
|
||||||
synchronized(this.regionsInTransition) {
|
synchronized(this.regionsInTransition) {
|
||||||
RegionState s = regionsInTransition.get(info.getRegionNameAsString());
|
s = regionsInTransition.get(info.getRegionNameAsString());
|
||||||
if (s == null) {
|
if (s == null) {
|
||||||
s = new RegionState(info);
|
s = new RegionState(info);
|
||||||
regionsInTransition.put(info.getRegionNameAsString(), s);
|
regionsInTransition.put(info.getRegionNameAsString(), s);
|
||||||
}
|
}
|
||||||
if (force || (!s.isPendingOpen() || !s.isOpen())) {
|
}
|
||||||
s.setUnassigned();
|
if (force || (!s.isPendingOpen() || !s.isOpen())) {
|
||||||
}
|
s.setUnassigned();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue