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