private void closeRecordingSegment() { IoUtil.unmap(mappedSegmentBuffer); mappedSegmentBuffer = null; }
public void close() { if (!isClosed) { if (null != mappedBuffer) { IoUtil.unmap(mappedBuffer); } isClosed = true; } }
/** * Unmap a {@link ByteBuffer} without waiting for the next GC cycle if its memory mapped. * * @param buffer to be unmapped. */ public static void unmap(final ByteBuffer buffer) { if (buffer instanceof MappedByteBuffer) { unmap((MappedByteBuffer)buffer); } }
private void unmap() { IoUtil.unmap(fileChannel, addressOffset, capacity); } }
/** * Free up resources but don't delete files in case they are required for debugging. */ public void close() { final MappedByteBuffer lossReportBuffer = this.lossReportBuffer; this.lossReportBuffer = null; IoUtil.unmap(lossReportBuffer); final MappedByteBuffer cncByteBuffer = this.cncByteBuffer; this.cncByteBuffer = null; IoUtil.unmap(cncByteBuffer); super.close(); }
public boolean free() { if (null != mappedBuffers) { for (final MappedByteBuffer buffer : mappedBuffers) { IoUtil.unmap(buffer); } mappedBuffers = null; } if (null != logFile) { if (!logFile.delete()) { return false; } logFile = null; } return true; }
public void close() { CloseHelper.close(fileChannel); for (final MappedByteBuffer buffer : mappedByteBuffers) { IoUtil.unmap(buffer); } }
/** * Clean up all resources that the client uses to communicate with the Media Driver. */ public void close() { final MappedByteBuffer cncByteBuffer = this.cncByteBuffer; this.cncByteBuffer = null; IoUtil.unmap(cncByteBuffer); super.close(); }
public void close() { if (!isClosed) { isClosed = true; CloseHelper.close(catalogChannel); IoUtil.unmap(catalogByteBuffer); } }
/** * Is a media driver active in the given directory? * * @param directory to check * @param driverTimeoutMs for the driver liveness check. * @param logger for feedback as liveness checked. * @return true if a driver is active or false if not. */ public static boolean isDriverActive( final File directory, final long driverTimeoutMs, final Consumer<String> logger) { final File cncFile = new File(directory, CncFileDescriptor.CNC_FILE); if (cncFile.exists() && cncFile.length() > 0) { logger.accept("INFO: Aeron CnC file exists: " + cncFile); final MappedByteBuffer cncByteBuffer = IoUtil.mapExistingFile(cncFile, "CnC file"); try { return isDriverActive(driverTimeoutMs, logger, cncByteBuffer); } finally { IoUtil.unmap(cncByteBuffer); } } return false; }
/** * Read the error log to a given {@link PrintStream} * * @param out to write the error log contents to. * @return the number of observations from the error log. */ public int saveErrorLog(final PrintStream out) { final MappedByteBuffer cncByteBuffer = mapExistingCncFile(null); try { return saveErrorLog(out, cncByteBuffer); } finally { IoUtil.unmap(cncByteBuffer); } }
/** * Is a media driver active in the current Aeron directory? * * @param driverTimeoutMs for the driver liveness check. * @param logger for feedback as liveness checked. * @return true if a driver is active or false if not. */ public boolean isDriverActive(final long driverTimeoutMs, final Consumer<String> logger) { final MappedByteBuffer cncByteBuffer = mapExistingCncFile(logger); try { return isDriverActive(driverTimeoutMs, logger, cncByteBuffer); } finally { IoUtil.unmap(cncByteBuffer); } }
IoUtil.unmap(byteBuffer);
IoUtil.unmap(byteBuffer);
private void fileChunk( final long correlationId, final long chunkOffset, final long chunkLength, final DirectBuffer buffer, final int offset) { final UnsafeBuffer fileBuffer = fileSessionByIdMap.get(correlationId); buffer.getBytes(offset + CHUNK_PAYLOAD_OFFSET, fileBuffer, (int)chunkOffset, (int)chunkLength); if ((chunkOffset + chunkLength) >= fileBuffer.capacity()) { fileSessionByIdMap.remove(correlationId); IoUtil.unmap(fileBuffer.byteBuffer()); } }
private static void ensureDirectoryIsRecreated(final Context ctx) { if (ctx.aeronDirectory().isDirectory()) { if (ctx.warnIfDirectoryExists()) { System.err.println("WARNING: " + ctx.aeronDirectory() + " already exists."); } if (!ctx.dirDeleteOnStart()) { final Consumer<String> logger = ctx.warnIfDirectoryExists() ? System.err::println : (s) -> {}; final MappedByteBuffer cncByteBuffer = ctx.mapExistingCncFile(logger); try { if (CommonContext.isDriverActive(ctx.driverTimeoutMs(), logger, cncByteBuffer)) { throw new ActiveDriverException("active driver detected"); } reportExistingErrors(ctx, cncByteBuffer); } finally { IoUtil.unmap(cncByteBuffer); } } ctx.deleteAeronDirectory(); } IoUtil.ensureDirectoryExists(ctx.aeronDirectory(), "aeron"); }
@After public void after() { IoUtil.unmap(mockLogBufferMapped.byteBuffer()); CloseHelper.close(mockLogBufferChannel); IoUtil.delete(archiveDir, false); IoUtil.delete(termFile, false); }
IoUtil.unmap(cncByteBuffer); cncByteBuffer = null; cncMetaDataBuffer = null;
/** * Unmap a {@link ByteBuffer} without waiting for the next GC cycle if its memory mapped. * * @param buffer to be unmapped. */ public static void unmap(final ByteBuffer buffer) { if (buffer instanceof MappedByteBuffer) { unmap((MappedByteBuffer)buffer); } }
public void closeSegment() { if (fileChannel.isOpen()) { try { this.metadataSection = null; IoUtil.unmap(mappedBuffer); fileChannel.close(); } catch (IOException e) { LOG.error("Failed to close segment", e); } } }