Search in sources :

Example 1 with ControlProtocolException

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

the class DriverConductor method onAddSendDestination.

void onAddSendDestination(final long registrationId, final String destinationChannel, final long correlationId) {
    final ChannelUri channelUri = ChannelUri.parse(destinationChannel);
    validateDestinationUri(channelUri, destinationChannel);
    validateSendDestinationUri(channelUri, destinationChannel);
    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 InetSocketAddress dstAddress = UdpChannel.destinationAddress(channelUri, nameResolver);
    senderProxy.addDestination(sendChannelEndpoint, channelUri, dstAddress);
    clientProxy.operationSucceeded(correlationId);
}
Also used : ChannelUri(io.aeron.ChannelUri) SendChannelEndpoint(io.aeron.driver.media.SendChannelEndpoint) InetSocketAddress(java.net.InetSocketAddress) ControlProtocolException(io.aeron.exceptions.ControlProtocolException) ReceiveChannelEndpoint(io.aeron.driver.media.ReceiveChannelEndpoint) SendChannelEndpoint(io.aeron.driver.media.SendChannelEndpoint)

Example 2 with ControlProtocolException

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

the class DriverConductor method onAddRcvSpyDestination.

void onAddRcvSpyDestination(final long registrationId, final String destinationChannel, final long correlationId) {
    final UdpChannel udpChannel = UdpChannel.parse(destinationChannel, nameResolver);
    final SubscriptionParams params = SubscriptionParams.getSubscriptionParams(udpChannel.channelUri(), ctx);
    final SubscriptionLink mdsSubscriptionLink = findMdsSubscriptionLink(subscriptionLinks, registrationId);
    if (null == mdsSubscriptionLink) {
        throw new ControlProtocolException(UNKNOWN_SUBSCRIPTION, "unknown MDS subscription: " + registrationId);
    }
    final SpySubscriptionLink subscriptionLink = new SpySubscriptionLink(registrationId, udpChannel, mdsSubscriptionLink.streamId(), mdsSubscriptionLink.aeronClient(), params);
    subscriptionLinks.add(subscriptionLink);
    clientProxy.operationSucceeded(correlationId);
    for (int i = 0, size = networkPublications.size(); i < size; i++) {
        final NetworkPublication publication = networkPublications.get(i);
        if (subscriptionLink.matches(publication) && publication.isAcceptingSubscriptions()) {
            clientProxy.onAvailableImage(publication.registrationId(), mdsSubscriptionLink.streamId(), publication.sessionId(), registrationId, linkSpy(publication, subscriptionLink).id(), publication.rawLog().fileName(), CommonContext.IPC_CHANNEL);
        }
    }
}
Also used : UdpChannel(io.aeron.driver.media.UdpChannel) ControlProtocolException(io.aeron.exceptions.ControlProtocolException) ReceiveChannelEndpoint(io.aeron.driver.media.ReceiveChannelEndpoint) SendChannelEndpoint(io.aeron.driver.media.SendChannelEndpoint)

Example 3 with ControlProtocolException

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

the class DriverConductor method onAddRcvIpcDestination.

void onAddRcvIpcDestination(final long registrationId, final String destinationChannel, final long correlationId) {
    final SubscriptionParams params = SubscriptionParams.getSubscriptionParams(ChannelUri.parse(destinationChannel), ctx);
    final SubscriptionLink mdsSubscriptionLink = findMdsSubscriptionLink(subscriptionLinks, registrationId);
    if (null == mdsSubscriptionLink) {
        throw new ControlProtocolException(UNKNOWN_SUBSCRIPTION, "unknown MDS subscription: " + registrationId);
    }
    final IpcSubscriptionLink subscriptionLink = new IpcSubscriptionLink(registrationId, mdsSubscriptionLink.streamId(), destinationChannel, mdsSubscriptionLink.aeronClient(), params);
    subscriptionLinks.add(subscriptionLink);
    clientProxy.operationSucceeded(correlationId);
    for (int i = 0, size = ipcPublications.size(); i < size; i++) {
        final IpcPublication publication = ipcPublications.get(i);
        if (subscriptionLink.matches(publication) && publication.isAcceptingSubscriptions()) {
            clientProxy.onAvailableImage(publication.registrationId(), mdsSubscriptionLink.streamId(), publication.sessionId(), registrationId, linkIpcSubscription(publication, subscriptionLink).id(), publication.rawLog().fileName(), CommonContext.IPC_CHANNEL);
        }
    }
}
Also used : ControlProtocolException(io.aeron.exceptions.ControlProtocolException) ReceiveChannelEndpoint(io.aeron.driver.media.ReceiveChannelEndpoint) SendChannelEndpoint(io.aeron.driver.media.SendChannelEndpoint)

