HBASE-6487 assign region doesn't check if the region is already assigned
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1374423 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
61f13bc832
commit
a7e18a9bfd
|
@ -2085,8 +2085,13 @@ Server {
|
||||||
LOG.warn("assignRegion specifier type: expected: " + RegionSpecifierType.REGION_NAME
|
LOG.warn("assignRegion specifier type: expected: " + RegionSpecifierType.REGION_NAME
|
||||||
+ " actual: " + type);
|
+ " actual: " + type);
|
||||||
}
|
}
|
||||||
HRegionInfo regionInfo = assignmentManager.getRegionStates().getRegionInfo(regionName);
|
RegionStates regionStates = assignmentManager.getRegionStates();
|
||||||
|
HRegionInfo regionInfo = regionStates.getRegionInfo(regionName);
|
||||||
if (regionInfo == null) throw new UnknownRegionException(Bytes.toString(regionName));
|
if (regionInfo == null) throw new UnknownRegionException(Bytes.toString(regionName));
|
||||||
|
RegionState regionState = regionStates.getRegionState(regionInfo);
|
||||||
|
if (regionState != null && !regionState.isOffline()) {
|
||||||
|
throw new IOException("Region " + regionInfo + " is not offline");
|
||||||
|
}
|
||||||
if (cpHost != null) {
|
if (cpHost != null) {
|
||||||
if (cpHost.preAssign(regionInfo)) {
|
if (cpHost.preAssign(regionInfo)) {
|
||||||
return arr;
|
return arr;
|
||||||
|
|
|
@ -132,6 +132,13 @@ public class RegionStates {
|
||||||
return regionAssignments.containsKey(hri);
|
return regionAssignments.containsKey(hri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the server the specified region assigned to; null if not assigned.
|
||||||
|
*/
|
||||||
|
public synchronized ServerName getAssignedServer(final HRegionInfo hri) {
|
||||||
|
return regionAssignments.get(hri);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wait for the state map to be updated by assignment manager.
|
* Wait for the state map to be updated by assignment manager.
|
||||||
*/
|
*/
|
||||||
|
@ -519,7 +526,11 @@ public class RegionStates {
|
||||||
try {
|
try {
|
||||||
Pair<HRegionInfo, ServerName> p =
|
Pair<HRegionInfo, ServerName> p =
|
||||||
MetaReader.getRegion(server.getCatalogTracker(), regionName);
|
MetaReader.getRegion(server.getCatalogTracker(), regionName);
|
||||||
return p == null ? null : p.getFirst();
|
HRegionInfo hri = p == null ? null : p.getFirst();
|
||||||
|
if (hri != null) {
|
||||||
|
createRegionState(hri);
|
||||||
|
}
|
||||||
|
return hri;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
server.abort("Aborting because error occoured while reading " +
|
server.abort("Aborting because error occoured while reading " +
|
||||||
Bytes.toStringBinary(regionName) + " from .META.", e);
|
Bytes.toStringBinary(regionName) + " from .META.", e);
|
||||||
|
|
|
@ -24,8 +24,7 @@ module Shell
|
||||||
def help
|
def help
|
||||||
return <<-EOF
|
return <<-EOF
|
||||||
Assign a region.Use with caution.If region already assigned,
|
Assign a region.Use with caution.If region already assigned,
|
||||||
this command will just go ahead and reassign
|
this command will throw an exception. For experts only.
|
||||||
the region anyways. For experts only.
|
|
||||||
EOF
|
EOF
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue