HBASE-4903 Return a result from RegionObserver.preIncrement (Daniel Gómez Ferro)
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1208952 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
50de126b79
commit
9581eea546
|
@ -736,6 +736,8 @@ Release 0.92.0 - Unreleased
|
|||
HBASE-4779 TestHTablePool, TestScanWithBloomError, TestRegionSplitCalculator are
|
||||
not tagged and TestPoolMap should not use TestSuite (N Keywal)
|
||||
HBASE-4805 Allow better control of resource consumption in HTable (Lars H)
|
||||
HBASE-4903 Return a result from RegionObserver.preIncrement
|
||||
(Daniel Gómez Ferro via Lars H)
|
||||
|
||||
TASKS
|
||||
HBASE-3559 Move report of split to master OFF the heartbeat channel
|
||||
|
|
|
@ -186,13 +186,15 @@ public abstract class BaseRegionObserver implements RegionObserver {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void preAppend(final ObserverContext<RegionCoprocessorEnvironment> e,
|
||||
final Append append, final Result result) throws IOException {
|
||||
public Result preAppend(final ObserverContext<RegionCoprocessorEnvironment> e,
|
||||
final Append append) throws IOException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postAppend(final ObserverContext<RegionCoprocessorEnvironment> e,
|
||||
public Result postAppend(final ObserverContext<RegionCoprocessorEnvironment> e,
|
||||
final Append append, final Result result) throws IOException {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -211,13 +213,15 @@ public abstract class BaseRegionObserver implements RegionObserver {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void preIncrement(final ObserverContext<RegionCoprocessorEnvironment> e,
|
||||
final Increment increment, final Result result) throws IOException {
|
||||
public Result preIncrement(final ObserverContext<RegionCoprocessorEnvironment> e,
|
||||
final Increment increment) throws IOException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postIncrement(final ObserverContext<RegionCoprocessorEnvironment> e,
|
||||
public Result postIncrement(final ObserverContext<RegionCoprocessorEnvironment> e,
|
||||
final Increment increment, final Result result) throws IOException {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,20 +16,19 @@
|
|||
|
||||
package org.apache.hadoop.hbase.coprocessor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.apache.hadoop.hbase.Coprocessor;
|
||||
import org.apache.hadoop.hbase.HRegionInfo;
|
||||
import org.apache.hadoop.hbase.KeyValue;
|
||||
import org.apache.hadoop.hbase.client.Append;
|
||||
import org.apache.hadoop.hbase.client.Delete;
|
||||
import org.apache.hadoop.hbase.client.Get;
|
||||
import org.apache.hadoop.hbase.client.Increment;
|
||||
import org.apache.hadoop.hbase.client.Put;
|
||||
import org.apache.hadoop.hbase.client.Result;
|
||||
import org.apache.hadoop.hbase.client.Scan;
|
||||
import org.apache.hadoop.hbase.client.Increment;
|
||||
import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp;
|
||||
import org.apache.hadoop.hbase.filter.WritableByteArrayComparable;
|
||||
import org.apache.hadoop.hbase.regionserver.HRegion;
|
||||
|
@ -40,7 +39,7 @@ import org.apache.hadoop.hbase.regionserver.StoreFile;
|
|||
import org.apache.hadoop.hbase.regionserver.wal.HLogKey;
|
||||
import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
|
||||
|
||||
import java.io.IOException;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
/**
|
||||
* Coprocessors implement this interface to observe and mediate client actions
|
||||
|
@ -467,13 +466,11 @@ public interface RegionObserver extends Coprocessor {
|
|||
* coprocessors
|
||||
* @param c the environment provided by the region server
|
||||
* @param append Append object
|
||||
* @param result The result to return to the client if default processing
|
||||
* is bypassed. Can be modified. Will not be used if default processing
|
||||
* is not bypassed.
|
||||
* @return result to return to the client if bypassing default processing
|
||||
* @throws IOException if an error occurred on the coprocessor
|
||||
*/
|
||||
void preAppend(final ObserverContext<RegionCoprocessorEnvironment> c,
|
||||
final Append append, final Result result)
|
||||
Result preAppend(final ObserverContext<RegionCoprocessorEnvironment> c,
|
||||
final Append append)
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
|
@ -483,10 +480,11 @@ public interface RegionObserver extends Coprocessor {
|
|||
* coprocessors
|
||||
* @param c the environment provided by the region server
|
||||
* @param append Append object
|
||||
* @param result the result returned by increment, can be modified
|
||||
* @param result the result returned by increment
|
||||
* @return the result to return to the client
|
||||
* @throws IOException if an error occurred on the coprocessor
|
||||
*/
|
||||
void postAppend(final ObserverContext<RegionCoprocessorEnvironment> c,
|
||||
Result postAppend(final ObserverContext<RegionCoprocessorEnvironment> c,
|
||||
final Append append, final Result result)
|
||||
throws IOException;
|
||||
|
||||
|
@ -499,13 +497,11 @@ public interface RegionObserver extends Coprocessor {
|
|||
* coprocessors
|
||||
* @param c the environment provided by the region server
|
||||
* @param increment increment object
|
||||
* @param result The result to return to the client if default processing
|
||||
* is bypassed. Can be modified. Will not be used if default processing
|
||||
* is not bypassed.
|
||||
* @return result to return to the client if bypassing default processing
|
||||
* @throws IOException if an error occurred on the coprocessor
|
||||
*/
|
||||
void preIncrement(final ObserverContext<RegionCoprocessorEnvironment> c,
|
||||
final Increment increment, final Result result)
|
||||
Result preIncrement(final ObserverContext<RegionCoprocessorEnvironment> c,
|
||||
final Increment increment)
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
|
@ -515,10 +511,11 @@ public interface RegionObserver extends Coprocessor {
|
|||
* coprocessors
|
||||
* @param c the environment provided by the region server
|
||||
* @param increment increment object
|
||||
* @param result the result returned by increment, can be modified
|
||||
* @param result the result returned by increment
|
||||
* @return the result to return to the client
|
||||
* @throws IOException if an error occurred on the coprocessor
|
||||
*/
|
||||
void postIncrement(final ObserverContext<RegionCoprocessorEnvironment> c,
|
||||
Result postIncrement(final ObserverContext<RegionCoprocessorEnvironment> c,
|
||||
final Increment increment, final Result result)
|
||||
throws IOException;
|
||||
|
||||
|
|
|
@ -3052,7 +3052,7 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler,
|
|||
resVal = region.increment(incVal, lock,
|
||||
increment.getWriteToWAL());
|
||||
if (region.getCoprocessorHost() != null) {
|
||||
region.getCoprocessorHost().postIncrement(incVal, resVal);
|
||||
resVal = region.getCoprocessorHost().postIncrement(incVal, resVal);
|
||||
}
|
||||
return resVal;
|
||||
} catch (IOException e) {
|
||||
|
|
|
@ -954,13 +954,13 @@ public class RegionCoprocessorHost
|
|||
public Result preAppend(Append append)
|
||||
throws IOException {
|
||||
boolean bypass = false;
|
||||
Result result = new Result();
|
||||
Result result = null;
|
||||
ObserverContext<RegionCoprocessorEnvironment> ctx = null;
|
||||
for (RegionEnvironment env: coprocessors) {
|
||||
if (env.getInstance() instanceof RegionObserver) {
|
||||
ctx = ObserverContext.createAndPrepare(env, ctx);
|
||||
try {
|
||||
((RegionObserver)env.getInstance()).preAppend(ctx, append, result);
|
||||
result = ((RegionObserver)env.getInstance()).preAppend(ctx, append);
|
||||
} catch (Throwable e) {
|
||||
handleCoprocessorThrowable(env, e);
|
||||
}
|
||||
|
@ -982,13 +982,13 @@ public class RegionCoprocessorHost
|
|||
public Result preIncrement(Increment increment)
|
||||
throws IOException {
|
||||
boolean bypass = false;
|
||||
Result result = new Result();
|
||||
Result result = null;
|
||||
ObserverContext<RegionCoprocessorEnvironment> ctx = null;
|
||||
for (RegionEnvironment env: coprocessors) {
|
||||
if (env.getInstance() instanceof RegionObserver) {
|
||||
ctx = ObserverContext.createAndPrepare(env, ctx);
|
||||
try {
|
||||
((RegionObserver)env.getInstance()).preIncrement(ctx, increment, result);
|
||||
result = ((RegionObserver)env.getInstance()).preIncrement(ctx, increment);
|
||||
} catch (Throwable e) {
|
||||
handleCoprocessorThrowable(env, e);
|
||||
}
|
||||
|
@ -1029,14 +1029,14 @@ public class RegionCoprocessorHost
|
|||
* @param result the result returned by postIncrement
|
||||
* @throws IOException if an error occurred on the coprocessor
|
||||
*/
|
||||
public void postIncrement(final Increment increment, Result result)
|
||||
public Result postIncrement(final Increment increment, Result result)
|
||||
throws IOException {
|
||||
ObserverContext<RegionCoprocessorEnvironment> ctx = null;
|
||||
for (RegionEnvironment env: coprocessors) {
|
||||
if (env.getInstance() instanceof RegionObserver) {
|
||||
ctx = ObserverContext.createAndPrepare(env, ctx);
|
||||
try {
|
||||
((RegionObserver)env.getInstance()).postIncrement(ctx, increment, result);
|
||||
result = ((RegionObserver)env.getInstance()).postIncrement(ctx, increment, result);
|
||||
} catch (Throwable e) {
|
||||
handleCoprocessorThrowable(env, e);
|
||||
}
|
||||
|
@ -1045,6 +1045,7 @@ public class RegionCoprocessorHost
|
|||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -371,15 +371,17 @@ public class SimpleRegionObserver extends BaseRegionObserver {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void preIncrement(final ObserverContext<RegionCoprocessorEnvironment> c,
|
||||
final Increment increment, final Result result) throws IOException {
|
||||
public Result preIncrement(final ObserverContext<RegionCoprocessorEnvironment> c,
|
||||
final Increment increment) throws IOException {
|
||||
hadPreIncrement = true;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postIncrement(final ObserverContext<RegionCoprocessorEnvironment> c,
|
||||
public Result postIncrement(final ObserverContext<RegionCoprocessorEnvironment> c,
|
||||
final Increment increment, final Result result) throws IOException {
|
||||
hadPostIncrement = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean hadPreGet() {
|
||||
|
|
Loading…
Reference in New Issue