List of usage examples for java.util.concurrent Executors newCachedThreadPool
public static ExecutorService newCachedThreadPool()
From source file:edu.cmu.lti.oaqa.bioasq.concept.retrieval.GoPubMedSeparateConceptRetrievalExecutor.java
@Override public void process(JCas jcas) throws AnalysisEngineProcessException { AbstractQuery aquery = TypeUtil.getAbstractQueries(jcas).stream().findFirst().get(); Collection<QueryConcept> qconcepts = TypeUtil.getQueryConcepts(aquery); List<ConceptSearchResult> concepts = Collections.synchronizedList(new ArrayList<>()); ExecutorService es = Executors.newCachedThreadPool(); for (QueryConcept qconcept : qconcepts) { String queryString = bopQueryStringConstructor.formatQueryConcept(qconcept) .replaceAll("[^A-Za-z0-9_\\-\"]+", " "); LOG.info("Query string: {}", queryString); for (BioASQUtil.Ontology ontology : BioASQUtil.Ontology.values()) { es.execute(() -> {/*w w w . ja v a 2s .c o m*/ try { concepts.addAll( BioASQUtil.searchOntology(service, jcas, queryString, pages, hits, ontology)); } catch (IOException e) { throw new RuntimeException(e); } }); } } es.shutdown(); try { if (!es.awaitTermination(timeout, TimeUnit.MINUTES)) { LOG.warn("Timeout occurs for one or some concept retrieval services."); } } catch (InterruptedException e) { throw new AnalysisEngineProcessException(e); } Map<String, List<ConceptSearchResult>> onto2concepts = concepts.stream() .collect(groupingBy(ConceptSearchResult::getSearchId)); for (Map.Entry<String, List<ConceptSearchResult>> entry : onto2concepts.entrySet()) { List<ConceptSearchResult> results = entry.getValue(); LOG.info("Retrieved {} concepts from {}", results.size(), entry.getKey()); if (LOG.isDebugEnabled()) { results.stream().limit(10).forEach(c -> LOG.debug(" - {}", TypeUtil.toString(c))); } } TypeUtil.rankedSearchResultsByScore(concepts, limit).forEach(ConceptSearchResult::addToIndexes); }
From source file:com.ottogroup.bi.spqr.pipeline.component.operator.DelayedResponseOperatorRuntimeEnvironment.java
/** * Initializes the runtime environment using the provied input * @param processingNodeId// w w w. j ava2 s .c o m * @param pipelineId * @param delayedResponseOperator * @param responseWaitStrategy * @param queueConsumer * @param queueProducer * @throws RequiredInputMissingException */ public DelayedResponseOperatorRuntimeEnvironment(final String processingNodeId, final String pipelineId, final DelayedResponseOperator delayedResponseOperator, final DelayedResponseOperatorWaitStrategy responseWaitStrategy, final StreamingMessageQueueConsumer queueConsumer, final StreamingMessageQueueProducer queueProducer) throws RequiredInputMissingException { this(processingNodeId, pipelineId, delayedResponseOperator, responseWaitStrategy, queueConsumer, queueProducer, Executors.newCachedThreadPool()); this.localExecutorService = true; }
From source file:com.vmware.bdd.plugin.clouderamgr.poller.host.HostInstallPoller.java
@Override public void setup() { try {/*from ww w .ja v a2 s. c o m*/ login(); httpClientConnectionManager = new PoolingHttpClientConnectionManager(); httpClientConnectionManager.setMaxTotal(20); this.httpClient = HttpClients.custom().setDefaultCookieStore(cookieStore) .setConnectionManager(httpClientConnectionManager).build(); int maxSessionNum = 10; int i = 0; reported = true; executor = Executors.newCachedThreadPool(); for (final ApiCommand command : rootResource.getCommandsResource().readCommand(parentCmdId) .getChildren()) { /* Each crawler will launch a http session with CM server and keep on requesting. * So far, we only report cluster level status, so it's no need to monitor each subcommand, * especially for large scale cluster. */ if (i == maxSessionNum) { break; } executor.submit(new Crawler(command.getId())); i += 1; } } catch (Exception e) { // As this implementation does not follow official APIs, may not work // in future version, just ignore any exception } }
From source file:org.openwms.common.comm.app.DriverConfig.java
@Bean
MessageChannel inboundChannel() {
return MessageChannels.executor(Executors.newCachedThreadPool()).get();
}
From source file:eu.seaclouds.common.compose.apps.AbstractSeaCloudsAppTest.java
@BeforeMethod(alwaysRun = true) public void setUp() throws Exception { mementoDir = Os.newTempDir(getClass()); mgmt = createOrigManagementContext(); LOG.info("Test " + getClass() + " persisting to " + mementoDir); launcher = new SimpleYamlLauncherForTests() { @Override/*from ww w . jav a2s.c o m*/ protected BrooklynCampPlatformLauncherAbstract newPlatformLauncher() { return new BrooklynCampPlatformLauncher() { protected ManagementContext newManagementContext() { return AbstractSeaCloudsAppTest.this.mgmt; } }; } }; viewer = BrooklynLauncher.newInstance().managementContext(mgmt).start(); executor = Executors.newCachedThreadPool(); }
From source file:com.amazonaws.services.dynamodbv2.streamsadapter.functionals.FunctionalTestBase.java
protected void startKCLWorker(KinesisClientLibConfiguration workerConfig) { recordProcessorFactory = new TestRecordProcessorFactory(dynamoDBClient, destTable); LOG.info("Creating worker for stream: " + streamId); worker = StreamsWorkerFactory.createDynamoDbStreamsWorker(recordProcessorFactory, workerConfig, adapterClient, dynamoDBClient, new NullMetricsFactory(), Executors.newCachedThreadPool()); LOG.info("Starting worker..."); workerThread = Executors.newSingleThreadExecutor(); workerThread.submit(worker);//from ww w . ja va 2s . co m workerThread.shutdown(); //This will wait till the KCL worker exits }
From source file:org.apache.hadoop.gateway.shell.Hadoop.java
public Hadoop(ClientContext clientContext) throws HadoopException, URISyntaxException { this.executor = Executors.newCachedThreadPool(); this.base = clientContext.url(); try {// w w w. ja v a2 s . c o m client = createClient(clientContext); } catch (GeneralSecurityException e) { throw new HadoopException("Failed to create HTTP client.", e); } }
From source file:org.openwms.common.comm.app.DriverConfig.java
@Bean
MessageChannel outboundChannel() {
return MessageChannels.executor(Executors.newCachedThreadPool()).get();
}
From source file:com.amazonaws.services.kinesis.multilang.MessageReaderTest.java
@Test public void drainInputTest() throws InterruptedException, ExecutionException { String[] sequenceNumbers = new String[] { "123", "456", "789" }; String[] responseFors = new String[] { "initialize", "processRecords", "processRecords", "shutdown" }; InputStream stream = buildInputStreamOfGoodInput(sequenceNumbers, responseFors); MessageReader reader = new MessageReader().initialize(stream, shardId, new ObjectMapper(), Executors.newCachedThreadPool()); Future<Boolean> drainFuture = reader.drainSTDOUT(); Boolean drainResult = drainFuture.get(); Assert.assertNotNull(drainResult);/*from w ww.j ava 2s .co m*/ Assert.assertTrue(drainResult); }
From source file:com.alliander.osgp.adapter.protocol.iec61850.application.config.Iec61850Config.java
/** * Returns a ServerBootstrap setting up a server pipeline listening for * incoming IEC61850 register device requests. * * @return an IEC61850 server bootstrap. */// w ww. ja v a 2 s . c o m @Bean(destroyMethod = "releaseExternalResources") public ServerBootstrap serverBootstrap() { final ChannelFactory factory = new NioServerSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool()); final ServerBootstrap bootstrap = new ServerBootstrap(factory); bootstrap.setPipelineFactory(new ChannelPipelineFactory() { @Override public ChannelPipeline getPipeline() throws ProtocolAdapterException { final ChannelPipeline pipeline = Iec61850Config.this .createChannelPipeline(Iec61850Config.this.iec61850ChannelHandlerServer()); LOGGER.info("Created new IEC61850 handler pipeline for server"); return pipeline; } }); bootstrap.setOption("child.tcpNoDelay", true); bootstrap.setOption("child.keepAlive", false); bootstrap.bind(new InetSocketAddress(this.iec61850PortListener())); return bootstrap; }