Search in sources :

Example 1 with ControlProtocolException

use of io.aeron.driver.exceptions.ControlProtocolException in project Aeron by real-logic.

the class DriverConductor method onRemoveDestination.

void onRemoveDestination(final long registrationId, final String destinationChannel, final long correlationId) {
    SendChannelEndpoint sendChannelEndpoint = null;
    for (int i = 0, size = networkPublications.size(); i < size; i++) {
        final NetworkPublication publication = networkPublications.get(i);
        if (registrationId == publication.registrationId()) {
            sendChannelEndpoint = publication.channelEndpoint();
            break;
        }
    }
    if (null == sendChannelEndpoint) {
        throw new ControlProtocolException(UNKNOWN_PUBLICATION, "Unknown publication: " + registrationId);
    }
    sendChannelEndpoint.validateAllowsManualControl();
    final AeronUri aeronUri = AeronUri.parse(destinationChannel);
    final InetSocketAddress dstAddress = UdpChannel.destinationAddress(aeronUri);
    senderProxy.removeDestination(sendChannelEndpoint, dstAddress);
    clientProxy.operationSucceeded(correlationId);
}
Also used : SendChannelEndpoint(io.aeron.driver.media.SendChannelEndpoint) AeronUri(io.aeron.driver.uri.AeronUri) InetSocketAddress(java.net.InetSocketAddress) ControlProtocolException(io.aeron.driver.exceptions.ControlProtocolException) ReceiveChannelEndpoint(io.aeron.driver.media.ReceiveChannelEndpoint) SendChannelEndpoint(io.aeron.driver.media.SendChannelEndpoint)

Example 2 with ControlProtocolException

use of io.aeron.driver.exceptions.ControlProtocolException in project Aeron by real-logic.

the class DriverConductor method onAddDestination.

void onAddDestination(final long registrationId, final String destinationChannel, final long correlationId) {
    SendChannelEndpoint sendChannelEndpoint = null;
    for (int i = 0, size = networkPublications.size(); i < size; i++) {
        final NetworkPublication publication = networkPublications.get(i);
        if (registrationId == publication.registrationId()) {
            sendChannelEndpoint = publication.channelEndpoint();
            break;
        }
    }
    if (null == sendChannelEndpoint) {
        throw new ControlProtocolException(UNKNOWN_PUBLICATION, "Unknown publication: " + registrationId);
    }
    sendChannelEndpoint.validateAllowsManualControl();
    final AeronUri aeronUri = AeronUri.parse(destinationChannel);
    final InetSocketAddress dstAddress = UdpChannel.destinationAddress(aeronUri);
    senderProxy.addDestination(sendChannelEndpoint, dstAddress);
    clientProxy.operationSucceeded(correlationId);
}
Also used : SendChannelEndpoint(io.aeron.driver.media.SendChannelEndpoint) AeronUri(io.aeron.driver.uri.AeronUri) InetSocketAddress(java.net.InetSocketAddress) ControlProtocolException(io.aeron.driver.exceptions.ControlProtocolException) ReceiveChannelEndpoint(io.aeron.driver.media.ReceiveChannelEndpoint) SendChannelEndpoint(io.aeron.driver.media.SendChannelEndpoint)

Example 3 with ControlProtocolException

use of io.aeron.driver.exceptions.ControlProtocolException in project Aeron by real-logic.

the class DriverConductor method onRemoveSubscription.

void onRemoveSubscription(final long registrationId, final long correlationId) {
    final SubscriptionLink subscription = removeSubscriptionLink(subscriptionLinks, registrationId);
    if (null == subscription) {
        throw new ControlProtocolException(UNKNOWN_SUBSCRIPTION, "Unknown Subscription: " + registrationId);
    }
    subscription.close();
    final ReceiveChannelEndpoint channelEndpoint = subscription.channelEndpoint();
    if (null != channelEndpoint) {
        final int refCount = channelEndpoint.decRefToStream(subscription.streamId());
        if (0 == refCount) {
            receiverProxy.removeSubscription(channelEndpoint, subscription.streamId());
        }
        if (channelEndpoint.shouldBeClosed()) {
            channelEndpoint.closeStatusIndicator();
            receiveChannelEndpointByChannelMap.remove(channelEndpoint.udpChannel().canonicalForm());
            receiverProxy.closeReceiveChannelEndpoint(channelEndpoint);
            while (!channelEndpoint.isClosed()) {
                Thread.yield();
            }
        }
    }
    clientProxy.operationSucceeded(correlationId);
}
Also used : ControlProtocolException(io.aeron.driver.exceptions.ControlProtocolException) ReceiveChannelEndpoint(io.aeron.driver.media.ReceiveChannelEndpoint) ReceiveChannelEndpoint(io.aeron.driver.media.ReceiveChannelEndpoint) SendChannelEndpoint(io.aeron.driver.media.SendChannelEndpoint)

Example 4 with ControlProtocolException

use of io.aeron.driver.exceptions.ControlProtocolException in project Aeron by real-logic.

the class DriverConductor method onRemovePublication.

void onRemovePublication(final long registrationId, final long correlationId) {
    PublicationLink publicationLink = null;
    final ArrayList<PublicationLink> publicationLinks = this.publicationLinks;
    for (int i = 0, size = publicationLinks.size(), lastIndex = size - 1; i < size; i++) {
        final PublicationLink publication = publicationLinks.get(i);
        if (registrationId == publication.registrationId()) {
            publicationLink = publication;
            ArrayListUtil.fastUnorderedRemove(publicationLinks, i, lastIndex);
            break;
        }
    }
    if (null == publicationLink) {
        throw new ControlProtocolException(UNKNOWN_PUBLICATION, "Unknown publication: " + registrationId);
    }
    publicationLink.close();
    clientProxy.operationSucceeded(correlationId);
}
Also used : ControlProtocolException(io.aeron.driver.exceptions.ControlProtocolException) ReceiveChannelEndpoint(io.aeron.driver.media.ReceiveChannelEndpoint) SendChannelEndpoint(io.aeron.driver.media.SendChannelEndpoint)

Aggregations

ControlProtocolException (io.aeron.driver.exceptions.ControlProtocolException)4 ReceiveChannelEndpoint (io.aeron.driver.media.ReceiveChannelEndpoint)4 SendChannelEndpoint (io.aeron.driver.media.SendChannelEndpoint)4 AeronUri (io.aeron.driver.uri.AeronUri)2 InetSocketAddress (java.net.InetSocketAddress)2