当前位置: 首页>>代码示例>>Java>>正文


Java NamedThreadFactory类代码示例

本文整理汇总了Java中org.apache.cassandra.concurrent.NamedThreadFactory的典型用法代码示例。如果您正苦于以下问题:Java NamedThreadFactory类的具体用法?Java NamedThreadFactory怎么用?Java NamedThreadFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NamedThreadFactory类属于org.apache.cassandra.concurrent包,在下文中一共展示了NamedThreadFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initSyncExecutor

import org.apache.cassandra.concurrent.NamedThreadFactory; //导入依赖的package包/类
private static ScheduledThreadPoolExecutor initSyncExecutor()
{
    if (DatabaseDescriptor.isClientOrToolInitialized())
        return null;

    // Do NOT start this thread pool in client mode

    ScheduledThreadPoolExecutor syncExecutor = new ScheduledThreadPoolExecutor(1, new NamedThreadFactory("read-hotness-tracker"));
    // Immediately remove readMeter sync task when cancelled.
    syncExecutor.setRemoveOnCancelPolicy(true);
    return syncExecutor;
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:13,代码来源:SSTableReader.java

示例2: initializeThreadPool

import org.apache.cassandra.concurrent.NamedThreadFactory; //导入依赖的package包/类
@VisibleForTesting
public void initializeThreadPool(
    int threadAmount,
    long repairTimeout,
    TimeUnit repairTimeoutTimeUnit,
    long retryDelay,
    TimeUnit retryDelayTimeUnit) {

  executor = MoreExecutors.listeningDecorator(
      Executors.newScheduledThreadPool(threadAmount, new NamedThreadFactory("RepairRunner")));

  repairTimeoutMillis = repairTimeoutTimeUnit.toMillis(repairTimeout);
  retryDelayMillis = retryDelayTimeUnit.toMillis(retryDelay);
}
 
开发者ID:thelastpickle,项目名称:cassandra-reaper,代码行数:15,代码来源:RepairManager.java

示例3: buildTServer

import org.apache.cassandra.concurrent.NamedThreadFactory; //导入依赖的package包/类
public TServer buildTServer(Args args)
{
    if (DatabaseDescriptor.getClientEncryptionOptions().enabled)
        throw new RuntimeException("Client SSL is not supported for non-blocking sockets (hsha). Please remove client ssl from the configuration.");

    final InetSocketAddress addr = args.addr;
    TNonblockingServerTransport serverTransport;
    try
    {
        serverTransport = new TCustomNonblockingServerSocket(addr, args.keepAlive, args.sendBufferSize, args.recvBufferSize);
    }
    catch (TTransportException e)
    {
        throw new RuntimeException(String.format("Unable to create thrift socket to %s:%s", addr.getAddress(), addr.getPort()), e);
    }

    ThreadPoolExecutor invoker = new JMXEnabledThreadPoolExecutor(DatabaseDescriptor.getRpcMinThreads(),
                                                                  DatabaseDescriptor.getRpcMaxThreads(),
                                                                  60L,
                                                                  TimeUnit.SECONDS,
                                                                  new SynchronousQueue<Runnable>(),
                                                                  new NamedThreadFactory("RPC-Thread"), "RPC-THREAD-POOL");

    com.thinkaurelius.thrift.util.TBinaryProtocol.Factory protocolFactory = new com.thinkaurelius.thrift.util.TBinaryProtocol.Factory(true, true);

    TDisruptorServer.Args serverArgs = new TDisruptorServer.Args(serverTransport).useHeapBasedAllocation(true)
                                                                                 .inputTransportFactory(args.inTransportFactory)
                                                                                 .outputTransportFactory(args.outTransportFactory)
                                                                                 .inputProtocolFactory(protocolFactory)
                                                                                 .outputProtocolFactory(protocolFactory)
                                                                                 .processor(args.processor)
                                                                                 .maxFrameSizeInBytes(DatabaseDescriptor.getThriftFramedTransportSize())
                                                                                 .invocationExecutor(invoker)
                                                                                 .alwaysReallocateBuffers(true);

    return new THsHaDisruptorServer(serverArgs);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:38,代码来源:THsHaDisruptorServer.java

示例4: main

import org.apache.cassandra.concurrent.NamedThreadFactory; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    int NUM_THREADS = Runtime.getRuntime().availableProcessors();
    if (args.length >= 1) {
        NUM_THREADS = Integer.parseInt(args[0]);
        System.out.println("Setting num threads to: " + NUM_THREADS);
    }
    ExecutorService executor = new JMXEnabledThreadPoolExecutor(NUM_THREADS, NUM_THREADS, 60,
            TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(10 * NUM_THREADS), new NamedThreadFactory(""), "");
    ScheduledExecutorService scheduled = Executors.newScheduledThreadPool(1);

    org.apache.cassandra.SchemaLoader.loadSchema();
    final AtomicLong count = new AtomicLong();
    final long start = System.currentTimeMillis();
    System.out.println(String.format(format, "seconds", "max_mb", "allocated_mb", "free_mb", "diffrence", "count"));
    scheduled.scheduleAtFixedRate(new Runnable() {
        long lastUpdate = 0;

        public void run() {
            Runtime runtime = Runtime.getRuntime();
            long maxMemory = mb(runtime.maxMemory());
            long allocatedMemory = mb(runtime.totalMemory());
            long freeMemory = mb(runtime.freeMemory());
            long temp = count.get();
            System.out.println(String.format(format, ((System.currentTimeMillis() - start) / 1000),
                    maxMemory, allocatedMemory, freeMemory, (temp - lastUpdate), lastUpdate));
            lastUpdate = temp;
        }
    }, 1, 1, TimeUnit.SECONDS);

    while (true) {
        executor.execute(new CommitlogExecutor());
        count.incrementAndGet();
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:35,代码来源:ComitLogStress.java

示例5: RequestThreadPoolExecutor

import org.apache.cassandra.concurrent.NamedThreadFactory; //导入依赖的package包/类
public RequestThreadPoolExecutor()
{
    super(DatabaseDescriptor.getNativeTransportMaxThreads(),
          0, // We don't use the per-channel limit, only the global one
          MAX_QUEUED_REQUESTS,
          CORE_THREAD_TIMEOUT_SEC, TimeUnit.SECONDS,
          sizeEstimator(),
          new NamedThreadFactory("Native-Transport-Requests"));
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:10,代码来源:RequestThreadPoolExecutor.java

示例6: HintsDispatchExecutor

import org.apache.cassandra.concurrent.NamedThreadFactory; //导入依赖的package包/类
HintsDispatchExecutor(File hintsDirectory, int maxThreads, AtomicBoolean isPaused)
{
    this.hintsDirectory = hintsDirectory;
    this.isPaused = isPaused;

    scheduledDispatches = new ConcurrentHashMap<>();
    executor = new JMXEnabledThreadPoolExecutor(1,
                                                maxThreads,
                                                1,
                                                TimeUnit.MINUTES,
                                                new LinkedBlockingQueue<>(),
                                                new NamedThreadFactory("HintsDispatcher", Thread.MIN_PRIORITY),
                                                "internal");
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:15,代码来源:HintsDispatchExecutor.java

示例7: UDFExecutorService

import org.apache.cassandra.concurrent.NamedThreadFactory; //导入依赖的package包/类
UDFExecutorService(NamedThreadFactory threadFactory, String jmxPath)
{
    super(FBUtilities.getAvailableProcessors(),
          KEEPALIVE,
          TimeUnit.MILLISECONDS,
          new LinkedBlockingQueue<>(),
          threadFactory,
          jmxPath);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:10,代码来源:UDFExecutorService.java

示例8: buildTServer

import org.apache.cassandra.concurrent.NamedThreadFactory; //导入依赖的package包/类
@SuppressWarnings("resource")
public TServer buildTServer(Args args)
{
    if (DatabaseDescriptor.getClientEncryptionOptions().enabled)
        throw new RuntimeException("Client SSL is not supported for non-blocking sockets (hsha). Please remove client ssl from the configuration.");

    final InetSocketAddress addr = args.addr;
    TNonblockingServerTransport serverTransport;
    try
    {
        serverTransport = new TCustomNonblockingServerSocket(addr, args.keepAlive, args.sendBufferSize, args.recvBufferSize);
    }
    catch (TTransportException e)
    {
        throw new RuntimeException(String.format("Unable to create thrift socket to %s:%s", addr.getAddress(), addr.getPort()), e);
    }

    ThreadPoolExecutor invoker = new JMXEnabledThreadPoolExecutor(DatabaseDescriptor.getRpcMinThreads(),
                                                                  DatabaseDescriptor.getRpcMaxThreads(),
                                                                  60L,
                                                                  TimeUnit.SECONDS,
                                                                  new SynchronousQueue<Runnable>(),
                                                                  new NamedThreadFactory("RPC-Thread"), "RPC-THREAD-POOL");

    com.thinkaurelius.thrift.util.TBinaryProtocol.Factory protocolFactory = new com.thinkaurelius.thrift.util.TBinaryProtocol.Factory(true, true);

    TDisruptorServer.Args serverArgs = new TDisruptorServer.Args(serverTransport).useHeapBasedAllocation(true)
                                                                                 .inputTransportFactory(args.inTransportFactory)
                                                                                 .outputTransportFactory(args.outTransportFactory)
                                                                                 .inputProtocolFactory(protocolFactory)
                                                                                 .outputProtocolFactory(protocolFactory)
                                                                                 .processor(args.processor)
                                                                                 .maxFrameSizeInBytes(DatabaseDescriptor.getThriftFramedTransportSize())
                                                                                 .invocationExecutor(invoker)
                                                                                 .alwaysReallocateBuffers(true);

    return new THsHaDisruptorServer(serverArgs);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:39,代码来源:THsHaDisruptorServer.java

示例9: main

import org.apache.cassandra.concurrent.NamedThreadFactory; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    int NUM_THREADS = Runtime.getRuntime().availableProcessors();
    if (args.length >= 1) {
        NUM_THREADS = Integer.parseInt(args[0]);
        System.out.println("Setting num threads to: " + NUM_THREADS);
    }
    ExecutorService executor = new JMXEnabledThreadPoolExecutor(NUM_THREADS, NUM_THREADS, 60,
            TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(10 * NUM_THREADS), new NamedThreadFactory(""), "");
    ScheduledExecutorService scheduled = Executors.newScheduledThreadPool(1);

    org.apache.cassandra.SchemaLoader.loadSchema();
    org.apache.cassandra.SchemaLoader.schemaDefinition(""); // leave def. blank to maintain old behaviour
    final AtomicLong count = new AtomicLong();
    final long start = System.currentTimeMillis();
    System.out.println(String.format(format, "seconds", "max_mb", "allocated_mb", "free_mb", "diffrence", "count"));
    scheduled.scheduleAtFixedRate(new Runnable() {
        long lastUpdate = 0;

        public void run() {
            Runtime runtime = Runtime.getRuntime();
            long maxMemory = mb(runtime.maxMemory());
            long allocatedMemory = mb(runtime.totalMemory());
            long freeMemory = mb(runtime.freeMemory());
            long temp = count.get();
            System.out.println(String.format(format, ((System.currentTimeMillis() - start) / 1000),
                    maxMemory, allocatedMemory, freeMemory, (temp - lastUpdate), lastUpdate));
            lastUpdate = temp;
        }
    }, 1, 1, TimeUnit.SECONDS);

    while (true) {
        executor.execute(new CommitlogExecutor());
        count.incrementAndGet();
    }
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:36,代码来源:ComitLogStress.java

示例10: buildTServer

import org.apache.cassandra.concurrent.NamedThreadFactory; //导入依赖的package包/类
public TServer buildTServer(Args args)
{
    if (DatabaseDescriptor.getClientEncryptionOptions().enabled)
        throw new RuntimeException("Client SSL is not supported for non-blocking sockets (hsha). Please remove client ssl from the configuration.");

    final InetSocketAddress addr = args.addr;
    TNonblockingServerTransport serverTransport;
    try
    {
        serverTransport = new TCustomNonblockingServerSocket(addr, args.keepAlive, args.sendBufferSize, args.recvBufferSize);
    }
    catch (TTransportException e)
    {
        throw new RuntimeException(String.format("Unable to create thrift socket to %s:%s", addr.getAddress(), addr.getPort()), e);
    }

    // This is NIO selector service but the invocation will be Multi-Threaded with the Executor service.
    ExecutorService executorService = new JMXEnabledThreadPoolExecutor(DatabaseDescriptor.getRpcMinThreads(),
                                                                       DatabaseDescriptor.getRpcMaxThreads(),
                                                                       60L,
                                                                       TimeUnit.SECONDS,
                                                                       new SynchronousQueue<Runnable>(),
                                                                       new NamedThreadFactory("RPC-Thread"), "RPC-THREAD-POOL");
    TNonblockingServer.Args serverArgs = new TNonblockingServer.Args(serverTransport).inputTransportFactory(args.inTransportFactory)
                                                                       .outputTransportFactory(args.outTransportFactory)
                                                                       .inputProtocolFactory(args.tProtocolFactory)
                                                                       .outputProtocolFactory(args.tProtocolFactory)
                                                                       .processor(args.processor);
    // Check for available processors in the system which will be equal to the IO Threads.
    return new CustomTHsHaServer(serverArgs, executorService, FBUtilities.getAvailableProcessors());
}
 
开发者ID:dprguiuc,项目名称:Cassandra-Wasef,代码行数:32,代码来源:CustomTHsHaServer.java

示例11: RequestThreadPoolExecutor

import org.apache.cassandra.concurrent.NamedThreadFactory; //导入依赖的package包/类
public RequestThreadPoolExecutor()
{
    super(DatabaseDescriptor.getNativeTransportMaxThreads(),
          0, // We don't use the per-channel limit, only the global one
          MAX_QUEUED_REQUESTS,
          CORE_THREAD_TIMEOUT_SEC, TimeUnit.SECONDS,
          sizeEstimator(),
          new NamedThreadFactory(THREAD_FACTORY_ID));
    metrics = new ThreadPoolMetrics(this, "transport", THREAD_FACTORY_ID);
}
 
开发者ID:mafernandez-stratio,项目名称:cassandra-cqlMod,代码行数:11,代码来源:RequestThreadPoolExecutor.java

示例12: CompactionExecutor

import org.apache.cassandra.concurrent.NamedThreadFactory; //导入依赖的package包/类
protected CompactionExecutor(int minThreads, int maxThreads, String name, BlockingQueue<Runnable> queue)
{
    super(minThreads,
          maxThreads,
          60,
          TimeUnit.SECONDS,
          queue,
          new NamedThreadFactory(name, DatabaseDescriptor.getCompactionThreadPriority()));
}
 
开发者ID:devdattakulkarni,项目名称:Cassandra-KVPM,代码行数:10,代码来源:CompactionManager.java

示例13: CompactionExecutor

import org.apache.cassandra.concurrent.NamedThreadFactory; //导入依赖的package包/类
protected CompactionExecutor(int minThreads, int maxThreads, String name, BlockingQueue<Runnable> queue)
{
    super(minThreads, maxThreads, 60, TimeUnit.SECONDS, queue, new NamedThreadFactory(name, Thread.MIN_PRIORITY), "internal");
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:5,代码来源:CompactionManager.java

示例14: buildTServer

import org.apache.cassandra.concurrent.NamedThreadFactory; //导入依赖的package包/类
public TServer buildTServer(Args args)
{
    final InetSocketAddress addr = args.addr;
    TServerTransport serverTransport;
    try
    {
        final ClientEncryptionOptions clientEnc = DatabaseDescriptor.getClientEncryptionOptions();
        if (clientEnc.enabled)
        {
            logger.info("enabling encrypted thrift connections between client and server");
            TSSLTransportParameters params = new TSSLTransportParameters(clientEnc.protocol, clientEnc.cipher_suites);
            params.setKeyStore(clientEnc.keystore, clientEnc.keystore_password);
            if (clientEnc.require_client_auth)
            {
                params.setTrustStore(clientEnc.truststore, clientEnc.truststore_password);
                params.requireClientAuth(true);
            }
            TServerSocket sslServer = TSSLTransportFactory.getServerSocket(addr.getPort(), 0, addr.getAddress(), params);
            SSLServerSocket sslServerSocket = (SSLServerSocket) sslServer.getServerSocket();
            sslServerSocket.setEnabledProtocols(SSLFactory.ACCEPTED_PROTOCOLS);
            serverTransport = new TCustomServerSocket(sslServer.getServerSocket(), args.keepAlive, args.sendBufferSize, args.recvBufferSize);
        }
        else
        {
            serverTransport = new TCustomServerSocket(addr, args.keepAlive, args.sendBufferSize, args.recvBufferSize, args.listenBacklog);
        }
    }
    catch (TTransportException e)
    {
        throw new RuntimeException(String.format("Unable to create thrift socket to %s:%s", addr.getAddress(), addr.getPort()), e);
    }
    // ThreadPool Server and will be invocation per connection basis...
    TThreadPoolServer.Args serverArgs = new TThreadPoolServer.Args(serverTransport)
                                                             .minWorkerThreads(DatabaseDescriptor.getRpcMinThreads())
                                                             .maxWorkerThreads(DatabaseDescriptor.getRpcMaxThreads())
                                                             .inputTransportFactory(args.inTransportFactory)
                                                             .outputTransportFactory(args.outTransportFactory)
                                                             .inputProtocolFactory(args.tProtocolFactory)
                                                             .outputProtocolFactory(args.tProtocolFactory)
                                                             .processor(args.processor);
    ExecutorService executorService = new ThreadPoolExecutor(serverArgs.minWorkerThreads,
                                                             serverArgs.maxWorkerThreads,
                                                             60,
                                                             TimeUnit.SECONDS,
                                                             new SynchronousQueue<Runnable>(),
                                                             new NamedThreadFactory("Thrift"));
    return new CustomTThreadPoolServer(serverArgs, executorService);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:49,代码来源:CustomTThreadPoolServer.java

示例15: CompactionExecutor

import org.apache.cassandra.concurrent.NamedThreadFactory; //导入依赖的package包/类
protected CompactionExecutor(int minThreads, int maxThreads, String name, BlockingQueue<Runnable> queue)
{
    super(minThreads, maxThreads, 60, TimeUnit.SECONDS, queue, new NamedThreadFactory(name, Thread.MIN_PRIORITY));
    allowCoreThreadTimeOut(true);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:6,代码来源:CompactionManager.java


注:本文中的org.apache.cassandra.concurrent.NamedThreadFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。