HBASE-10157 Provide CP hook post log replay

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1551417 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
anoopsamjohn 2013-12-17 00:37:14 +00:00
parent ef5c528427
commit fb5e7b3869
4 changed files with 34 additions and 0 deletions

View File

@ -81,6 +81,9 @@ public abstract class BaseRegionObserver implements RegionObserver {
@Override
public void postOpen(ObserverContext<RegionCoprocessorEnvironment> e) { }
@Override
public void postLogReplay(ObserverContext<RegionCoprocessorEnvironment> e) { }
@Override
public void preClose(ObserverContext<RegionCoprocessorEnvironment> c, boolean abortRequested)
throws IOException { }

View File

@ -86,6 +86,12 @@ public interface RegionObserver extends Coprocessor {
*/
void postOpen(final ObserverContext<RegionCoprocessorEnvironment> c);
/**
* Called after the log replay on the region is over.
* @param c the environment provided by the region server
*/
void postLogReplay(final ObserverContext<RegionCoprocessorEnvironment> c);
/**
* Called before a memstore is flushed to disk and prior to creating the scanner to read from
* the memstore. To override or modify how a memstore is flushed,

View File

@ -859,7 +859,12 @@ public class HRegion implements HeapSize { // , Writable{
* @param newState
*/
public void setRecovering(boolean newState) {
boolean wasRecovering = this.isRecovering;
this.isRecovering = newState;
if (wasRecovering && !isRecovering) {
// Call only when log replay is over.
coprocessorHost.postLogReplay();
}
}
/**

View File

@ -316,6 +316,26 @@ public class RegionCoprocessorHost
}
}
/**
* Invoked after log replay on region
*/
public void postLogReplay() {
ObserverContext<RegionCoprocessorEnvironment> ctx = null;
for (RegionEnvironment env: coprocessors) {
if (env.getInstance() instanceof RegionObserver) {
ctx = ObserverContext.createAndPrepare(env, ctx);
try {
((RegionObserver) env.getInstance()).postLogReplay(ctx);
} catch (Throwable e) {
handleCoprocessorThrowableNoRethrow(env, e);
}
if (ctx.shouldComplete()) {
break;
}
}
}
}
/**
* Invoked before a region is closed
* @param abortRequested true if the server is aborting