下面列出了怎么用org.apache.hadoop.hbase.regionserver.Region.Operation的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
public void postStartRegionOperation(ObserverContext<RegionCoprocessorEnvironment> ctx, Operation operation) throws IOException {
if(LOG.isDebugEnabled()) {
LOG.debug("==> RangerAuthorizationCoprocessor.postStartRegionOperation()");
}
try {
activatePluginClassLoader();
implRegionObserver.postStartRegionOperation(ctx, operation);
} finally {
deactivatePluginClassLoader();
}
if(LOG.isDebugEnabled()) {
LOG.debug("<== RangerAuthorizationCoprocessor.postStartRegionOperation()");
}
}
@Override
public void postCloseRegionOperation(ObserverContext<RegionCoprocessorEnvironment> ctx, Operation operation) throws IOException {
if(LOG.isDebugEnabled()) {
LOG.debug("==> RangerAuthorizationCoprocessor.postCloseRegionOperation()");
}
try {
activatePluginClassLoader();
implRegionObserver.postCloseRegionOperation(ctx, operation);
} finally {
deactivatePluginClassLoader();
}
if(LOG.isDebugEnabled()) {
LOG.debug("<== RangerAuthorizationCoprocessor.postCloseRegionOperation()");
}
}
public void postStartRegionOperation(final Operation op) throws IOException {
execOperation(coprocEnvironments.isEmpty()? null:
new RegionObserverOperationWithoutResult() {
@Override
public void call(RegionObserver observer) throws IOException {
observer.postStartRegionOperation(this, op);
}
});
}
public void postCloseRegionOperation(final Operation op) throws IOException {
execOperation(coprocEnvironments.isEmpty()? null:
new RegionObserverOperationWithoutResult() {
@Override
public void call(RegionObserver observer) throws IOException {
observer.postCloseRegionOperation(this, op);
}
});
}
@Override
public void postCloseRegionOperation(final ObserverContext<RegionCoprocessorEnvironment> ctx,
Operation op) throws IOException {
if (ctPostStartRegionOperation.get() > 0) {
ctPostCloseRegionOperation.incrementAndGet();
}
}
@Override
public Void call() throws Exception {
// Taking the region read lock prevents the individual region from being closed while a
// snapshot is in progress. This is helpful but not sufficient for preventing races with
// snapshots that involve multiple regions and regionservers. It is still possible to have
// an interleaving such that globally regions are missing, so we still need the verification
// step.
LOG.debug("Starting snapshot operation on " + region);
region.startRegionOperation(Operation.SNAPSHOT);
try {
if (skipFlush) {
/*
* This is to take an online-snapshot without force a coordinated flush to prevent pause
* The snapshot type is defined inside the snapshot description. FlushSnapshotSubprocedure
* should be renamed to distributedSnapshotSubprocedure, and the flush() behavior can be
* turned on/off based on the flush type.
* To minimized the code change, class name is not changed.
*/
LOG.debug("take snapshot without flush memstore first");
} else {
LOG.debug("Flush Snapshotting region " + region.toString() + " started...");
boolean succeeded = false;
long readPt = region.getReadPoint(IsolationLevel.READ_COMMITTED);
for (int i = 0; i < MAX_RETRIES; i++) {
FlushResult res = region.flush(true);
if (res.getResult() == FlushResult.Result.CANNOT_FLUSH) {
// CANNOT_FLUSH may mean that a flush is already on-going
// we need to wait for that flush to complete
region.waitForFlushes();
if (region.getMaxFlushedSeqId() >= readPt) {
// writes at the start of the snapshot have been persisted
succeeded = true;
break;
}
} else {
succeeded = true;
break;
}
}
if (!succeeded) {
throw new IOException("Unable to complete flush after " + MAX_RETRIES + " attempts");
}
}
region.addRegionToSnapshot(snapshotDesc, monitor);
if (skipFlush) {
LOG.debug("... SkipFlush Snapshotting region " + region.toString() + " completed.");
} else {
LOG.debug("... Flush Snapshotting region " + region.toString() + " completed.");
}
} finally {
LOG.debug("Closing snapshot operation on " + region);
region.closeRegionOperation(Operation.SNAPSHOT);
}
return null;
}
@Override
public void postStartRegionOperation(final ObserverContext<RegionCoprocessorEnvironment> ctx,
Operation op) throws IOException {
ctPostStartRegionOperation.incrementAndGet();
}
@Override
public void postStartRegionOperation(ObserverContext<RegionCoprocessorEnvironment> ctx,
Operation operation) throws IOException {
delegate.postStartRegionOperation(ctx, operation);
}
@Override
public void postCloseRegionOperation(ObserverContext<RegionCoprocessorEnvironment> ctx,
Operation operation) throws IOException {
delegate.postCloseRegionOperation(ctx, operation);
}
/**
* This will be called for region operations where read lock is acquired in
* {@link Region#startRegionOperation()}.
* @param ctx
* @param operation The operation is about to be taken on the region
*/
default void postStartRegionOperation(ObserverContext<RegionCoprocessorEnvironment> ctx,
Operation operation) throws IOException {}
/**
* Called after releasing read lock in {@link Region#closeRegionOperation()}.
* @param ctx
* @param operation
*/
default void postCloseRegionOperation(ObserverContext<RegionCoprocessorEnvironment> ctx,
Operation operation) throws IOException {}