Search in sources :

Example 6 with NamedThreadFactory

use of org.webpieces.util.threading.NamedThreadFactory in project webpieces by deanhiller.

the class ServerFactory method createTestServer.

static int createTestServer(boolean alwaysHttp2, Long maxConcurrentStreams) {
    BufferCreationPool pool = new BufferCreationPool();
    ScheduledExecutorService timer = new ScheduledThreadPoolExecutor(1, new NamedThreadFactory("webpieces-timer"));
    HttpFrontendManager frontEndMgr = HttpFrontendFactory.createFrontEnd("frontEnd", 10, timer, pool);
    FrontendConfig config = new FrontendConfig("id2", new InetSocketAddress(0));
    HttpServer server = frontEndMgr.createHttpServer(config, new OurListener());
    server.start();
    return server.getUnderlyingChannel().getLocalAddress().getPort();
}
Also used : FrontendConfig(org.webpieces.frontend2.api.FrontendConfig) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) HttpFrontendManager(org.webpieces.frontend2.api.HttpFrontendManager) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) NamedThreadFactory(org.webpieces.util.threading.NamedThreadFactory) InetSocketAddress(java.net.InetSocketAddress) HttpServer(org.webpieces.frontend2.api.HttpServer) BufferCreationPool(org.webpieces.data.api.BufferCreationPool)

Example 7 with NamedThreadFactory

use of org.webpieces.util.threading.NamedThreadFactory in project webpieces by deanhiller.

the class IntegTestEchoClientToOurServer method testSoTimeoutOnSocket.

public void testSoTimeoutOnSocket() throws InterruptedException {
    EchoClient client = new EchoClient();
    Executor executor = Executors.newFixedThreadPool(10, new NamedThreadFactory("serverThread"));
    BufferPool pool = new BufferCreationPool();
    ChannelManagerFactory factory = ChannelManagerFactory.createFactory();
    ChannelManager mgr = factory.createMultiThreadedChanMgr("server", pool, executor);
    AsyncServerManager serverMgr = AsyncServerMgrFactory.createAsyncServer(mgr);
    AsyncServer server = serverMgr.createTcpServer(new AsyncConfig("tcpServer"), new IntegTestLocalhostServerListener());
    server.start(new InetSocketAddress(8080));
    client.start(8080);
    synchronized (this) {
        this.wait();
    }
}
Also used : Executor(java.util.concurrent.Executor) BufferPool(org.webpieces.data.api.BufferPool) ChannelManager(org.webpieces.nio.api.ChannelManager) NamedThreadFactory(org.webpieces.util.threading.NamedThreadFactory) InetSocketAddress(java.net.InetSocketAddress) AsyncServer(org.webpieces.asyncserver.api.AsyncServer) AsyncConfig(org.webpieces.asyncserver.api.AsyncConfig) AsyncServerManager(org.webpieces.asyncserver.api.AsyncServerManager) BufferCreationPool(org.webpieces.data.api.BufferCreationPool) ChannelManagerFactory(org.webpieces.nio.api.ChannelManagerFactory)

Example 8 with NamedThreadFactory

use of org.webpieces.util.threading.NamedThreadFactory in project webpieces by deanhiller.

the class HttpFrontendFactory method createFrontEnd.

/**
	 * 
	 * @param id Use for logging and also file recording names
	 * @param threadPoolSize The size of the threadpool, although all data comes in order as we
	 * use the SessionExecutorImpl found in webpieces
	 * 
	 * @return
	 */
public static HttpFrontendManager createFrontEnd(String id, int threadPoolSize, ScheduledExecutorService timer, BufferPool pool) {
    Executor executor = Executors.newFixedThreadPool(threadPoolSize, new NamedThreadFactory(id));
    ChannelManagerFactory factory = ChannelManagerFactory.createFactory();
    ChannelManager chanMgr = factory.createMultiThreadedChanMgr(id, pool, executor);
    AsyncServerManager svrMgr = AsyncServerMgrFactory.createAsyncServer(chanMgr);
    HttpParser httpParser = HttpParserFactory.createParser(pool);
    HpackParser http2Parser = HpackParserFactory.createParser(pool, true);
    InjectionConfig injConfig = new InjectionConfig(http2Parser, new TimeImpl(), new Http2Config());
    Http2ServerEngineFactory svrEngineFactory = new Http2ServerEngineFactory(injConfig);
    return new FrontEndServerManagerImpl(svrMgr, timer, svrEngineFactory, httpParser);
}
Also used : HpackParser(com.webpieces.hpack.api.HpackParser) Executor(java.util.concurrent.Executor) ChannelManager(org.webpieces.nio.api.ChannelManager) NamedThreadFactory(org.webpieces.util.threading.NamedThreadFactory) Http2Config(com.webpieces.http2engine.api.client.Http2Config) InjectionConfig(com.webpieces.http2engine.api.client.InjectionConfig) HttpParser(org.webpieces.httpparser.api.HttpParser) AsyncServerManager(org.webpieces.asyncserver.api.AsyncServerManager) Http2ServerEngineFactory(com.webpieces.http2engine.api.server.Http2ServerEngineFactory) ChannelManagerFactory(org.webpieces.nio.api.ChannelManagerFactory) TimeImpl(com.webpieces.util.time.TimeImpl) FrontEndServerManagerImpl(org.webpieces.frontend2.impl.FrontEndServerManagerImpl)

