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);
}
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);
}
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);
}
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();
}
}
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();
}
Aggregations