Search in sources :

Example 1 with LocalAddress

use of org.jboss.netty.channel.local.LocalAddress in project sockjs-netty by cgbystrom.

the class StressTestServer method start.

public void start() throws Exception {
    final JmxReporter reporter = JmxReporter.forRegistry(registry).build();
    final ServiceRouter router = new ServiceRouter();
    reporter.start();
    router.setMetricRegistry(registry);
    Service echoService = new Service("/stresstest", new SessionCallbackFactory() {

        @Override
        public StressTestSession getSession(String id) throws Exception {
            return new StressTestSession();
        }
    });
    router.registerService(echoService);
    bootstrap.setPipelineFactory(new ChannelPipelineFactory() {

        @Override
        public ChannelPipeline getPipeline() throws Exception {
            ChannelPipeline pipeline = pipeline();
            pipeline.addLast("decoder", new HttpRequestDecoder());
            // Required for WS handshaker or else NPE.
            pipeline.addLast("chunkAggregator", new HttpChunkAggregator(130 * 1024));
            pipeline.addLast("encoder", new HttpResponseEncoder());
            pipeline.addLast("preflight", new PreflightHandler());
            pipeline.addLast("router", router);
            return pipeline;
        }
    });
    bootstrap.bind(new LocalAddress(port));
}
Also used : LocalAddress(org.jboss.netty.channel.local.LocalAddress) HttpChunkAggregator(org.jboss.netty.handler.codec.http.HttpChunkAggregator) JmxReporter(com.codahale.metrics.JmxReporter) ChannelPipeline(org.jboss.netty.channel.ChannelPipeline) HttpResponseEncoder(org.jboss.netty.handler.codec.http.HttpResponseEncoder) HttpRequestDecoder(org.jboss.netty.handler.codec.http.HttpRequestDecoder) ChannelPipelineFactory(org.jboss.netty.channel.ChannelPipelineFactory)

Example 2 with LocalAddress

use of org.jboss.netty.channel.local.LocalAddress in project databus by linkedin.

the class TestRelayCommandsLocal method setUp.

@BeforeMethod
public void setUp() throws Exception {
    // creates an event factory for us
    _relay = new HttpRelay(_staticConfig, null);
    _eventBuffer = _relay.getEventBuffer();
    DatabusEventProducer randomEventProducer = new DatabusEventRandomProducer(_eventBuffer, 10, 1, 10, _staticConfig.getSourceIds(), null, null);
    RequestProcessorRegistry processorRegistry = _relay.getProcessorRegistry();
    processorRegistry.register(EchoRequestProcessor.COMMAND_NAME, new EchoRequestProcessor(null));
    processorRegistry.register(GenerateDataEventsRequestProcessor.COMMAND_NAME, new GenerateDataEventsRequestProcessor(null, _relay, randomEventProducer));
    // Configure the server.
    _bootstrap = new ServerBootstrap(new DefaultLocalServerChannelFactory());
    // Set up the event pipeline factory.
    _bootstrap.setPipelineFactory(new HttpServerPipelineFactory(_relay));
    _serverAddress = new LocalAddress(10);
    _serverChannel = _bootstrap.bind(_serverAddress);
}
Also used : DatabusEventRandomProducer(com.linkedin.databus.core.util.DatabusEventRandomProducer) HttpServerPipelineFactory(com.linkedin.databus2.core.container.netty.HttpServerPipelineFactory) EchoRequestProcessor(com.linkedin.databus2.core.container.request.EchoRequestProcessor) DefaultLocalServerChannelFactory(org.jboss.netty.channel.local.DefaultLocalServerChannelFactory) LocalAddress(org.jboss.netty.channel.local.LocalAddress) RequestProcessorRegistry(com.linkedin.databus2.core.container.request.RequestProcessorRegistry) DatabusEventProducer(com.linkedin.databus.core.util.DatabusEventProducer) GenerateDataEventsRequestProcessor(com.linkedin.databus.container.request.GenerateDataEventsRequestProcessor) ServerBootstrap(org.jboss.netty.bootstrap.ServerBootstrap) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 3 with LocalAddress

use of org.jboss.netty.channel.local.LocalAddress in project sockjs-netty by cgbystrom.

the class WebSocketClient method connect.

@Override
public ChannelFuture connect() throws URISyntaxException {
    this.sessionId = UUID.randomUUID().toString();
    URI sockJsUri = new URI("http", uri.getUserInfo(), uri.getHost(), uri.getPort(), uri.getPath() + "/999/" + sessionId + "/websocket", uri.getQuery(), uri.getFragment());
    this.wsHandshaker = new WebSocketClientHandshakerFactory().newHandshaker(sockJsUri, WebSocketVersion.V13, null, false, null);
    if (bootstrap.getFactory() instanceof LocalClientChannelFactory) {
        return bootstrap.connect(new LocalAddress(getPort(uri)));
    } else {
        return bootstrap.connect(new InetSocketAddress(uri.getHost(), getPort(uri)));
    }
}
Also used : WebSocketClientHandshakerFactory(org.jboss.netty.handler.codec.http.websocketx.WebSocketClientHandshakerFactory) LocalAddress(org.jboss.netty.channel.local.LocalAddress) InetSocketAddress(java.net.InetSocketAddress) LocalClientChannelFactory(org.jboss.netty.channel.local.LocalClientChannelFactory) URI(java.net.URI)

