private void assertProgressUpdatedToTimestamp(long ts, int shard) { assertThat(progress.getLastSweptTimestamp(ShardAndStrategy.conservative(shard))).isEqualTo(ts); }
public void runIterationOfTargetedSweep() { targetedSweeper.get().sweepNextBatch(ShardAndStrategy.conservative(0)); targetedSweeper.get().sweepNextBatch(ShardAndStrategy.thorough(0)); }
public static Optional<TargetedSweeperLock> tryAcquire(int shard, TableMetadataPersistence.SweepStrategy strategy, TimelockService timeLock) { ShardAndStrategy shardStrategy = ShardAndStrategy.of(shard, strategy); LockDescriptor lock = StringLockDescriptor.of(shardStrategy.toText()); // We do not want the timeout to be too low to avoid a race condition where we give up too soon LockRequest request = LockRequest.of(ImmutableSet.of(lock), 100L); return timeLock.lock(request) .getTokenOrEmpty() .map(lockToken -> new TargetedSweeperLock(shardStrategy, timeLock, lockToken)); }
@Value.Check void allowOnlyConservativeAndThorough() { Preconditions.checkArgument(isConservative() || isThorough(), "Sweep strategy should be CONSERVATIVE or " + "THOROUGH, but it is %s instead.", strategy()); }
private SweepBatch readThorough(long partition, long minExclusive, long maxExclusive) { return sweepableCells.getBatchForPartition(thorough(shardThor), partition, minExclusive, maxExclusive); }
private byte[] computeRowBytes(ShardAndStrategy shardStrategy, long coarsePartition) { SweepableTimestampsTable.SweepableTimestampsRow row = SweepableTimestampsTable.SweepableTimestampsRow.of( shardStrategy.shard(), coarsePartition, PersistableBoolean.of(shardStrategy.isConservative()).persistToBytes()); return row.persistToBytes(); }
public static ShardAndStrategy conservative(int shard) { return ShardAndStrategy.of(shard, TableMetadataPersistence.SweepStrategy.CONSERVATIVE); }
public boolean isConservative() { return strategy() == TableMetadataPersistence.SweepStrategy.CONSERVATIVE; }
private void updateWriteMetrics(Map<PartitionInfo, List<WriteInfo>> partitionedWrites) { maybeMetrics.ifPresent(metrics -> partitionedWrites.forEach((info, writes) -> metrics.updateEnqueuedWrites(ShardAndStrategy.fromInfo(info), writes.size()))); }
public void updateProgressForShard(ShardAndStrategy shardStrategy, long lastSweptTs) { getMetrics(shardStrategy).updateProgressForShard(shardStrategy.shard(), lastSweptTs); }
private Cell cellForShard(ShardAndStrategy shardAndStrategy) { SweepShardProgressTable.SweepShardProgressRow row = SweepShardProgressTable.SweepShardProgressRow.of( shardAndStrategy.shard(), PersistableBoolean.of(shardAndStrategy.isConservative()).persistToBytes()); return Cell.create(row.persistToBytes(), SweepShardProgressTable.SweepShardProgressNamedColumn.VALUE.getShortName()); }
@Value.Check void allowOnlyConservativeAndThorough() { Preconditions.checkArgument(isConservative() || isThorough(), "Sweep strategy should be CONSERVATIVE or " + "THOROUGH, but it is %s instead.", strategy()); }
public static ShardAndStrategy thorough(int shard) { return ShardAndStrategy.of(shard, TableMetadataPersistence.SweepStrategy.THOROUGH); }
public boolean isThorough() { return strategy() == TableMetadataPersistence.SweepStrategy.THOROUGH; }
private void updateWriteMetrics(Map<PartitionInfo, List<WriteInfo>> partitionedWrites) { maybeMetrics.ifPresent(metrics -> partitionedWrites.forEach((info, writes) -> metrics.updateEnqueuedWrites(ShardAndStrategy.fromInfo(info), writes.size()))); }
public void updateProgressForShard(ShardAndStrategy shardStrategy, long lastSweptTs) { getMetrics(shardStrategy).updateProgressForShard(shardStrategy.shard(), lastSweptTs); }
private SweepBatch readConservative(int shard, long partition, long minExclusive, long maxExclusive) { return sweepableCells.getBatchForPartition(conservative(shard), partition, minExclusive, maxExclusive); }