Java Code Examples for org.apache.hadoop.hbase.regionserver.compactions.CompactionRequest

The following examples show how to use org.apache.hadoop.hbase.regionserver.compactions.CompactionRequest. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: phoenix-tephra   Source File: TransactionProcessor.java    License: Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 2
Source Project: phoenix-tephra   Source File: TransactionProcessor.java    License: Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 3
Source Project: phoenix-tephra   Source File: TransactionProcessor.java    License: Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 4
Source Project: phoenix-tephra   Source File: TransactionProcessor.java    License: Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example 5
Source Project: phoenix-tephra   Source File: TransactionProcessor.java    License: Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 6
Source Project: phoenix-tephra   Source File: TransactionProcessor.java    License: Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 7
Source Project: phoenix-tephra   Source File: TransactionProcessor.java    License: Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 8
Source Project: phoenix-tephra   Source File: TransactionProcessor.java    License: Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 9
Source Project: phoenix   Source File: IndexHalfStoreFileReaderGenerator.java    License: Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example 10
Source Project: ranger   Source File: RangerAuthorizationCoprocessor.java    License: Apache License 2.0 6 votes vote down vote up
@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()");
	}
}
 
Example 11
Source Project: ranger   Source File: RangerAuthorizationCoprocessor.java    License: Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example 12
Source Project: ranger   Source File: RangerAuthorizationCoprocessor.java    License: Apache License 2.0 6 votes vote down vote up
@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()");
	}
}
 
Example 13
Source Project: geowave   Source File: ServerSideOperationsObserver.java    License: Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 14
@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);
    }
}
 
Example 15
Source Project: phoenix-omid   Source File: BaseRegionObserver.java    License: Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 16
Source Project: phoenix-omid   Source File: BaseRegionObserver.java    License: Apache License 2.0 5 votes vote down vote up
public InternalScanner preCompact(ObserverContext<RegionCoprocessorEnvironment> env,
                                  Store store,
                                  InternalScanner scanner,
                                  ScanType scanType,
                                  CompactionRequest request) throws IOException {
    return scanner;
}
 
Example 17
Source Project: phoenix-tephra   Source File: CompactionState.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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;
  }
}
 
Example 18
Source Project: phoenix-tephra   Source File: TransactionProcessor.java    License: Apache License 2.0 5 votes vote down vote up
@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();
  }
}
 
Example 19
Source Project: phoenix-tephra   Source File: CompactionState.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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;
  }
}
 
Example 20
Source Project: phoenix-tephra   Source File: TransactionProcessor.java    License: Apache License 2.0 5 votes vote down vote up
@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();
  }
}
 
Example 21
Source Project: phoenix-tephra   Source File: CompactionState.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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;
  }
}
 
Example 22
Source Project: phoenix-tephra   Source File: TransactionProcessor.java    License: Apache License 2.0 5 votes vote down vote up
@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();
  }
}
 
Example 23
@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);
    }
}
 
Example 24
Source Project: phoenix-tephra   Source File: CompactionState.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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;
  }
}
 
Example 25
Source Project: phoenix-tephra   Source File: TransactionProcessor.java    License: Apache License 2.0 5 votes vote down vote up
@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();
  }
}
 
Example 26
Source Project: phoenix-tephra   Source File: TransactionProcessor.java    License: Apache License 2.0 5 votes vote down vote up
@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();
  }
}
 
Example 27
Source Project: phoenix-tephra   Source File: InvalidListPruneTest.java    License: Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example 28
Source Project: phoenix-tephra   Source File: CompactionState.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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;
  }
}
 
Example 29
Source Project: phoenix-tephra   Source File: TransactionProcessor.java    License: Apache License 2.0 5 votes vote down vote up
@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();
  }
}
 
Example 30
Source Project: phoenix-tephra   Source File: CompactionState.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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;
  }
}