Search in sources :

Example 31 with RangesAtEndpoint

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)));
}
Also used : RowUpdateBuilder(org.apache.cassandra.db.RowUpdateBuilder) Keyspace(org.apache.cassandra.db.Keyspace) Token(org.apache.cassandra.dht.Token) RangesAtEndpoint(org.apache.cassandra.locator.RangesAtEndpoint) BeforeClass(org.junit.BeforeClass)

Example 32 with RangesAtEndpoint

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);
}
Also used : CassandraOutgoingFile(org.apache.cassandra.db.streaming.CassandraOutgoingFile) AsyncStreamingOutputPlus(org.apache.cassandra.net.AsyncStreamingOutputPlus) Descriptor(org.apache.cassandra.io.sstable.Descriptor) RangesAtEndpoint(org.apache.cassandra.locator.RangesAtEndpoint) Test(org.junit.Test)

Aggregations

RangesAtEndpoint (org.apache.cassandra.locator.RangesAtEndpoint)32 Token (org.apache.cassandra.dht.Token)22 Range (org.apache.cassandra.dht.Range)20 Replica (org.apache.cassandra.locator.Replica)17 SSTableReader (org.apache.cassandra.io.sstable.format.SSTableReader)10 EndpointsByReplica (org.apache.cassandra.locator.EndpointsByReplica)10 ArrayList (java.util.ArrayList)9 List (java.util.List)9 Test (org.junit.Test)9 Logger (org.slf4j.Logger)9 LoggerFactory (org.slf4j.LoggerFactory)9 Collection (java.util.Collection)8 DatabaseDescriptor (org.apache.cassandra.config.DatabaseDescriptor)8 InetAddressAndPort (org.apache.cassandra.locator.InetAddressAndPort)8 VisibleForTesting (com.google.common.annotations.VisibleForTesting)7 Set (java.util.Set)7 UUID (java.util.UUID)7 Replica.fullReplica (org.apache.cassandra.locator.Replica.fullReplica)7 IOException (java.io.IOException)6 Replica.transientReplica (org.apache.cassandra.locator.Replica.transientReplica)6