List of usage examples for java.util.concurrent Executors newCachedThreadPool
public static ExecutorService newCachedThreadPool()
From source file:com.buaa.cfs.common.oncrpc.SimpleTcpServer.java
public void run() { // Configure the Server. ChannelFactory factory;//from w w w.ja v a 2 s. c o m if (workerCount == 0) { // Use default workers: 2 * the number of available processors factory = new NioServerSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool()); } else { factory = new NioServerSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool(), workerCount); } server = new ServerBootstrap(factory); server.setPipelineFactory(new ChannelPipelineFactory() { @Override public ChannelPipeline getPipeline() throws Exception { return Channels.pipeline(RpcUtil.constructRpcFrameDecoder(), RpcUtil.STAGE_RPC_MESSAGE_PARSER, rpcProgram, RpcUtil.STAGE_RPC_TCP_RESPONSE); } }); server.setOption("child.tcpNoDelay", true); server.setOption("child.keepAlive", true); // Listen to TCP port ch = server.bind(new InetSocketAddress(port)); InetSocketAddress socketAddr = (InetSocketAddress) ch.getLocalAddress(); boundPort = socketAddr.getPort(); LOG.info("Started listening to TCP requests at port " + boundPort + " for " + rpcProgram + " with workerCount " + workerCount); }
From source file:com.github.matthesrieke.simplebroker.SimpleBrokerServlet.java
public SimpleBrokerServlet() { this.executor = Executors.newCachedThreadPool(); }
From source file:com.cloudera.branchreduce.impl.distributed.TaskMaster.java
public TaskMaster(int vassalCount, List<T> initialTasks, G globalState) { this(vassalCount, initialTasks, globalState, Executors.newCachedThreadPool()); }
From source file:com.gitblit.plugin.hipchat.HipChatter.java
HipChatter(IRuntimeManager runtimeManager) { this.runtimeManager = runtimeManager; this.taskPool = Executors.newCachedThreadPool(); parseConfigs(); }
From source file:org.semispace.google.space.address.GoogleAddressFetcher.java
public void init() { log.debug("Initializing " + getClass().getName()); threadPool = Executors.newCachedThreadPool(); // TODO Que?//from w w w .j a v a2s.c o m //AddressLookupSemaphore counter = new AddressLookupSemaphore(); if (simultanousLookups < 1) { throw new RuntimeException( "Configuration error - need to configure field simultanousLookups to a value greater than 0."); } resetSemaphores(); // Add notifier for query if (lease != null) { log.warn("Double initialization? Strange."); lease.getLease().cancel(); } lease = space.notify(new AddressQuery(), this, TEN_YEARS); }
From source file:be.vlaanderen.sesam.monitor.internal.ClientConnectionServiceImpl.java
public void afterPropertiesSet() throws Exception { ExecutorService locutus = Executors.newCachedThreadPool(); timer = new HashedWheelTimer(); FACTORY = new NioClientSocketChannelFactory(locutus, locutus); Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { public void run() { FACTORY.releaseExternalResources(); timer.stop();// w ww .jav a2s . com } })); }
From source file:com.qwazr.Qwazr.java
private Qwazr(QwazrConfiguration configuration) { super(Executors.newCachedThreadPool(), configuration); }
From source file:com.intel.cosbench.driver.service.COSBDriverService.java
public void init() { handlers = new HashMap<String, MissionHandler>(); handlers = Collections.synchronizedMap(handlers); executor = Executors.newCachedThreadPool(); }
From source file:configurator.Configurator.java
/** * The main method for telnet configuring the network devices. Prepare data * and create thread for each device/*from w w w . ja v a 2s . c o m*/ * * @param ipText - List of ip ranges, subnets and single ip * @param authData - authorization data for work on devices * @param models list of models for telnet configure */ void telnetWork(String ipText, AuthenticationData authData, List<String> models) { try { List<String> ipList = parseIp(ipText); ExecutorService exec = Executors.newCachedThreadPool(); ipList.forEach((ip) -> { Snmp snmp = new Snmp(authData.getCommunity()); String modelOid = mainProperites.getProperty("Identifier_Oid"); String model = snmp.get(ip, modelOid).trim(); if (models.contains(model)) { try { String modelAddress = getAddressByModelName(model); if (modelAddress != null) { exec.execute(new TelnetConfigureThread(ip, authData, modelAddress)); } else { throw new FileNotFoundException(); } } catch (FileNotFoundException ex) { System.exit(0); } } else { } }); exec.shutdown(); } catch (Exception e) { System.out.println(e); //ip address is incorrect } }
From source file:jenkins.plugins.office365connector.HttpWorkerTest.java
@Test public void testSendingMultipleWebhooks() throws IOException, InterruptedException { ExecutorService executorService = Executors.newCachedThreadPool(); HttpWorker worker1 = new HttpWorker("http://localhost:8000/test1", "test1body", 30000, Mockito.mock(PrintStream.class)); HttpWorker worker2 = new HttpWorker("http://localhost:8000/test2", "test2body", 30000, Mockito.mock(PrintStream.class)); executorService.submit(worker1);//from w w w. jav a 2 s .c o m executorService.submit(worker2); executorService.shutdown(); executorService.awaitTermination(5, TimeUnit.SECONDS); Assert.assertTrue(MyHandler.getTest1Result()); Assert.assertTrue(MyHandler.getTest2Result()); }