com.alibaba.dubbo.common.threadpool.ThreadPool Java Examples
The following examples show how to use
com.alibaba.dubbo.common.threadpool.ThreadPool.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LimitedThreadPoolTest.java From dubbo-2.6.5 with Apache License 2.0 | 5 votes |
@Test public void getExecutor2() throws Exception { URL url = URL.valueOf("dubbo://10.20.130.230:20880/context/path?" + Constants.QUEUES_KEY + "=1"); ThreadPool threadPool = new LimitedThreadPool(); ThreadPoolExecutor executor = (ThreadPoolExecutor) threadPool.getExecutor(url); assertThat(executor.getQueue(), Matchers.<BlockingQueue<Runnable>>instanceOf(LinkedBlockingQueue.class)); }
Example #2
Source File: WrappedChannelHandler.java From dubbo3 with Apache License 2.0 | 5 votes |
public WrappedChannelHandler(ChannelHandler handler, URL url) { this.handler = handler; this.url = url; executor = (ExecutorService) ExtensionLoader.getExtensionLoader(ThreadPool.class).getAdaptiveExtension().getExecutor(url); String componentKey = Constants.EXECUTOR_SERVICE_COMPONENT_KEY; if (Constants.CONSUMER_SIDE.equalsIgnoreCase(url.getParameter(Constants.SIDE_KEY))) { componentKey = Constants.CONSUMER_SIDE; } DataStore dataStore = ExtensionLoader.getExtensionLoader(DataStore.class).getDefaultExtension(); dataStore.put(componentKey, Integer.toString(url.getPort()), executor); }
Example #3
Source File: WrappedChannelHandler.java From dubbox-hystrix with Apache License 2.0 | 5 votes |
public WrappedChannelHandler(ChannelHandler handler, URL url) { this.handler = handler; this.url = url; executor = (ExecutorService) ExtensionLoader.getExtensionLoader(ThreadPool.class).getAdaptiveExtension().getExecutor(url); String componentKey = Constants.EXECUTOR_SERVICE_COMPONENT_KEY; if (Constants.CONSUMER_SIDE.equalsIgnoreCase(url.getParameter(Constants.SIDE_KEY))) { componentKey = Constants.CONSUMER_SIDE; } DataStore dataStore = ExtensionLoader.getExtensionLoader(DataStore.class).getDefaultExtension(); dataStore.put(componentKey, Integer.toString(url.getPort()), executor); }
Example #4
Source File: WrappedChannelHandler.java From dubbox with Apache License 2.0 | 5 votes |
public WrappedChannelHandler(ChannelHandler handler, URL url) { this.handler = handler; this.url = url; executor = (ExecutorService) ExtensionLoader.getExtensionLoader(ThreadPool.class).getAdaptiveExtension().getExecutor(url); String componentKey = Constants.EXECUTOR_SERVICE_COMPONENT_KEY; if (Constants.CONSUMER_SIDE.equalsIgnoreCase(url.getParameter(Constants.SIDE_KEY))) { componentKey = Constants.CONSUMER_SIDE; } DataStore dataStore = ExtensionLoader.getExtensionLoader(DataStore.class).getDefaultExtension(); dataStore.put(componentKey, Integer.toString(url.getPort()), executor); }
Example #5
Source File: WrappedChannelHandler.java From dubbo-2.6.5 with Apache License 2.0 | 5 votes |
public WrappedChannelHandler(ChannelHandler handler, URL url) { this.handler = handler; this.url = url; // 线程池,协议和provider中如果有threadpool参数配置线程池的形式就用这个,没有配置就是用默认的fixed executor = (ExecutorService) ExtensionLoader.getExtensionLoader(ThreadPool.class).getAdaptiveExtension().getExecutor(url); String componentKey = Constants.EXECUTOR_SERVICE_COMPONENT_KEY; if (Constants.CONSUMER_SIDE.equalsIgnoreCase(url.getParameter(Constants.SIDE_KEY))) { componentKey = Constants.CONSUMER_SIDE; } DataStore dataStore = ExtensionLoader.getExtensionLoader(DataStore.class).getDefaultExtension(); dataStore.put(componentKey, Integer.toString(url.getPort()), executor); }
Example #6
Source File: WrappedChannelHandler.java From dubbox with Apache License 2.0 | 5 votes |
public WrappedChannelHandler(ChannelHandler handler, URL url) { this.handler = handler; this.url = url; executor = (ExecutorService) ExtensionLoader.getExtensionLoader(ThreadPool.class).getAdaptiveExtension().getExecutor(url); String componentKey = Constants.EXECUTOR_SERVICE_COMPONENT_KEY; if (Constants.CONSUMER_SIDE.equalsIgnoreCase(url.getParameter(Constants.SIDE_KEY))) { componentKey = Constants.CONSUMER_SIDE; } DataStore dataStore = ExtensionLoader.getExtensionLoader(DataStore.class).getDefaultExtension(); dataStore.put(componentKey, Integer.toString(url.getPort()), executor); }
Example #7
Source File: EagerThreadPoolExecutorTest.java From dubbo-2.6.5 with Apache License 2.0 | 5 votes |
@Test public void testSPI() { ExecutorService executorService = (ExecutorService) ExtensionLoader.getExtensionLoader(ThreadPool.class) .getExtension("eager") .getExecutor(URL); Assert.assertTrue("test spi fail!", executorService.getClass() .getSimpleName() .equals("EagerThreadPoolExecutor")); }
Example #8
Source File: EagerThreadPoolTest.java From dubbo-2.6.5 with Apache License 2.0 | 5 votes |
@Test public void getExecutor2() throws Exception { URL url = URL.valueOf("dubbo://10.20.130.230:20880/context/path?" + Constants.QUEUES_KEY + "=2"); ThreadPool threadPool = new EagerThreadPool(); ThreadPoolExecutor executor = (ThreadPoolExecutor) threadPool.getExecutor(url); assertThat(executor.getQueue().remainingCapacity(), is(2)); }
Example #9
Source File: EagerThreadPoolTest.java From dubbo-2.6.5 with Apache License 2.0 | 5 votes |
@Test public void getExecutor1() throws Exception { URL url = URL.valueOf("dubbo://10.20.130.230:20880/context/path?" + Constants.THREAD_NAME_KEY + "=demo&" + Constants.CORE_THREADS_KEY + "=1&" + Constants.THREADS_KEY + "=2&" + Constants.ALIVE_KEY + "=1000&" + Constants.QUEUES_KEY + "=0"); ThreadPool threadPool = new EagerThreadPool(); ThreadPoolExecutor executor = (ThreadPoolExecutor) threadPool.getExecutor(url); assertThat(executor, instanceOf(EagerThreadPoolExecutor.class)); assertThat(executor.getCorePoolSize(), is(1)); assertThat(executor.getMaximumPoolSize(), is(2)); assertThat(executor.getKeepAliveTime(TimeUnit.MILLISECONDS), is(1000L)); assertThat(executor.getQueue().remainingCapacity(), is(1)); assertThat(executor.getQueue(), Matchers.<BlockingQueue<Runnable>>instanceOf(TaskQueue.class)); assertThat(executor.getRejectedExecutionHandler(), Matchers.<RejectedExecutionHandler>instanceOf(AbortPolicyWithReport.class)); final CountDownLatch latch = new CountDownLatch(1); executor.execute(new Runnable() { @Override public void run() { Thread thread = Thread.currentThread(); assertThat(thread, instanceOf(InternalThread.class)); assertThat(thread.getName(), startsWith("demo")); latch.countDown(); } }); latch.await(); assertThat(latch.getCount(), is(0L)); }
Example #10
Source File: LimitedThreadPoolTest.java From dubbo-2.6.5 with Apache License 2.0 | 5 votes |
@Test public void getExecutor1() throws Exception { URL url = URL.valueOf("dubbo://10.20.130.230:20880/context/path?" + Constants.THREAD_NAME_KEY + "=demo&" + Constants.CORE_THREADS_KEY + "=1&" + Constants.THREADS_KEY + "=2&" + Constants.QUEUES_KEY + "=0"); ThreadPool threadPool = new LimitedThreadPool(); ThreadPoolExecutor executor = (ThreadPoolExecutor) threadPool.getExecutor(url); assertThat(executor.getCorePoolSize(), is(1)); assertThat(executor.getMaximumPoolSize(), is(2)); assertThat(executor.getQueue(), Matchers.<BlockingQueue<Runnable>>instanceOf(SynchronousQueue.class)); assertThat(executor.getRejectedExecutionHandler(), Matchers.<RejectedExecutionHandler>instanceOf(AbortPolicyWithReport.class)); final CountDownLatch latch = new CountDownLatch(1); executor.execute(new Runnable() { @Override public void run() { Thread thread = Thread.currentThread(); assertThat(thread, instanceOf(InternalThread.class)); assertThat(thread.getName(), startsWith("demo")); latch.countDown(); } }); latch.await(); assertThat(latch.getCount(), is(0L)); }
Example #11
Source File: CachedThreadPoolTest.java From dubbo-2.6.5 with Apache License 2.0 | 5 votes |
@Test public void getExecutor2() throws Exception { URL url = URL.valueOf("dubbo://10.20.130.230:20880/context/path?" + Constants.QUEUES_KEY + "=1"); ThreadPool threadPool = new CachedThreadPool(); ThreadPoolExecutor executor = (ThreadPoolExecutor) threadPool.getExecutor(url); assertThat(executor.getQueue(), Matchers.<BlockingQueue<Runnable>>instanceOf(LinkedBlockingQueue.class)); }
Example #12
Source File: CachedThreadPoolTest.java From dubbo-2.6.5 with Apache License 2.0 | 5 votes |
@Test public void getExecutor1() throws Exception { URL url = URL.valueOf("dubbo://10.20.130.230:20880/context/path?" + Constants.THREAD_NAME_KEY + "=demo&" + Constants.CORE_THREADS_KEY + "=1&" + Constants.THREADS_KEY + "=2&" + Constants.ALIVE_KEY + "=1000&" + Constants.QUEUES_KEY + "=0"); ThreadPool threadPool = new CachedThreadPool(); ThreadPoolExecutor executor = (ThreadPoolExecutor) threadPool.getExecutor(url); assertThat(executor.getCorePoolSize(), is(1)); assertThat(executor.getMaximumPoolSize(), is(2)); assertThat(executor.getQueue(), Matchers.<BlockingQueue<Runnable>>instanceOf(SynchronousQueue.class)); assertThat(executor.getRejectedExecutionHandler(), Matchers.<RejectedExecutionHandler>instanceOf(AbortPolicyWithReport.class)); final CountDownLatch latch = new CountDownLatch(1); executor.execute(new Runnable() { @Override public void run() { Thread thread = Thread.currentThread(); assertThat(thread, instanceOf(InternalThread.class)); assertThat(thread.getName(), startsWith("demo")); latch.countDown(); } }); latch.await(); assertThat(latch.getCount(), is(0L)); }
Example #13
Source File: FixedThreadPoolTest.java From dubbo-2.6.5 with Apache License 2.0 | 5 votes |
@Test public void getExecutor2() throws Exception { URL url = URL.valueOf("dubbo://10.20.130.230:20880/context/path?" + Constants.QUEUES_KEY + "=1"); ThreadPool threadPool = new FixedThreadPool(); ThreadPoolExecutor executor = (ThreadPoolExecutor) threadPool.getExecutor(url); assertThat(executor.getQueue(), Matchers.<BlockingQueue<Runnable>>instanceOf(LinkedBlockingQueue.class)); }
Example #14
Source File: FixedThreadPoolTest.java From dubbo-2.6.5 with Apache License 2.0 | 5 votes |
@Test public void getExecutor1() throws Exception { URL url = URL.valueOf("dubbo://10.20.130.230:20880/context/path?" + Constants.THREAD_NAME_KEY + "=demo&" + Constants.CORE_THREADS_KEY + "=1&" + Constants.THREADS_KEY + "=2&" + Constants.QUEUES_KEY + "=0"); ThreadPool threadPool = new FixedThreadPool(); ThreadPoolExecutor executor = (ThreadPoolExecutor) threadPool.getExecutor(url); assertThat(executor.getCorePoolSize(), is(2)); assertThat(executor.getMaximumPoolSize(), is(2)); assertThat(executor.getKeepAliveTime(TimeUnit.MILLISECONDS), is(0L)); assertThat(executor.getQueue(), Matchers.<BlockingQueue<Runnable>>instanceOf(SynchronousQueue.class)); assertThat(executor.getRejectedExecutionHandler(), Matchers.<RejectedExecutionHandler>instanceOf(AbortPolicyWithReport.class)); final CountDownLatch latch = new CountDownLatch(1); executor.execute(new Runnable() { @Override public void run() { Thread thread = Thread.currentThread(); assertThat(thread, instanceOf(InternalThread.class)); assertThat(thread.getName(), startsWith("demo")); latch.countDown(); } }); latch.await(); assertThat(latch.getCount(), is(0L)); }
Example #15
Source File: WrappedChannelHandler.java From dubbox with Apache License 2.0 | 5 votes |
public WrappedChannelHandler(ChannelHandler handler, URL url) { this.handler = handler; this.url = url; executor = (ExecutorService) ExtensionLoader.getExtensionLoader(ThreadPool.class).getAdaptiveExtension().getExecutor(url); String componentKey = Constants.EXECUTOR_SERVICE_COMPONENT_KEY; if (Constants.CONSUMER_SIDE.equalsIgnoreCase(url.getParameter(Constants.SIDE_KEY))) { componentKey = Constants.CONSUMER_SIDE; } DataStore dataStore = ExtensionLoader.getExtensionLoader(DataStore.class).getDefaultExtension(); dataStore.put(componentKey, Integer.toString(url.getPort()), executor); }
Example #16
Source File: ProtocolConfig.java From dubbo-2.6.5 with Apache License 2.0 | 4 votes |
public void setThreadpool(String threadpool) { // 这里可以同过threadpool参数指定线程池,默认是fixed checkExtension(ThreadPool.class, "threadpool", threadpool); this.threadpool = threadpool; }
Example #17
Source File: ProviderConfig.java From dubbox with Apache License 2.0 | 4 votes |
public void setThreadpool(String threadpool) { checkExtension(ThreadPool.class, "threadpool", threadpool); this.threadpool = threadpool; }
Example #18
Source File: ProtocolConfig.java From dubbox with Apache License 2.0 | 4 votes |
public void setThreadpool(String threadpool) { checkExtension(ThreadPool.class, "threadpool", threadpool); this.threadpool = threadpool; }
Example #19
Source File: ProtocolConfig.java From dubbo3 with Apache License 2.0 | 4 votes |
public void setThreadpool(String threadpool) { checkExtension(ThreadPool.class, "threadpool", threadpool); this.threadpool = threadpool; }
Example #20
Source File: ProviderConfig.java From dubbo3 with Apache License 2.0 | 4 votes |
public void setThreadpool(String threadpool) { checkExtension(ThreadPool.class, "threadpool", threadpool); this.threadpool = threadpool; }
Example #21
Source File: ProviderConfig.java From dubbox with Apache License 2.0 | 4 votes |
public void setThreadpool(String threadpool) { checkExtension(ThreadPool.class, "threadpool", threadpool); this.threadpool = threadpool; }
Example #22
Source File: ProtocolConfig.java From dubbox with Apache License 2.0 | 4 votes |
public void setThreadpool(String threadpool) { checkExtension(ThreadPool.class, "threadpool", threadpool); this.threadpool = threadpool; }
Example #23
Source File: ProtocolConfig.java From dubbox-hystrix with Apache License 2.0 | 4 votes |
public void setThreadpool(String threadpool) { checkExtension(ThreadPool.class, "threadpool", threadpool); this.threadpool = threadpool; }
Example #24
Source File: ProviderConfig.java From dubbox-hystrix with Apache License 2.0 | 4 votes |
public void setThreadpool(String threadpool) { checkExtension(ThreadPool.class, "threadpool", threadpool); this.threadpool = threadpool; }
Example #25
Source File: ProtocolConfig.java From dubbox with Apache License 2.0 | 4 votes |
public void setThreadpool(String threadpool) { checkExtension(ThreadPool.class, "threadpool", threadpool); this.threadpool = threadpool; }
Example #26
Source File: ProviderConfig.java From dubbox with Apache License 2.0 | 4 votes |
public void setThreadpool(String threadpool) { checkExtension(ThreadPool.class, "threadpool", threadpool); this.threadpool = threadpool; }
Example #27
Source File: ProviderConfig.java From dubbo-2.6.5 with Apache License 2.0 | 4 votes |
public void setThreadpool(String threadpool) { // // 这里可以同过threadpool参数指定线程池,默认是fixed checkExtension(ThreadPool.class, "threadpool", threadpool); this.threadpool = threadpool; }
Example #28
Source File: ConfigUtilsTest.java From dubbo-2.6.5 with Apache License 2.0 | 4 votes |
/** * The user configures -default, which will delete all the default parameters */ @Test public void testMergeValuesDelete() { List<String> merged = ConfigUtils.mergeValues(ThreadPool.class, "-fixed,aaa", asList("fixed", "default.limited", "cached")); assertEquals(asList("cached", "aaa"), merged); }
Example #29
Source File: ConfigUtilsTest.java From dubbo-2.6.5 with Apache License 2.0 | 4 votes |
@Test public void testMergeValuesDeleteDefault_2() { List<String> merged = ConfigUtils.mergeValues(ThreadPool.class, "-default,aaa", asList("fixed", "default.limited", "cached")); assertEquals(asList("aaa"), merged); }
Example #30
Source File: ConfigUtilsTest.java From dubbo-2.6.5 with Apache License 2.0 | 4 votes |
@Test public void testMergeValuesDeleteDefault() { List<String> merged = ConfigUtils.mergeValues(ThreadPool.class, "-default", asList("fixed", "default.limited", "cached")); assertEquals(asList(), merged); }