Example 4 with ControlProtocolException

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

the class DriverConductor method onRemoveRcvNetworkDestination.

void onRemoveRcvNetworkDestination(final long registrationId, final String destinationChannel, final long correlationId) {
    ReceiveChannelEndpoint receiveChannelEndpoint = null;
    for (int i = 0, size = subscriptionLinks.size(); i < size; i++) {
        final SubscriptionLink subscriptionLink = subscriptionLinks.get(i);
        if (registrationId == subscriptionLink.registrationId()) {
            receiveChannelEndpoint = subscriptionLink.channelEndpoint();
            break;
        }
    }
    if (null == receiveChannelEndpoint) {
        throw new ControlProtocolException(UNKNOWN_SUBSCRIPTION, "unknown subscription: " + registrationId);
    }
    receiveChannelEndpoint.validateAllowsDestinationControl();
    receiverProxy.removeDestination(receiveChannelEndpoint, UdpChannel.parse(destinationChannel, nameResolver, true));
    clientProxy.operationSucceeded(correlationId);
}
Also used : ControlProtocolException(io.aeron.exceptions.ControlProtocolException) ReceiveChannelEndpoint(io.aeron.driver.media.ReceiveChannelEndpoint) ReceiveChannelEndpoint(io.aeron.driver.media.ReceiveChannelEndpoint) SendChannelEndpoint(io.aeron.driver.media.SendChannelEndpoint)

Example 5 with ControlProtocolException

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

the class DriverConductor method onRemoveCounter.

void onRemoveCounter(final long registrationId, final long correlationId) {
    CounterLink counterLink = null;
    final ArrayList<CounterLink> counterLinks = this.counterLinks;
    for (int i = 0, size = counterLinks.size(); i < size; i++) {
        final CounterLink link = counterLinks.get(i);
        if (registrationId == link.registrationId()) {
            counterLink = link;
            fastUnorderedRemove(counterLinks, i);
            break;
        }
    }
    if (null == counterLink) {
        throw new ControlProtocolException(UNKNOWN_COUNTER, "unknown counter: " + registrationId);
    }
    clientProxy.operationSucceeded(correlationId);
    clientProxy.onUnavailableCounter(registrationId, counterLink.counterId());
    counterLink.close();
}
Also used : ControlProtocolException(io.aeron.exceptions.ControlProtocolException) ReceiveChannelEndpoint(io.aeron.driver.media.ReceiveChannelEndpoint) SendChannelEndpoint(io.aeron.driver.media.SendChannelEndpoint)

Aggregations

ReceiveChannelEndpoint (io.aeron.driver.media.ReceiveChannelEndpoint)9 ControlProtocolException (io.aeron.exceptions.ControlProtocolException)9 SendChannelEndpoint (io.aeron.driver.media.SendChannelEndpoint)8 ChannelUri (io.aeron.ChannelUri)2 UdpChannel (io.aeron.driver.media.UdpChannel)2 InetSocketAddress (java.net.InetSocketAddress)2 ReceiveDestinationTransport (io.aeron.driver.media.ReceiveDestinationTransport)1 AtomicCounter (org.agrona.concurrent.status.AtomicCounter)1