HBASE-4011 Add MasterObserver hook for post active master initialization
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1137830 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a3d1ab8df0
commit
cf25a779aa
|
@ -269,6 +269,7 @@ Release 0.91.0 - Unreleased
|
|||
periodically (Li Pi)
|
||||
HBASE-3789 Cleanup the locking contention in the master
|
||||
HBASE-3927 Display total uncompressed byte size of a region in web UI
|
||||
HBASE-4011 New MasterObserver hook: post startup of active master
|
||||
|
||||
TASKS
|
||||
HBASE-3559 Move report of split to master OFF the heartbeat channel
|
||||
|
|
|
@ -161,6 +161,11 @@ public class BaseMasterObserver implements MasterObserver {
|
|||
throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postStartMaster(ObserverContext<MasterCoprocessorEnvironment> ctx)
|
||||
throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(CoprocessorEnvironment ctx) throws IOException {
|
||||
}
|
||||
|
|
|
@ -217,4 +217,12 @@ public interface MasterObserver extends Coprocessor {
|
|||
*/
|
||||
void preStopMaster(final ObserverContext<MasterCoprocessorEnvironment> ctx)
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
* Called immediately after an active master instance has completed
|
||||
* initialization. Will not be called on standby master instances unless
|
||||
* they take over the active role.
|
||||
*/
|
||||
void postStartMaster(final ObserverContext<MasterCoprocessorEnvironment> ctx)
|
||||
throws IOException;
|
||||
}
|
||||
|
|
|
@ -468,6 +468,15 @@ implements HMasterInterface, HMasterRegionInterface, MasterServices, Server {
|
|||
status.markComplete("Initialization successful");
|
||||
LOG.info("Master has completed initialization");
|
||||
initialized = true;
|
||||
|
||||
if (this.cpHost != null) {
|
||||
// don't let cp initialization errors kill the master
|
||||
try {
|
||||
this.cpHost.postStartMaster();
|
||||
} catch (IOException ioe) {
|
||||
LOG.error("Coprocessor postStartMaster() hook failed", ioe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isMetaHRIUpdated()
|
||||
|
|
|
@ -466,4 +466,16 @@ public class MasterCoprocessorHost
|
|||
}
|
||||
}
|
||||
|
||||
void postStartMaster() throws IOException {
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx = null;
|
||||
for (MasterEnvironment env: coprocessors) {
|
||||
if (env.getInstance() instanceof MasterObserver) {
|
||||
ctx = ObserverContext.createAndPrepare(env, ctx);
|
||||
((MasterObserver)env.getInstance()).postStartMaster(ctx);
|
||||
if (ctx.shouldComplete()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,6 +86,7 @@ public class TestMasterObserver {
|
|||
private boolean postBalanceSwitchCalled;
|
||||
private boolean preShutdownCalled;
|
||||
private boolean preStopMasterCalled;
|
||||
private boolean postStartMasterCalled;
|
||||
private boolean startCalled;
|
||||
private boolean stopCalled;
|
||||
|
||||
|
@ -312,6 +313,16 @@ public class TestMasterObserver {
|
|||
preStopMasterCalled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postStartMaster(ObserverContext<MasterCoprocessorEnvironment> ctx)
|
||||
throws IOException {
|
||||
postStartMasterCalled = true;
|
||||
}
|
||||
|
||||
public boolean wasStartMasterCalled() {
|
||||
return postStartMasterCalled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(CoprocessorEnvironment env) throws IOException {
|
||||
startCalled = true;
|
||||
|
@ -360,6 +371,8 @@ public class TestMasterObserver {
|
|||
|
||||
// check basic lifecycle
|
||||
assertTrue("MasterObserver should have been started", cp.wasStarted());
|
||||
assertTrue("postStartMaster() hook should have been called",
|
||||
cp.wasStartMasterCalled());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue