HBASE-8548 postOpen hook called twice
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1508895 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1ed35e4cb6
commit
b4a120164a
|
@ -29,6 +29,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.NavigableSet;
|
import java.util.NavigableSet;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
@ -64,45 +65,44 @@ import org.apache.hadoop.hbase.util.Pair;
|
||||||
public class SimpleRegionObserver extends BaseRegionObserver {
|
public class SimpleRegionObserver extends BaseRegionObserver {
|
||||||
static final Log LOG = LogFactory.getLog(TestRegionObserverInterface.class);
|
static final Log LOG = LogFactory.getLog(TestRegionObserverInterface.class);
|
||||||
|
|
||||||
boolean beforeDelete = true;
|
final AtomicInteger ctBeforeDelete = new AtomicInteger(1);
|
||||||
boolean scannerOpened = false;
|
final AtomicInteger ctPreOpen = new AtomicInteger(0);
|
||||||
boolean hadPreOpen;
|
final AtomicInteger ctPostOpen = new AtomicInteger(0);
|
||||||
boolean hadPostOpen;
|
final AtomicInteger ctPreClose = new AtomicInteger(0);
|
||||||
boolean hadPreClose;
|
final AtomicInteger ctPostClose = new AtomicInteger(0);
|
||||||
boolean hadPostClose;
|
final AtomicInteger ctPreFlush = new AtomicInteger(0);
|
||||||
boolean hadPreFlush;
|
final AtomicInteger ctPreFlushScannerOpen = new AtomicInteger(0);
|
||||||
boolean hadPreFlushScannerOpen;
|
final AtomicInteger ctPostFlush = new AtomicInteger(0);
|
||||||
boolean hadPostFlush;
|
final AtomicInteger ctPreSplit = new AtomicInteger(0);
|
||||||
boolean hadPreSplit;
|
final AtomicInteger ctPostSplit = new AtomicInteger(0);
|
||||||
boolean hadPostSplit;
|
final AtomicInteger ctPreCompactSelect = new AtomicInteger(0);
|
||||||
boolean hadPreCompactSelect;
|
final AtomicInteger ctPostCompactSelect = new AtomicInteger(0);
|
||||||
boolean hadPostCompactSelect;
|
final AtomicInteger ctPreCompactScanner = new AtomicInteger(0);
|
||||||
boolean hadPreCompactScanner;
|
final AtomicInteger ctPreCompact = new AtomicInteger(0);
|
||||||
boolean hadPreCompact;
|
final AtomicInteger ctPostCompact = new AtomicInteger(0);
|
||||||
boolean hadPostCompact;
|
final AtomicInteger ctPreGet = new AtomicInteger(0);
|
||||||
boolean hadPreGet = false;
|
final AtomicInteger ctPostGet = new AtomicInteger(0);
|
||||||
boolean hadPostGet = false;
|
final AtomicInteger ctPrePut = new AtomicInteger(0);
|
||||||
boolean hadPrePut = false;
|
final AtomicInteger ctPostPut = new AtomicInteger(0);
|
||||||
boolean hadPostPut = false;
|
final AtomicInteger ctPreDeleted = new AtomicInteger(0);
|
||||||
boolean hadPreDeleted = false;
|
final AtomicInteger ctPostDeleted = new AtomicInteger(0);
|
||||||
boolean hadPostDeleted = false;
|
final AtomicInteger ctPreGetClosestRowBefore = new AtomicInteger(0);
|
||||||
boolean hadPreGetClosestRowBefore = false;
|
final AtomicInteger ctPostGetClosestRowBefore = new AtomicInteger(0);
|
||||||
boolean hadPostGetClosestRowBefore = false;
|
final AtomicInteger ctPreIncrement = new AtomicInteger(0);
|
||||||
boolean hadPreIncrement = false;
|
final AtomicInteger ctPostIncrement = new AtomicInteger(0);
|
||||||
boolean hadPostIncrement = false;
|
final AtomicInteger ctPreWALRestored = new AtomicInteger(0);
|
||||||
boolean hadPreWALRestored = false;
|
final AtomicInteger ctPostWALRestored = new AtomicInteger(0);
|
||||||
boolean hadPostWALRestored = false;
|
final AtomicInteger ctPreScannerNext = new AtomicInteger(0);
|
||||||
boolean hadPreScannerNext = false;
|
final AtomicInteger ctPostScannerNext = new AtomicInteger(0);
|
||||||
boolean hadPostScannerNext = false;
|
final AtomicInteger ctPreScannerClose = new AtomicInteger(0);
|
||||||
boolean hadPreScannerClose = false;
|
final AtomicInteger ctPostScannerClose = new AtomicInteger(0);
|
||||||
boolean hadPostScannerClose = false;
|
final AtomicInteger ctPreScannerOpen = new AtomicInteger(0);
|
||||||
boolean hadPreScannerOpen = false;
|
final AtomicInteger ctPreStoreScannerOpen = new AtomicInteger(0);
|
||||||
boolean hadPreStoreScannerOpen = false;
|
final AtomicInteger ctPostScannerOpen = new AtomicInteger(0);
|
||||||
boolean hadPostScannerOpen = false;
|
final AtomicInteger ctPreBulkLoadHFile = new AtomicInteger(0);
|
||||||
boolean hadPreBulkLoadHFile = false;
|
final AtomicInteger ctPostBulkLoadHFile = new AtomicInteger(0);
|
||||||
boolean hadPostBulkLoadHFile = false;
|
final AtomicInteger ctPreBatchMutate = new AtomicInteger(0);
|
||||||
boolean hadPreBatchMutate = false;
|
final AtomicInteger ctPostBatchMutate = new AtomicInteger(0);
|
||||||
boolean hadPostBatchMutate = false;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start(CoprocessorEnvironment e) throws IOException {
|
public void start(CoprocessorEnvironment e) throws IOException {
|
||||||
|
@ -116,86 +116,86 @@ public class SimpleRegionObserver extends BaseRegionObserver {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void preOpen(ObserverContext<RegionCoprocessorEnvironment> c) {
|
public void preOpen(ObserverContext<RegionCoprocessorEnvironment> c) {
|
||||||
hadPreOpen = true;
|
ctPreOpen.incrementAndGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postOpen(ObserverContext<RegionCoprocessorEnvironment> c) {
|
public void postOpen(ObserverContext<RegionCoprocessorEnvironment> c) {
|
||||||
hadPostOpen = true;
|
ctPostOpen.incrementAndGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean wasOpened() {
|
public boolean wasOpened() {
|
||||||
return hadPreOpen && hadPostOpen;
|
return ctPreOpen.get() > 0 && ctPostOpen.get() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void preClose(ObserverContext<RegionCoprocessorEnvironment> c, boolean abortRequested) {
|
public void preClose(ObserverContext<RegionCoprocessorEnvironment> c, boolean abortRequested) {
|
||||||
hadPreClose = true;
|
ctPreClose.incrementAndGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postClose(ObserverContext<RegionCoprocessorEnvironment> c, boolean abortRequested) {
|
public void postClose(ObserverContext<RegionCoprocessorEnvironment> c, boolean abortRequested) {
|
||||||
hadPostClose = true;
|
ctPostClose.incrementAndGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean wasClosed() {
|
public boolean wasClosed() {
|
||||||
return hadPreClose && hadPostClose;
|
return ctPreClose.get() > 0 && ctPostClose.get() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InternalScanner preFlush(ObserverContext<RegionCoprocessorEnvironment> c,
|
public InternalScanner preFlush(ObserverContext<RegionCoprocessorEnvironment> c,
|
||||||
Store store, InternalScanner scanner) {
|
Store store, InternalScanner scanner) {
|
||||||
hadPreFlush = true;
|
ctPreFlush.incrementAndGet();
|
||||||
return scanner;
|
return scanner;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InternalScanner preFlushScannerOpen(final ObserverContext<RegionCoprocessorEnvironment> c,
|
public InternalScanner preFlushScannerOpen(final ObserverContext<RegionCoprocessorEnvironment> c,
|
||||||
Store store, KeyValueScanner memstoreScanner, InternalScanner s) throws IOException {
|
Store store, KeyValueScanner memstoreScanner, InternalScanner s) throws IOException {
|
||||||
hadPreFlushScannerOpen = true;
|
ctPreFlushScannerOpen.incrementAndGet();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postFlush(ObserverContext<RegionCoprocessorEnvironment> c,
|
public void postFlush(ObserverContext<RegionCoprocessorEnvironment> c,
|
||||||
Store store, StoreFile resultFile) {
|
Store store, StoreFile resultFile) {
|
||||||
hadPostFlush = true;
|
ctPostFlush.incrementAndGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean wasFlushed() {
|
public boolean wasFlushed() {
|
||||||
return hadPreFlush && hadPostFlush;
|
return ctPreFlush.get() > 0 && ctPostFlush.get() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void preSplit(ObserverContext<RegionCoprocessorEnvironment> c) {
|
public void preSplit(ObserverContext<RegionCoprocessorEnvironment> c) {
|
||||||
hadPreSplit = true;
|
ctPreSplit.incrementAndGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postSplit(ObserverContext<RegionCoprocessorEnvironment> c, HRegion l, HRegion r) {
|
public void postSplit(ObserverContext<RegionCoprocessorEnvironment> c, HRegion l, HRegion r) {
|
||||||
hadPostSplit = true;
|
ctPostSplit.incrementAndGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean wasSplit() {
|
public boolean wasSplit() {
|
||||||
return hadPreSplit && hadPostSplit;
|
return ctPreSplit.get() > 0 && ctPostSplit.get() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void preCompactSelection(ObserverContext<RegionCoprocessorEnvironment> c,
|
public void preCompactSelection(ObserverContext<RegionCoprocessorEnvironment> c,
|
||||||
Store store, List<StoreFile> candidates) {
|
Store store, List<StoreFile> candidates) {
|
||||||
hadPreCompactSelect = true;
|
ctPreCompactSelect.incrementAndGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postCompactSelection(ObserverContext<RegionCoprocessorEnvironment> c,
|
public void postCompactSelection(ObserverContext<RegionCoprocessorEnvironment> c,
|
||||||
Store store, ImmutableList<StoreFile> selected) {
|
Store store, ImmutableList<StoreFile> selected) {
|
||||||
hadPostCompactSelect = true;
|
ctPostCompactSelect.incrementAndGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InternalScanner preCompact(ObserverContext<RegionCoprocessorEnvironment> e,
|
public InternalScanner preCompact(ObserverContext<RegionCoprocessorEnvironment> e,
|
||||||
Store store, InternalScanner scanner, ScanType scanType) {
|
Store store, InternalScanner scanner, ScanType scanType) {
|
||||||
hadPreCompact = true;
|
ctPreCompact.incrementAndGet();
|
||||||
return scanner;
|
return scanner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,25 +204,25 @@ public class SimpleRegionObserver extends BaseRegionObserver {
|
||||||
final ObserverContext<RegionCoprocessorEnvironment> c,
|
final ObserverContext<RegionCoprocessorEnvironment> c,
|
||||||
Store store, List<? extends KeyValueScanner> scanners, ScanType scanType, long earliestPutTs,
|
Store store, List<? extends KeyValueScanner> scanners, ScanType scanType, long earliestPutTs,
|
||||||
InternalScanner s) throws IOException {
|
InternalScanner s) throws IOException {
|
||||||
hadPreCompactScanner = true;
|
ctPreCompactScanner.incrementAndGet();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postCompact(ObserverContext<RegionCoprocessorEnvironment> e,
|
public void postCompact(ObserverContext<RegionCoprocessorEnvironment> e,
|
||||||
Store store, StoreFile resultFile) {
|
Store store, StoreFile resultFile) {
|
||||||
hadPostCompact = true;
|
ctPostCompact.incrementAndGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean wasCompacted() {
|
public boolean wasCompacted() {
|
||||||
return hadPreCompact && hadPostCompact;
|
return ctPreCompact.get() > 0 && ctPostCompact.get() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RegionScanner preScannerOpen(final ObserverContext<RegionCoprocessorEnvironment> c,
|
public RegionScanner preScannerOpen(final ObserverContext<RegionCoprocessorEnvironment> c,
|
||||||
final Scan scan,
|
final Scan scan,
|
||||||
final RegionScanner s) throws IOException {
|
final RegionScanner s) throws IOException {
|
||||||
hadPreScannerOpen = true;
|
ctPreScannerOpen.incrementAndGet();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,7 +230,7 @@ public class SimpleRegionObserver extends BaseRegionObserver {
|
||||||
public KeyValueScanner preStoreScannerOpen(final ObserverContext<RegionCoprocessorEnvironment> c,
|
public KeyValueScanner preStoreScannerOpen(final ObserverContext<RegionCoprocessorEnvironment> c,
|
||||||
final Store store, final Scan scan, final NavigableSet<byte[]> targetCols,
|
final Store store, final Scan scan, final NavigableSet<byte[]> targetCols,
|
||||||
final KeyValueScanner s) throws IOException {
|
final KeyValueScanner s) throws IOException {
|
||||||
hadPreStoreScannerOpen = true;
|
ctPreStoreScannerOpen.incrementAndGet();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,7 +238,7 @@ public class SimpleRegionObserver extends BaseRegionObserver {
|
||||||
public RegionScanner postScannerOpen(final ObserverContext<RegionCoprocessorEnvironment> c,
|
public RegionScanner postScannerOpen(final ObserverContext<RegionCoprocessorEnvironment> c,
|
||||||
final Scan scan, final RegionScanner s)
|
final Scan scan, final RegionScanner s)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
hadPostScannerOpen = true;
|
ctPostScannerOpen.incrementAndGet();
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,7 +246,7 @@ public class SimpleRegionObserver extends BaseRegionObserver {
|
||||||
public boolean preScannerNext(final ObserverContext<RegionCoprocessorEnvironment> c,
|
public boolean preScannerNext(final ObserverContext<RegionCoprocessorEnvironment> c,
|
||||||
final InternalScanner s, final List<Result> results,
|
final InternalScanner s, final List<Result> results,
|
||||||
final int limit, final boolean hasMore) throws IOException {
|
final int limit, final boolean hasMore) throws IOException {
|
||||||
hadPreScannerNext = true;
|
ctPreScannerNext.incrementAndGet();
|
||||||
return hasMore;
|
return hasMore;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,20 +254,20 @@ public class SimpleRegionObserver extends BaseRegionObserver {
|
||||||
public boolean postScannerNext(final ObserverContext<RegionCoprocessorEnvironment> c,
|
public boolean postScannerNext(final ObserverContext<RegionCoprocessorEnvironment> c,
|
||||||
final InternalScanner s, final List<Result> results, final int limit,
|
final InternalScanner s, final List<Result> results, final int limit,
|
||||||
final boolean hasMore) throws IOException {
|
final boolean hasMore) throws IOException {
|
||||||
hadPostScannerNext = true;
|
ctPostScannerNext.incrementAndGet();
|
||||||
return hasMore;
|
return hasMore;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void preScannerClose(final ObserverContext<RegionCoprocessorEnvironment> c,
|
public void preScannerClose(final ObserverContext<RegionCoprocessorEnvironment> c,
|
||||||
final InternalScanner s) throws IOException {
|
final InternalScanner s) throws IOException {
|
||||||
hadPreScannerClose = true;
|
ctPreScannerClose.incrementAndGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postScannerClose(final ObserverContext<RegionCoprocessorEnvironment> c,
|
public void postScannerClose(final ObserverContext<RegionCoprocessorEnvironment> c,
|
||||||
final InternalScanner s) throws IOException {
|
final InternalScanner s) throws IOException {
|
||||||
hadPostScannerClose = true;
|
ctPostScannerClose.incrementAndGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -278,7 +278,7 @@ public class SimpleRegionObserver extends BaseRegionObserver {
|
||||||
assertNotNull(e.getRegion());
|
assertNotNull(e.getRegion());
|
||||||
assertNotNull(get);
|
assertNotNull(get);
|
||||||
assertNotNull(results);
|
assertNotNull(results);
|
||||||
hadPreGet = true;
|
ctPreGet.incrementAndGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -309,7 +309,7 @@ public class SimpleRegionObserver extends BaseRegionObserver {
|
||||||
assertTrue(foundB);
|
assertTrue(foundB);
|
||||||
assertTrue(foundC);
|
assertTrue(foundC);
|
||||||
}
|
}
|
||||||
hadPostGet = true;
|
ctPostGet.incrementAndGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -342,7 +342,7 @@ public class SimpleRegionObserver extends BaseRegionObserver {
|
||||||
assertTrue(Bytes.equals(kv.getQualifier(),
|
assertTrue(Bytes.equals(kv.getQualifier(),
|
||||||
TestRegionObserverInterface.C));
|
TestRegionObserverInterface.C));
|
||||||
}
|
}
|
||||||
hadPrePut = true;
|
ctPrePut.incrementAndGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -375,7 +375,7 @@ public class SimpleRegionObserver extends BaseRegionObserver {
|
||||||
kv = (KeyValue)cells.get(0);
|
kv = (KeyValue)cells.get(0);
|
||||||
assertTrue(Bytes.equals(kv.getQualifier(), TestRegionObserverInterface.C));
|
assertTrue(Bytes.equals(kv.getQualifier(), TestRegionObserverInterface.C));
|
||||||
}
|
}
|
||||||
hadPostPut = true;
|
ctPostPut.incrementAndGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -387,8 +387,8 @@ public class SimpleRegionObserver extends BaseRegionObserver {
|
||||||
assertNotNull(e);
|
assertNotNull(e);
|
||||||
assertNotNull(e.getRegion());
|
assertNotNull(e.getRegion());
|
||||||
assertNotNull(familyMap);
|
assertNotNull(familyMap);
|
||||||
if (beforeDelete) {
|
if (ctBeforeDelete.get() > 0) {
|
||||||
hadPreDeleted = true;
|
ctPreDeleted.incrementAndGet();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -401,8 +401,8 @@ public class SimpleRegionObserver extends BaseRegionObserver {
|
||||||
assertNotNull(e);
|
assertNotNull(e);
|
||||||
assertNotNull(e.getRegion());
|
assertNotNull(e.getRegion());
|
||||||
assertNotNull(familyMap);
|
assertNotNull(familyMap);
|
||||||
beforeDelete = false;
|
ctBeforeDelete.set(0);
|
||||||
hadPostDeleted = true;
|
ctPostDeleted.incrementAndGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -412,7 +412,7 @@ public class SimpleRegionObserver extends BaseRegionObserver {
|
||||||
assertNotNull(e);
|
assertNotNull(e);
|
||||||
assertNotNull(e.getRegion());
|
assertNotNull(e.getRegion());
|
||||||
assertNotNull(miniBatchOp);
|
assertNotNull(miniBatchOp);
|
||||||
hadPreBatchMutate = true;
|
ctPreBatchMutate.incrementAndGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -422,7 +422,7 @@ public class SimpleRegionObserver extends BaseRegionObserver {
|
||||||
assertNotNull(e);
|
assertNotNull(e);
|
||||||
assertNotNull(e.getRegion());
|
assertNotNull(e.getRegion());
|
||||||
assertNotNull(miniBatchOp);
|
assertNotNull(miniBatchOp);
|
||||||
hadPostBatchMutate = true;
|
ctPostBatchMutate.incrementAndGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -434,8 +434,8 @@ public class SimpleRegionObserver extends BaseRegionObserver {
|
||||||
assertNotNull(e.getRegion());
|
assertNotNull(e.getRegion());
|
||||||
assertNotNull(row);
|
assertNotNull(row);
|
||||||
assertNotNull(result);
|
assertNotNull(result);
|
||||||
if (beforeDelete) {
|
if (ctBeforeDelete.get() > 0) {
|
||||||
hadPreGetClosestRowBefore = true;
|
ctPreGetClosestRowBefore.incrementAndGet();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -448,20 +448,20 @@ public class SimpleRegionObserver extends BaseRegionObserver {
|
||||||
assertNotNull(e.getRegion());
|
assertNotNull(e.getRegion());
|
||||||
assertNotNull(row);
|
assertNotNull(row);
|
||||||
assertNotNull(result);
|
assertNotNull(result);
|
||||||
hadPostGetClosestRowBefore = true;
|
ctPostGetClosestRowBefore.incrementAndGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result preIncrement(final ObserverContext<RegionCoprocessorEnvironment> c,
|
public Result preIncrement(final ObserverContext<RegionCoprocessorEnvironment> c,
|
||||||
final Increment increment) throws IOException {
|
final Increment increment) throws IOException {
|
||||||
hadPreIncrement = true;
|
ctPreIncrement.incrementAndGet();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result postIncrement(final ObserverContext<RegionCoprocessorEnvironment> c,
|
public Result postIncrement(final ObserverContext<RegionCoprocessorEnvironment> c,
|
||||||
final Increment increment, final Result result) throws IOException {
|
final Increment increment, final Result result) throws IOException {
|
||||||
hadPostIncrement = true;
|
ctPostIncrement.incrementAndGet();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -480,7 +480,7 @@ public class SimpleRegionObserver extends BaseRegionObserver {
|
||||||
String familyName = Bytes.toString(TestRegionObserverInterface.A);
|
String familyName = Bytes.toString(TestRegionObserverInterface.A);
|
||||||
assertEquals(familyPath.substring(familyPath.length()-familyName.length()-1),"/"+familyName);
|
assertEquals(familyPath.substring(familyPath.length()-familyName.length()-1),"/"+familyName);
|
||||||
}
|
}
|
||||||
hadPreBulkLoadHFile = true;
|
ctPreBulkLoadHFile.incrementAndGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -498,71 +498,172 @@ public class SimpleRegionObserver extends BaseRegionObserver {
|
||||||
String familyName = Bytes.toString(TestRegionObserverInterface.A);
|
String familyName = Bytes.toString(TestRegionObserverInterface.A);
|
||||||
assertEquals(familyPath.substring(familyPath.length()-familyName.length()-1),"/"+familyName);
|
assertEquals(familyPath.substring(familyPath.length()-familyName.length()-1),"/"+familyName);
|
||||||
}
|
}
|
||||||
hadPostBulkLoadHFile = true;
|
ctPostBulkLoadHFile.incrementAndGet();
|
||||||
return hasLoaded;
|
return hasLoaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hadPreGet() {
|
public boolean hadPreGet() {
|
||||||
return hadPreGet;
|
return ctPreGet.get() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hadPostGet() {
|
public boolean hadPostGet() {
|
||||||
return hadPostGet;
|
return ctPostGet.get() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hadPrePut() {
|
public boolean hadPrePut() {
|
||||||
return hadPrePut;
|
return ctPrePut.get() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hadPostPut() {
|
public boolean hadPostPut() {
|
||||||
return hadPostPut;
|
return ctPostPut.get() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hadPreBatchMutate() {
|
public boolean hadPreBatchMutate() {
|
||||||
return hadPreBatchMutate;
|
return ctPreBatchMutate.get() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hadPostBatchMutate() {
|
public boolean hadPostBatchMutate() {
|
||||||
return hadPostBatchMutate;
|
return ctPostBatchMutate.get() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hadDelete() {
|
public boolean hadDelete() {
|
||||||
return !beforeDelete;
|
return !(ctBeforeDelete.get() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hadPreIncrement() {
|
public boolean hadPreIncrement() {
|
||||||
return hadPreIncrement;
|
return ctPreIncrement.get() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hadPostIncrement() {
|
public boolean hadPostIncrement() {
|
||||||
return hadPostIncrement;
|
return ctPostIncrement.get() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hadPreWALRestored() {
|
public boolean hadPreWALRestored() {
|
||||||
return hadPreWALRestored;
|
return ctPreWALRestored.get() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hadPostWALRestored() {
|
public boolean hadPostWALRestored() {
|
||||||
return hadPostWALRestored;
|
return ctPostWALRestored.get() > 0;
|
||||||
}
|
}
|
||||||
public boolean wasScannerNextCalled() {
|
public boolean wasScannerNextCalled() {
|
||||||
return hadPreScannerNext && hadPostScannerNext;
|
return ctPreScannerNext.get() > 0 && ctPostScannerNext.get() > 0;
|
||||||
}
|
}
|
||||||
public boolean wasScannerCloseCalled() {
|
public boolean wasScannerCloseCalled() {
|
||||||
return hadPreScannerClose && hadPostScannerClose;
|
return ctPreScannerClose.get() > 0 && ctPostScannerClose.get() > 0;
|
||||||
}
|
}
|
||||||
public boolean wasScannerOpenCalled() {
|
public boolean wasScannerOpenCalled() {
|
||||||
return hadPreScannerOpen && hadPostScannerOpen;
|
return ctPreScannerOpen.get() > 0 && ctPostScannerOpen.get() > 0;
|
||||||
}
|
}
|
||||||
public boolean hadDeleted() {
|
public boolean hadDeleted() {
|
||||||
return hadPreDeleted && hadPostDeleted;
|
return ctPreDeleted.get() > 0 && ctPostDeleted.get() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hadPostBulkLoadHFile() {
|
public boolean hadPostBulkLoadHFile() {
|
||||||
return hadPostBulkLoadHFile;
|
return ctPostBulkLoadHFile.get() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hadPreBulkLoadHFile() {
|
public boolean hadPreBulkLoadHFile() {
|
||||||
return hadPreBulkLoadHFile;
|
return ctPreBulkLoadHFile.get() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int getCtBeforeDelete() {
|
||||||
|
return ctBeforeDelete.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCtPreOpen() {
|
||||||
|
return ctPreOpen.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCtPostOpen() {
|
||||||
|
return ctPostOpen.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCtPreClose() {
|
||||||
|
return ctPreClose.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCtPostClose() {
|
||||||
|
return ctPostClose.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCtPreFlush() {
|
||||||
|
return ctPreFlush.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCtPreFlushScannerOpen() {
|
||||||
|
return ctPreFlushScannerOpen.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCtPostFlush() {
|
||||||
|
return ctPostFlush.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCtPreSplit() {
|
||||||
|
return ctPreSplit.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCtPostSplit() {
|
||||||
|
return ctPostSplit.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCtPreCompactSelect() {
|
||||||
|
return ctPreCompactSelect.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCtPostCompactSelect() {
|
||||||
|
return ctPostCompactSelect.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCtPreCompactScanner() {
|
||||||
|
return ctPreCompactScanner.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCtPreCompact() {
|
||||||
|
return ctPreCompact.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCtPostCompact() {
|
||||||
|
return ctPostCompact.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCtPreGet() {
|
||||||
|
return ctPreGet.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCtPostGet() {
|
||||||
|
return ctPostGet.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCtPrePut() {
|
||||||
|
return ctPrePut.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCtPostPut() {
|
||||||
|
return ctPostPut.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCtPreDeleted() {
|
||||||
|
return ctPreDeleted.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCtPostDeleted() {
|
||||||
|
return ctPostDeleted.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCtPreGetClosestRowBefore() {
|
||||||
|
return ctPreGetClosestRowBefore.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCtPostGetClosestRowBefore() {
|
||||||
|
return ctPostGetClosestRowBefore.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCtPreIncrement() {
|
||||||
|
return ctPreIncrement.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCtPostIncrement() {
|
||||||
|
return ctPostIncrement.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,7 @@ public class TestRegionObserverInterface {
|
||||||
public void testRegionObserver() throws IOException {
|
public void testRegionObserver() throws IOException {
|
||||||
byte[] tableName = TEST_TABLE;
|
byte[] tableName = TEST_TABLE;
|
||||||
// recreate table every time in order to reset the status of the
|
// recreate table every time in order to reset the status of the
|
||||||
// coproccessor.
|
// coprocessor.
|
||||||
HTable table = util.createTable(tableName, new byte[][] {A, B, C});
|
HTable table = util.createTable(tableName, new byte[][] {A, B, C});
|
||||||
verifyMethodResult(SimpleRegionObserver.class,
|
verifyMethodResult(SimpleRegionObserver.class,
|
||||||
new String[] {"hadPreGet", "hadPostGet", "hadPrePut", "hadPostPut",
|
new String[] {"hadPreGet", "hadPostGet", "hadPrePut", "hadPostPut",
|
||||||
|
@ -126,6 +126,11 @@ public class TestRegionObserverInterface {
|
||||||
new Boolean[] {false, false, true, true, true, true, false}
|
new Boolean[] {false, false, true, true, true, true, false}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
verifyMethodResult(SimpleRegionObserver.class,
|
||||||
|
new String[] {"getCtPreOpen", "getCtPostOpen", "getCtPreClose", "getCtPostClose"},
|
||||||
|
TEST_TABLE,
|
||||||
|
new Integer[] {1, 1, 0, 0});
|
||||||
|
|
||||||
Get get = new Get(ROW);
|
Get get = new Get(ROW);
|
||||||
get.addColumn(A, A);
|
get.addColumn(A, A);
|
||||||
get.addColumn(B, B);
|
get.addColumn(B, B);
|
||||||
|
@ -153,6 +158,11 @@ public class TestRegionObserverInterface {
|
||||||
);
|
);
|
||||||
util.deleteTable(tableName);
|
util.deleteTable(tableName);
|
||||||
table.close();
|
table.close();
|
||||||
|
|
||||||
|
verifyMethodResult(SimpleRegionObserver.class,
|
||||||
|
new String[] {"getCtPreOpen", "getCtPostOpen", "getCtPreClose", "getCtPostClose"},
|
||||||
|
TEST_TABLE,
|
||||||
|
new Integer[] {1, 1, 1, 1});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue