Package com.google.common.util.concurrent

Examples of com.google.common.util.concurrent.ThreadFactoryBuilder


        this.numSlots = numSlots;
        this.slotFactory = slotFactory;
        this.slotCapacity = slotCapacity;
        if (slotDuration > 0l) {
            slotDurationInMilliseconds = TimeUnit.MILLISECONDS.convert(slotDuration, timeUnit);
            ThreadFactory threadFactory = new ThreadFactoryBuilder().setDaemon(true)
                    .setNameFormat("SlidingWindow-" + getClass().getSimpleName()).build();
            windowingTimerService = Executors.newSingleThreadScheduledExecutor(threadFactory);

        } else {
            slotDurationInMilliseconds = 0;
View Full Code Here


     *
     * @param dataSource  may or may not be FiberDataSource
     * @param threadCount
     */
    public FiberDBI(DataSource dataSource, int threadCount) {
        this(dataSource, Executors.newFixedThreadPool(threadCount, new ThreadFactoryBuilder().setDaemon(true).build()));
    }
View Full Code Here

    @Override
    public Connection connect(final String url, final Properties info) throws SQLException {
        final String dbURL = url.replaceFirst("fiber:", "");
        int threadCount = Integer.parseInt(info.getProperty(THREADS_COUNT, "10"));
        info.remove(THREADS_COUNT);
        ExecutorService es = Executors.newFixedThreadPool(threadCount, new ThreadFactoryBuilder().setNameFormat("jdbc-worker-%d").setDaemon(true).build());
        try {
            Connection con = FiberAsync.runBlocking(es, new CheckedCallable<Connection, SQLException>() {
                @Override
                public Connection call() throws SQLException {
                    return DriverManager.getConnection(dbURL, info);
View Full Code Here

     * @param ds The {@link DataSource} to wrap.
     * @param numThreads The number of threads to create in the thread pool that will be used to execute JDBC operations.
     * @return
     */
    public static DataSource wrap(DataSource ds, final int numThreads) {
        return wrap(ds, Executors.newFixedThreadPool(numThreads, new ThreadFactoryBuilder().setNameFormat("jdbc-worker-%d").setDaemon(true).build()));
    }
View Full Code Here

    @Before
    public void setUp() throws Exception {
        final Connection connection = cls.newInstance().getConnection();
        this.conn = new FiberConnection(connection,
                MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(10, new ThreadFactoryBuilder().setNameFormat("jdbc-worker-%d").setDaemon(true).build())));
    }
View Full Code Here

    }

    private static ClientConfig addDefaultConfigurations(Configuration configuration) {
        // currently there is no usage with the singleThreadPool variable due to jersey bug. See below.
        final RequestExecutorProvider singleThreadPool = new RequestExecutorProvider() {
            private ExecutorService tp = Executors.newSingleThreadExecutor(new ThreadFactoryBuilder().setDaemon(true).setNameFormat("jersey-puniverse-single-worker-%d").build());

            @Override
            public ExecutorService getRequestingExecutor() {
                return tp;
            }
View Full Code Here

        this.builder = new DBIFactory();
        this.es = es;
    }

    public FiberDBIFactory(final int threadsNum) {
        this(Executors.newFixedThreadPool(threadsNum, new ThreadFactoryBuilder().setNameFormat("jdbc-worker-%d").setDaemon(true).build()));
    }
View Full Code Here

public class FiberManagedDataSource extends FiberDataSource implements ManagedDataSource {
    private final ManagedDataSource myds;

    public static ManagedDataSource wrap(ManagedDataSource ds, int numThreads) {
        return wrap(ds, Executors.newFixedThreadPool(numThreads, new ThreadFactoryBuilder().setNameFormat("jdbc-worker-%d").setDaemon(true).build()));
    }
View Full Code Here

     * @param ioThreadCount
     * @return
     */
    public static FiberHttpClientBuilder create(int ioThreadCount) {
        return new FiberHttpClientBuilder(HttpAsyncClientBuilder.create().
                setThreadFactory(new ThreadFactoryBuilder().setDaemon(true).build()).
                setDefaultIOReactorConfig(IOReactorConfig.custom().setIoThreadCount(ioThreadCount).build()));
    }
View Full Code Here

        configuredPort = config.getPort();

        workerThreads = config.getWorkerThreads();

        workerExecutor = newFixedThreadPool(workerThreads, new ThreadFactoryBuilder().setNameFormat("thrift-worker-%s").build());

        acceptorExecutor = newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat("thrift-acceptor-%s").build());
        ioExecutor = newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat("thrift-io-%s").build());

        serverChannelFactory = new NioServerSocketChannelFactory(acceptorExecutor, ioExecutor);

        ThriftServerDef thriftServerDef = ThriftServerDef.newBuilder()
                                                         .name("thrift")
View Full Code Here

TOP

Related Classes of com.google.common.util.concurrent.ThreadFactoryBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.