Search in sources :

Example 1 with SimpleFileInput

use of org.apache.ignite.internal.processors.cache.persistence.wal.io.SimpleFileInput in project ignite by apache.

the class IgniteDataIntegrityTests method setUp.

/**
 */
@Before
public void setUp() throws Exception {
    File file = File.createTempFile("integrity", "dat");
    file.deleteOnExit();
    expBuf = new ByteBufferExpander(1024, ByteOrder.BIG_ENDIAN);
    FileIOFactory factory = new RandomAccessFileIOFactory();
    fileInput = new SimpleFileInput(factory.create(file), expBuf);
    ByteBuffer buf = ByteBuffer.allocate(1024);
    ThreadLocalRandom curr = ThreadLocalRandom.current();
    for (int i = 0; i < 1024; i += 16) {
        buf.putInt(curr.nextInt());
        buf.putInt(curr.nextInt());
        buf.putInt(curr.nextInt());
        buf.position(i);
        buf.putInt(FastCrc.calcCrc(buf, 12));
    }
    buf.rewind();
    fileInput.io().writeFully(buf);
    fileInput.io().force();
}
Also used : ByteBufferExpander(org.apache.ignite.internal.processors.cache.persistence.wal.ByteBufferExpander) RandomAccessFileIOFactory(org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory) FileIOFactory(org.apache.ignite.internal.processors.cache.persistence.file.FileIOFactory) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) SimpleFileInput(org.apache.ignite.internal.processors.cache.persistence.wal.io.SimpleFileInput) File(java.io.File) ByteBuffer(java.nio.ByteBuffer) RandomAccessFileIOFactory(org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory) Before(org.junit.Before)

Aggregations

File (java.io.File)1 ByteBuffer (java.nio.ByteBuffer)1 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)1 FileIOFactory (org.apache.ignite.internal.processors.cache.persistence.file.FileIOFactory)1 RandomAccessFileIOFactory (org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory)1 ByteBufferExpander (org.apache.ignite.internal.processors.cache.persistence.wal.ByteBufferExpander)1 SimpleFileInput (org.apache.ignite.internal.processors.cache.persistence.wal.io.SimpleFileInput)1 Before (org.junit.Before)1