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.");
}
}
}
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));
}
Aggregations