HBASE-4420 MasterObserver preMove() and postMove() should throw IOException

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1171785 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary Helmling 2011-09-16 21:10:56 +00:00
parent 6571376717
commit 900a9124c4
6 changed files with 26 additions and 17 deletions

View File

@ -279,6 +279,8 @@ Release 0.91.0 - Unreleased
(Stefan Seelmann)
HBASE-4195 Possible inconsistency in a memstore read after a reseek,
possible performance improvement (nkeywal)
HBASE-4420 MasterObserver preMove() and postMove() should throw
IOException instead of UnknownRegionException
IMPROVEMENTS
HBASE-3290 Max Compaction Size (Nicolas Spiegelberg via Stack)

View File

@ -177,12 +177,12 @@ public class BaseMasterObserver implements MasterObserver {
@Override
public void preMove(ObserverContext<MasterCoprocessorEnvironment> ctx,
HRegionInfo region, ServerName srcServer, ServerName destServer)
throws UnknownRegionException {
throws IOException {
}
@Override
public void postMove(ObserverContext<MasterCoprocessorEnvironment> ctx,
HRegionInfo region, ServerName srcServer, ServerName destServer)
throws UnknownRegionException {
throws IOException {
}
}

View File

@ -187,7 +187,7 @@ public interface MasterObserver extends Coprocessor {
void preMove(final ObserverContext<MasterCoprocessorEnvironment> ctx,
final HRegionInfo region, final ServerName srcServer,
final ServerName destServer)
throws UnknownRegionException;
throws IOException;
/**
* Called after the region move has been requested.
@ -199,7 +199,7 @@ public interface MasterObserver extends Coprocessor {
void postMove(final ObserverContext<MasterCoprocessorEnvironment> ctx,
final HRegionInfo region, final ServerName srcServer,
final ServerName destServer)
throws UnknownRegionException;
throws IOException;
/**
* Called prior to assigning a specific region.

View File

@ -922,16 +922,23 @@ implements HMasterInterface, HMasterRegionInterface, MasterServices, Server {
this.assignmentManager.unassign(hri);
} else {
dest = new ServerName(Bytes.toString(destServerName));
if (this.cpHost != null) {
if (this.cpHost.preMove(p.getFirst(), p.getSecond(), dest)) {
return;
try {
if (this.cpHost != null) {
if (this.cpHost.preMove(p.getFirst(), p.getSecond(), dest)) {
return;
}
}
}
RegionPlan rp = new RegionPlan(p.getFirst(), p.getSecond(), dest);
LOG.info("Added move plan " + rp + ", running balancer");
this.assignmentManager.balance(rp);
if (this.cpHost != null) {
this.cpHost.postMove(p.getFirst(), p.getSecond(), dest);
RegionPlan rp = new RegionPlan(p.getFirst(), p.getSecond(), dest);
LOG.info("Added move plan " + rp + ", running balancer");
this.assignmentManager.balance(rp);
if (this.cpHost != null) {
this.cpHost.postMove(p.getFirst(), p.getSecond(), dest);
}
} catch (IOException ioe) {
UnknownRegionException ure = new UnknownRegionException(
Bytes.toStringBinary(encodedRegionName));
ure.initCause(ioe);
throw ure;
}
}
}

View File

@ -300,7 +300,7 @@ public class MasterCoprocessorHost
}
boolean preMove(final HRegionInfo region, final ServerName srcServer, final ServerName destServer)
throws UnknownRegionException {
throws IOException {
boolean bypass = false;
ObserverContext<MasterCoprocessorEnvironment> ctx = null;
for (MasterEnvironment env: coprocessors) {
@ -318,7 +318,7 @@ public class MasterCoprocessorHost
}
void postMove(final HRegionInfo region, final ServerName srcServer, final ServerName destServer)
throws UnknownRegionException {
throws IOException {
ObserverContext<MasterCoprocessorEnvironment> ctx = null;
for (MasterEnvironment env: coprocessors) {
if (env.getInstance() instanceof MasterObserver) {

View File

@ -312,7 +312,7 @@ public class TestMasterObserver {
@Override
public void preMove(ObserverContext<MasterCoprocessorEnvironment> env,
HRegionInfo region, ServerName srcServer, ServerName destServer)
throws UnknownRegionException {
throws IOException {
if (bypass) {
env.bypass();
}
@ -322,7 +322,7 @@ public class TestMasterObserver {
@Override
public void postMove(ObserverContext<MasterCoprocessorEnvironment> env, HRegionInfo region,
ServerName srcServer, ServerName destServer)
throws UnknownRegionException {
throws IOException {
postMoveCalled = true;
}