Package ch.bind.philib.msg.vm

Examples of ch.bind.philib.msg.vm.PubSubVM$Channel


            return channel;
        }

        Channel openChannel(final Connection connection) throws IOException {
            final IoFuture<Channel> future = connection.openChannel(DEFAULT_CHANNEL_SERVICE_TYPE, OptionMap.EMPTY);
            final Channel channel = future.get();
            channel.addCloseHandler(new CloseHandler<Channel>() {
                @Override
                public void handleClose(final Channel old, final IOException e) {
                    synchronized (ChannelStrategy.this) {
                        if(ChannelStrategy.this.channel == old) {
                            ChannelStrategy.this.channel = null;
View Full Code Here


            return channel;
        }

        @Override
        public void close() throws IOException {
            final Channel channel = this.channel;
            if(channel != null) {
                channel.close();
            }
        }
View Full Code Here

     * @return the operation result
     * @throws IOException for any error
     */
    public ModelNode executeAwaitConnectionClosed(final ModelNode operation) throws IOException {
        final DomainTestClient client = internalGetOrCreateClient();
        final Channel channel = client.getChannel();
        if( null == channel )
            throw new IllegalStateException("Didn't get a remoting channel from the DomainTestClient.");
        final Connection ref = channel.getConnection();
        ModelNode result = new ModelNode();
        try {
            result = client.execute(operation);
            // IN case the operation wasn't successful, don't bother waiting
            if(! "success".equals(result.get("outcome").asString())) {
                return result;
            }
        } catch(Exception e) {
            if(e instanceof IOException) {
                final Throwable cause = e.getCause();
                if(cause instanceof ExecutionException) {
                    // ignore, this might happen if the channel gets closed before we got the response
                } else {
                    throw (IOException) e;
                }
            } else {
                throw new RuntimeException(e);
            }
        }
        try {
            if(channel != null) {
                // Wait for the channel to close
                channel.awaitClosed();
            }
            // Wait for the connection to be closed
            connection.awaitConnectionClosed(ref);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
View Full Code Here

        this.clientMappingRegistryCollector = clientMappingRegistryCollector;
        this.remoteAsyncInvocationCancelStatus = asyncInvocationCancelStatusService;
    }

    public void startReceiving() {
        final Channel channel = this.channelAssociation.getChannel();
        channel.addCloseHandler(new ChannelCloseHandler());

        channel.receiveMessage(this);
        // listen to module availability/unavailability events
        this.deploymentRepository.addListener(this);
        // listen to new clusters (a.k.a groups) being started/stopped
        this.clientMappingRegistryCollector.addListener(this);
        // Send the cluster topology for existing clusters in the registry
View Full Code Here

    private volatile Channel channel;
    private volatile boolean closed;

    @Override
    public Channel getChannel() throws IOException {
        final Channel channel = this.channel;
        if(channel == null && closed) {
            throw ProtocolMessages.MESSAGES.channelClosed();
        }
        return channel;
    }
View Full Code Here

     *
     * @return the channel
     * @throws IOException for any error
     */
    protected Channel awaitChannel() throws IOException {
        Channel channel = this.channel;
        if(channel != null) {
            return channel;
        }
        synchronized (lock) {
            for(;;) {
View Full Code Here

            this.connectionManager = ProtocolConnectionManager.create(configuration, this);
        }

        @Override
        public Channel getChannel() throws IOException {
            Channel channel = super.getChannel();
            if(channel != null) {
                return channel;
            }
            // Try to connect and wait for the channel
            connectionManager.connect();
View Full Code Here

            return channel;
        }

        @Override
        public void connectionOpened(final Connection connection) throws IOException {
            final Channel channel = openChannel(connection, serviceType, channelOptions);
            if(setChannel(channel)) {
                channel.receiveMessage(receiver);
            } else {
                channel.closeAsync();
            }
        }
View Full Code Here

        return channelHandler;
    }

    @Override
    public Channel getChannel() throws IOException {
        final Channel channel = this.channel;
        if(channel == null) {
            synchronized (this) {
                if(this.channel == null) {
                    throw ProtocolMessages.MESSAGES.channelClosed();
                }
View Full Code Here

            }
            // Read the domain model async, this will block until the registration process is complete
            context.executeAsync(new ManagementRequestContext.AsyncTask<RegistrationContext>() {
                @Override
                public void execute(ManagementRequestContext<RegistrationContext> context) throws Exception {
                    final Channel channel = context.getChannel();
                    try {
                        // The domain model is going to be sent as part of the prepared notification
                        final OperationStepHandler handler = new HostRegistrationStepHandler(registration);
                        operationExecutor.execute(READ_DOMAIN_MODEL, OperationMessageHandler.logging, registration, OperationAttachments.EMPTY, handler);
                    } catch (Exception e) {
                        registration.failed(e);
                        return;
                    }
                    // Send a registered notification back
                    registration.sendCompletedMessage();
                    // Make sure that the host controller gets unregistered when the channel is closed
                    channel.addCloseHandler(new CloseHandler<Channel>() {
                        @Override
                        public void handleClose(Channel closed, IOException exception) {
                            if(domainController.isHostRegistered(hostName)) {
                                DOMAIN_LOGGER.lostConnectionToRemoteHost(hostName);
                            }
View Full Code Here

TOP

Related Classes of ch.bind.philib.msg.vm.PubSubVM$Channel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.