Example 4 with LocalAddress

use of org.jboss.netty.channel.local.LocalAddress in project databus by linkedin.

the class DummyHttpRequestHandler method setupServer.

private void setupServer(DummyHttpRequestHandler requestHandler) {
    _serverBootstrap = new ServerBootstrap(new DefaultLocalServerChannelFactory());
    ChannelPipeline serverPipeline = pipeline();
    serverPipeline.addLast("server logger 1", new LoggingHandler("server logger 1", InternalLogLevel.DEBUG, true));
    serverPipeline.addLast("decoder", new HttpRequestDecoder());
    serverPipeline.addLast("encoder", new HttpResponseEncoder());
    serverPipeline.addLast("server loggger 5", new LoggingHandler("server logger 5", InternalLogLevel.DEBUG, true));
    serverPipeline.addLast("handler", requestHandler);
    _serverBootstrap.setPipeline(serverPipeline);
    _serverAddress = new LocalAddress(1);
    _serverChannel = _serverBootstrap.bind(_serverAddress);
}
Also used : HttpResponseEncoder(org.jboss.netty.handler.codec.http.HttpResponseEncoder) DefaultLocalServerChannelFactory(org.jboss.netty.channel.local.DefaultLocalServerChannelFactory) LoggingHandler(org.jboss.netty.handler.logging.LoggingHandler) LocalAddress(org.jboss.netty.channel.local.LocalAddress) HttpRequestDecoder(org.jboss.netty.handler.codec.http.HttpRequestDecoder) ServerBootstrap(org.jboss.netty.bootstrap.ServerBootstrap) ChannelPipeline(org.jboss.netty.channel.ChannelPipeline)

Example 5 with LocalAddress

use of org.jboss.netty.channel.local.LocalAddress in project databus by linkedin.

the class SimpleTestClientConnection method start.

public void start(final int serverAddr) {
    _shutdownRequested = false;
    _shutdown = false;
    _connected = false;
    _thread = new Thread(new Runnable() {

        @Override
        public void run() {
            //System.err.println("Client running on thread: " + Thread.currentThread());
            ChannelFuture connectFuture = _clientBootstrap.connect(new LocalAddress(serverAddr));
            connectFuture.awaitUninterruptibly();
            _channel = connectFuture.getChannel();
            _lock.lock();
            try {
                _connected = connectFuture.isSuccess();
                _connectedCondition.signalAll();
                while (!_shutdownRequested) {
                    try {
                        _shutdownReqCondition.await();
                    } catch (InterruptedException ie) {
                    }
                }
                _shutdown = true;
                _shutdownCondition.signalAll();
            } finally {
                _lock.unlock();
            }
        }
    });
    _thread.setDaemon(true);
    _thread.start();
}
Also used : ChannelFuture(org.jboss.netty.channel.ChannelFuture) LocalAddress(org.jboss.netty.channel.local.LocalAddress)

Aggregations

LocalAddress (org.jboss.netty.channel.local.LocalAddress)6 InetSocketAddress (java.net.InetSocketAddress)2 ServerBootstrap (org.jboss.netty.bootstrap.ServerBootstrap)2 ChannelPipeline (org.jboss.netty.channel.ChannelPipeline)2 DefaultLocalServerChannelFactory (org.jboss.netty.channel.local.DefaultLocalServerChannelFactory)2 HttpRequestDecoder (org.jboss.netty.handler.codec.http.HttpRequestDecoder)2 HttpResponseEncoder (org.jboss.netty.handler.codec.http.HttpResponseEncoder)2 JmxReporter (com.codahale.metrics.JmxReporter)1 GenerateDataEventsRequestProcessor (com.linkedin.databus.container.request.GenerateDataEventsRequestProcessor)1 DatabusEventProducer (com.linkedin.databus.core.util.DatabusEventProducer)1 DatabusEventRandomProducer (com.linkedin.databus.core.util.DatabusEventRandomProducer)1 HttpServerPipelineFactory (com.linkedin.databus2.core.container.netty.HttpServerPipelineFactory)1 EchoRequestProcessor (com.linkedin.databus2.core.container.request.EchoRequestProcessor)1 RequestProcessorRegistry (com.linkedin.databus2.core.container.request.RequestProcessorRegistry)1 SocketAddress (java.net.SocketAddress)1 URI (java.net.URI)1 ChannelFuture (org.jboss.netty.channel.ChannelFuture)1 ChannelPipelineFactory (org.jboss.netty.channel.ChannelPipelineFactory)1 LocalClientChannelFactory (org.jboss.netty.channel.local.LocalClientChannelFactory)1 HttpChunkAggregator (org.jboss.netty.handler.codec.http.HttpChunkAggregator)1