Java Code Examples for org.agrona.concurrent.status.CountersReader#forEach()
The following examples show how to use
org.agrona.concurrent.status.CountersReader#forEach() .
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: DriverNameResolverTest.java From aeron with Apache License 2.0 | 6 votes |
private int neighborsCounterId(final String name) { final CountersReader countersReader = clients.get(name).countersReader(); final MutableInteger id = new MutableInteger(NULL_VALUE); countersReader.forEach( (counterId, typeId, keyBuffer, label) -> { if (label.startsWith("Resolver neighbors")) { id.value = counterId; } }); return id.value; }
Example 2
Source File: DriverNameResolverTest.java From aeron with Apache License 2.0 | 6 votes |
private int cacheEntriesCounterId(final String name) { final CountersReader countersReader = clients.get(name).countersReader(); final MutableInteger id = new MutableInteger(NULL_VALUE); countersReader.forEach( (counterId, typeId, keyBuffer, label) -> { if (label.startsWith("Resolver cache entries")) { id.value = counterId; } }); return id.value; }
Example 3
Source File: ClusterTool.java From aeron with Apache License 2.0 | 6 votes |
public static boolean nextBackupQueryDeadlineMs(final ClusterMarkFile markFile, final long timeMs) { final String aeronDirectoryName = markFile.decoder().aeronDirectory(); final MutableBoolean result = new MutableBoolean(false); try (Aeron aeron = Aeron.connect(new Aeron.Context().aeronDirectoryName(aeronDirectoryName))) { final CountersReader countersReader = aeron.countersReader(); countersReader.forEach( (counterId, typeId, keyBuffer, label) -> { if (ClusterBackup.QUERY_DEADLINE_TYPE_ID == typeId) { final AtomicCounter atomicCounter = new AtomicCounter( countersReader.valuesBuffer(), counterId, null); atomicCounter.setOrdered(timeMs); result.value = true; } }); } return result.value; }
Example 4
Source File: AeronStat.java From aeron with Apache License 2.0 | 6 votes |
private static void printOutput(final CncFileReader cncFileReader, final CounterFilter counterFilter) { final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); System.out.print(dateFormat.format(new Date())); System.out.println( " - Aeron Stat (CnC v" + cncFileReader.semanticVersion() + ")" + ", pid " + SystemUtil.getPid() + ", heartbeat age " + cncFileReader.driverHeartbeatAgeMs() + "ms"); System.out.println("======================================================================"); final CountersReader counters = cncFileReader.countersReader(); counters.forEach( (counterId, typeId, keyBuffer, label) -> { if (counterFilter.filter(typeId, keyBuffer)) { final long value = counters.getCounterValue(counterId); System.out.format("%3d: %,20d - %s%n", counterId, value, label); } } ); System.out.println("--"); }
Example 5
Source File: StatusUtil.java From aeron with Apache License 2.0 | 6 votes |
/** * Return the controllable idle strategy {@link StatusIndicator}. * * @param countersReader that holds the status indicator. * @return status indicator to use or null if not found. */ public static StatusIndicator controllableIdleStrategy(final CountersReader countersReader) { StatusIndicator statusIndicator = null; final MutableInteger id = new MutableInteger(-1); countersReader.forEach( (counterId, label) -> { if (counterId == SystemCounterDescriptor.CONTROLLABLE_IDLE_STRATEGY.id() && label.equals(SystemCounterDescriptor.CONTROLLABLE_IDLE_STRATEGY.label())) { id.value = counterId; } }); if (Aeron.NULL_VALUE != id.value) { statusIndicator = new UnsafeBufferStatusIndicator(countersReader.valuesBuffer(), id.value); } return statusIndicator; }
Example 6
Source File: StatusUtil.java From aeron with Apache License 2.0 | 6 votes |
/** * Return the read-only status indicator for the given send channel URI. * * @param countersReader that holds the status indicator. * @param channel for the send channel. * @return read-only status indicator that can be used to query the status of the send channel or null * @see ChannelEndpointStatus for status values and indications. */ public static StatusIndicatorReader sendChannelStatus(final CountersReader countersReader, final String channel) { StatusIndicatorReader statusReader = null; final MutableInteger id = new MutableInteger(-1); countersReader.forEach( (counterId, typeId, keyBuffer, label) -> { if (typeId == SendChannelStatus.SEND_CHANNEL_STATUS_TYPE_ID) { if (channel.startsWith(keyBuffer.getStringAscii(ChannelEndpointStatus.CHANNEL_OFFSET))) { id.value = counterId; } } }); if (Aeron.NULL_VALUE != id.value) { statusReader = new UnsafeBufferStatusIndicator(countersReader.valuesBuffer(), id.value); } return statusReader; }
Example 7
Source File: StatusUtil.java From aeron with Apache License 2.0 | 6 votes |
/** * Return the read-only status indicator for the given receive channel URI. * * @param countersReader that holds the status indicator. * @param channel for the receive channel. * @return read-only status indicator that can be used to query the status of the receive channel or null. * @see ChannelEndpointStatus for status values and indications. */ public static StatusIndicatorReader receiveChannelStatus(final CountersReader countersReader, final String channel) { StatusIndicatorReader statusReader = null; final MutableInteger id = new MutableInteger(-1); countersReader.forEach( (counterId, typeId, keyBuffer, label) -> { if (typeId == ReceiveChannelStatus.RECEIVE_CHANNEL_STATUS_TYPE_ID) { if (channel.startsWith(keyBuffer.getStringAscii(ChannelEndpointStatus.CHANNEL_OFFSET))) { id.value = counterId; } } }); if (Aeron.NULL_VALUE != id.value) { statusReader = new UnsafeBufferStatusIndicator(countersReader.valuesBuffer(), id.value); } return statusReader; }
Example 8
Source File: FixCounters.java From artio with Apache License 2.0 | 5 votes |
public static IntHashSet lookupCounterIds( final FixCountersId counterTypeId, final CountersReader countersReader) { final int requiredTypeId = counterTypeId.id(); final IntHashSet counterIds = new IntHashSet(); countersReader.forEach((counterId, typeId, keyBuffer, label) -> { if (typeId == requiredTypeId) { counterIds.add(counterId); } }); return counterIds; }
Example 9
Source File: Aeron.java From aeron with Apache License 2.0 | 4 votes |
/** * Print out the values from {@link #countersReader()} which can be useful for debugging. * * @param out to where the counters get printed. */ public void printCounters(final PrintStream out) { final CountersReader counters = countersReader(); counters.forEach((value, id, label) -> out.format("%3d: %,20d - %s%n", id, value, label)); }