Example usage for java.util.concurrent Executors defaultThreadFactory

List of usage examples for java.util.concurrent Executors defaultThreadFactory

Introduction

In this page you can find the example usage for java.util.concurrent Executors defaultThreadFactory.

Prototype

public static ThreadFactory defaultThreadFactory() 

Source Link

Document

Returns a default thread factory used to create new threads.

Usage

From source file:com.aliyun.oss.common.comm.TimeoutServiceClient.java

public TimeoutServiceClient(ClientConfiguration config) {
    super(config);

    int processors = Runtime.getRuntime().availableProcessors();
    executor = new ThreadPoolExecutor(processors * 5, processors * 10, 60L, TimeUnit.SECONDS,
            new ArrayBlockingQueue<Runnable>(processors * 100), Executors.defaultThreadFactory(),
            new ThreadPoolExecutor.CallerRunsPolicy());
    executor.allowCoreThreadTimeOut(true);
}

From source file:io.github.mmichaelis.selenium.client.provider.internal.QuitWebDriverRunnableTest.java

@Test
public void ignore_failure_when_server_is_unreachable_meanwhile() throws Exception {
    final Runnable runnable = new QuitWebDriverRunnable(driver);
    final Thread thread = Executors.defaultThreadFactory().newThread(runnable);
    Mockito.doThrow(unreachableBrowserException).when(driver).quit();
    thread.start();/*  w w  w . j  a  va2  s .  co m*/
    thread.join();
    verify(driver, atLeastOnce()).quit();
}

From source file:com.meltmedia.dropwizard.etcd.cluster.ClusterProcessorIT.java

@Before
public void setUp() throws Exception {
    ObjectMapper mapper = new ObjectMapper();
    executor = Executors.newScheduledThreadPool(4, Executors.defaultThreadFactory());
    lifecycle = mock(ClusterProcessLifecycle.class);

    service = ClusterProcessor.<NodeData>builder().withMapper(mapper)
            .withDirectory(factoryRule.getFactory().newDirectory("/jobs", new TypeReference<ClusterProcess>() {
            })).withLifecycleFactory(d -> lifecycle).withNodeId("1").withType(new TypeReference<NodeData>() {
            }).build();//from ww w  . j a v  a  2  s  . c  o  m

    dao = new EtcdDirectoryDao<ClusterProcess>(etcdClientSupplier::getClient, "/test/jobs", mapper,
            new TypeReference<ClusterProcess>() {
            });

    service.start();
}

From source file:de.jackwhite20.japs.client.cache.impl.PubSubCacheImpl.java

public PubSubCacheImpl(List<ClusterServer> clusterServers) {

    super(clusterServers);

    this.executorService = Executors.newSingleThreadExecutor(r -> {
        Thread thread = Executors.defaultThreadFactory().newThread(r);
        thread.setName("PubSubCache Thread");

        return thread;
    });// w ww .j  a va 2 s  .co m
    this.asyncPubSubCache = new AsyncPubSubCacheImpl(executorService, this);
}

From source file:org.elasticsoftware.elasticactors.http.actors.HttpService.java

@PostConstruct
public void init() {
    ExecutorService bossExecutor = Executors.newCachedThreadPool(Executors.defaultThreadFactory());
    ExecutorService workerExecutor = Executors.newCachedThreadPool(Executors.defaultThreadFactory());
    int workers = Runtime.getRuntime().availableProcessors();
    NioServerSocketChannelFactory channelFactory = new NioServerSocketChannelFactory(bossExecutor,
            workerExecutor, workers);//from www . j  a  va 2  s .  c o  m
    httpServer = new HttpServer(channelFactory, this, actorSystem,
            configuration.getProperty(this.getClass(), "listenPort", Integer.class, 8080));
    httpServer.init();
}

From source file:com.moilioncircle.redis.replicator.io.AsyncBufferedInputStream.java

public AsyncBufferedInputStream(InputStream is, int size) {
    this(is, size, Executors.defaultThreadFactory());
}

