Java Code Examples for io.aeron.CommonContext#errorLogBuffer()
The following examples show how to use
io.aeron.CommonContext#errorLogBuffer() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DistinctErrorLogTestWatcher.java From aeron with Apache License 2.0 | 6 votes |
public void captureErrors(final String aeronDirectoryName) { final File cncFile = CommonContext.newCncFile(aeronDirectoryName); assertTrue(cncFile.exists()); MappedByteBuffer cncByteBuffer = null; try (RandomAccessFile file = new RandomAccessFile(cncFile, "r"); FileChannel channel = file.getChannel()) { cncByteBuffer = channel.map(READ_ONLY, 0, channel.size()); final AtomicBuffer errorLogBuffer = CommonContext.errorLogBuffer(cncByteBuffer); ErrorLogReader.read(errorLogBuffer, this::onObservation); } catch (final IOException ex) { ex.printStackTrace(); } finally { IoUtil.unmap(cncByteBuffer); } }
Example 2
Source File: ErrorStat.java From aeron with Apache License 2.0 | 5 votes |
public static void main(final String[] args) { final File cncFile = CommonContext.newDefaultCncFile(); System.out.println("Command `n Control file " + cncFile); final MappedByteBuffer cncByteBuffer = SamplesUtil.mapExistingFileReadOnly(cncFile); final AtomicBuffer buffer = CommonContext.errorLogBuffer(cncByteBuffer); final int distinctErrorCount = ErrorLogReader.read(buffer, ErrorStat::accept); System.out.format("%n%d distinct errors observed.%n", distinctErrorCount); }
Example 3
Source File: ErrorReportTestUtil.java From aeron with Apache License 2.0 | 4 votes |
public static void waitForErrorToOccur( final String aeronDirectoryName, final Matcher<String> matcher, final IdleStrategy retryIdle) throws IOException { final File cncFile = CommonContext.newCncFile(aeronDirectoryName); assertTrue(cncFile.exists()); MappedByteBuffer cncByteBuffer = null; try ( RandomAccessFile file = new RandomAccessFile(cncFile, "r"); FileChannel channel = file.getChannel()) { cncByteBuffer = channel.map(READ_ONLY, 0, channel.size()); final AtomicBuffer errorLogBuffer = CommonContext.errorLogBuffer(cncByteBuffer); final MatcherErrorConsumer errorConsumer = new MatcherErrorConsumer(matcher); ErrorLogReader.read(errorLogBuffer, errorConsumer); if (errorConsumer.hasMatched()) { return; } if (null == retryIdle) { fail(errorConsumer.toString()); } while (!errorConsumer.hasMatched()) { errorConsumer.reset(); ErrorLogReader.read(errorLogBuffer, errorConsumer); Tests.wait(retryIdle, errorConsumer::toString); } } finally { IoUtil.unmap(cncByteBuffer); } }