Example 9 with NamedThreadFactory

use of org.webpieces.util.threading.NamedThreadFactory in project webpieces by deanhiller.

the class IntegGoogleHttps method createHttpClient.

public static HttpClient createHttpClient() {
    BufferPool pool2 = new BufferCreationPool();
    Executor executor2 = Executors.newFixedThreadPool(10, new NamedThreadFactory("clientThread"));
    ChannelManagerFactory factory = ChannelManagerFactory.createFactory();
    ChannelManager mgr = factory.createMultiThreadedChanMgr("client", pool2, executor2);
    HttpParser parser = HttpParserFactory.createParser(pool2);
    HttpClient client = HttpClientFactory.createHttpClient(mgr, parser);
    return client;
}
Also used : BufferPool(org.webpieces.data.api.BufferPool) Executor(java.util.concurrent.Executor) ChannelManager(org.webpieces.nio.api.ChannelManager) NamedThreadFactory(org.webpieces.util.threading.NamedThreadFactory) HttpClient(org.webpieces.httpclient.api.HttpClient) HttpParser(org.webpieces.httpparser.api.HttpParser) BufferCreationPool(org.webpieces.data.api.BufferCreationPool) ChannelManagerFactory(org.webpieces.nio.api.ChannelManagerFactory)

Example 10 with NamedThreadFactory

use of org.webpieces.util.threading.NamedThreadFactory in project webpieces by deanhiller.

the class HttpClientFactory method createHttpClient.

public static HttpClient createHttpClient(int numThreads) {
    Executor executor = Executors.newFixedThreadPool(numThreads, new NamedThreadFactory("httpclient"));
    BufferCreationPool pool = new BufferCreationPool();
    HttpParser parser = HttpParserFactory.createParser(pool);
    ChannelManagerFactory factory = ChannelManagerFactory.createFactory();
    ChannelManager mgr = factory.createMultiThreadedChanMgr("httpClientChanMgr", pool, executor);
    return createHttpClient(mgr, parser);
}
Also used : Executor(java.util.concurrent.Executor) ChannelManager(org.webpieces.nio.api.ChannelManager) NamedThreadFactory(org.webpieces.util.threading.NamedThreadFactory) HttpParser(org.webpieces.httpparser.api.HttpParser) BufferCreationPool(org.webpieces.data.api.BufferCreationPool) ChannelManagerFactory(org.webpieces.nio.api.ChannelManagerFactory)

Aggregations

NamedThreadFactory (org.webpieces.util.threading.NamedThreadFactory)11 Executor (java.util.concurrent.Executor)9 BufferCreationPool (org.webpieces.data.api.BufferCreationPool)9 ChannelManager (org.webpieces.nio.api.ChannelManager)8 ChannelManagerFactory (org.webpieces.nio.api.ChannelManagerFactory)8 BufferPool (org.webpieces.data.api.BufferPool)5 InetSocketAddress (java.net.InetSocketAddress)4 HpackParser (com.webpieces.hpack.api.HpackParser)3 InjectionConfig (com.webpieces.http2engine.api.client.InjectionConfig)3 AsyncServerManager (org.webpieces.asyncserver.api.AsyncServerManager)3 HttpParser (org.webpieces.httpparser.api.HttpParser)3 Http2Config (com.webpieces.http2engine.api.client.Http2Config)2 TimeImpl (com.webpieces.util.time.TimeImpl)2 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)2 AsyncConfig (org.webpieces.asyncserver.api.AsyncConfig)2 AsyncServer (org.webpieces.asyncserver.api.AsyncServer)2 Channel (org.webpieces.nio.api.channels.Channel)2 TCPChannel (org.webpieces.nio.api.channels.TCPChannel)2 DataListener (org.webpieces.nio.api.handlers.DataListener)2 Provides (com.google.inject.Provides)1