use of org.apache.cassandra.locator.RangesAtEndpoint in project cassandra by apache.
the class EntireSSTableStreamingCorrectFilesCountTest method defineSchemaAndPrepareSSTable.
@BeforeClass
public static void defineSchemaAndPrepareSSTable() {
SchemaLoader.prepareServer();
SchemaLoader.createKeyspace(KEYSPACE, KeyspaceParams.simple(1), SchemaLoader.standardCFMD(KEYSPACE, CF_STANDARD).compaction(CompactionParams.lcs(Collections.emptyMap())).partitioner(ByteOrderedPartitioner.instance));
Keyspace keyspace = Keyspace.open(KEYSPACE);
store = keyspace.getColumnFamilyStore(CF_STANDARD);
// insert data and compact to a single sstable
CompactionManager.instance.disableAutoCompaction();
for (int j = 0; j < 10; j++) {
new RowUpdateBuilder(store.metadata(), j, String.valueOf(j)).clustering("0").add("val", ByteBufferUtil.EMPTY_BYTE_BUFFER).build().applyUnsafe();
}
store.forceBlockingFlush();
CompactionManager.instance.performMaximal(store, false);
sstable = store.getLiveSSTables().iterator().next();
Token start = ByteOrderedPartitioner.instance.getTokenFactory().fromString(Long.toHexString(0));
Token end = ByteOrderedPartitioner.instance.getTokenFactory().fromString(Long.toHexString(100));
rangesAtEndpoint = RangesAtEndpoint.toDummyList(Collections.singleton(new Range<>(start, end)));
}
use of org.apache.cassandra.locator.RangesAtEndpoint in project cassandra by apache.
the class EntireSSTableStreamingCorrectFilesCountTest method test.
@Test
public void test() throws Exception {
FileCountingStreamEventHandler streamEventHandler = new FileCountingStreamEventHandler();
StreamSession session = setupStreamingSessionForTest(streamEventHandler);
Collection<OutgoingStream> outgoingStreams = store.getStreamManager().createOutgoingStreams(session, rangesAtEndpoint, NO_PENDING_REPAIR, PreviewKind.NONE);
session.addTransferStreams(outgoingStreams);
AsyncStreamingOutputPlus out = constructDataOutputStream();
for (OutgoingStream outgoingStream : outgoingStreams) {
outgoingStream.write(session, out, MessagingService.VERSION_40);
// verify hardlinks are removed after streaming
Descriptor descriptor = ((CassandraOutgoingFile) outgoingStream).getRef().get().descriptor;
assertTrue(descriptor.getTemporaryFiles().isEmpty());
}
int totalNumberOfFiles = session.transfers.get(store.metadata.id).getTotalNumberOfFiles();
assertEquals(ComponentManifest.create(sstable.descriptor).components().size(), totalNumberOfFiles);
assertEquals(streamEventHandler.fileNames.size(), totalNumberOfFiles);
}
Aggregations