下面列出了怎么用org.apache.hadoop.hbase.regionserver.compactions.CompactionRequest的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
public InternalScanner preCompactScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c, Store store,
List<? extends KeyValueScanner> scanners, ScanType scanType, long earliestPutTs, InternalScanner s,
CompactionRequest request)
throws IOException {
// Get the latest tx snapshot state for the compaction
TransactionVisibilityState snapshot = cache.getLatestState();
// Record tx state before the compaction
if (compactionState != null) {
compactionState.record(request, snapshot);
}
// silently close the passed scanner as we're returning a brand-new one
try (InternalScanner temp = s) { }
// Also make sure to use the same snapshot for the compaction
return createStoreScanner(c.getEnvironment(), "compaction", snapshot, store, scanners, scanType, earliestPutTs);
}
@Override
public InternalScanner preCompactScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c, Store store,
List<? extends KeyValueScanner> scanners, ScanType scanType, long earliestPutTs, InternalScanner s,
CompactionRequest request)
throws IOException {
// Get the latest tx snapshot state for the compaction
TransactionVisibilityState snapshot = cache.getLatestState();
// Record tx state before the compaction
if (compactionState != null) {
compactionState.record(request, snapshot);
}
// silently close the passed scanner as we're returning a brand-new one
try (InternalScanner temp = s) { }
// Also make sure to use the same snapshot for the compaction
return createStoreScanner(c.getEnvironment(), "compaction", snapshot, store, scanners, scanType, earliestPutTs);
}
@Override
public InternalScanner preCompactScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c, Store store,
List<? extends KeyValueScanner> scanners, ScanType scanType, long earliestPutTs, InternalScanner s,
CompactionRequest request)
throws IOException {
// Get the latest tx snapshot state for the compaction
TransactionVisibilityState snapshot = cache.getLatestState();
// Record tx state before the compaction
if (compactionState != null) {
compactionState.record(request, snapshot);
}
// silently close the passed scanner as we're returning a brand-new one
try (InternalScanner temp = s) { }
// Also make sure to use the same snapshot for the compaction
return createStoreScanner(c.getEnvironment(), "compaction", snapshot, store, scanners, scanType, earliestPutTs);
}
@Override
public InternalScanner preCompact(
org.apache.hadoop.hbase.coprocessor.ObserverContext<RegionCoprocessorEnvironment> c,
Store store, InternalScanner scanner, ScanType scanType,
org.apache.hadoop.hbase.regionserver.compactions.CompactionLifeCycleTracker tracker,
CompactionRequest request) throws IOException {
// Get the latest tx snapshot state for the compaction
TransactionVisibilityState snapshot = cache.getLatestState();
// Record tx state before the compaction
if (compactionState != null) {
compactionState.record(request, snapshot);
}
// Also make sure to use the same snapshot for the compaction
InternalScanner s =
createStoreScanner(c.getEnvironment(), "compaction", snapshot, scanner, scanType);
if (s != null) {
return s;
}
return scanner;
}
@Override
public InternalScanner preCompactScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c, Store store,
List<? extends KeyValueScanner> scanners, ScanType scanType, long earliestPutTs, InternalScanner s,
CompactionRequest request)
throws IOException {
// Get the latest tx snapshot state for the compaction
TransactionVisibilityState snapshot = cache.getLatestState();
// Record tx state before the compaction
if (compactionState != null) {
compactionState.record(request, snapshot);
}
// silently close the passed scanner as we're returning a brand-new one
try (InternalScanner temp = s) { }
// Also make sure to use the same snapshot for the compaction
return createStoreScanner(c.getEnvironment(), "compaction", snapshot, store, scanners, scanType, earliestPutTs);
}
@Override
public InternalScanner preCompactScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c, Store store,
List<? extends KeyValueScanner> scanners, ScanType scanType, long earliestPutTs, InternalScanner s,
CompactionRequest request)
throws IOException {
// Get the latest tx snapshot state for the compaction
TransactionVisibilityState snapshot = cache.getLatestState();
// Record tx state before the compaction
if (compactionState != null) {
compactionState.record(request, snapshot);
}
// silently close the passed scanner as we're returning a brand-new one
try (InternalScanner temp = s) { }
// Also make sure to use the same snapshot for the compaction
return createStoreScanner(c.getEnvironment(), "compaction", snapshot, store, scanners, scanType, earliestPutTs);
}
@Override
public InternalScanner preCompactScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c, Store store,
List<? extends KeyValueScanner> scanners, ScanType scanType, long earliestPutTs, InternalScanner s,
CompactionRequest request)
throws IOException {
// Get the latest tx snapshot state for the compaction
TransactionVisibilityState snapshot = cache.getLatestState();
// Record tx state before the compaction
if (compactionState != null) {
compactionState.record(request, snapshot);
}
// silently close the passed scanner as we're returning a brand-new one
try (InternalScanner temp = s) { }
// Also make sure to use the same snapshot for the compaction
return createStoreScanner(c.getEnvironment(), "compaction", snapshot, store, scanners, scanType, earliestPutTs);
}
@Override
public InternalScanner preCompactScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c, Store store,
List<? extends KeyValueScanner> scanners, ScanType scanType, long earliestPutTs, InternalScanner s,
CompactionRequest request)
throws IOException {
// Get the latest tx snapshot state for the compaction
TransactionVisibilityState snapshot = cache.getLatestState();
// Record tx state before the compaction
if (compactionState != null) {
compactionState.record(request, snapshot);
}
// silently close the passed scanner as we're returning a brand-new one
try (InternalScanner temp = s) { }
// Also make sure to use the same snapshot for the compaction
return createStoreScanner(c.getEnvironment(), "compaction", snapshot, store, scanners, scanType, earliestPutTs);
}
@Override
public InternalScanner preCompactScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c,
Store store, List<? extends KeyValueScanner> scanners, ScanType scanType,
long earliestPutTs, InternalScanner s, CompactionRequest request) throws IOException {
InternalScanner internalScanner = super.preCompactScannerOpen(c, store, scanners, scanType, earliestPutTs, s, request);
Collection<StoreFile> files = request.getFiles();
storeFilesCount = 0;
compactedFilesCount = 0;
for(StoreFile file:files) {
if(!file.isReference()) {
return internalScanner;
}
}
storeFilesCount = files.size();
return internalScanner;
}
@Override
public void postCompactSelection(ObserverContext<RegionCoprocessorEnvironment> c, Store store, List<? extends StoreFile> selected, CompactionLifeCycleTracker tracker, CompactionRequest request) {
if(LOG.isDebugEnabled()) {
LOG.debug("==> RangerAuthorizationCoprocessor.postCompactSelection()");
}
try {
activatePluginClassLoader();
implRegionObserver.postCompactSelection(c, store, selected, tracker, request);
} finally {
deactivatePluginClassLoader();
}
if(LOG.isDebugEnabled()) {
LOG.debug("<== RangerAuthorizationCoprocessor.postCompactSelection()");
}
}
@Override
public InternalScanner preCompact(ObserverContext<RegionCoprocessorEnvironment> c, Store store, InternalScanner scanner,
ScanType scanType, CompactionLifeCycleTracker tracker, CompactionRequest request) throws IOException {
final InternalScanner ret;
if(LOG.isDebugEnabled()) {
LOG.debug("==> RangerAuthorizationCoprocessor.preCompact()");
}
try {
activatePluginClassLoader();
ret = implRegionObserver.preCompact(c, store, scanner, scanType, tracker, request);
} finally {
deactivatePluginClassLoader();
}
if(LOG.isDebugEnabled()) {
LOG.debug("<== RangerAuthorizationCoprocessor.preCompact()");
}
return ret;
}
@Override
public void postCompact(ObserverContext<RegionCoprocessorEnvironment> c, Store store, StoreFile resultFile,
CompactionLifeCycleTracker tracker, CompactionRequest request) throws IOException {
if(LOG.isDebugEnabled()) {
LOG.debug("==> RangerAuthorizationCoprocessor.postCompact()");
}
try {
activatePluginClassLoader();
implRegionObserver.postCompact(c, store, resultFile, tracker, request);
} finally {
deactivatePluginClassLoader();
}
if(LOG.isDebugEnabled()) {
LOG.debug("<== RangerAuthorizationCoprocessor.postCompact()");
}
}
@Override
public InternalScanner preCompact(
final ObserverContext<RegionCoprocessorEnvironment> e,
final Store store,
final InternalScanner scanner,
final ScanType scanType,
final CompactionRequest request) throws IOException {
if (opStore == null) {
return super.preCompact(e, store, scanner, scanType, request);
}
return super.preCompact(
e,
store,
wrapScannerWithOps(
e.getEnvironment().getRegionInfo().getTable(),
scanner,
null,
ServerOpScope.MAJOR_COMPACTION,
INTERNAL_SCANNER_FACTORY),
scanType,
request);
}
@Override
public InternalScanner preCompact(ObserverContext<RegionCoprocessorEnvironment> c, Store store,
InternalScanner scanner, ScanType scanType, CompactionLifeCycleTracker tracker,
CompactionRequest request) throws IOException {
try {
BlockingProbe.blockPreCompact();
if (!(request instanceof SpliceCompactionRequest)) {
SpliceLogUtils.error(LOG,"Compaction request must be a SpliceCompactionRequest");
throw new DoNotRetryIOException();
}
SpliceCompactionRequest scr = (SpliceCompactionRequest) request;
// memstoreAware is injected into the request, where the blocking logic lives, and where compaction
// count will be incremented and decremented.
scr.setMemstoreAware(memstoreAware);
HRegion region = (HRegion) c.getEnvironment().getRegion();
scr.setRegion(region);
return scanner == null ? DummyScanner.INSTANCE : scanner;
} catch (Throwable t) {
throw CoprocessorUtils.getIOException(t);
}
}
public InternalScanner preCompact(ObserverContext<RegionCoprocessorEnvironment> c,
Store store,
InternalScanner scanner,
ScanType scanType,
CompactionLifeCycleTracker tracker,
CompactionRequest request) throws IOException {
return preCompact(c,store,scanner,scanType,request);
}
public InternalScanner preCompact(ObserverContext<RegionCoprocessorEnvironment> env,
Store store,
InternalScanner scanner,
ScanType scanType,
CompactionRequest request) throws IOException {
return scanner;
}
/**
* Records the transaction state used for a compaction. This method is called when the compaction starts.
*
* @param request {@link CompactionRequest} for the compaction
* @param snapshot transaction state that will be used for the compaction
*/
public void record(CompactionRequest request, @Nullable TransactionVisibilityState snapshot) {
if (request.isMajor() && snapshot != null) {
Transaction tx = TxUtils.createDummyTransaction(snapshot);
pruneUpperBound = TxUtils.getPruneUpperBound(tx);
if (LOG.isDebugEnabled()) {
LOG.debug(
String.format("Computed prune upper bound %s for compaction request %s using transaction state from time %s",
pruneUpperBound, request, snapshot.getTimestamp()));
}
} else {
pruneUpperBound = -1;
}
}
@Override
public void postCompact(ObserverContext<RegionCoprocessorEnvironment> e, Store store, StoreFile resultFile,
CompactionRequest request) throws IOException {
// Persist the compaction state after a successful compaction
if (compactionState != null) {
compactionState.persist();
}
}
/**
* Records the transaction state used for a compaction. This method is called when the compaction starts.
*
* @param request {@link CompactionRequest} for the compaction
* @param snapshot transaction state that will be used for the compaction
*/
public void record(CompactionRequest request, @Nullable TransactionVisibilityState snapshot) {
if (request.isMajor() && snapshot != null) {
Transaction tx = TxUtils.createDummyTransaction(snapshot);
pruneUpperBound = TxUtils.getPruneUpperBound(tx);
if (LOG.isDebugEnabled()) {
LOG.debug(
String.format("Computed prune upper bound %s for compaction request %s using transaction state from time %s",
pruneUpperBound, request, snapshot.getTimestamp()));
}
} else {
pruneUpperBound = -1;
}
}
@Override
public void postCompact(ObserverContext<RegionCoprocessorEnvironment> e, Store store, StoreFile resultFile,
CompactionRequest request) throws IOException {
// Persist the compaction state after a succesful compaction
if (compactionState != null) {
compactionState.persist();
}
}
/**
* Records the transaction state used for a compaction. This method is called when the compaction starts.
*
* @param request {@link CompactionRequest} for the compaction
* @param snapshot transaction state that will be used for the compaction
*/
public void record(CompactionRequest request, @Nullable TransactionVisibilityState snapshot) {
if (request.isMajor() && snapshot != null) {
Transaction tx = TxUtils.createDummyTransaction(snapshot);
pruneUpperBound = TxUtils.getPruneUpperBound(tx);
if (LOG.isDebugEnabled()) {
LOG.debug(
String.format("Computed prune upper bound %s for compaction request %s using transaction state from time %s",
pruneUpperBound, request, snapshot.getTimestamp()));
}
} else {
pruneUpperBound = -1;
}
}
@Override
public void postCompact(ObserverContext<RegionCoprocessorEnvironment> e, Store store, StoreFile resultFile,
CompactionRequest request) throws IOException {
// Persist the compaction state after a successful compaction
if (compactionState != null) {
compactionState.persist();
}
}
@Override
public void postCompact(ObserverContext<RegionCoprocessorEnvironment> c, Store store, StoreFile resultFile,
CompactionLifeCycleTracker tracker, CompactionRequest request) throws IOException {
try {
BlockingProbe.blockPostCompact();
} catch (Throwable t) {
throw CoprocessorUtils.getIOException(t);
}
}
/**
* Records the transaction state used for a compaction. This method is called when the compaction starts.
*
* @param request {@link CompactionRequest} for the compaction
* @param snapshot transaction state that will be used for the compaction
*/
public void record(CompactionRequest request, @Nullable TransactionVisibilityState snapshot) {
if (request.isMajor() && snapshot != null) {
Transaction tx = TxUtils.createDummyTransaction(snapshot);
pruneUpperBound = TxUtils.getPruneUpperBound(tx);
if (LOG.isDebugEnabled()) {
LOG.debug(
String.format("Computed prune upper bound %s for compaction request %s using transaction state from time %s",
pruneUpperBound, request, snapshot.getTimestamp()));
}
} else {
pruneUpperBound = -1;
}
}
@Override
public void preCompactScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c, Store store,
ScanType scanType, ScanOptions options, CompactionLifeCycleTracker tracker,
CompactionRequest request) throws IOException {
if (cache.getLatestState() != null) {
options.readAllVersions();
}
}
@Override
public void postCompact(
org.apache.hadoop.hbase.coprocessor.ObserverContext<RegionCoprocessorEnvironment> c,
Store store, StoreFile resultFile,
org.apache.hadoop.hbase.regionserver.compactions.CompactionLifeCycleTracker tracker,
CompactionRequest request) throws IOException {
// Persist the compaction state after a successful compaction
if (compactionState != null) {
compactionState.persist();
}
}
@Override
public void postCompact(
org.apache.hadoop.hbase.coprocessor.ObserverContext<RegionCoprocessorEnvironment> c,
Store store, StoreFile resultFile,
org.apache.hadoop.hbase.regionserver.compactions.CompactionLifeCycleTracker tracker,
CompactionRequest request) throws IOException {
super.postCompact(c, store, resultFile, tracker, request);
lastMajorCompactionTime.set(System.currentTimeMillis());
}
/**
* Records the transaction state used for a compaction. This method is called when the compaction starts.
*
* @param request {@link CompactionRequest} for the compaction
* @param snapshot transaction state that will be used for the compaction
*/
public void record(CompactionRequest request, @Nullable TransactionVisibilityState snapshot) {
if (request.isMajor() && snapshot != null) {
Transaction tx = TxUtils.createDummyTransaction(snapshot);
pruneUpperBound = TxUtils.getPruneUpperBound(tx);
if (LOG.isDebugEnabled()) {
LOG.debug(
String.format("Computed prune upper bound %s for compaction request %s using transaction state from time %s",
pruneUpperBound, request, snapshot.getTimestamp()));
}
} else {
pruneUpperBound = -1;
}
}
@Override
public void postCompact(ObserverContext<RegionCoprocessorEnvironment> e, Store store, StoreFile resultFile,
CompactionRequest request) throws IOException {
// Persist the compaction state after a successful compaction
if (compactionState != null) {
compactionState.persist();
}
}
/**
* Records the transaction state used for a compaction. This method is called when the compaction starts.
*
* @param request {@link CompactionRequest} for the compaction
* @param snapshot transaction state that will be used for the compaction
*/
public void record(CompactionRequest request, @Nullable TransactionVisibilityState snapshot) {
if (request.isMajor() && snapshot != null) {
Transaction tx = TxUtils.createDummyTransaction(snapshot);
pruneUpperBound = TxUtils.getPruneUpperBound(tx);
if (LOG.isDebugEnabled()) {
LOG.debug(
String.format("Computed prune upper bound %s for compaction request %s using transaction state from time %s",
pruneUpperBound, request, snapshot.getTimestamp()));
}
} else {
pruneUpperBound = -1;
}
}