Search in sources :

Example 1 with StatusIndicatorReader

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

the class StatusUtil method sendChannelStatus.

/**
 * 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;
}
Also used : StatusIndicatorReader(org.agrona.concurrent.status.StatusIndicatorReader) MutableInteger(org.agrona.collections.MutableInteger) UnsafeBufferStatusIndicator(org.agrona.concurrent.status.UnsafeBufferStatusIndicator)

Example 2 with StatusIndicatorReader

use of org.agrona.concurrent.status.StatusIndicatorReader in project aeron by real-logic.

the class StatusUtil method receiveChannelStatus.

/**
 * 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;
}
Also used : StatusIndicatorReader(org.agrona.concurrent.status.StatusIndicatorReader) MutableInteger(org.agrona.collections.MutableInteger) UnsafeBufferStatusIndicator(org.agrona.concurrent.status.UnsafeBufferStatusIndicator)

Example 3 with StatusIndicatorReader

use of org.agrona.concurrent.status.StatusIndicatorReader in project aeron by real-logic.

the class StatusUtil method sendChannelStatus.

/**
 * 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;
}
Also used : StatusIndicatorReader(org.agrona.concurrent.status.StatusIndicatorReader) MutableInteger(org.agrona.collections.MutableInteger) UnsafeBufferStatusIndicator(org.agrona.concurrent.status.UnsafeBufferStatusIndicator)

Example 4 with StatusIndicatorReader

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

the class StatusUtil method receiveChannelStatus.

/**
 * 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;
}
Also used : StatusIndicatorReader(org.agrona.concurrent.status.StatusIndicatorReader) MutableInteger(org.agrona.collections.MutableInteger) UnsafeBufferStatusIndicator(org.agrona.concurrent.status.UnsafeBufferStatusIndicator)

Aggregations

MutableInteger (org.agrona.collections.MutableInteger)4 StatusIndicatorReader (org.agrona.concurrent.status.StatusIndicatorReader)4 UnsafeBufferStatusIndicator (org.agrona.concurrent.status.UnsafeBufferStatusIndicator)4