use of org.apache.cassandra.io.util.FileInputStreamPlus in project cassandra by apache.
the class LegacySSTableTest method copyFile.
private static void copyFile(File cfDir, File file) throws IOException {
byte[] buf = new byte[65536];
if (file.isFile()) {
File target = new File(cfDir, file.name());
int rd;
try (FileInputStreamPlus is = new FileInputStreamPlus(file);
FileOutputStreamPlus os = new FileOutputStreamPlus(target)) {
while ((rd = is.read(buf)) >= 0) os.write(buf, 0, rd);
}
}
}
use of org.apache.cassandra.io.util.FileInputStreamPlus in project cassandra by apache.
the class SerializationsTest method testSyncCompleteRead.
@Test
public void testSyncCompleteRead() throws IOException {
if (EXECUTE_WRITES)
testSyncCompleteWrite();
InetAddressAndPort src = InetAddressAndPort.getByNameOverrideDefaults("127.0.0.2", PORT);
InetAddressAndPort dest = InetAddressAndPort.getByNameOverrideDefaults("127.0.0.3", PORT);
SyncNodePair nodes = new SyncNodePair(src, dest);
try (FileInputStreamPlus in = getInput("service.SyncComplete.bin")) {
// success
SyncResponse message = SyncResponse.serializer.deserialize(in, getVersion());
assert DESC.equals(message.desc);
System.out.println(nodes);
System.out.println(message.nodes);
assert nodes.equals(message.nodes);
assert message.success;
// fail
message = SyncResponse.serializer.deserialize(in, getVersion());
assert DESC.equals(message.desc);
assert nodes.equals(message.nodes);
assert !message.success;
}
}
use of org.apache.cassandra.io.util.FileInputStreamPlus in project cassandra by apache.
the class SerializationsTest method testBloomFilterRead1000.
@Test
public void testBloomFilterRead1000() throws IOException {
if (EXECUTE_WRITES) {
testBloomFilterWrite1000(false);
testBloomFilterWrite1000(true);
}
try (FileInputStreamPlus in = getInput("4.0", "utils.BloomFilter1000.bin");
IFilter filter = BloomFilterSerializer.deserialize(in, false)) {
boolean present;
for (int i = 0; i < 1000; i++) {
present = filter.isPresent(Util.dk(Int32Type.instance.decompose(i)));
Assert.assertTrue(present);
}
for (int i = 1000; i < 2000; i++) {
present = filter.isPresent(Util.dk(Int32Type.instance.decompose(i)));
Assert.assertFalse(present);
}
}
try (FileInputStreamPlus in = getInput("3.0", "utils.BloomFilter1000.bin");
IFilter filter = BloomFilterSerializer.deserialize(in, true)) {
boolean present;
for (int i = 0; i < 1000; i++) {
present = filter.isPresent(Util.dk(Int32Type.instance.decompose(i)));
Assert.assertTrue(present);
}
for (int i = 1000; i < 2000; i++) {
present = filter.isPresent(Util.dk(Int32Type.instance.decompose(i)));
Assert.assertFalse(present);
}
}
}
use of org.apache.cassandra.io.util.FileInputStreamPlus in project cassandra by apache.
the class VerifyTest method simpleFullChecksum.
protected long simpleFullChecksum(String filename) throws IOException {
try (FileInputStreamPlus inputStream = new FileInputStreamPlus(filename)) {
CRC32 checksum = new CRC32();
CheckedInputStream cinStream = new CheckedInputStream(inputStream, checksum);
byte[] b = new byte[128];
while (cinStream.read(b) >= 0) {
}
return cinStream.getChecksum().getValue();
}
}
use of org.apache.cassandra.io.util.FileInputStreamPlus in project cassandra by apache.
the class TTLTest method copyFile.
private static void copyFile(File src, File dest) throws IOException {
byte[] buf = new byte[65536];
if (src.isFile()) {
File target = new File(dest, src.name());
int rd;
FileInputStreamPlus is = new FileInputStreamPlus(src);
FileOutputStreamPlus os = new FileOutputStreamPlus(target);
while ((rd = is.read(buf)) >= 0) os.write(buf, 0, rd);
os.close();
}
}
Aggregations