Search in sources :

Example 1 with FileInputStreamPlus

use of org.apache.cassandra.io.util.FileInputStreamPlus in project cassandra by apache.

the class CommitLogUpgradeTestMaker method initialize.

public static void initialize() throws IOException, ConfigurationException {
    try (FileInputStreamPlus fis = new FileInputStreamPlus("CHANGES.txt")) {
        dataSource = ByteBuffer.allocateDirect((int) fis.getChannel().size());
        while (dataSource.hasRemaining()) {
            fis.getChannel().read(dataSource);
        }
        dataSource.flip();
    }
    SchemaLoader.loadSchema();
    SchemaLoader.createKeyspace(KEYSPACE, KeyspaceParams.simple(1), metadata);
}
Also used : FileInputStreamPlus(org.apache.cassandra.io.util.FileInputStreamPlus)

Example 2 with FileInputStreamPlus

use of org.apache.cassandra.io.util.FileInputStreamPlus in project cassandra by apache.

the class CommitLogUpgradeTest method testRestore.

public void testRestore(String location) throws IOException, InterruptedException {
    Properties prop = new Properties();
    prop.load(new FileInputStreamPlus(new File(location + File.pathSeparator() + PROPERTIES_FILE)));
    int hash = Integer.parseInt(prop.getProperty(HASH_PROPERTY));
    int cells = Integer.parseInt(prop.getProperty(CELLS_PROPERTY));
    String cfidString = prop.getProperty(CFID_PROPERTY);
    if (cfidString != null) {
        TableId tableId = TableId.fromString(cfidString);
        if (Schema.instance.getTableMetadata(tableId) == null)
            Schema.instance.load(KeyspaceMetadata.create(KEYSPACE, KeyspaceParams.simple(1), Tables.of(metadata.unbuild().id(tableId).build())));
    }
    Hasher hasher = new Hasher();
    CommitLogTestReplayer replayer = new CommitLogTestReplayer(hasher);
    File[] files = new File(location).tryList((file, name) -> name.endsWith(".log"));
    replayer.replayFiles(files);
    Assert.assertEquals(cells, hasher.cells);
    Assert.assertEquals(hash, hasher.hash);
}
Also used : TableId(org.apache.cassandra.schema.TableId) FileInputStreamPlus(org.apache.cassandra.io.util.FileInputStreamPlus) Properties(java.util.Properties) File(org.apache.cassandra.io.util.File)

Example 3 with FileInputStreamPlus

use of org.apache.cassandra.io.util.FileInputStreamPlus in project cassandra by apache.

the class CommitLogStressTest method initialize.

@BeforeClass
public static void initialize() throws IOException {
    try (FileInputStreamPlus fis = new FileInputStreamPlus("CHANGES.txt")) {
        dataSource = ByteBuffer.allocateDirect((int) fis.getChannel().size());
        while (dataSource.hasRemaining()) {
            fis.getChannel().read(dataSource);
        }
        dataSource.flip();
    }
    SchemaLoader.loadSchema();
    // leave def. blank to maintain old behaviour
    SchemaLoader.schemaDefinition("");
    CommitLog.instance.stopUnsafe(true);
}
Also used : FileInputStreamPlus(org.apache.cassandra.io.util.FileInputStreamPlus) BeforeClass(org.junit.BeforeClass)

Example 4 with FileInputStreamPlus

use of org.apache.cassandra.io.util.FileInputStreamPlus in project cassandra by apache.

the class BloomFilterSerializerBench method serializationTest.

@Benchmark
public void serializationTest() throws IOException {
    File file = FileUtils.createTempFile("bloomFilterTest-", ".dat");
    try {
        BloomFilter filter = (BloomFilter) FilterFactory.getFilter(numElemsInK * 1024, 0.01d);
        filter.add(wrap(testVal));
        DataOutputStreamPlus out = new FileOutputStreamPlus(file);
        if (oldBfFormat)
            SerializationsTest.serializeOldBfFormat(filter, out);
        else
            BloomFilterSerializer.serialize(filter, out);
        out.close();
        filter.close();
        FileInputStreamPlus in = new FileInputStreamPlus(file);
        BloomFilter filter2 = BloomFilterSerializer.deserialize(in, oldBfFormat);
        FileUtils.closeQuietly(in);
        filter2.close();
    } finally {
        file.tryDelete();
    }
}
Also used : FileInputStreamPlus(org.apache.cassandra.io.util.FileInputStreamPlus) File(org.apache.cassandra.io.util.File) FileOutputStreamPlus(org.apache.cassandra.io.util.FileOutputStreamPlus) BloomFilter(org.apache.cassandra.utils.BloomFilter) DataOutputStreamPlus(org.apache.cassandra.io.util.DataOutputStreamPlus) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Example 5 with FileInputStreamPlus

use of org.apache.cassandra.io.util.FileInputStreamPlus in project cassandra by apache.

the class CompressorPerformance method main.

public static void main(String[] args) throws IOException {
    try (FileInputStreamPlus fis = new FileInputStreamPlus("CHANGES.txt")) {
        int len = (int) fis.getChannel().size();
        dataSource = ByteBuffer.allocateDirect(len);
        while (dataSource.hasRemaining()) {
            fis.getChannel().read(dataSource);
        }
        dataSource.flip();
    }
    testPerformances();
}
Also used : FileInputStreamPlus(org.apache.cassandra.io.util.FileInputStreamPlus)

Aggregations

FileInputStreamPlus (org.apache.cassandra.io.util.FileInputStreamPlus)16 Test (org.junit.Test)7 File (org.apache.cassandra.io.util.File)5 FileOutputStreamPlus (org.apache.cassandra.io.util.FileOutputStreamPlus)3 InetAddressAndPort (org.apache.cassandra.locator.InetAddressAndPort)2 DataInputStream (java.io.DataInputStream)1 Properties (java.util.Properties)1 CRC32 (java.util.zip.CRC32)1 CheckedInputStream (java.util.zip.CheckedInputStream)1 DecoratedKey (org.apache.cassandra.db.DecoratedKey)1 CassandraOutgoingFile (org.apache.cassandra.db.streaming.CassandraOutgoingFile)1 Murmur3Partitioner (org.apache.cassandra.dht.Murmur3Partitioner)1 DataOutputStreamPlus (org.apache.cassandra.io.util.DataOutputStreamPlus)1 SyncNodePair (org.apache.cassandra.repair.SyncNodePair)1 TableId (org.apache.cassandra.schema.TableId)1 BloomFilter (org.apache.cassandra.utils.BloomFilter)1 BeforeClass (org.junit.BeforeClass)1 Benchmark (org.openjdk.jmh.annotations.Benchmark)1