Refine search
@Override protected void doOpen() throws Throwable { FilterChainBuilder filterChainBuilder = FilterChainBuilder.stateless(); filterChainBuilder.add(new TransportFilter()); filterChainBuilder.add(new GrizzlyCodecAdapter(getCodec(), getUrl(), this)); filterChainBuilder.add(new GrizzlyHandler(getUrl(), this)); TCPNIOTransportBuilder builder = TCPNIOTransportBuilder.newInstance(); ThreadPoolConfig config = builder.getWorkerThreadPoolConfig(); config.setPoolName(SERVER_THREAD_POOL_NAME).setQueueLimit(-1); String threadpool = getUrl().getParameter(Constants.THREADPOOL_KEY, Constants.DEFAULT_THREADPOOL); if (Constants.DEFAULT_THREADPOOL.equals(threadpool)) { int threads = getUrl().getPositiveParameter(Constants.THREADS_KEY, Constants.DEFAULT_THREADS); config.setCorePoolSize(threads).setMaxPoolSize(threads) .setKeepAliveTime(0L, TimeUnit.SECONDS); } else if ("cached".equals(threadpool)) { int threads = getUrl().getPositiveParameter(Constants.THREADS_KEY, Integer.MAX_VALUE); config.setCorePoolSize(0).setMaxPoolSize(threads) .setKeepAliveTime(60L, TimeUnit.SECONDS); } else { throw new IllegalArgumentException("Unsupported threadpool type " + threadpool); } builder.setKeepAlive(true).setReuseAddress(false) .setIOStrategy(SameThreadIOStrategy.getInstance()); transport = builder.build(); transport.setProcessor(filterChainBuilder.build()); transport.bind(getBindAddress()); transport.start(); }
@Override public FilterChainContext createContext(Connection connection, Operation operation) { return wrappedFilter.createContext(connection, operation); } }
@Override public void exceptionOccurred(FilterChainContext ctx, Throwable error) { wrappedFilter.exceptionOccurred(ctx, error); }
@Override public NextAction handleRead(final FilterChainContext ctx) throws IOException { final Connection connection = ctx.getConnection(); final SSLConnectionContext sslCtx = getSslConnectionContext(connection); if (sslCtx != null && sslCtx.getSslEngine() != null) { ctx.setMessage(allowDispose(allocateInputBuffer(sslCtx))); } return wrappedFilter.handleRead(ctx); } }
/** * Delegates close operation to {@link Transport}'s specific transport * filter. */ @Override public NextAction handleClose(final FilterChainContext ctx) throws IOException { final Filter transportFilter0 = getTransportFilter0( ctx.getConnection().getTransport()); if (transportFilter0 != null) { return transportFilter0.handleClose(ctx); } return null; }
public void flush(final CompletionHandler completionHandler) { final FilterChainContext newContext = getFilterChain().obtainFilterChainContext(getConnection()); newContext.operation = Operation.EVENT; newContext.closeable = closeable; newContext.event = TransportFilter.createFlushEvent(completionHandler); newContext.transportFilterContext.configureBlocking(transportFilterContext.isBlocking()); newContext.addressHolder = addressHolder; newContext.startIdx = filterIdx - 1; newContext.filterIdx = filterIdx - 1; newContext.endIdx = -1; getAttributes().copyTo(newContext.getAttributes()); ProcessorExecutor.execute(newContext.internalContext); }
@Override public void flush(final Connection connection, final CompletionHandler<WriteResult> completionHandler) { final FilterChainContext context = obtainFilterChainContext(connection); context.setOperation(Operation.EVENT); context.event = TransportFilter.createFlushEvent(completionHandler); ExecutorResolver.DOWNSTREAM_EXECUTOR_SAMPLE.initIndexes(context); ProcessorExecutor.execute(context.internalContext); }
@Override public NextAction handleAccept(FilterChainContext ctx) throws IOException { return wrappedFilter.handleAccept(ctx); }
@Override public NextAction handleClose(FilterChainContext ctx) throws IOException { return wrappedFilter.handleClose(ctx); }
@Override public NextAction handleRead(final FilterChainContext ctx) throws IOException { final Connection connection = ctx.getConnection(); final SSLConnectionContext sslCtx = getSslConnectionContext(connection); if (sslCtx != null && sslCtx.getSslEngine() != null) { ctx.setMessage(allowDispose(allocateInputBuffer(sslCtx))); } return wrappedFilter.handleRead(ctx); } }
/** * Delegates accept operation to {@link Transport}'s specific transport * filter. */ @Override public NextAction handleAccept(final FilterChainContext ctx) throws IOException { final Filter transportFilter0 = getTransportFilter0( ctx.getConnection().getTransport()); if (transportFilter0 != null) { return transportFilter0.handleAccept(ctx); } return null; }
@Override public void flush(final Connection connection, final CompletionHandler<WriteResult> completionHandler) { final FilterChainContext context = obtainFilterChainContext(connection); context.setOperation(Operation.EVENT); context.event = TransportFilter.createFlushEvent(completionHandler); ExecutorResolver.DOWNSTREAM_EXECUTOR_SAMPLE.initIndexes(context); ProcessorExecutor.execute(context.internalContext); }
@Override public NextAction handleAccept(FilterChainContext ctx) throws IOException { return wrappedFilter.handleAccept(ctx); }
@Override public NextAction handleClose(FilterChainContext ctx) throws IOException { return wrappedFilter.handleClose(ctx); }
@Override public NextAction handleRead(final FilterChainContext ctx) throws IOException { final Connection connection = ctx.getConnection(); final SSLConnectionContext sslCtx = sslBaseFilter.obtainSslConnectionContext(connection); if (sslCtx.getSslEngine() == null) { final SSLEngine sslEngine = sslBaseFilter.serverSSLEngineConfigurator.createSSLEngine(); sslEngine.beginHandshake(); sslCtx.configure(sslEngine); sslBaseFilter.notifyHandshakeStart(connection); } ctx.setMessage(allowDispose(allocateInputBuffer(sslCtx))); return wrappedFilter.handleRead(ctx); }
/** * Delegates close operation to {@link Transport}'s specific transport * filter. */ @Override public NextAction handleClose(final FilterChainContext ctx) throws IOException { final Filter transportFilter0 = getTransportFilter0( ctx.getConnection().getTransport()); if (transportFilter0 != null) { return transportFilter0.handleClose(ctx); } return null; }
@Override protected void doOpen() throws Throwable { FilterChainBuilder filterChainBuilder = FilterChainBuilder.stateless(); filterChainBuilder.add(new TransportFilter()); filterChainBuilder.add(new GrizzlyCodecAdapter(getCodec(), getUrl(), this)); filterChainBuilder.add(new GrizzlyHandler(getUrl(), this)); TCPNIOTransportBuilder builder = TCPNIOTransportBuilder.newInstance(); ThreadPoolConfig config = builder.getWorkerThreadPoolConfig(); config.setPoolName(SERVER_THREAD_POOL_NAME).setQueueLimit(-1); String threadpool = getUrl().getParameter(Constants.THREADPOOL_KEY, Constants.DEFAULT_THREADPOOL); if (Constants.DEFAULT_THREADPOOL.equals(threadpool)) { int threads = getUrl().getPositiveParameter(Constants.THREADS_KEY, Constants.DEFAULT_THREADS); config.setCorePoolSize(threads).setMaxPoolSize(threads) .setKeepAliveTime(0L, TimeUnit.SECONDS); } else if ("cached".equals(threadpool)) { int threads = getUrl().getPositiveParameter(Constants.THREADS_KEY, Integer.MAX_VALUE); config.setCorePoolSize(0).setMaxPoolSize(threads) .setKeepAliveTime(60L, TimeUnit.SECONDS); } else { throw new IllegalArgumentException("Unsupported threadpool type " + threadpool); } builder.setKeepAlive(true).setReuseAddress(false) .setIOStrategy(SameThreadIOStrategy.getInstance()); transport = builder.build(); transport.setProcessor(filterChainBuilder.build()); transport.bind(getBindAddress()); transport.start(); }
@Override public void flush(final Connection connection, final CompletionHandler<WriteResult> completionHandler) { final FilterChainContext context = obtainFilterChainContext(connection); context.setOperation(Operation.EVENT); context.event = TransportFilter.createFlushEvent(completionHandler); ExecutorResolver.DOWNSTREAM_EXECUTOR_SAMPLE.initIndexes(context); ProcessorExecutor.execute(context.internalContext); }
@Override public FilterChainContext createContext(Connection connection, Operation operation) { return wrappedFilter.createContext(connection, operation); } }
@Override public NextAction handleAccept(FilterChainContext ctx) throws IOException { return wrappedFilter.handleAccept(ctx); }