Skip to content

Commit

Permalink
Use shard UUID instead of ID in ShardCompactionManager
Browse files Browse the repository at this point in the history
  • Loading branch information
electrum committed Oct 7, 2015
1 parent 84cd71a commit ca21c60
Showing 1 changed file with 4 additions and 5 deletions.
Expand Up @@ -95,7 +95,7 @@ public class ShardCompactionManager
private final AtomicBoolean shutdown = new AtomicBoolean();

// Tracks shards that are scheduled for compaction so that we do not schedule them more than once
private final Set<Long> shardsInProgress = newConcurrentHashSet();
private final Set<UUID> shardsInProgress = newConcurrentHashSet();
private final BlockingQueue<CompactionSet> compactionQueue = new LinkedBlockingQueue<>();

private final MetadataDao metadataDao;
Expand Down Expand Up @@ -225,7 +225,7 @@ private void discoverShards()

Set<ShardMetadata> shards = shardMetadata.stream()
.filter(this::needsCompaction)
.filter(shard -> !shardsInProgress.contains(shard.getShardId()))
.filter(shard -> !shardsInProgress.contains(shard.getShardUuid()))
.collect(toSet());

if (shards.size() <= 1) {
Expand Down Expand Up @@ -310,7 +310,7 @@ private void addToCompactionQueue(CompactionSetCreator compactionSetCreator, lon
}

compactionSet.getShardsToCompact().stream()
.map(ShardMetadata::getShardId)
.map(ShardMetadata::getShardUuid)
.forEach(shardsInProgress::add);

compactionQueue.add(compactionSet);
Expand Down Expand Up @@ -370,7 +370,6 @@ public CompactionJob(CompactionSet compactionSet)
public void run()
{
Set<UUID> shardUuids = compactionSet.getShardsToCompact().stream().map(ShardMetadata::getShardUuid).collect(toSet());
Set<Long> shardIds = compactionSet.getShardsToCompact().stream().map(ShardMetadata::getShardId).collect(toSet());

try {
TableMetadata tableMetadata = getTableMetadata(compactionSet.getTableId());
Expand All @@ -381,7 +380,7 @@ public void run()
throw Throwables.propagate(e);
}
finally {
shardsInProgress.removeAll(shardIds);
shardsInProgress.removeAll(shardUuids);
}
}

Expand Down

0 comments on commit ca21c60

Please sign in to comment.