Java Code Examples for io.aeron.CommonContext#newDefaultCncFile()

The following examples show how to use io.aeron.CommonContext#newDefaultCncFile() . 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: CncFileReader.java    From aeron with Apache License 2.0 5 votes vote down vote up
/**
 * Map an existing CnC file.
 *
 * @return the {@link CncFileReader} wrapper for reading useful data from the cnc file.
 * @throws AeronException if the cnc version major version is not compatible.
 */
public static CncFileReader map()
{
    final File cncFile = CommonContext.newDefaultCncFile();
    final MappedByteBuffer cncByteBuffer = mapExistingFileReadOnly(cncFile);

    return new CncFileReader(cncByteBuffer);
}
 
Example 2
Source File: ErrorStat.java    From aeron with Apache License 2.0 5 votes vote down vote up
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: AeronStat.java    From nd4j with Apache License 2.0 5 votes vote down vote up
public static CountersReader mapCounters() {
    final File cncFile = CommonContext.newDefaultCncFile();
    System.out.println("Command `n Control file " + cncFile);

    final MappedByteBuffer cncByteBuffer = IoUtil.mapExistingFile(cncFile, "cnc");
    final DirectBuffer cncMetaData = createMetaDataBuffer(cncByteBuffer);
    final int cncVersion = cncMetaData.getInt(cncVersionOffset(0));

    if (CncFileDescriptor.CNC_VERSION != cncVersion) {
        throw new IllegalStateException("CnC version not supported: file version=" + cncVersion);
    }

    return new CountersReader(createCountersMetaDataBuffer(cncByteBuffer, cncMetaData),
                    createCountersValuesBuffer(cncByteBuffer, cncMetaData));
}
 
Example 4
Source File: DriverTool.java    From aeron with Apache License 2.0 4 votes vote down vote up
public static void main(final String[] args)
{
    boolean printPidOnly = false;
    boolean terminateDriver = false;

    if (0 != args.length)
    {
        checkForHelp(args);

        if (args[0].equals("pid"))
        {
            printPidOnly = true;
        }
        else if (args[0].equals("terminate"))
        {
            terminateDriver = true;
        }
    }

    final File cncFile = CommonContext.newDefaultCncFile();
    final MappedByteBuffer cncByteBuffer = IoUtil.mapExistingFile(cncFile, "cnc");
    final DirectBuffer cncMetaData = createMetaDataBuffer(cncByteBuffer);
    final int cncVersion = cncMetaData.getInt(cncVersionOffset(0));

    checkVersion(cncVersion);

    final ManyToOneRingBuffer toDriver = new ManyToOneRingBuffer(createToDriverBuffer(cncByteBuffer, cncMetaData));

    if (printPidOnly)
    {
        System.out.println(pid(cncMetaData));
    }
    else if (terminateDriver)
    {
        final DriverProxy driverProxy = new DriverProxy(toDriver, toDriver.nextCorrelationId());

        if (!driverProxy.terminateDriver(null, 0, 0))
        {
            throw new AeronException("could not send termination request.");
        }
    }
    else
    {
        System.out.println("Command `n Control file: " + cncFile);
        System.out.format("Version: %d, PID: %d%n", cncVersion, pid(cncMetaData));
        printDateActivityAndStartTimestamps(startTimestampMs(cncMetaData), toDriver.consumerHeartbeatTime());
    }
}