Skip to content

Commit

Permalink
SQUASH – fix handling of intentionally empty test data directories
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelsembwever committed Nov 27, 2024
1 parent 7e4d9e0 commit b97512b
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions test/unit/org/apache/cassandra/io/sstable/LegacySSTableTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,12 @@ public void tearDown()
*/
protected Descriptor getDescriptor(String legacyVersion, String table) throws IOException
{
Path file = Files.list(getTableDir(legacyVersion, table).toPath()).findFirst().orElseThrow(() -> new RuntimeException(String.format("No files for verion=%s and table=%s", legacyVersion, table)));
return Descriptor.fromFilename(new File(file));
Path file = Files.list(getTableDir(legacyVersion, table).toPath())
.findFirst()
.orElseThrow(() -> new RuntimeException(String.format("No files for verion=%s and table=%s", legacyVersion, table)));

// ignore intentionally empty directory .keep files
return ".keep".equals(file.toFile().getName()) ? null : Descriptor.fromFilename(new File(file));
}

@Test
Expand Down Expand Up @@ -424,17 +428,21 @@ private void streamLegacyTable(String tablePattern, String legacyVersion) throws
{
String table = String.format(tablePattern, legacyVersion);
Descriptor descriptor = getDescriptor(legacyVersion, table);
SSTableReader sstable = descriptor.formatType.info.getReaderFactory().open(getDescriptor(legacyVersion, table));
IPartitioner p = sstable.getPartitioner();
List<Range<Token>> ranges = new ArrayList<>();
ranges.add(new Range<>(p.getMinimumToken(), p.getToken(ByteBufferUtil.bytes("100"))));
ranges.add(new Range<>(p.getToken(ByteBufferUtil.bytes("100")), p.getMinimumToken()));
List<OutgoingStream> streams = Lists.newArrayList(new CassandraOutgoingFile(StreamOperation.OTHER,
sstable.ref(),
sstable.getPositionsForRanges(ranges),
ranges,
sstable.estimatedKeysForRanges(ranges)));
new StreamPlan(StreamOperation.OTHER).transferStreams(FBUtilities.getBroadcastAddressAndPort(), streams).execute().get();
if (null != descriptor) {
SSTableReader sstable = descriptor.formatType.info.getReaderFactory().open(descriptor);
IPartitioner p = sstable.getPartitioner();
List<Range<Token>> ranges = new ArrayList<>();
ranges.add(new Range<>(p.getMinimumToken(), p.getToken(ByteBufferUtil.bytes("100"))));
ranges.add(new Range<>(p.getToken(ByteBufferUtil.bytes("100")), p.getMinimumToken()));

List<OutgoingStream> streams = Lists.newArrayList(new CassandraOutgoingFile(StreamOperation.OTHER,
sstable.ref(),
sstable.getPositionsForRanges(ranges),
ranges,
sstable.estimatedKeysForRanges(ranges)));

new StreamPlan(StreamOperation.OTHER).transferStreams(FBUtilities.getBroadcastAddressAndPort(), streams).execute().get();
}
}

public static void truncateLegacyTables(String legacyVersion)
Expand Down

0 comments on commit b97512b

Please sign in to comment.