Search in sources :

Example 1 with PhysicalFlushableChannel

use of org.neo4j.kernel.impl.transaction.log.PhysicalFlushableChannel in project neo4j by neo4j.

the class SimpleFileStorage method writeState.

@Override
public void writeState(T state) throws IOException {
    fileSystem.mkdirs(file.getParentFile());
    fileSystem.deleteFile(file);
    try (FlushableChannel channel = new PhysicalFlushableChannel(fileSystem.create(file))) {
        marshal.marshal(state, channel);
    }
}
Also used : FlushableChannel(org.neo4j.kernel.impl.transaction.log.FlushableChannel) PhysicalFlushableChannel(org.neo4j.kernel.impl.transaction.log.PhysicalFlushableChannel) PhysicalFlushableChannel(org.neo4j.kernel.impl.transaction.log.PhysicalFlushableChannel)

Example 2 with PhysicalFlushableChannel

use of org.neo4j.kernel.impl.transaction.log.PhysicalFlushableChannel in project neo4j by neo4j.

the class RecoveryProtocol method writeHeader.

private static void writeHeader(FileSystemAbstraction fileSystem, File file, SegmentHeader header) throws IOException {
    try (StoreChannel channel = fileSystem.open(file, "rw")) {
        channel.position(0);
        PhysicalFlushableChannel writer = new PhysicalFlushableChannel(channel, SegmentHeader.SIZE);
        headerMarshal.marshal(header, writer);
        writer.prepareForFlush().flush();
    }
}
Also used : PhysicalFlushableChannel(org.neo4j.kernel.impl.transaction.log.PhysicalFlushableChannel) StoreChannel(org.neo4j.io.fs.StoreChannel)

Example 3 with PhysicalFlushableChannel

use of org.neo4j.kernel.impl.transaction.log.PhysicalFlushableChannel in project neo4j by neo4j.

the class CheckTxLogsTest method writeContent.

private void writeContent(File log, ThrowingConsumer<TransactionLogWriter, IOException> consumer) throws IOException {
    FileSystemAbstraction fs = ensureLogExists(log);
    try (StoreChannel channel = fs.open(log, "rw");
        LogVersionedStoreChannel versionedChannel = new PhysicalLogVersionedStoreChannel(channel, 0, (byte) 0);
        PhysicalFlushableChannel writableLogChannel = new PhysicalFlushableChannel(versionedChannel)) {
        long offset = channel.size();
        channel.position(offset);
        consumer.accept(new TransactionLogWriter(new LogEntryWriter(writableLogChannel)));
    }
}
Also used : FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) LogVersionedStoreChannel(org.neo4j.kernel.impl.transaction.log.LogVersionedStoreChannel) PhysicalLogVersionedStoreChannel(org.neo4j.kernel.impl.transaction.log.PhysicalLogVersionedStoreChannel) PhysicalFlushableChannel(org.neo4j.kernel.impl.transaction.log.PhysicalFlushableChannel) LogVersionedStoreChannel(org.neo4j.kernel.impl.transaction.log.LogVersionedStoreChannel) StoreChannel(org.neo4j.io.fs.StoreChannel) PhysicalLogVersionedStoreChannel(org.neo4j.kernel.impl.transaction.log.PhysicalLogVersionedStoreChannel) PhysicalLogVersionedStoreChannel(org.neo4j.kernel.impl.transaction.log.PhysicalLogVersionedStoreChannel) TransactionLogWriter(org.neo4j.kernel.impl.transaction.log.TransactionLogWriter) LogEntryWriter(org.neo4j.kernel.impl.transaction.log.entry.LogEntryWriter)

Example 4 with PhysicalFlushableChannel

use of org.neo4j.kernel.impl.transaction.log.PhysicalFlushableChannel in project neo4j by neo4j.

the class RecoveryProtocolTest method createLogFile.

private void createLogFile(EphemeralFileSystemAbstraction fsa, long prevFileLastIndex, long fileNameVersion, long headerVersion, long prevIndex, long prevTerm) throws IOException {
    StoreChannel channel = fsa.open(fileNames.getForVersion(fileNameVersion), "w");
    PhysicalFlushableChannel writer = new PhysicalFlushableChannel(channel);
    headerMarshal.marshal(new SegmentHeader(prevFileLastIndex, headerVersion, prevIndex, prevTerm), writer);
    writer.prepareForFlush().flush();
    channel.close();
}
Also used : PhysicalFlushableChannel(org.neo4j.kernel.impl.transaction.log.PhysicalFlushableChannel) StoreChannel(org.neo4j.io.fs.StoreChannel)

Example 5 with PhysicalFlushableChannel

use of org.neo4j.kernel.impl.transaction.log.PhysicalFlushableChannel in project neo4j by neo4j.

the class SegmentFile method getOrCreateWriter.

private synchronized PhysicalFlushableChannel getOrCreateWriter() throws IOException {
    if (bufferedWriter == null) {
        if (!refCount.increase()) {
            throw new IOException("Writer has been closed");
        }
        StoreChannel channel = fileSystem.open(file, "rw");
        channel.position(channel.size());
        bufferedWriter = new PhysicalFlushableChannel(channel);
    }
    return bufferedWriter;
}
Also used : PhysicalFlushableChannel(org.neo4j.kernel.impl.transaction.log.PhysicalFlushableChannel) StoreChannel(org.neo4j.io.fs.StoreChannel) IOException(java.io.IOException)

Aggregations

PhysicalFlushableChannel (org.neo4j.kernel.impl.transaction.log.PhysicalFlushableChannel)6 StoreChannel (org.neo4j.io.fs.StoreChannel)5 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)2 FlushableChannel (org.neo4j.kernel.impl.transaction.log.FlushableChannel)2 File (java.io.File)1 IOException (java.io.IOException)1 Map (java.util.Map)1 Test (org.junit.Test)1 DefaultFileSystemAbstraction (org.neo4j.io.fs.DefaultFileSystemAbstraction)1 CountsKey (org.neo4j.kernel.impl.store.counts.keys.CountsKey)1 LogVersionedStoreChannel (org.neo4j.kernel.impl.transaction.log.LogVersionedStoreChannel)1 PhysicalLogVersionedStoreChannel (org.neo4j.kernel.impl.transaction.log.PhysicalLogVersionedStoreChannel)1 ReadAheadChannel (org.neo4j.kernel.impl.transaction.log.ReadAheadChannel)1 TransactionLogWriter (org.neo4j.kernel.impl.transaction.log.TransactionLogWriter)1 LogEntryWriter (org.neo4j.kernel.impl.transaction.log.entry.LogEntryWriter)1