HBASE-473 When a table is deleted, master sends multiple close messages to the region server

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@632131 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Bryan Duxbury 2008-02-28 22:08:35 +00:00
parent dee0ea4c7a
commit 1dc387a0a6
6 changed files with 41 additions and 36 deletions

View File

@ -26,6 +26,8 @@ Hbase Change Log
that reach the client even after retries
HBASE-460 TestMigrate broken when HBase moved to subproject
HBASE-462 Update migration tool
HBASE-473 When a table is deleted, master sends multiple close messages to
the region server
IMPROVEMENTS
HBASE-415 Rewrite leases to use DelayedBlockingQueue instead of polling

View File

@ -358,7 +358,7 @@ abstract class BaseScanner extends Chore implements HConstants {
boolean deadServer = false;
if (serverName.length() != 0) {
if (regionManager.isMarkedClosedNoReopen(serverName, info.getRegionName())) {
if (regionManager.isMarkedToClose(serverName, info.getRegionName())) {
// Skip if region is on kill list
if(LOG.isDebugEnabled()) {
LOG.debug("not assigning region (on kill list): " +

View File

@ -121,7 +121,7 @@ class ChangeTableState extends TableOperation {
new HashMap<Text, HRegionInfo>();
Map<Text, HRegionInfo> killedRegions =
master.regionManager.getMarkedClosedNoReopen(serverName);
master.regionManager.getMarkedToClose(serverName);
if (killedRegions != null) {
localKillList.putAll(killedRegions);
}
@ -138,7 +138,7 @@ class ChangeTableState extends TableOperation {
LOG.debug("inserted local kill list into kill list for server " +
serverName);
}
master.regionManager.markClosedNoReopenBulk(serverName, localKillList);
master.regionManager.markToCloseBulk(serverName, localKillList);
}
}
servedRegions.clear();

View File

@ -158,8 +158,8 @@ class ProcessServerShutdown extends RegionServerOperation {
ToDoEntry todo = new ToDoEntry(row, info);
toDoList.add(todo);
if (master.regionManager.isMarkedClosedNoReopen(deadServerName, info.getRegionName())) {
master.regionManager.noLongerMarkedClosedNoReopen(deadServerName, info.getRegionName());
if (master.regionManager.isMarkedToClose(deadServerName, info.getRegionName())) {
master.regionManager.noLongerMarkedToClose(deadServerName, info.getRegionName());
master.regionManager.noLongerUnassigned(info);
if (master.regionManager.isMarkedForDeletion(info.getRegionName())) {
// Delete this region

View File

@ -95,14 +95,17 @@ class RegionManager implements HConstants {
Collections.synchronizedSet(new HashSet<Text>());
/**
* The 'killList' is a list of regions that are going to be closed, but not
* reopened.
* List of regions that are going to be closed.
*/
private final Map<String, Map<Text, HRegionInfo>> killList =
private final Map<String, Map<Text, HRegionInfo>> regionsToClose =
new ConcurrentHashMap<String, Map<Text, HRegionInfo>>();
/** 'killedRegions' contains regions that are in the process of being closed */
private final Set<Text> killedRegions =
/** Regions that are in the process of being closed */
private final Set<Text> closingRegions =
Collections.synchronizedSet(new HashSet<Text>());
/** Regions that are being reassigned for load balancing. */
private final Set<Text> regionsBeingReassigned =
Collections.synchronizedSet(new HashSet<Text>());
/**
@ -498,66 +501,65 @@ class RegionManager implements HConstants {
unassignedRegions.remove(info);
}
/** Mark a region to be closed and not reopened */
public void markClosedNoReopen(String serverName, HRegionInfo info) {
synchronized (killList) {
Map<Text, HRegionInfo> serverKillList = killList.get(serverName);
if (serverKillList != null) {
serverKillList.put(info.getRegionName(), info);
/** Mark a region to be closed */
public void markToClose(String serverName, HRegionInfo info) {
synchronized (regionsToClose) {
Map<Text, HRegionInfo> serverToClose = regionsToClose.get(serverName);
if (serverToClose != null) {
serverToClose.put(info.getRegionName(), info);
}
}
}
/** Mark a bunch of regions as closed not reopen at once for a server */
public void markClosedNoReopenBulk(String serverName,
public void markToCloseBulk(String serverName,
Map<Text, HRegionInfo> map) {
killList.put(serverName, map);
regionsToClose.put(serverName, map);
}
/**
* Get a map of region names to region infos waiting to be offlined for a
* given server
*/
public Map<Text, HRegionInfo> getMarkedClosedNoReopen(String serverName) {
return killList.get(serverName);
public Map<Text, HRegionInfo> getMarkedToClose(String serverName) {
return regionsToClose.get(serverName);
}
/**
* Check if a region is marked as closed not reopen.
*/
public boolean isMarkedClosedNoReopen(String serverName, Text regionName) {
synchronized (killList) {
Map<Text, HRegionInfo> regionsToKill =
killList.get(serverName);
return (regionsToKill != null && regionsToKill.containsKey(regionName));
public boolean isMarkedToClose(String serverName, Text regionName) {
synchronized (regionsToClose) {
Map<Text, HRegionInfo> serverToClose = regionsToClose.get(serverName);
return (serverToClose != null && serverToClose.containsKey(regionName));
}
}
/**
* Mark a region as no longer waiting to be closed and not reopened.
*/
public void noLongerMarkedClosedNoReopen(String serverName, Text regionName) {
synchronized (killList) {
Map<Text, HRegionInfo> serverKillList = killList.get(serverName);
if (serverKillList != null) {
serverKillList.remove(regionName);
public void noLongerMarkedToClose(String serverName, Text regionName) {
synchronized (regionsToClose) {
Map<Text, HRegionInfo> serverToClose = regionsToClose.get(serverName);
if (serverToClose != null) {
serverToClose.remove(regionName);
}
}
}
/** Check if a region is closing */
public boolean isClosing(Text regionName) {
return killedRegions.contains(regionName);
return closingRegions.contains(regionName);
}
/** Set a region as no longer closing (closed?) */
public void noLongerClosing(Text regionName) {
killedRegions.remove(regionName);
closingRegions.remove(regionName);
}
/** mark a region as closing */
public void setClosing(Text regionName) {
killedRegions.add(regionName);
closingRegions.add(regionName);
}
/**

View File

@ -279,7 +279,7 @@ class ServerManager implements HConstants {
throws IOException {
ArrayList<HMsg> returnMsgs = new ArrayList<HMsg>();
Map<Text, HRegionInfo> regionsToKill =
master.regionManager.getMarkedClosedNoReopen(serverName);
master.regionManager.getMarkedToClose(serverName);
// Get reports on what the RegionServer did.
for (int i = 0; i < incomingMsgs.length; i++) {
@ -361,12 +361,13 @@ class ServerManager implements HConstants {
}
}
// Process the kill list
// Tell the region server to close regions that we have marked for closing.
if (regionsToKill != null) {
for (HRegionInfo i: regionsToKill.values()) {
returnMsgs.add(new HMsg(HMsg.MSG_REGION_CLOSE, i));
// Transition the region from toClose to closing state
master.regionManager.setClosing(i.getRegionName());
master.regionManager.noLongerMarkedToClose(serverName, i.getRegionName());
}
}