Java Code Examples for org.agrona.collections.ArrayUtil#UNKNOWN_INDEX

The following examples show how to use org.agrona.collections.ArrayUtil#UNKNOWN_INDEX . 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: ClusterMember.java    From aeron with Apache License 2.0 6 votes vote down vote up
/**
 * Find the index at which a member id is present.
 *
 * @param clusterMembers to be searched.
 * @param memberId       to search for.
 * @return the index at which the member id is found otherwise {@link ArrayUtil#UNKNOWN_INDEX}.
 */
public static int findMemberIndex(final ClusterMember[] clusterMembers, final int memberId)
{
    final int length = clusterMembers.length;
    int index = ArrayUtil.UNKNOWN_INDEX;

    for (int i = 0; i < length; i++)
    {
        if (clusterMembers[i].id() == memberId)
        {
            index = i;
        }
    }

    return index;
}
 
Example 2
Source File: DataTransportPoller.java    From aeron with Apache License 2.0 6 votes vote down vote up
public void cancelRead(final ReceiveChannelEndpoint channelEndpoint, final UdpChannelTransport transport)
{
    final ChannelAndTransport[] transports = this.channelAndTransports;
    int index = ArrayUtil.UNKNOWN_INDEX;

    for (int i = 0, length = transports.length; i < length; i++)
    {
        if (channelEndpoint == transports[i].channelEndpoint && transport == transports[i].transport)
        {
            index = i;
            break;
        }
    }

    if (index != ArrayUtil.UNKNOWN_INDEX)
    {
        channelAndTransports = ArrayUtil.remove(transports, index);
    }
}
 
Example 3
Source File: Receiver.java    From aeron with Apache License 2.0 6 votes vote down vote up
public void onRemoveDestination(final ReceiveChannelEndpoint channelEndpoint, final UdpChannel udpChannel)
{
    final int transportIndex = channelEndpoint.destination(udpChannel);

    if (ArrayUtil.UNKNOWN_INDEX != transportIndex)
    {
        final ReceiveDestinationTransport transport = channelEndpoint.destination(transportIndex);

        dataTransportPoller.cancelRead(channelEndpoint, transport);
        channelEndpoint.removeDestination(transportIndex);
        CloseHelper.close(transport);
        dataTransportPoller.selectNowWithoutProcessing();

        for (final PublicationImage image : publicationImages)
        {
            if (channelEndpoint == image.channelEndpoint())
            {
                image.removeDestination(transportIndex);
            }
        }
    }
}
 
Example 4
Source File: MultiRcvDestination.java    From aeron with Apache License 2.0 5 votes vote down vote up
void updateControlAddress(final int transportIndex, final InetSocketAddress newAddress)
{
    if (ArrayUtil.UNKNOWN_INDEX != transportIndex)
    {
        final ReceiveDestinationTransport transport = transports[transportIndex];

        if (null != transport)
        {
            transport.currentControlAddress(newAddress);
        }
    }
}