List of usage examples for java.util.concurrent Executors newCachedThreadPool
public static ExecutorService newCachedThreadPool()
From source file:edu.umass.cs.gnsclient.client.http.GNSHTTPProxy.java
/** * Try to start the http server at the port. * * @param port/*www . j a v a 2 s . c o m*/ * @return true if it was started */ public HttpServer tryPort(int port) throws IOException { try { InetSocketAddress addr = new InetSocketAddress(port); HttpServer server = HttpServer.create(addr, 0); server.createContext("/", new EchoHttpHandler()); server.createContext("/" + GNS_PATH, new DefaultHttpHandler()); server.setExecutor(Executors.newCachedThreadPool()); server.start(); LOGGER.log(Level.INFO, "HTTP server is listening on port {0}", port); return server; } catch (IOException e) { LOGGER.log(Level.WARNING, "HTTP server failed to start on port " + "{0}" + " " + "due to {1}", new Object[] { port, e.getMessage() }); throw e; } }
From source file:com.thoughtworks.go.buildsession.BuildSession.java
public BuildSession(String buildId, BuildStateReporter buildStateReporter, StreamConsumer console, StrLookup buildVariables, ArtifactsRepository artifactsRepository, HttpService httpService, Clock clock, File workingDir) {/*w ww .jav a 2 s. c o m*/ this.buildId = buildId; this.buildStateReporter = buildStateReporter; this.console = console; this.buildVariables = buildVariables; this.artifactsRepository = artifactsRepository; this.httpService = httpService; this.clock = clock; this.workingDir = workingDir; this.envs = new HashMap<>(); this.secretSubstitutions = new HashMap<>(); this.buildResult = JobResult.Passed; this.doneLatch = new CountDownLatch(1); this.cancelLatch = new CountDownLatch(1); this.downloadAction = new DownloadAction(httpService, getPublisher(), clock); this.executorService = Executors.newCachedThreadPool(); }
From source file:com.alliander.osgp.adapter.protocol.oslp.elster.application.config.OslpConfig.java
@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// ww w.j a v a2s .co m public ChannelPipeline getPipeline() throws ProtocolAdapterException { final ChannelPipeline pipeline = OslpConfig.this .createChannelPipeline(OslpConfig.this.oslpChannelHandlerServer()); LOGGER.info("Created server new pipeline"); return pipeline; } }); bootstrap.setOption("child.tcpNoDelay", true); bootstrap.setOption("child.keepAlive", false); bootstrap.bind(new InetSocketAddress(this.oslpPortServer())); return bootstrap; }
From source file:com.smartitengineering.event.hub.spi.hbase.di.GuiceModule.java
@Override protected void configure() { bind(HubPersistentStorer.class).annotatedWith(Names.named("storer")).to(HubPersistentStorerImpl.class) .in(Scopes.SINGLETON);/*from www . jav a 2 s . c o m*/ bind(AsyncExecutorService.class).to(MixedExecutorServiceImpl.class).in(Scopes.SINGLETON); bind(ExecutorService.class).toInstance(Executors.newCachedThreadPool()); bind(Integer.class).annotatedWith(Names.named("maxRows")).toInstance(new Integer(100)); bind(Long.class).annotatedWith(Names.named("waitTime")).toInstance(waitTime); bind(TimeUnit.class).annotatedWith(Names.named("unit")).toInstance(TimeUnit.SECONDS); bind(Boolean.class).annotatedWith(Names.named("mergeEnabled")).toInstance(Boolean.TRUE); bind(DomainIdInstanceProvider.class).to(DomainIdInstanceProviderImpl.class).in(Scopes.SINGLETON); { bind(new TypeLiteral<ObjectRowConverter<PersistentEvent>>() { }).to(EventObjectConverter.class).in(Scopes.SINGLETON); bind(new TypeLiteral<CommonReadDao<PersistentEvent, EventId>>() { }).to(new TypeLiteral<com.smartitengineering.dao.common.CommonDao<PersistentEvent, EventId>>() { }).in(Scopes.SINGLETON); bind(new TypeLiteral<CommonWriteDao<PersistentEvent>>() { }).to(new TypeLiteral<com.smartitengineering.dao.common.CommonDao<PersistentEvent, EventId>>() { }).in(Scopes.SINGLETON); bind(new TypeLiteral<com.smartitengineering.dao.common.CommonDao<PersistentEvent, EventId>>() { }).to(new TypeLiteral<CommonDao<PersistentEvent, EventId>>() { }).in(Scopes.SINGLETON); final TypeLiteral<SchemaInfoProviderImpl<PersistentEvent, EventId>> typeLiteral = new TypeLiteral<SchemaInfoProviderImpl<PersistentEvent, EventId>>() { }; bind(new TypeLiteral<MergeService<PersistentEvent, EventId>>() { }).to(new TypeLiteral<DiffBasedMergeService<PersistentEvent, EventId>>() { }); bind(new TypeLiteral<LockAttainer<PersistentEvent, EventId>>() { }).to(new TypeLiteral<LockAttainerImpl<PersistentEvent, EventId>>() { }).in(Scopes.SINGLETON); bind(new TypeLiteral<Class<EventId>>() { }).toInstance(EventId.class); bind(new TypeLiteral<SchemaInfoProvider<PersistentEvent, EventId>>() { }).to(typeLiteral).in(Scopes.SINGLETON); bind(new TypeLiteral<FilterConfigs<PersistentEvent>>() { }).toProvider(new GenericFilterConfigsProvider<PersistentEvent>( "com/smartitengineering/event/hub/spi/hbase/persistents/EventFilterConfigs.json")) .in(Scopes.SINGLETON); bind(new TypeLiteral<SchemaInfoProviderBaseConfig<PersistentEvent>>() { }).toProvider(new GenericBaseConfigProvider<PersistentEvent>( "com/smartitengineering/event/hub/spi/hbase/persistents/EventSchemaBaseConfig.json")) .in(Scopes.SINGLETON); } { bind(new TypeLiteral<ObjectRowConverter<PersistentChannel>>() { }).to(ChannelObjectConverter.class).in(Scopes.SINGLETON); bind(new TypeLiteral<CommonReadDao<PersistentChannel, Long>>() { }).to(new TypeLiteral<com.smartitengineering.dao.common.CommonDao<PersistentChannel, Long>>() { }).in(Scopes.SINGLETON); bind(new TypeLiteral<CommonWriteDao<PersistentChannel>>() { }).to(new TypeLiteral<com.smartitengineering.dao.common.CommonDao<PersistentChannel, Long>>() { }).in(Scopes.SINGLETON); bind(new TypeLiteral<com.smartitengineering.dao.common.CommonDao<PersistentChannel, Long>>() { }).to(new TypeLiteral<CommonDao<PersistentChannel, Long>>() { }).in(Scopes.SINGLETON); final TypeLiteral<SchemaInfoProviderImpl<PersistentChannel, Long>> typeLiteral = new TypeLiteral<SchemaInfoProviderImpl<PersistentChannel, Long>>() { }; bind(new TypeLiteral<MergeService<PersistentChannel, Long>>() { }).to(new TypeLiteral<DiffBasedMergeService<PersistentChannel, Long>>() { }); bind(new TypeLiteral<LockAttainer<PersistentChannel, Long>>() { }).to(new TypeLiteral<LockAttainerImpl<PersistentChannel, Long>>() { }).in(Scopes.SINGLETON); bind(new TypeLiteral<Class<Long>>() { }).toInstance(Long.class); bind(new TypeLiteral<SchemaInfoProvider<PersistentChannel, Long>>() { }).to(typeLiteral).in(Scopes.SINGLETON); bind(new TypeLiteral<FilterConfigs<PersistentChannel>>() { }).toProvider(new GenericFilterConfigsProvider<PersistentChannel>( "com/smartitengineering/event/hub/spi/hbase/persistents/ChannelFilterConfigs.json")) .in(Scopes.SINGLETON); bind(new TypeLiteral<SchemaInfoProviderBaseConfig<PersistentChannel>>() { }).toProvider(new GenericBaseConfigProvider<PersistentChannel>( "com/smartitengineering/event/hub/spi/hbase/persistents/ChannelSchemaBaseConfig.json")) .in(Scopes.SINGLETON); } { bind(new TypeLiteral<ObjectRowConverter<RowAutoIdIndex>>() { }).to(AutoIdObjectConverter.class).in(Scopes.SINGLETON); bind(new TypeLiteral<CommonReadDao<RowAutoIdIndex, String>>() { }).to(new TypeLiteral<com.smartitengineering.dao.common.CommonDao<RowAutoIdIndex, String>>() { }).in(Scopes.SINGLETON); bind(new TypeLiteral<CommonWriteDao<RowAutoIdIndex>>() { }).to(new TypeLiteral<com.smartitengineering.dao.common.CommonDao<RowAutoIdIndex, String>>() { }).in(Scopes.SINGLETON); bind(new TypeLiteral<com.smartitengineering.dao.common.CommonDao<RowAutoIdIndex, String>>() { }).to(new TypeLiteral<CommonDao<RowAutoIdIndex, String>>() { }).in(Scopes.SINGLETON); final TypeLiteral<SchemaInfoProviderImpl<RowAutoIdIndex, String>> typeLiteral = new TypeLiteral<SchemaInfoProviderImpl<RowAutoIdIndex, String>>() { }; bind(new TypeLiteral<MergeService<RowAutoIdIndex, String>>() { }).to(new TypeLiteral<DiffBasedMergeService<RowAutoIdIndex, String>>() { }); bind(new TypeLiteral<LockAttainer<RowAutoIdIndex, String>>() { }).to(new TypeLiteral<LockAttainerImpl<RowAutoIdIndex, String>>() { }).in(Scopes.SINGLETON); bind(new TypeLiteral<Class<String>>() { }).toInstance(String.class); bind(new TypeLiteral<SchemaInfoProvider<RowAutoIdIndex, String>>() { }).to(typeLiteral).in(Scopes.SINGLETON); bind(new TypeLiteral<FilterConfigs<RowAutoIdIndex>>() { }).toProvider(new GenericFilterConfigsProvider<RowAutoIdIndex>( "com/smartitengineering/event/hub/spi/hbase/persistents/AutoIdFilterConfigs.json")) .in(Scopes.SINGLETON); bind(new TypeLiteral<SchemaInfoProviderBaseConfig<RowAutoIdIndex>>() { }).toProvider(new GenericBaseConfigProvider<RowAutoIdIndex>( "com/smartitengineering/event/hub/spi/hbase/persistents/AutoIdSchemaBaseConfig.json")) .in(Scopes.SINGLETON); } { bind(new TypeLiteral<ObjectRowConverter<EventUUID>>() { }).to(EventUUIDObjectConverter.class).in(Scopes.SINGLETON); bind(new TypeLiteral<CommonReadDao<EventUUID, String>>() { }).to(new TypeLiteral<com.smartitengineering.dao.common.CommonDao<EventUUID, String>>() { }).in(Scopes.SINGLETON); bind(new TypeLiteral<CommonWriteDao<EventUUID>>() { }).to(new TypeLiteral<com.smartitengineering.dao.common.CommonDao<EventUUID, String>>() { }).in(Scopes.SINGLETON); bind(new TypeLiteral<com.smartitengineering.dao.common.CommonDao<EventUUID, String>>() { }).to(new TypeLiteral<CommonDao<EventUUID, String>>() { }).in(Scopes.SINGLETON); final TypeLiteral<SchemaInfoProviderImpl<EventUUID, String>> typeLiteral = new TypeLiteral<SchemaInfoProviderImpl<EventUUID, String>>() { }; bind(new TypeLiteral<MergeService<EventUUID, String>>() { }).to(new TypeLiteral<DiffBasedMergeService<EventUUID, String>>() { }); bind(new TypeLiteral<LockAttainer<EventUUID, String>>() { }).to(new TypeLiteral<LockAttainerImpl<EventUUID, String>>() { }).in(Scopes.SINGLETON); bind(new TypeLiteral<SchemaInfoProvider<EventUUID, String>>() { }).to(typeLiteral).in(Scopes.SINGLETON); bind(new TypeLiteral<FilterConfigs<EventUUID>>() { }).toProvider(new GenericFilterConfigsProvider<EventUUID>( "com/smartitengineering/event/hub/spi/hbase/persistents/EventUUIDFilterConfigs.json")) .in(Scopes.SINGLETON); bind(new TypeLiteral<SchemaInfoProviderBaseConfig<EventUUID>>() { }).toProvider(new GenericBaseConfigProvider<EventUUID>( "com/smartitengineering/event/hub/spi/hbase/persistents/EventUUIDSchemaBaseConfig.json")) .in(Scopes.SINGLETON); } { bind(new TypeLiteral<ObjectRowConverter<ReverseIdIndex>>() { }).to(ReverseIndexObjectConverter.class).in(Scopes.SINGLETON); bind(new TypeLiteral<CommonReadDao<ReverseIdIndex, String>>() { }).to(new TypeLiteral<com.smartitengineering.dao.common.CommonDao<ReverseIdIndex, String>>() { }).in(Scopes.SINGLETON); bind(new TypeLiteral<CommonWriteDao<ReverseIdIndex>>() { }).to(new TypeLiteral<com.smartitengineering.dao.common.CommonDao<ReverseIdIndex, String>>() { }).in(Scopes.SINGLETON); bind(new TypeLiteral<com.smartitengineering.dao.common.CommonDao<ReverseIdIndex, String>>() { }).to(new TypeLiteral<CommonDao<ReverseIdIndex, String>>() { }).in(Scopes.SINGLETON); final TypeLiteral<SchemaInfoProviderImpl<ReverseIdIndex, String>> typeLiteral = new TypeLiteral<SchemaInfoProviderImpl<ReverseIdIndex, String>>() { }; bind(new TypeLiteral<MergeService<ReverseIdIndex, String>>() { }).to(new TypeLiteral<DiffBasedMergeService<ReverseIdIndex, String>>() { }); bind(new TypeLiteral<LockAttainer<ReverseIdIndex, String>>() { }).to(new TypeLiteral<LockAttainerImpl<ReverseIdIndex, String>>() { }).in(Scopes.SINGLETON); bind(new TypeLiteral<SchemaInfoProvider<ReverseIdIndex, String>>() { }).to(typeLiteral).in(Scopes.SINGLETON); bind(new TypeLiteral<FilterConfigs<ReverseIdIndex>>() { }).toProvider(new GenericFilterConfigsProvider<ReverseIdIndex>( "com/smartitengineering/event/hub/spi/hbase/persistents/ReverseIdIndexFilterConfigs.json")) .in(Scopes.SINGLETON); bind(new TypeLiteral<SchemaInfoProviderBaseConfig<ReverseIdIndex>>() { }).toProvider(new GenericBaseConfigProvider<ReverseIdIndex>( "com/smartitengineering/event/hub/spi/hbase/persistents/ReverseIdIndexSchemaBaseConfig.json")) .in(Scopes.SINGLETON); } bind(new TypeLiteral<RowCellIncrementor<Channel, RowAutoIdIndex, String>>() { }).to(new TypeLiteral<RowCellIncrementorImpl<Channel, RowAutoIdIndex, String>>() { }); CellConfigImpl<Channel> configImpl = new CellConfigImpl<Channel>(); configImpl.setFamily("self"); configImpl.setQualifier("idValue"); bind(new TypeLiteral<CellConfig<Channel>>() { }).toInstance(configImpl); bind(new TypeLiteral<RowCellIncrementor<ReverseIdIndex, RowAutoIdIndex, String>>() { }).to(new TypeLiteral<RowCellIncrementorImpl<ReverseIdIndex, RowAutoIdIndex, String>>() { }); CellConfigImpl<ReverseIdIndex> configRevImpl = new CellConfigImpl<ReverseIdIndex>(); configRevImpl.setFamily("self"); configRevImpl.setQualifier("reverseIdValue"); bind(new TypeLiteral<CellConfig<ReverseIdIndex>>() { }).toInstance(configRevImpl); }
From source file:org.openwms.common.comm.app.DriverConfig.java
@Bean
MessageChannel enrichedOutboundChannel() {
return MessageChannels.executor(Executors.newCachedThreadPool()).get();
}
From source file:com.flipkart.bifrost.framework.impl.RabbitMQBifrostExecutorBuilder.java
public BifrostExecutor<T> build() throws Exception { if (null == connection) { throw new IllegalArgumentException("Call connection() to set a connection."); }// ww w . j a va2 s. co m if (null == executorService) { executorService = Executors.newCachedThreadPool(); logger.warn("Thread pool set to cached thread pool."); } if (null == objectMapper) { objectMapper = new ObjectMapper(); logger.warn("ObjectMapper is set to default"); } objectMapper.getSubtypeResolver().registerSubtypes(new NamedType(callerSubType)); if (0 == concurrency) { concurrency = (0 >= concurrency) ? 10 : concurrency; logger.warn("No concurrency specified. Setting to 10."); } if (0 == responseWaitTimeout) { responseWaitTimeout = 5000; logger.warn("No timeout specified, set to 5000ms"); } if (Strings.isNullOrEmpty(requestQueue)) { throw new IllegalArgumentException("Set request queue name"); } if (Strings.isNullOrEmpty(responseQueue)) { throw new IllegalArgumentException("Set response queue name"); } return new RabbitMQBifrostExecutor<T>(connection, executorService, concurrency, objectMapper, requestQueue, responseQueue, responseWaitTimeout); }
From source file:com.palantir.stash.stashbot.managers.JenkinsManager.java
public JenkinsManager(RepositoryService repositoryService, ConfigurationPersistenceService cpm, JobTemplateManager jtm, JenkinsJobXmlFormatter xmlFormatter, JenkinsClientManager jenkisnClientManager, StashbotUrlBuilder sub, PluginLoggerFactory lf, SecurityService ss, UserService us, UserManager um, VelocityManager vm) {/* ww w. j ava2s . c om*/ this.repositoryService = repositoryService; this.cpm = cpm; this.jtm = jtm; this.xmlFormatter = xmlFormatter; this.jenkinsClientManager = jenkisnClientManager; this.sub = sub; this.lf = lf; this.log = lf.getLoggerForThis(this); this.ss = ss; this.us = us; this.um = um; this.es = Executors.newCachedThreadPool(); this.vm = vm; }
From source file:com.alliander.osgp.adapter.protocol.oslp.application.config.OslpConfig.java
/** * @return//from w w w . j a v a 2 s . co 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 = OslpConfig.this .createChannelPipeline(OslpConfig.this.oslpChannelHandlerServer()); LOGGER.info("Created server new pipeline"); return pipeline; } }); bootstrap.setOption("child.tcpNoDelay", true); bootstrap.setOption("child.keepAlive", false); bootstrap.bind(new InetSocketAddress(this.oslpPortServer())); return bootstrap; }
From source file:com.google.android.gcm.server.AsyncSender.java
/** * Default constructor./*from w w w . ja va 2 s.c o m*/ * * @param key * API key obtained through the Google API Console. */ public AsyncSender(String key) { this.key = nonNull(key); this.callbackExecutor = Executors.newCachedThreadPool(); }