use of org.apache.tephra.persist.TransactionVisibilityState in project cdap by caskdata.
the class MessageTableRegionObserver method preCompactScannerOpen.
@Override
public InternalScanner preCompactScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c, Store store, List<? extends KeyValueScanner> scanners, ScanType scanType, long earliestPutTs, InternalScanner s, CompactionRequest request) throws IOException {
LOG.info("preCompact, filter using MessageDataFilter");
TransactionVisibilityState txVisibilityState = txStateCache.getLatestState();
reloadPruneState(c.getEnvironment());
if (compactionState != null) {
// Record tx state before the compaction
compactionState.record(request, txVisibilityState);
}
Scan scan = new Scan();
scan.setFilter(new MessageDataFilter(c.getEnvironment(), System.currentTimeMillis(), prefixLength, topicMetadataCache, txVisibilityState));
return new LoggingInternalScanner("MessageDataFilter", "preCompact", new StoreScanner(store, store.getScanInfo(), scan, scanners, scanType, store.getSmallestReadPoint(), earliestPutTs), txVisibilityState);
}
use of org.apache.tephra.persist.TransactionVisibilityState in project cdap by caskdata.
the class MessageTableRegionObserver method preFlushScannerOpen.
@Override
public InternalScanner preFlushScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c, Store store, KeyValueScanner memstoreScanner, InternalScanner s) throws IOException {
LOG.info("preFlush, filter using MessageDataFilter");
TransactionVisibilityState txVisibilityState = txStateCache.getLatestState();
Scan scan = new Scan();
scan.setFilter(new MessageDataFilter(c.getEnvironment(), System.currentTimeMillis(), prefixLength, topicMetadataCache, txVisibilityState));
return new LoggingInternalScanner("MessageDataFilter", "preFlush", new StoreScanner(store, store.getScanInfo(), scan, Collections.singletonList(memstoreScanner), ScanType.COMPACT_DROP_DELETES, store.getSmallestReadPoint(), HConstants.OLDEST_TIMESTAMP), txVisibilityState);
}
use of org.apache.tephra.persist.TransactionVisibilityState in project cdap by caskdata.
the class MessageTableRegionObserver method preCompactScannerOpen.
@Override
public InternalScanner preCompactScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c, Store store, List<? extends KeyValueScanner> scanners, ScanType scanType, long earliestPutTs, InternalScanner s, CompactionRequest request) throws IOException {
LOG.info("preCompact, filter using MessageDataFilter");
TransactionVisibilityState txVisibilityState = txStateCache.getLatestState();
reloadPruneState(c.getEnvironment());
if (compactionState != null) {
// Record tx state before the compaction
compactionState.record(request, txVisibilityState);
}
Scan scan = new Scan();
scan.setFilter(new MessageDataFilter(c.getEnvironment(), System.currentTimeMillis(), prefixLength, topicMetadataCache, txVisibilityState));
return new LoggingInternalScanner("MessageDataFilter", "preCompact", new StoreScanner(store, store.getScanInfo(), scan, scanners, scanType, store.getSmallestReadPoint(), earliestPutTs), txVisibilityState);
}
use of org.apache.tephra.persist.TransactionVisibilityState in project cdap by caskdata.
the class HBaseQueueRegionObserver method start.
@Override
public void start(CoprocessorEnvironment env) {
if (env instanceof RegionCoprocessorEnvironment) {
HTableDescriptor tableDesc = ((RegionCoprocessorEnvironment) env).getRegion().getTableDesc();
String hTableName = tableDesc.getNameAsString();
String prefixBytes = tableDesc.getValue(HBaseQueueAdmin.PROPERTY_PREFIX_BYTES);
try {
// Default to SALT_BYTES for the older salted queue implementation.
this.prefixBytes = prefixBytes == null ? SaltedHBaseQueueStrategy.SALT_BYTES : Integer.parseInt(prefixBytes);
} catch (NumberFormatException e) {
// Shouldn't happen for table created by cdap.
LOG.error("Unable to parse value of '" + HBaseQueueAdmin.PROPERTY_PREFIX_BYTES + "' property. " + "Default to " + SaltedHBaseQueueStrategy.SALT_BYTES, e);
this.prefixBytes = SaltedHBaseQueueStrategy.SALT_BYTES;
}
namespaceId = HTableNameConverter.from(tableDesc).getNamespace();
appName = HBaseQueueAdmin.getApplicationName(hTableName);
flowName = HBaseQueueAdmin.getFlowName(hTableName);
Configuration conf = env.getConfiguration();
String hbaseNamespacePrefix = tableDesc.getValue(Constants.Dataset.TABLE_PREFIX);
final String sysConfigTablePrefix = HTableNameConverter.getSysConfigTablePrefix(hbaseNamespacePrefix);
txStateCacheSupplier = new DefaultTransactionStateCacheSupplier(sysConfigTablePrefix, conf);
txStateCache = txStateCacheSupplier.get();
txSnapshotSupplier = new Supplier<TransactionVisibilityState>() {
@Override
public TransactionVisibilityState get() {
return txStateCache.getLatestState();
}
};
String queueConfigTableId = HBaseQueueAdmin.getConfigTableName();
configTableName = HTableNameConverter.toTableName(hbaseNamespacePrefix, TableId.from(namespaceId, queueConfigTableId));
cConfReader = new CConfigurationReader(conf, sysConfigTablePrefix);
configCacheSupplier = createConfigCache(env);
configCache = configCacheSupplier.get();
}
}
use of org.apache.tephra.persist.TransactionVisibilityState in project cdap by caskdata.
the class MessageTableRegionObserver method preCompactScannerOpen.
@Override
public InternalScanner preCompactScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c, Store store, List<? extends KeyValueScanner> scanners, ScanType scanType, long earliestPutTs, InternalScanner s, CompactionRequest request) throws IOException {
LOG.info("preCompact, filter using MessageDataFilter");
TransactionVisibilityState txVisibilityState = txStateCache.getLatestState();
reloadPruneState(c.getEnvironment());
if (compactionState != null) {
// Record tx state before the compaction
compactionState.record(request, txVisibilityState);
}
Scan scan = new Scan();
scan.setFilter(new MessageDataFilter(c.getEnvironment(), System.currentTimeMillis(), prefixLength, topicMetadataCache, txVisibilityState));
return new LoggingInternalScanner("MessageDataFilter", "preCompact", new StoreScanner(store, store.getScanInfo(), scan, scanners, scanType, store.getSmallestReadPoint(), earliestPutTs), txVisibilityState);
}
Aggregations