From source file:io.selendroid.server.SelendroidStandaloneServer.java

public SelendroidStandaloneServer(SelendroidConfiguration configuration)
        throws AndroidSdkException, AndroidDeviceException {
    this.configuration = configuration;
    NamingThreadFactory namingThreadFactory = new NamingThreadFactory(Executors.defaultThreadFactory(),
            "selendroid-standalone-handler");
    webServer = WebServers.createWebServer(Executors.newCachedThreadPool(namingThreadFactory),
            new InetSocketAddress(configuration.getPort()), remoteUri(configuration.getPort()));
    driver = initializeSelendroidServer();
    init();/*www .j  a  v  a  2s  .  c  o  m*/
}

From source file:org.fuin.esc.eshttp.ESHttpEventStoreIT.java

@Before
public void setup() throws MalformedURLException {

    final ThreadFactory threadFactory = Executors.defaultThreadFactory();
    final URL url = new URL("http://127.0.0.1:2113/");
    final XmlDeSerializer xmlDeSer = new XmlDeSerializer(false, MyMeta.class, MyEvent.class, EscEvent.class,
            EscEvents.class, EscMeta.class);

    final SimpleSerializerDeserializerRegistry registry = new SimpleSerializerDeserializerRegistry();
    registry.add(new SerializedDataType(MyEvent.TYPE.asBaseType()), "application/xml", xmlDeSer);
    registry.add(new SerializedDataType(MyMeta.TYPE.asBaseType()), "application/xml", xmlDeSer);
    registry.add(new SerializedDataType(EscEvent.TYPE.asBaseType()), "application/xml", xmlDeSer);
    registry.add(new SerializedDataType(EscEvents.TYPE.asBaseType()), "application/xml", xmlDeSer);
    registry.add(new SerializedDataType(EscMeta.TYPE.asBaseType()), "application/xml", xmlDeSer);

    registry.add(new SerializedDataType(CUSTOMER_CREATED.asBaseType()), "application/xml", xmlDeSer);
    registry.add(new SerializedDataType(CUSTOMER_RENAMED.asBaseType()), "application/xml", xmlDeSer);

    final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
    final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials("admin", "changeit");
    credentialsProvider.setCredentials(AuthScope.ANY, credentials);

    testee = new ESHttpEventStore(threadFactory, url, ESEnvelopeType.XML, registry, registry,
            credentialsProvider);/*from  ww w  . j  a va 2s  . co m*/
    testee.open();

}

From source file:io.github.mmichaelis.selenium.client.provider.internal.QuitWebDriverRunnableTest.java

@Test
public void ignore_failure_on_any_other_failure_when_quitting() throws Exception {
    final Runnable runnable = new QuitWebDriverRunnable(driver);
    final Thread thread = Executors.defaultThreadFactory().newThread(runnable);
    Mockito.doThrow(webDriverException).when(driver).quit();
    thread.start();//from   w w  w  . j  a va2s  . com
    thread.join();
    verify(driver, atLeastOnce()).quit();
}

From source file:com.ning.metrics.eventtracker.ScribeSender.java

public ScribeSender(ScribeClient scribeClient, int messagesToSendBeforeReconnecting, int maxIdleTimeInMinutes) {
    this.scribeClient = scribeClient;
    this.messagesToSendBeforeReconnecting = messagesToSendBeforeReconnecting;

    // Setup a watchdog for the Scribe connection. We don't want to keep it open forever. For instance, SLB VIP
    // may trigger a RST if idle more than a few minutes.
    final ScheduledExecutorService executor = new ScheduledThreadPoolExecutor(1,
            Executors.defaultThreadFactory());
    executor.scheduleAtFixedRate(new Runnable() {
        @Override/*from   ww w .ja  v a 2s  .com*/
        public void run() {
            if (sleeping.get()) {
                log.info("Idle connection to Scribe, re-opening it");
                createConnection();
            }
            sleeping.set(true);
        }
    }, maxIdleTimeInMinutes, maxIdleTimeInMinutes, TimeUnit.MINUTES);
}