Search in sources :

Example 1 with CountersReader

use of org.agrona.concurrent.status.CountersReader in project Aeron by real-logic.

the class SetControllableIdleStrategy method main.

public static void main(final String[] args) throws Exception {
    try (Aeron aeron = Aeron.connect()) {
        final CountersReader countersReader = aeron.countersReader();
        final MutableInteger id = new MutableInteger();
        id.value = -1;
        countersReader.forEach((counterId, typeId, keyBuffer, label) -> {
            if (counterId == SystemCounterDescriptor.CONTROLLABLE_IDLE_STRATEGY.id() && label.equals(SystemCounterDescriptor.CONTROLLABLE_IDLE_STRATEGY.label())) {
                id.value = counterId;
            }
        });
        if (-1 != id.value) {
            final StatusIndicator statusIndicator = new UnsafeBufferStatusIndicator(countersReader.valuesBuffer(), id.value);
            final int status = Integer.parseInt(args[0]);
            statusIndicator.setOrdered(status);
            System.out.println("Set ControllableIdleStrategy status to " + status);
        } else {
            System.out.println("Could not find ControllableIdleStrategy status.");
        }
    }
}
Also used : StatusIndicator(org.agrona.concurrent.status.StatusIndicator) UnsafeBufferStatusIndicator(org.agrona.concurrent.status.UnsafeBufferStatusIndicator) MutableInteger(org.agrona.collections.MutableInteger) UnsafeBufferStatusIndicator(org.agrona.concurrent.status.UnsafeBufferStatusIndicator) Aeron(io.aeron.Aeron) CountersReader(org.agrona.concurrent.status.CountersReader)

Example 2 with CountersReader

use of org.agrona.concurrent.status.CountersReader in project Aeron by real-logic.

the class AeronStat method mapCounters.

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));
}
Also used : DirectBuffer(org.agrona.DirectBuffer) MappedByteBuffer(java.nio.MappedByteBuffer) File(java.io.File) CountersReader(org.agrona.concurrent.status.CountersReader)

Aggregations

CountersReader (org.agrona.concurrent.status.CountersReader)2 Aeron (io.aeron.Aeron)1 File (java.io.File)1 MappedByteBuffer (java.nio.MappedByteBuffer)1 DirectBuffer (org.agrona.DirectBuffer)1 MutableInteger (org.agrona.collections.MutableInteger)1 StatusIndicator (org.agrona.concurrent.status.StatusIndicator)1 UnsafeBufferStatusIndicator (org.agrona.concurrent.status.UnsafeBufferStatusIndicator)1