use of java.util.concurrent.SynchronousQueue in project jPOS by jpos.
the class TSpacePerformanceTest method testStolenEntryAtNotify.
@Disabled("Remove it when TSpace can pass it")
@Test
public void testStolenEntryAtNotify() throws Throwable {
int size = 10;
final ExecutorService es = new ThreadPoolExecutor(size * 2, Integer.MAX_VALUE, 30, TimeUnit.SECONDS, new SynchronousQueue());
((ThreadPoolExecutor) es).prestartAllCoreThreads();
for (int i = 0; i < size; i++) es.execute(new WriteSpaceWithNotifyReadTask("WriteTask-" + i));
// Threads which may stole entries
for (int i = 0; i < size; i++) es.execute(new ReadSpaceTask("WriteTask-" + i));
assertNull(sp2.in("lost-entry", 200), "Detected stolen entry at notify");
es.shutdownNow();
// es.awaitTermination(5, TimeUnit.SECONDS);
}
use of java.util.concurrent.SynchronousQueue in project jPOS by jpos.
the class TSpacePerformanceTest method testReadPerformance.
@Test
public void testReadPerformance() throws Throwable {
int size = 10;
ExecutorService es = new ThreadPoolExecutor(size, Integer.MAX_VALUE, 30, TimeUnit.SECONDS, new SynchronousQueue());
((ThreadPoolExecutor) es).prestartAllCoreThreads();
for (int i = 0; i < size; i++) es.execute(new WriteSpaceTask("PerformTask-" + i));
ISOUtil.sleep(500);
printAvg(t1, "Avg. write: ");
for (int i = 0; i < size; i++) es.execute(new ReadSpaceTask("PerformTask-" + i));
ISOUtil.sleep(500);
es.shutdown();
printAvg(t2, "Avg. read : ");
}
use of java.util.concurrent.SynchronousQueue in project jPOS by jpos.
the class OneShotChannelAdaptorMK2 method startService.
public void startService() {
setRealm(getName());
cnt = new AtomicInteger(0);
threadPool = new ThreadPoolExecutor(1, maxConnections, 10, TimeUnit.SECONDS, new SynchronousQueue<Runnable>());
new Thread(this).start();
checkTimer = Executors.newScheduledThreadPool(1);
checkTimer.scheduleAtFixedRate(new CheckChannelTask(), 0L, checkInterval, TimeUnit.MILLISECONDS);
}
use of java.util.concurrent.SynchronousQueue in project metacat by Netflix.
the class AbstractThriftServer method start.
/**
* Server initialization.
*
* @throws Exception error
*/
public void start() throws Exception {
log.info("initializing thrift server {}", getServerName());
final ThreadFactory threadFactory = new ThreadFactoryBuilder().setNameFormat(threadPoolNameFormat).setUncaughtExceptionHandler((t, e) -> log.error("Uncaught exception in thread: {}", t.getName(), e)).build();
final ExecutorService executorService = new ThreadPoolExecutor(Math.min(2, config.getThriftServerMaxWorkerThreads()), config.getThriftServerMaxWorkerThreads(), 60L, TimeUnit.SECONDS, new SynchronousQueue<>(), threadFactory);
RegistryUtil.registerThreadPool(registry, threadPoolNameFormat, (ThreadPoolExecutor) executorService);
final int timeout = config.getThriftServerSocketClientTimeoutInSeconds() * 1000;
final TServerTransport serverTransport = new TServerSocket(portNumber, timeout);
startServing(executorService, serverTransport);
}
use of java.util.concurrent.SynchronousQueue in project verify-hub by alphagov.
the class PrometheusClient method createMatchingServiceHealthCheckMetrics.
public void createMatchingServiceHealthCheckMetrics() {
final PrometheusClientServiceConfiguration configuration = samlSoapProxyConfiguration.getMatchingServiceHealthCheckServiceConfiguration();
if (configuration.getEnable()) {
Gauge healthStatusGauge = Gauge.build(VERIFY_SAML_SOAP_PROXY_MSA_HEALTH_STATUS, VERIFY_SAML_SOAP_PROXY_MSA_HEALTH_STATUS_HELP).labelNames("matchingService").register();
Gauge healthStatusLastUpdatedGauge = Gauge.build(VERIFY_SAML_SOAP_PROXY_MSA_HEALTH_STATUS_LAST_UPDATED, VERIFY_SAML_SOAP_PROXY_MSA_HEALTH_STATUS_LAST_UPDATED_HELP).labelNames("matchingService").register();
MatchingServiceInfoMetric infoMetric = new MatchingServiceInfoMetric().register();
ExecutorService matchingServiceHealthCheckTaskManager = environment.lifecycle().executorService(MSA_HEALTH_CHECK_TASK_MANAGER).threadFactory(new ThreadFactoryBuilder().setNameFormat(MSA_HEALTH_CHECK_TASK_MANAGER).setDaemon(USE_DAEMON_THREADS).build()).minThreads(configuration.getMinNumOfThreads()).maxThreads(configuration.getMaxNumOfThreads()).keepAliveTime(configuration.getKeepAliveTime()).workQueue(new SynchronousQueue<>()).build();
MatchingServiceHealthCheckService matchingServiceHealthCheckService = new MatchingServiceHealthCheckService(matchingServiceHealthCheckTaskManager, samlSoapProxyConfiguration.getHealthCheckSoapHttpClient().getTimeout(), matchingServiceConfigProxy, matchingServiceHealthChecker, healthStatusGauge, healthStatusLastUpdatedGauge, infoMetric);
createScheduledExecutorService(configuration, VERIFY_SAML_SOAP_PROXY_MSA_HEALTH_STATUS, matchingServiceHealthCheckService);
}
}
Aggregations