private void logUnlockException(Throwable th, Optional<TargetedSweeperLock> maybeLock) { if (maybeLock.isPresent()) { log.info("Failed to unlock targeted sweep lock for {}.", SafeArg.of("shardStrategy", maybeLock.get().getShardAndStrategy().toText()), th); } else { log.info("Failed to unlock targeted sweep lock for sweep strategy {}.", SafeArg.of("sweepStrategy", sweepStrategy), th); } }
private void logException(Throwable th, Optional<TargetedSweeperLock> maybeLock) { if (maybeLock.isPresent()) { log.warn("Targeted sweep for {} failed and will be retried later.", SafeArg.of("shardStrategy", maybeLock.get().getShardAndStrategy().toText()), th); } else { log.warn("Targeted sweep for sweep strategy {} failed and will be retried later.", SafeArg.of("sweepStrategy", sweepStrategy), th); } }
private void progressTo(ShardAndStrategy shardStrategy, long newProgress) { if (newProgress < 0) { log.warn("Wasn't able to progress targeted sweep for {} since last swept timestamp {} is negative.", SafeArg.of("shardStrategy", shardStrategy.toText()), SafeArg.of("timestamp", newProgress)); return; } progress.updateLastSweptTimestamp(shardStrategy, newProgress); log.debug("Progressed last swept timestamp for {} to {}.", SafeArg.of("shardStrategy", shardStrategy.toText()), SafeArg.of("timestamp", newProgress)); }
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)); }
private void logUnlockException(Throwable th, Optional<TargetedSweeperLock> maybeLock) { if (maybeLock.isPresent()) { log.info("Failed to unlock targeted sweep lock for {}.", SafeArg.of("shardStrategy", maybeLock.get().getShardAndStrategy().toText()), th); } else { log.info("Failed to unlock targeted sweep lock for sweep strategy {}.", SafeArg.of("sweepStrategy", sweepStrategy), th); } }
private void logException(Throwable th, Optional<TargetedSweeperLock> maybeLock) { if (maybeLock.isPresent()) { log.warn("Targeted sweep for {} failed and will be retried later.", SafeArg.of("shardStrategy", maybeLock.get().getShardAndStrategy().toText()), th); } else { log.warn("Targeted sweep for sweep strategy {} failed and will be retried later.", SafeArg.of("sweepStrategy", sweepStrategy), th); } }
private void progressTo(ShardAndStrategy shardStrategy, long newProgress) { if (newProgress < 0) { log.warn("Wasn't able to progress targeted sweep for {} since last swept timestamp {} is negative.", SafeArg.of("shardStrategy", shardStrategy.toText()), SafeArg.of("timestamp", newProgress)); return; } progress.updateLastSweptTimestamp(shardStrategy, newProgress); log.debug("Progressed last swept timestamp for {} to {}.", SafeArg.of("shardStrategy", shardStrategy.toText()), SafeArg.of("timestamp", newProgress)); }
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)); }