List of usage examples for java.util.concurrent Executors newCachedThreadPool
public static ExecutorService newCachedThreadPool(ThreadFactory threadFactory)
From source file:com.sds.acube.ndisc.mts.xserver.XNDiscServer.java
/** * //from w ww . j a v a2s .c o m * * @throws Exception * ? */ private void init() throws Exception { /* xsocket - FINE ??? ? ? ? ? */ if (XSOCKET_DEBUG) { xsocket_log.setLevel(Level.ALL); } else { xsocket_log.setLevel(Level.INFO); } ConsoleHandler console = new ConsoleHandler(); if (XSOCKET_DEBUG) { console.setLevel(Level.ALL); } else { console.setLevel(Level.INFO); } xsocket_log.addHandler(console); /* xsocket - FINE ??? ? ? ? ? */ initLogger(); initFilter(); initStorage(); InetAddress ia = InetAddress.getByName(HOST); if (ia == null) { ia = InetAddress.getLocalHost(); } /* ? ( ) - Receive Buffer Size ? */ Map<String, Object> options = new HashMap<String, Object>(); // - 2014.04.29 - ? - START - Multiplexing? . // options.put(IConnection.SO_REUSEADDR, true); // options.put(IConnection.SO_LINGER, "5"); // ? ?? (? ? ? ) // options.put(IConnection.SO_KEEPALIVE, true); // options.put(IConnection.TCP_NODELAY, true); // options.put(IConnection.SO_RCVBUF, XNDiscConfig.INIT_BUFFER_SIZE); // options.put(IConnection.SO_SNDBUF, XNDiscConfig.INIT_BUFFER_SIZE); // - 2014.04.29 - ? - END - Multiplexing? . /* SERVER? ? ? */ /* workerpool (?? ? ? )? ?. */ /* ? ? workerpool? ? ? workerpool ? ?. ? 100. */ System.setProperty(XNDiscUtils.XSOCKET_WORKER_POOL_MIN_SIZE, SIZE_WORKER_POOL); /* workerpool? ?. ? 4 */ System.setProperty(XNDiscUtils.XSOCKET_WORKER_POOL_MIN_SIZE, MIN_SIZE_WORKER_POOL); /* ? ? (NIO Selectors)? . ? 2 ? ?. */ System.setProperty(XNDiscUtils.XSOKET_DISPATCHER_INIT_COUNT, DISPATCHER_INIT_COUNT); /* ?? ? ?? */ /* , ?? ?? ?. ? ?? . */ System.setProperty(XNDiscUtils.XSOCKET_DISPATCHER_MAX_HANDLE, DISPATCHER_MAX_HANDLES); /* ? ? ? ?? ?? ? . ? false. */ System.setProperty(XNDiscUtils.XSOCKET_SERVER_READ_BUFFER_USEDIRECT, READ_BUFFER_USEDIRECT); // - 2014.04.25 - ByteBuffer Direct - START System.setProperty(XNDiscUtils.XSOCKET_CLIENT_READ_BUFFER_USEDIRECT, READ_BUFFER_USEDIRECT); System.setProperty(XNDiscUtils.XSOCKET_WRITE_BUFFER_USEDIRECT, READ_BUFFER_USEDIRECT); // - 2014.04.25 - ByteBuffer Direct - END // - 2014.04.29 - - START System.setProperty(XNDiscUtils.XSOCKET_SUPPRESS_SYNC_FLUSH_WARNING, "true"); System.setProperty(XNDiscUtils.XSOCKET_SUPPRESS_REUSE_BUFFER_WARNING, "true"); // or FlushMode.SYNC (GET ? ) System.setProperty(XNDiscUtils.XSOCKET_SUPPRESS_SYNC_FLUSH_COMPLETION_HANDLER_WARNING, "true"); System.setProperty(XNDiscUtils.XSOCKET_DISPATCHER_BYPASSING_WRITE_ALLOWED, "true"); // - 2014.04.29 - - END /* (NIO SelectionKey)? ? true ? ?? detach?. ?? ??? . false. */ System.setProperty(XNDiscUtils.XSOCKET_DISPATCHER_DETACH_HANDLE_ON_NO_OPS, DETACH_HANDLE_NO_OPERATION); /* ? ?? ? ?? ? ? (1024 * 16) */ Integer mapped_bytebuffer_maxsize = 1024 * XNDiscConfig.getInt(XNDiscConfig.TRANSFER_MAPPED_BYTE_BUFFER_MAXSIZE, 16); System.setProperty(XNDiscUtils.XSOCKET_TRANFER_MAPPED_BYTEBUFFER_MAX_SIZE, mapped_bytebuffer_maxsize.toString()); /* ? Sever - SSL ? ? Connection? ? ?! */ if (USE_SSL) { this.server = new Server(ia, PORT, options, new MultiplexedProtocolAdapter(new XNDiscHandler(storage, logger)), XNDiscSSLContextFactory.getSSLContext(), true); // this.server = new Server(ia, PORT, options, new XNDiscHandler(storage, logger), XNDiscSSLContextFactory.getSSLContext(), true); } else { this.server = new Server(ia, PORT, options, new MultiplexedProtocolAdapter(new XNDiscHandler(storage, logger)), null, false); // this.server = new Server(ia, PORT, options, new XNDiscHandler(storage, logger), null, false); } /* ThreadPool? ? , Cached ? ? ??? ? ? ? ?. */ /* SERVER? ? ? (? Fixed) */ /* ? : ? ? ?? Runtime.availableProcessors() ? ? ?? ??? */ /* newFixedThreadPool ? ? ? corePoolSize, maximumPoolSize . ? */ /* newCachedThreadPool ? corePoolSize = 0, maximumPoolSize Integer.MAX_VALUE . ? 1 */ if (WORKER_POOL_TYPE.equals("C")) { this.server.setWorkerpool(Executors.newCachedThreadPool(new XNDiscThreadFactory(true))); } else { if (XNDiscConfig.getBoolean(XNDiscConfig.MULTIPLICATION_THREAD_AVAILABLE_PROCESSORS)) { WORKER_THREAD_POOL = Runtime.getRuntime().availableProcessors() * WORKER_THREAD_POOL; } this.server .setWorkerpool(Executors.newFixedThreadPool(WORKER_THREAD_POOL, new XNDiscThreadFactory(true))); } this.server.setFlushmode(FlushMode.ASYNC); }
From source file:com.linkedin.pinot.query.selection.SelectionQueriesForMultiValueColumnTest.java
@Test public void testInterSegmentSelectionPlanMakerAndRun() throws Exception { final int numSegments = 20; setupSegmentList(numSegments);/*from w ww . j a v a 2s . com*/ final PlanMaker instancePlanMaker = new InstancePlanMakerImplV2(); final BrokerRequest brokerRequest = getSelectionNoFilterBrokerRequest(); final ExecutorService executorService = Executors .newCachedThreadPool(new NamedThreadFactory("test-plan-maker")); final Plan globalPlan = instancePlanMaker.makeInterSegmentPlan(_indexSegmentList, brokerRequest, executorService, 150000); globalPlan.print(); globalPlan.execute(); final DataTable instanceResponse = globalPlan.getInstanceResponse(); System.out.println("instanceResponse : " + instanceResponse); final BrokerReduceService reduceService = new BrokerReduceService(); final Map<ServerInstance, DataTable> instanceResponseMap = new HashMap<ServerInstance, DataTable>(); instanceResponseMap.put(new ServerInstance("localhost:0000"), instanceResponse); final BrokerResponseNative brokerResponse = reduceService.reduceOnDataTable(brokerRequest, instanceResponseMap); SelectionResults selectionResults = brokerResponse.getSelectionResults(); List<String> columns = selectionResults.getColumns(); Assert.assertEquals(columns.get(0), "column2"); Assert.assertEquals(columns.get(1), "column1"); Assert.assertEquals(columns.get(2), "column5"); Assert.assertEquals(columns.get(3), "column6"); Assert.assertEquals(columns.get(4), "column7"); Assert.assertEquals(columns.get(5), "count"); List<Serializable[]> rows = selectionResults.getRows(); for (int i = 0; i < rows.size(); ++i) { Serializable[] row = rows.get(i); Assert.assertEquals(row[0], "2147434110"); } }