-
Notifications
You must be signed in to change notification settings - Fork 26.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug in InternalThreadLocal and provides unit test (#1803)
* SerializerFactory 获取Serializer时,锁住整个hashmap,导致整个过程被block * 单元测试。保证一个class只有一个serializer和deserializer。单线程和多线程测试 * 增加线程数 50 模拟多个线程来获取serializer和deserializer * 当cores线程数全都使用的情况下,默认线程池会把任务放入到队列中。队列满则再创建线程(总数不会超过Max线程数) 增强线程池:在请求量阶段性出现高峰时使用 特性:cores线程全部使用的情况下,优先创建线程(总数不会超过max),当max个线程全都在忙的情况下,才将任务放入队列。请求量下降时,线程池会自动维持cores个线程,多余的线程退出。 * 当cores线程数全都使用的情况下,默认线程池会把任务放入到队列中。队列满则再创建线程(总数不会超过Max线程数) 增强线程池:在请求量阶段性出现高峰时使用 特性:cores线程全部使用的情况下,优先创建线程(总数不会超过max),当max个线程全都在忙的情况下,才将任务放入队列。请求量下降时,线程池会自动维持cores个线程,多余的线程退出。 * 补全单元测试,测试扩展是否生效 * 错误命名 * 增加@OverRide注解 long 初始化赋值时,小写l改为大写L防止误读 * 修复单元测试 * remove enhanced * remove enhanced * Faster ThreadLocal impl in internal use * Used in RpcContext`s LOCAL field. * Faster get than the traditional ThreadLocal * add License * fix ci failed * fix ci failed * fix ci failed * fix ci failed * fix ci failed * remove author info * fix destroy method * fix bug at method size. * Unit test for InternalThreadLocal * Unit test for InternalThreadLocal Fix bug in method removeAll
- Loading branch information
Showing
3 changed files
with
92 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...on/src/test/java/com/alibaba/dubbo/common/threadlocal/NamedInternalThreadFactoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.alibaba.dubbo.common.threadlocal; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class NamedInternalThreadFactoryTest { | ||
|
||
@Test | ||
public void newThread() throws Exception { | ||
NamedInternalThreadFactory namedInternalThreadFactory = new NamedInternalThreadFactory(); | ||
Thread t = namedInternalThreadFactory.newThread(new Runnable() { | ||
@Override | ||
public void run() { | ||
|
||
} | ||
}); | ||
Assert.assertTrue("thread is not InternalThread", t.getClass().equals(InternalThread.class)); | ||
} | ||
} |