@Override public void flush() { if (_flushable) { ((MappedByteBuffer) _buffer).force(); } }
@Override public Bytes flush() { ((MappedByteBuffer) buffer).force(); return this; }
/** * This method forces all data cached in memory but not yet stored in the file, * to be stored in it. */ protected synchronized void sync() { if (byteBuffer != null) { byteBuffer.force(); } } }
/** * Flushes the mapped buffer to disk. */ public void flush() { buffer.force(); }
@Override public void close() { buffer.force(); buffer = null; }
@Override public void flush() { mappedBuffer.force(); }
public void force() { if (!unmapped) buffer.force(); }
@Override public void force(boolean metaData) throws IOException { mapped.force(); file.getFD().sync(); }
@Override public void force(boolean metaData) throws IOException { mapped.force(); file.getFD().sync(); }
public int flush() { final int value = wrotePosition.get(); try { if (fileChannel.position() != 0) { fileChannel.force(false); } else { mappedByteBuffer.force(); } } catch (IOException e) { throw new RuntimeException("flush segment failed. segment: " + fileName, e); } return value; }
public static MappedByteBuffer expandBuffer(String filename, MappedByteBuffer buffer, long newSize) { buffer.force(); int oldPosition = buffer.position(); try (RandomAccessFile raf = new RandomAccessFile(filename, "rw")) { raf.setLength(newSize); buffer = raf.getChannel().map(FileChannel.MapMode.READ_WRITE, 0, raf.length()); buffer.position(oldPosition); return buffer; } catch (IOException e) { throw new RuntimeException(e); } }
public void signalReady() { markFile.signalReady(VERSION_READY); markFile.mappedByteBuffer().force(); }
public void signalFailedStart() { markFile.signalReady(VERSION_FAILED); markFile.mappedByteBuffer().force(); }
@Override public void flush() { if (isClosed()) throw new IllegalStateException("already closed"); try { if (!segments.isEmpty() && segments.get(0) instanceof MappedByteBuffer) { for (ByteBuffer bb : segments) { ((MappedByteBuffer) bb).force(); } } writeHeader(raFile, raFile.length(), segmentSizeInBytes); // this could be necessary too // http://stackoverflow.com/q/14011398/194609 raFile.getFD().sync(); // equivalent to raFile.getChannel().force(true); } catch (Exception ex) { throw new RuntimeException(ex); } }
public void flush() { long beginTime = System.currentTimeMillis(); if (this.mappedFile.hold()) { this.indexHeader.updateByteBuffer(); this.mappedByteBuffer.force(); this.mappedFile.release(); log.info("flush index file eclipse time(ms) " + (System.currentTimeMillis() - beginTime)); } }
public void flush() { this.mappedByteBuffer.putLong(0, this.physicMsgTimestamp); this.mappedByteBuffer.putLong(8, this.logicsMsgTimestamp); this.mappedByteBuffer.putLong(16, this.indexMsgTimestamp); this.mappedByteBuffer.force(); }
/** * Record the fact that a node has voted in a current election for a candidate so it can survive a restart. * * @param candidateTermId to record that a vote has taken place. */ public void candidateTermId(final long candidateTermId) { buffer.putLongVolatile(MarkFileHeaderEncoder.candidateTermIdEncodingOffset(), candidateTermId); markFile.mappedByteBuffer().force(); }
public void memberId(final int memberId) { buffer.putIntVolatile(MarkFileHeaderEncoder.memberIdEncodingOffset(), memberId); markFile.mappedByteBuffer().force(); }
/** * @return The current flushed position */ public int flush(final int flushLeastPages) { if (this.isAbleToFlush(flushLeastPages)) { if (this.hold()) { int value = getReadPosition(); try { //We only append data to fileChannel or mappedByteBuffer, never both. if (writeBuffer != null || this.fileChannel.position() != 0) { this.fileChannel.force(false); } else { this.mappedByteBuffer.force(); } } catch (Throwable e) { log.error("Error occurred when force data to disk.", e); } this.flushedPosition.set(value); this.release(); } else { log.warn("in flush, hold failed, flush offset = " + this.flushedPosition.get()); this.flushedPosition.set(getReadPosition()); } } return this.getFlushedPosition(); }