Search in sources :

Example 46 with Channel

use of com.google.cloud.video.livestream.v1.Channel in project wildfly-core by wildfly.

the class RemoteProxyControllerProtocolTestCase method setupProxyHandlers.

private RemoteProxyController setupProxyHandlers(final ModelController proxiedController) {
    try {
        channels = new RemoteChannelPairSetup();
        channels.setupRemoting(new ManagementChannelInitialization() {

            @Override
            public ManagementChannelHandler startReceiving(Channel channel) {
                final ManagementClientChannelStrategy strategy = ManagementClientChannelStrategy.create(channel);
                final ManagementChannelHandler support = new ManagementChannelHandler(strategy, channels.getExecutorService());
                support.addHandlerFactory(new TransactionalProtocolOperationHandler(proxiedController, support, responseAttachmentSupport));
                channel.addCloseHandler(new CloseHandler<Channel>() {

                    @Override
                    public void handleClose(Channel closed, IOException exception) {
                        support.shutdownNow();
                    }
                });
                channel.receiveMessage(support.getReceiver());
                return support;
            }
        });
        channels.startClientConnetion();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    final Channel clientChannel = channels.getClientChannel();
    final ManagementClientChannelStrategy strategy = ManagementClientChannelStrategy.create(clientChannel);
    final ManagementChannelHandler support = new ManagementChannelHandler(strategy, channels.getExecutorService());
    final RemoteProxyController proxyController = RemoteProxyController.create(support, PathAddress.pathAddress(), ProxyOperationAddressTranslator.HOST);
    clientChannel.addCloseHandler(new CloseHandler<Channel>() {

        @Override
        public void handleClose(Channel closed, IOException exception) {
            support.shutdownNow();
        }
    });
    clientChannel.receiveMessage(support.getReceiver());
    return proxyController;
}
Also used : ManagementClientChannelStrategy(org.jboss.as.protocol.mgmt.ManagementClientChannelStrategy) ManagementChannelHandler(org.jboss.as.protocol.mgmt.ManagementChannelHandler) Channel(org.jboss.remoting3.Channel) ManagementChannelInitialization(org.jboss.as.protocol.mgmt.support.ManagementChannelInitialization) IOException(java.io.IOException) IOException(java.io.IOException) RemoteChannelPairSetup(org.jboss.as.controller.support.RemoteChannelPairSetup) CloseHandler(org.jboss.remoting3.CloseHandler) RemoteProxyController(org.jboss.as.controller.remote.RemoteProxyController) TransactionalProtocolOperationHandler(org.jboss.as.controller.remote.TransactionalProtocolOperationHandler)

Example 47 with Channel

use of com.google.cloud.video.livestream.v1.Channel in project wildfly-core by wildfly.

the class RemoteChannelProxyControllerTestCase method createProxyController.

@Override
protected ProxyController createProxyController(final ModelController proxiedController, final PathAddress proxyNodeAddress) {
    try {
        channels = new RemoteChannelPairSetup();
        channels.setupRemoting(new ManagementChannelInitialization() {

            @Override
            public ManagementChannelHandler startReceiving(Channel channel) {
                final ManagementClientChannelStrategy strategy = ManagementClientChannelStrategy.create(channel);
                final ManagementChannelHandler support = new ManagementChannelHandler(strategy, channels.getExecutorService());
                support.addHandlerFactory(new TransactionalProtocolOperationHandler(proxiedController, support, new ResponseAttachmentInputStreamSupport()));
                channel.addCloseHandler(new CloseHandler<Channel>() {

                    @Override
                    public void handleClose(Channel closed, IOException exception) {
                        support.shutdownNow();
                    }
                });
                channel.receiveMessage(support.getReceiver());
                return support;
            }
        });
        channels.startClientConnetion();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    final Channel clientChannel = channels.getClientChannel();
    final ManagementClientChannelStrategy strategy = ManagementClientChannelStrategy.create(clientChannel);
    final ManagementChannelHandler support = new ManagementChannelHandler(strategy, channels.getExecutorService());
    final RemoteProxyController proxyController = RemoteProxyController.create(support, proxyNodeAddress, ProxyOperationAddressTranslator.SERVER);
    clientChannel.addCloseHandler(new CloseHandler<Channel>() {

        @Override
        public void handleClose(Channel closed, IOException exception) {
            support.shutdownNow();
        }
    });
    clientChannel.receiveMessage(support.getReceiver());
    return proxyController;
}
Also used : ManagementClientChannelStrategy(org.jboss.as.protocol.mgmt.ManagementClientChannelStrategy) ManagementChannelHandler(org.jboss.as.protocol.mgmt.ManagementChannelHandler) Channel(org.jboss.remoting3.Channel) ResponseAttachmentInputStreamSupport(org.jboss.as.controller.remote.ResponseAttachmentInputStreamSupport) ManagementChannelInitialization(org.jboss.as.protocol.mgmt.support.ManagementChannelInitialization) IOException(java.io.IOException) IOException(java.io.IOException) RemoteChannelPairSetup(org.jboss.as.controller.support.RemoteChannelPairSetup) CloseHandler(org.jboss.remoting3.CloseHandler) RemoteProxyController(org.jboss.as.controller.remote.RemoteProxyController) TransactionalProtocolOperationHandler(org.jboss.as.controller.remote.TransactionalProtocolOperationHandler)

Example 48 with Channel

use of com.google.cloud.video.livestream.v1.Channel in project wildfly-core by wildfly.

the class TransactionalProtocolClientTestCase method startChannelServer.

@Before
public void startChannelServer() throws Exception {
    final ChannelServer.Configuration configuration = new ChannelServer.Configuration();
    configuration.setEndpointName(ENDPOINT_NAME);
    configuration.setUriScheme(URI_SCHEME);
    configuration.setBindAddress(new InetSocketAddress("127.0.0.1", PORT));
    channelServer = ChannelServer.create(configuration);
    // 
    channelServer.addChannelOpenListener(TEST_CHANNEL, new OpenListener() {

        @Override
        public void channelOpened(final Channel channel) {
            final MockController controller = new MockController();
            final ManagementClientChannelStrategy strategy = ManagementClientChannelStrategy.create(channel);
            final ManagementChannelHandler channels = new ManagementChannelHandler(strategy, remoteExecutors);
            final ManagementRequestHandlerFactory handlerFactory = new TransactionalProtocolOperationHandler(controller, channels, new ResponseAttachmentInputStreamSupport());
            channels.addHandlerFactory(handlerFactory);
            transferQueue.offer(controller);
            channel.addCloseHandler(channels);
            channel.receiveMessage(channels.getReceiver());
        }

        @Override
        public void registrationTerminated() {
        // 
        }
    });
    final ProtocolConnectionConfiguration connectionConfig = ProtocolConnectionConfiguration.create(channelServer.getEndpoint(), new URI("" + URI_SCHEME + "://127.0.0.1:" + PORT + ""));
    connectionConfig.setEndpoint(channelServer.getEndpoint());
    // 
    futureConnection = connectionConfig.getEndpoint().getConnection(connectionConfig.getUri());
}
Also used : ManagementClientChannelStrategy(org.jboss.as.protocol.mgmt.ManagementClientChannelStrategy) ManagementChannelHandler(org.jboss.as.protocol.mgmt.ManagementChannelHandler) ProtocolConnectionConfiguration(org.jboss.as.protocol.ProtocolConnectionConfiguration) InetSocketAddress(java.net.InetSocketAddress) OpenListener(org.jboss.remoting3.OpenListener) Channel(org.jboss.remoting3.Channel) ResponseAttachmentInputStreamSupport(org.jboss.as.controller.remote.ResponseAttachmentInputStreamSupport) URI(java.net.URI) ChannelServer(org.jboss.as.controller.support.ChannelServer) ProtocolConnectionConfiguration(org.jboss.as.protocol.ProtocolConnectionConfiguration) TransactionalProtocolOperationHandler(org.jboss.as.controller.remote.TransactionalProtocolOperationHandler) ManagementRequestHandlerFactory(org.jboss.as.protocol.mgmt.ManagementRequestHandlerFactory) Before(org.junit.Before)

Example 49 with Channel

use of com.google.cloud.video.livestream.v1.Channel in project wildfly-core by wildfly.

the class TransactionalProtocolClientTestCase method createClient.

/**
 * Create the protocol client to talk to the remote controller.
 *
 * @return the client
 * @throws Exception
 */
TransactionalProtocolClient createClient() throws Exception {
    final Connection connection = futureConnection.get();
    final IoFuture<Channel> channelIoFuture = connection.openChannel(TEST_CHANNEL, OptionMap.EMPTY);
    return createClient(channelIoFuture.get());
}
Also used : Channel(org.jboss.remoting3.Channel) Connection(org.jboss.remoting3.Connection)

Example 50 with Channel

use of com.google.cloud.video.livestream.v1.Channel in project wildfly-core by wildfly.

the class TestControllerClient method executeAwaitClosed.

protected ModelNode executeAwaitClosed(final ModelNode operation) throws IOException {
    final Channel channel = getChannelAssociation().getChannel();
    final Connection connection = channel.getConnection();
    final ModelNode result = execute(operation);
    if (!ModelDescriptionConstants.SUCCESS.equals(result.get(ModelDescriptionConstants.OUTCOME).asString())) {
        return result;
    }
    try {
        connection.awaitClosed();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    return result;
}
Also used : FutureManagementChannel(org.jboss.as.protocol.mgmt.FutureManagementChannel) Channel(org.jboss.remoting3.Channel) Connection(org.jboss.remoting3.Connection) ModelNode(org.jboss.dmr.ModelNode)

Aggregations

Channel (org.jboss.remoting3.Channel)41 IOException (java.io.IOException)29 Test (org.junit.Test)14 LivestreamServiceClient (com.google.cloud.video.livestream.v1.LivestreamServiceClient)13 Connection (org.jboss.remoting3.Connection)12 MessageInputStream (org.jboss.remoting3.MessageInputStream)12 CountDownLatch (java.util.concurrent.CountDownLatch)10 OpenListener (org.jboss.remoting3.OpenListener)10 MessageOutputStream (org.jboss.remoting3.MessageOutputStream)9 InetSocketAddress (java.net.InetSocketAddress)8 URI (java.net.URI)8 AtomicReference (java.util.concurrent.atomic.AtomicReference)8 IoFuture (org.xnio.IoFuture)7 Channel (com.google.cloud.video.livestream.v1.Channel)6 URISyntaxException (java.net.URISyntaxException)6 ManagementClientChannelStrategy (org.jboss.as.protocol.mgmt.ManagementClientChannelStrategy)6 FutureResult (org.xnio.FutureResult)6 ManagementChannelHandler (org.jboss.as.protocol.mgmt.ManagementChannelHandler)5 Endpoint (org.jboss.remoting3.Endpoint)5 Event (com.google.cloud.video.livestream.v1.Event)4