Merge branch 'develop' into fix/createThreadPoll_contentNotChange

pull/1414/head
smily 2 years ago
commit 032a4aced2

@ -120,7 +120,8 @@ For full documentation & more details, visit: [Docs](https://www.hippo4j.cn)
- [[ JavaGuide ]](https://github.com/Snailclimb/JavaGuide):一份涵盖大部分 Java 程序员所需要掌握的核心知识。 - [[ JavaGuide ]](https://github.com/Snailclimb/JavaGuide):一份涵盖大部分 Java 程序员所需要掌握的核心知识。
- [[ toBeBetterJavaer ]](https://github.com/itwanger/toBeBetterJavaer):一份通俗易懂、风趣幽默的 Java 学习指南。 - [[ toBeBetterJavaer ]](https://github.com/itwanger/toBeBetterJavaer):一份通俗易懂、风趣幽默的 Java 学习指南。
- [[ Jpom ]](https://gitee.com/dromara/Jpom):简而轻的低侵入式在线构建、自动部署、日常运维、项目监控软件。 - [[ Jpom ]](https://gitee.com/dromara/Jpom):简而轻的低侵入式在线构建、自动部署、日常运维、项目监控软件。
- [[ CongoMall ]](https://gitee.com/opengoofy/congomall):作者的另一个开源项目刚果商城,包含了商城业务和基础架构两大模块。 - [[ 12306 ]](https://gitee.com/nageoffer/12306):完成高仿 12306 用户+抢票+订单+支付服务,帮助学生主打就业的项目。
- [[ CongoMall ]](https://gitee.com/nageoffer/congomall):企业级商城,基于 DDD 领域驱动模型开发,包含商城业务和基础架构。
### 贡献者 ### 贡献者

@ -6,215 +6,211 @@ const darkCodeTheme = require('prism-react-renderer/themes/dracula');
/** @type {import('@docusaurus/types').Config} */ /** @type {import('@docusaurus/types').Config} */
const config = { const config = {
title: 'Hippo4j', title: 'Hippo4j',
tagline: '动态可观测线程池框架,为业务系统提高线上运行保障能力', tagline: '动态可观测线程池框架,为业务系统提高线上运行保障能力',
url: 'https://hippo4j.cn', url: 'https://hippo4j.cn',
baseUrl: '/', baseUrl: '/',
onBrokenLinks: 'throw', onBrokenLinks: 'throw',
onBrokenMarkdownLinks: 'warn', onBrokenMarkdownLinks: 'warn',
favicon: 'img/hippo4j_favicon.ico', favicon: 'img/hippo4j_favicon.ico',
// GitHub pages deployment config. // GitHub pages deployment config.
// If you aren't using GitHub pages, you don't need these. // If you aren't using GitHub pages, you don't need these.
organizationName: 'hippo4j', // Usually your GitHub org/user name. organizationName: 'hippo4j', // Usually your GitHub org/user name.
projectName: 'hippo4j.github.io', // Usually your repo name. projectName: 'hippo4j.github.io', // Usually your repo name.
deploymentBranch: 'main', deploymentBranch: 'main',
// Even if you don't use internalization, you can use this field to set useful // Even if you don't use internalization, you can use this field to set useful
// metadata like html lang. For example, if your site is Chinese, you may want // metadata like html lang. For example, if your site is Chinese, you may want
// to replace "en" with "zh-Hans". // to replace "en" with "zh-Hans".
i18n: { i18n: {
defaultLocale: 'en', defaultLocale: 'en',
locales: ['en', 'zh'], locales: ['en', 'zh'],
localeConfigs: { localeConfigs: {
en: { en: {
label: 'English', label: 'English',
direction: 'ltr', direction: 'ltr',
}, },
zh: { zh: {
label: '简体中文', label: '简体中文',
direction: 'ltr', direction: 'ltr',
}, },
},
}, },
},
presets: [ presets: [
[ [
'classic', 'classic',
/** @type {import('@docusaurus/preset-classic').Options} */ /** @type {import('@docusaurus/preset-classic').Options} */
({ ({
docs: { docs: {
sidebarPath: require.resolve('./sidebars.js'), sidebarPath: require.resolve('./sidebars.js'),
// Please change this to your repo. // Please change this to your repo.
// Remove this to remove the "edit this page" links. // Remove this to remove the "edit this page" links.
sidebarCollapsed: false, sidebarCollapsed: false,
/*editUrl: 'https://github.com/longtai-cn',*/ /*editUrl: 'https://github.com/longtai-cn',*/
}, },
blog: { blog: {
showReadingTime: true, showReadingTime: true,
// Please change this to your repo. // Please change this to your repo.
// Remove this to remove the "edit this page" links. // Remove this to remove the "edit this page" links.
editUrl: editUrl:
'https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/', 'https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/',
}, },
theme: { theme: {
customCss: require.resolve('./src/css/custom.css'), customCss: require.resolve('./src/css/custom.css'),
}, },
}), }),
],
], ],
],
plugins: [ plugins: [
[ [
'@docusaurus/plugin-content-docs', '@docusaurus/plugin-content-docs',
{ {
id: 'community', id: 'community',
path: 'community', path: 'community',
routeBasePath: 'community', routeBasePath: 'community',
sidebarPath: require.resolve('./sidebarsCommunity.js'), sidebarPath: require.resolve('./sidebarsCommunity.js'),
}, },
],
], ],
],
themeConfig: themeConfig:
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */ /** @type {import('@docusaurus/preset-classic').ThemeConfig} */
({ ({
autoCollapseCategories: true, autoCollapseCategories: true,
announcementBar: { announcementBar: {
id: 'announcementBar-1', // Increment on change id: 'announcementBar-1', // Increment on change
// content: `⭐️ If you like hippo4j, give it a star on <a target="_blank" rel="noopener noreferrer" href="https://gitee.com/mabaiwancn/hippo4j">Gitee</a>, thanks.`, // content: `⭐️ If you like hippo4j, give it a star on <a target="_blank" rel="noopener noreferrer" href="https://gitee.com/mabaiwancn/hippo4j">Gitee</a>, thanks.`,
// content: `⭐️ 如果您喜欢 hippo4j请在 <a target="_blank" rel="noopener noreferrer" href="https://gitee.com/mabaiwancn/hippo4j">Gitee</a> 和 <a target="_blank" rel="noopener noreferrer" href="https://github.com/opengoofy/hippo4j">GitHub</a> 上给它一个 star谢谢`, // content: `⭐️ 如果您喜欢 hippo4j请在 <a target="_blank" rel="noopener noreferrer" href="https://gitee.com/mabaiwancn/hippo4j">Gitee</a> 和 <a target="_blank" rel="noopener noreferrer" href="https://github.com/opengoofy/hippo4j">GitHub</a> 上给它一个 star谢谢`,
content: `⭐️ 开源不易,如果 Hippo4j 对您有帮助,请在 <a target="_blank" rel="noopener noreferrer" href="https://github.com/opengoofy/hippo4j">GitHub</a> 上给它一个 Star 🌟`, content: `⭐️ 开源不易,如果 Hippo4j 对您有帮助,请在 <a target="_blank" rel="noopener noreferrer" href="https://github.com/opengoofy/hippo4j">GitHub</a> 上给它一个 Star 🌟`,
// content: `<a target="_blank" rel="noopener noreferrer" href="https://xiaomage.info/knowledge-planet/">👉 《小马哥的代码实战课》官方知识星球来啦!!!</a>`, // content: `<a target="_blank" rel="noopener noreferrer" href="https://xiaomage.info/knowledge-planet/">👉 《小马哥的代码实战课》官方知识星球来啦!!!</a>`,
}, },
navbar: { navbar: {
title: '', title: '',
logo: { logo: {
alt: 'Hippo4j 动态可观测线程池框架', alt: 'Hippo4j 动态可观测线程池框架',
src: 'img/hippo4j.png', src: 'img/hippo4j.png',
}, },
items: [ items: [
{ {
type: 'docSidebar', type: 'docSidebar',
docId: 'intro', docId: 'intro',
position: 'left', position: 'left',
sidebarId: 'user_docs', sidebarId: 'user_docs',
label: '文档', label: '文档',
}, },
{ {
to: '/community/contributor-guide', to: '/community/contributor-guide',
label: '社区', label: '社区',
position: 'left', position: 'left',
activeBaseRegex: `/community/`, activeBaseRegex: `/community/`,
}, },
/*{ to: "/team", label: "团队", position: "left" },*/ /*{ to: "/team", label: "团队", position: "left" },*/
{ to: '/users', label: '采用公司', position: 'left' }, {to: '/users', label: '采用公司', position: 'left'},
{ to: '/group', label: '加群沟通', position: 'left' }, {to: '/group', label: '加群沟通', position: 'left'},
/*{to: '/blog', label: '博客', position: 'left'},*/ /*{to: '/blog', label: '博客', position: 'left'},*/
{ {
href: 'http://console.hippo4j.cn/index.html', href: 'http://console.hippo4j.cn/index.html',
label: '控制台样例', label: '控制台样例',
position: 'left', position: 'left',
}, },
{ {
href: 'https://gitee.com/opengoofy/congomall', href: 'https://magestack.cn',
label: '👉 刚果商城', label: '🚀 拿个offer',
position: 'left', position: 'left',
}, },
{ {
type: 'docsVersionDropdown', type: 'docsVersionDropdown',
position: 'right',
dropdownActiveClassDisabled: true,
},
{ type: 'localeDropdown', position: 'right' },
/*{
href: 'https://gitee.com/mabaiwancn/hippo4j',
label: 'Gitee',
position: 'right', position: 'right',
},*/ dropdownActiveClassDisabled: true,
{ },
href: 'https://github.com/opengoofy/hippo4j',
className: 'header-github-link',
'aria-label': 'GitHub repository',
position: 'right',
},
/*{ {type: 'localeDropdown', position: 'right'},
/*{
href: 'https://gitee.com/mabaiwancn/hippo4j',
label: 'Gitee',
position: 'right',
},*/
{
href: 'https://github.com/opengoofy/hippo4j', href: 'https://github.com/opengoofy/hippo4j',
label: 'GitHub', className: 'header-github-link',
'aria-label': 'GitHub repository',
position: 'right', position: 'right',
},*/ },
],
}, /*{
footer: { href: 'https://github.com/opengoofy/hippo4j',
style: 'dark', label: 'GitHub',
links: [ position: 'right',
{ },*/
title: 'Docs', ],
items: [ },
{ footer: {
label: 'Intro', style: 'dark',
to: '/docs/user_docs/intro', links: [
}, {
{ title: 'Docs',
label: 'Config Mode', items: [
to: '/docs/user_docs/getting_started/config/hippo4j-config-start', {
}, label: 'Intro',
{ to: '/docs/user_docs/intro',
label: 'Server Mode', },
to: '/docs/user_docs/getting_started/server/hippo4j-server-start', {
}, label: 'Config Mode',
], to: '/docs/user_docs/getting_started/config/hippo4j-config-start',
}, },
{ {
title: 'Community', label: 'Server Mode',
items: [ to: '/docs/user_docs/getting_started/server/hippo4j-server-start',
{ },
label: 'Group', ],
href: 'https://hippo4j.cn/group', },
}, {
{ title: 'Community',
label: 'WeChat', items: [
href: 'https://mp.weixin.qq.com/s/diVHYvwiuYH9aWpZDPc27g', {
}, label: 'Group',
], href: 'https://hippo4j.cn/group',
}, },
{ {
title: 'More', label: 'WeChat',
items: [ href: 'https://mp.weixin.qq.com/s/diVHYvwiuYH9aWpZDPc27g',
{ },
label: 'Gitee', ],
href: 'https://gitee.com/opengoofy/hippo4j', },
}, {
{ title: 'More',
label: 'GitHub', items: [
href: 'https://github.com/opengoofy/hippo4j', {
}, label: 'Gitee',
], href: 'https://gitee.com/opengoofy/hippo4j',
}, },
{ {
title: 'Links', label: 'GitHub',
items: [ href: 'https://github.com/opengoofy/hippo4j',
{ },
label: '书源', ],
href: 'https://bookyuan.cn/', },
}, {
{ title: 'Links',
label: '推广合作', items: [
href: 'https://hippo4j.cn/docs/user_docs/other/operation', {
}, label: '推广合作',
], href: 'https://hippo4j.cn/docs/user_docs/other/operation',
}, },
], ],
copyright: `Copyright © 2021-2022 马丁版权所有 <a href="https://beian.miit.gov.cn">京ICP备2021038095号 },
],
copyright: `Copyright © 2021-2023 马丁版权所有 <a href="https://beian.miit.gov.cn">京ICP备2021038095号
</a>`, </a>`,
}, },
prism: { prism: {
theme: lightCodeTheme, theme: lightCodeTheme,
darkTheme: darkCodeTheme, darkTheme: darkCodeTheme,
additionalLanguages: ['java'], additionalLanguages: ['java'],
}, },
}), }),
}; };
module.exports = config; module.exports = config;

@ -5,7 +5,7 @@ title: 采用公司
## 谁在使用 Hippo4j ## 谁在使用 Hippo4j
共计 39+ 家公司生产接入 Hippo4j按照公司登记时间排序。 共计 42+ 家公司生产接入 Hippo4j按照公司登记时间排序。
- [身边云](https://serviceshare.com) - [身边云](https://serviceshare.com)
- [思派健康科技](https://www.medbanks.cn) - [思派健康科技](https://www.medbanks.cn)
@ -46,6 +46,9 @@ title: 采用公司
- [广联达科技股份有限公司](https://www.glodon.com) - [广联达科技股份有限公司](https://www.glodon.com)
- [天健联创控股集团有限公司](https://www.tjlc.com.cn) - [天健联创控股集团有限公司](https://www.tjlc.com.cn)
- [知乎](https://www.zhihu.com/) - [知乎](https://www.zhihu.com/)
- [广东谷通科技有限公司](https://www.duofriend.com)
- [成都全域智旅科技有限公司](http://qyzl.com)
- [深圳市华云中盛科技股份有限公司](http://www.hua-cloud.cn)
## 登记 ## 登记

@ -5,7 +5,7 @@ title: 采用公司
## 谁在使用 Hippo4j ## 谁在使用 Hippo4j
共计 39+ 家公司生产接入 Hippo4j按照公司登记时间排序。 共计 42+ 家公司生产接入 Hippo4j按照公司登记时间排序。
- [身边云](https://serviceshare.com) - [身边云](https://serviceshare.com)
- [思派健康科技](https://www.medbanks.cn) - [思派健康科技](https://www.medbanks.cn)
@ -46,6 +46,9 @@ title: 采用公司
- [广联达科技股份有限公司](https://www.glodon.com) - [广联达科技股份有限公司](https://www.glodon.com)
- [天健联创控股集团有限公司](https://www.tjlc.com.cn) - [天健联创控股集团有限公司](https://www.tjlc.com.cn)
- [知乎](https://www.zhihu.com/) - [知乎](https://www.zhihu.com/)
- [广东谷通科技有限公司](https://www.duofriend.com)
- [成都全域智旅科技有限公司](http://qyzl.com)
- [深圳市华云中盛科技股份有限公司](http://www.hua-cloud.cn)
## 登记 ## 登记

@ -0,0 +1,95 @@
/*
* 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 cn.hippo4j.common.executor.support;
import cn.hippo4j.common.toolkit.ThreadPoolExecutorUtil;
import lombok.extern.slf4j.Slf4j;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
* Thread pool executor util test
*/
@Slf4j
public class ThreadPoolExecutorUtilTest {
private ThreadPoolExecutor executor;
private int corePoolSize;
private int maxPoolSize;
@Before
public void testSafeSetPoolSize() {
corePoolSize = 2;
maxPoolSize = 4;
executor = new ThreadPoolExecutor(
corePoolSize,
maxPoolSize,
1L,
TimeUnit.SECONDS,
new ArrayBlockingQueue<>(10)
);
}
@Test
public void testEquals(){
// Test when the new core pool size equals the original maximum pool size.
int newCorePoolSize1 = maxPoolSize;
int newMaxPoolSize1 = 6;
ThreadPoolExecutorUtil.safeSetPoolSize(executor, newCorePoolSize1, newMaxPoolSize1);
Assert.assertEquals(newCorePoolSize1, executor.getCorePoolSize());
Assert.assertEquals(newMaxPoolSize1, executor.getMaximumPoolSize());
}
@Test
public void testGreater(){
// Test when the new core pool size is greater than the original maximum pool size.
int newCorePoolSize2 = 8;
int newMaxPoolSize2 = 10;
ThreadPoolExecutorUtil.safeSetPoolSize(executor, newCorePoolSize2, newMaxPoolSize2);
Assert.assertEquals(newCorePoolSize2, executor.getCorePoolSize());
Assert.assertEquals(newMaxPoolSize2, executor.getMaximumPoolSize());
}
@Test
public void testLess(){
// Test when the new core pool size is less than the original maximum pool size.
int newCorePoolSize3 = 3;
int newMaxPoolSize3 = 5;
ThreadPoolExecutorUtil.safeSetPoolSize(executor, newCorePoolSize3, newMaxPoolSize3);
Assert.assertEquals(newCorePoolSize3, executor.getCorePoolSize());
Assert.assertEquals(newMaxPoolSize3, executor.getMaximumPoolSize());
}
@Test
public void testException(){
// Test when the new core pool size is greater than the new maximum pool size, which should throw an IllegalArgumentException.
int newCorePoolSize4 = 6;
int newMaxPoolSize4 = 4;
try {
ThreadPoolExecutorUtil.safeSetPoolSize(executor, newCorePoolSize4, newMaxPoolSize4);
} catch (IllegalArgumentException e) {
// Expected to throw an exception.
Assert.assertEquals("newCorePoolSize must be smaller than newMaximumPoolSize", e.getMessage());
log.error("newCorePoolSize must be smaller than newMaximumPoolSize;{}",e.getMessage());
}
}
}

@ -45,6 +45,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.BlockingQueue; import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -136,7 +137,7 @@ public class ReportingEventExecutor implements Runnable, CommandLineRunner, Disp
properties.getCollectInterval(), properties.getCollectInterval(),
TimeUnit.MILLISECONDS); TimeUnit.MILLISECONDS);
Integer bufferSize = properties.getTaskBufferSize(); Integer bufferSize = properties.getTaskBufferSize();
messageCollectVessel = new ArrayBlockingQueue(bufferSize); messageCollectVessel = new LinkedBlockingQueue(bufferSize);
// Get all data collection components, currently only historical operation data collection. // Get all data collection components, currently only historical operation data collection.
collectors = ApplicationContextHolder.getBeansOfType(Collector.class); collectors = ApplicationContextHolder.getBeansOfType(Collector.class);
// Start reporting monitoring data thread. // Start reporting monitoring data thread.

@ -0,0 +1,100 @@
/*
* 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 cn.hippo4j.server.common.base;
import cn.hippo4j.common.toolkit.Assert;
import cn.hippo4j.server.common.base.exception.ErrorCode;
import cn.hippo4j.server.common.base.exception.ErrorCodeEnum;
import cn.hippo4j.server.common.base.exception.ServiceException;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.checkerframework.checker.units.qual.A;
import org.junit.jupiter.api.Test;
import java.util.Objects;
/**
* Service exception test
*/
public class ServiceExceptionTest {
@Test
public void ServiceExceptionTest1(){
ServiceException serviceException = new ServiceException();
Assert.isTrue(Objects.equals(serviceException.getErrorCode().getCode(), "3"));
Assert.isTrue(Objects.equals(serviceException.getMessage(), "SERVICE_ERROR"));
}
@Test
public void ServiceExceptionTest2(){
ErrorCode errorCode = ErrorCodeEnum.LOGIN_TIMEOUT;
ServiceException serviceException = new ServiceException(errorCode);
Assert.isTrue(Objects.equals(serviceException.getErrorCode().getCode(), ErrorCodeEnum.LOGIN_TIMEOUT.getCode()));
Assert.isTrue(Objects.equals(serviceException.getMessage(), ErrorCodeEnum.LOGIN_TIMEOUT.getMessage()));
}
@Test
public void ServiceExceptionTest3(){
String message = ErrorCodeEnum.SERVICE_ERROR.getMessage();
ServiceException serviceException = new ServiceException(message);
Assert.isTrue(Objects.equals(serviceException.getMessage(), message));
}
@Test
public void ServiceExceptionTest4(){
Throwable cause = new Throwable();
ServiceException serviceException = new ServiceException(cause);
Assert.isTrue(Objects.equals(serviceException.getCause().getMessage(), cause.getMessage()));
}
@Test
public void ServiceExceptionTest5(){
String message = ErrorCodeEnum.SERVICE_ERROR.getMessage();
Throwable cause = new Throwable();
ServiceException serviceException = new ServiceException(message, cause);
Assert.isTrue(Objects.equals(serviceException.getCause().getMessage(), cause.getMessage()));
Assert.isTrue(Objects.equals(serviceException.getMessage(), message));
}
@Test
public void ServiceExceptionTest6(){
String message = ErrorCodeEnum.SERVICE_ERROR.getMessage();
Throwable cause = new Throwable();
ServiceException serviceException = new ServiceException(cause, message);
Assert.isTrue(Objects.equals(serviceException.getCause().getMessage(), cause.getMessage()));
Assert.isTrue(Objects.equals(serviceException.getMessage(), message));
}
@Test
public void ServiceExceptionTest7(){
Throwable cause = new Throwable();
ErrorCode errorCode = ErrorCodeEnum.LOGIN_TIMEOUT;
ServiceException serviceException = new ServiceException(cause, errorCode);
Assert.isTrue(Objects.equals(serviceException.getCause().getMessage(), cause.getMessage()));
Assert.isTrue(Objects.equals(serviceException.getErrorCode().getCode(), ErrorCodeEnum.LOGIN_TIMEOUT.getCode()));
}
@Test
public void ServiceExceptionTest8(){
Throwable cause = new Throwable();
ErrorCode errorCode = ErrorCodeEnum.LOGIN_TIMEOUT;
String message = ErrorCodeEnum.SERVICE_ERROR.getMessage();
ServiceException serviceException = new ServiceException(message, cause, errorCode);
Assert.isTrue(Objects.equals(serviceException.getCause().getMessage(), cause.getMessage()));
Assert.isTrue(Objects.equals(serviceException.getErrorCode().getCode(), ErrorCodeEnum.LOGIN_TIMEOUT.getCode()));
Assert.isTrue(Objects.equals(serviceException.getMessage(), message));
}
}
Loading…
Cancel
Save