public synchronized static ExecutionHandler getExecutionHandler() { if(null == EXECUTION_HANDLER){ EXECUTION_HANDLER = new ExecutionHandler( new OrderedMemoryAwareThreadPoolExecutor(16, 1048576, 1048576)); } return EXECUTION_HANDLER; }
new NioServerSocketChannelFactory (Executors.newCachedThreadPool(), Executors.newCachedThreadPool()), new ExecutionHandler(Executors.newCachedThreadPool())); server.start();
public HttpServerPipelineFactory(final RequestDispatcher dispatcher, final String root, final int executorThreadCount, final int maxRequestSize, final boolean isKeepAlive, final List<ChannelHandler> additionalChannelHandlers) { this.resteasyDecoder = new RestEasyHttpRequestDecoder(dispatcher.getDispatcher(), root, getProtocol(), isKeepAlive); this.resteasyEncoder = new RestEasyHttpResponseEncoder(dispatcher); this.resteasyRequestHandler = new RequestHandler(dispatcher); if (executorThreadCount > 0) { this.executionHandler = new ExecutionHandler(new OrderedMemoryAwareThreadPoolExecutor(executorThreadCount, 0L, 0L)); } else { this.executionHandler = null; } this.maxRequestSize = maxRequestSize; this.additionalChannelHandlers = additionalChannelHandlers; }
public NettyServer(InetSocketAddress addr, ChannelFactory channelFactory, Configuration conf) { this(addr, channelFactory, new ExecutionHandler( new MemoryAwareThreadPoolExecutor(128, 1024 * 1024 * 32, 1024 * 1024 * 32)), conf); }
protected ExecutionHandler createExecutionHandler(int size) { return new ExecutionHandler(new OrderedMemoryAwareThreadPoolExecutor(size, 0, 0)); }
protected ExecutionHandler createExecutionHandler(int size) { return new ExecutionHandler(new OrderedMemoryAwareThreadPoolExecutor(size, 0, 0)); }
public SimplePipelineFactory(SimpleServerHandler handler) { this.handler = handler; this.executor = new ThreadPoolExecutor(60, 600, 30000L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(), new ThreadFactory() { @Override public Thread newThread(Runnable runnable) { Thread thread = new Thread(runnable); thread.setUncaughtExceptionHandler(new UncaughtExceptionHandler() { @Override public void uncaughtException(Thread thread, Throwable e) { logger.error("thread:" + thread.getName() + " uncaughtException:" + e.getMessage(), e); } }); thread.setName("worker-pool-thread-" + threaCounter.incrementAndGet()); thread.setDaemon(false); return thread; } }, new ThreadPoolExecutor.DiscardPolicy()); this.executionHandler = new ExecutionHandler(executor); }
@PostConstruct public void start() throws IOException, RepositoryException, InterruptedException { AvroLilyImpl avroLily = new AvroLilyImpl(repositoryManager, repositoryManager.getDefaultRepository().getTypeManager()); Responder responder = new LilySpecificResponder(AvroLily.class, avroLily); ThreadFactory threadFactory = new CustomThreadFactory("avro-exechandler", new ThreadGroup("AvroExecHandler")); if (maxServerThreads == -1) { executorService = Executors.newCachedThreadPool(threadFactory); executionHandler = new ExecutionHandler(executorService); } else { executorService = new ThreadPoolExecutor(maxServerThreads / 3, maxServerThreads, 60, TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), threadFactory, new WaitPolicy()); executionHandler = new ExecutionHandler(executorService); } //server = new HttpServer(responder, port); server = new NettyServer(responder, new InetSocketAddress(port), new NioServerSocketChannelFactory (Executors.newCachedThreadPool(), Executors.newCachedThreadPool()), executionHandler); server.start(); }
public SwitchChannelPipeline( final OpenVirteXController openVirteXController, final ThreadPoolExecutor pipelineExecutor) { super(); this.ctrl = openVirteXController; this.pipelineExecutor = pipelineExecutor; this.timer = PhysicalNetwork.getTimer(); this.idleHandler = new IdleStateHandler(this.timer, 20, 25, 0); this.readTimeoutHandler = new ReadTimeoutHandler(this.timer, 30); this.eh = new ExecutionHandler(this.pipelineExecutor); }
@Override protected void doStart() { executionHandler = new ExecutionHandler(executor); bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool())); bootstrap.setOption("child.tcpNoDelay", true); bootstrap.setPipelineFactory(new PipelineFactory()); bootstrap.bind(new InetSocketAddress(this.port)); }
protected CoapChannelPipelineFactory(ScheduledExecutorService executor) { this.channelHandlers = new LinkedHashSet<>(); addChannelHandler(new ExecutionHandler(executor)); addChannelHandler(new CoapMessageEncoder()); addChannelHandler(new CoapMessageDecoder()); }
/** * Create a new {@link ExecutionHandler} which is used to execute IO-Bound handlers * * @return ehandler */ protected ExecutionHandler createExecutionHander() { return new ExecutionHandler(new JMXEnabledOrderedMemoryAwareThreadPoolExecutor(maxExecutorThreads, 0, 0, getThreadPoolJMXPath(), getDefaultJMXName() + "-executor")); }
@Override public ChannelPipeline getPipeline() throws Exception { final ChannelPipeline pipeline = Channels.pipeline(); if(executor != null) pipeline.addLast("executor", new ExecutionHandler(executor)); pipeline.addLast("logging", new LoggingHandler(logger)); // a node resolver must be added before the mesage codec pipeline.addLast("messageCodec", new MessagePacketCodec()); pipeline.addLast("nodeResolver", nodeResolver); return pipeline; } }
if (pipelineExecutor != null) { pipeline.addLast("pipelineExecutor", new ExecutionHandler(pipelineExecutor));
public HttpServerPipelineFactory(RequestDispatcher dispatcher, String root, int executorThreadCount, int maxRequestSize, boolean isKeepAlive, List<ChannelHandler> additionalChannelHandlers) { this.resteasyDecoder = new RestEasyHttpRequestDecoder(dispatcher.getDispatcher(), root, getProtocol(), isKeepAlive); this.resteasyEncoder = new RestEasyHttpResponseEncoder(dispatcher); this.resteasyRequestHandler = new RequestHandler(dispatcher); if (executorThreadCount > 0) { this.executionHandler = new ExecutionHandler(new OrderedMemoryAwareThreadPoolExecutor(executorThreadCount, 0L, 0L)); } else { this.executionHandler = null; } this.maxRequestSize = maxRequestSize; this.additionalChannelHandlers = additionalChannelHandlers; }
@Override protected void startUp() throws Exception { executionHandler = new ExecutionHandler(new OrderedMemoryAwareThreadPoolExecutor(4, 0, 0)); bootstrap = new ClientBootstrap(new NioClientSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool())); bootstrap.setPipelineFactory(new ChannelPipelineFactory() { @Override public ChannelPipeline getPipeline() throws Exception { final ChannelPipeline pipeline = Channels.pipeline(); //pipeline.addLast("logger", new LoggingHandler(InternalLogLevel.INFO)); pipeline.addLast("xmlFramer", new XMLFrameDecoder()); pipeline.addLast("xmlDecoder", new XMLElementDecoder()); pipeline.addLast("xmppDecoder", new XEP0114Decoder(xmppHost, xmppSecret)); pipeline.addLast("executor", executionHandler); pipeline.addLast("xmppHandler", new XMPPStreamHandler(component)); return pipeline; } }); final ChannelFuture future = bootstrap.connect(serverAddress).await(); if (!future.isSuccess()) { bootstrap.releaseExternalResources(); executionHandler.releaseExternalResources(); future.rethrowIfFailed(); } channel = future.getChannel(); component.init(channel, JID.jid("localhost"), JID.jid(xmppHost)); // FIXME }
@Override public ChannelPipeline getPipeline() throws Exception { final ChannelPipeline pipeline = Channels.pipeline(); if (configuration.isRestEnableTls()) { pipeline.addLast("tls", buildSslHandler()); } pipeline.addLast("decoder", new HttpRequestDecoder(maxInitialLineLength, maxHeaderSize, maxChunkSize)); pipeline.addLast("encoder", new HttpResponseEncoder()); pipeline.addLast("chunks", new ChunkedWriteHandler()); pipeline.addLast("executor", new ExecutionHandler(executor)); pipeline.addLast("jerseyHandler", jerseyHandler); return pipeline; }
public ChannelPipeline getPipeline() throws Exception { // Create a default pipeline implementation. ChannelPipeline pipeline = pipeline(); // timeout read requests pipeline.addLast("timeout", timeoutHandler); // read and write http messages pipeline.addLast("codec", new HttpClientCodec()); // decompress gzip responses pipeline.addLast("inflater", new HttpContentDecompressor()); // gather all chunks into a single http message pipeline.addLast("aggregator", new HttpChunkAggregator(maxContentLength)); // move response handler to user worker pool pipeline.addLast("pipelineExecutor", new ExecutionHandler(executor)); // response handler pipeline.addLast("handler", new NettyHttpResponseChannelHandler(nettyConnectionPool)); return pipeline; } }
@Override public ChannelPipeline getPipeline() throws Exception { // Create a default pipeline implementation. ChannelPipeline pipeline = pipeline(); // Add the text line codec combination first, pipeline.addLast("framer", new DelimiterBasedFrameDecoder(3000000, ChannelBuffers.wrappedBuffer(new byte[] {'E','O','F'}))); //pipeline.addLast("framer", new DelimiterBasedFrameDecoder(Integer.MAX_VALUE, // Delimiters.lineDelimiter())); //pipeline.addLast("eofFramer", new TextProtocolFrameDecoder()); pipeline.addLast("decoder", new StringDecoder()); pipeline.addLast("encoder", new StringEncoder()); // Insert OrderedMemoryAwareThreadPoolExecutor before your blocking handler pipeline.addLast("pipelineExecutor", new ExecutionHandler(this.eventExecutor)); // and then business logic. pipeline.addLast("handler", new TextProtocolHandler()); return pipeline; } }
@Override public ChannelPipeline getPipeline() throws Exception { final ControllerChannelHandler handler = new ControllerChannelHandler( this.ctrl, this.sw); final ChannelPipeline pipeline = Channels.pipeline(); pipeline.addLast("reconnect", new ReconnectHandler(this.sw, this.bootstrap, this.timer, 15, this.cg)); pipeline.addLast("ofmessagedecoder", new OVXMessageDecoder()); pipeline.addLast("ofmessageencoder", new OVXMessageEncoder()); pipeline.addLast("idle", this.idleHandler); pipeline.addLast("timeout", this.readTimeoutHandler); pipeline.addLast("handshaketimeout", new HandshakeTimeoutHandler( handler, this.timer, 15)); pipeline.addLast("pipelineExecutor", new ExecutionHandler( this.pipelineExecutor)); pipeline.addLast("handler", handler); return pipeline; }