Skip to content

Commit

Permalink
fix(config): fix jmx already registered with name bug
Browse files Browse the repository at this point in the history
fix jmx already registered with name.
add doc to project

Closes #18,#8
  • Loading branch information
tobato committed Jun 14, 2017
1 parent 216fc97 commit 8396c28
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
buildNumber.properties
/.apt_generated/
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
## 1.25.4 (2017-06-14)

Bugfixes:

- 解决在SpringBoot项目当中JMX重复注册的问题 (#8,#18,@flykarry,@SevenSecondsOfMemory)

错误信息

javax.management.InstanceAlreadyExistsException: MXBean already registered with name org.apache.commons.pool2:type=GenericKeyedObjectPool,name=pool

解决办法配置

@EnableMBeanExport(registration = RegistrationPolicy.IGNORE_EXISTING)



Docs:

- 增加文档目录,把相关文档完善提交一下

## 1.25.3 (2017-03-11)

Features:
Expand Down
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,11 @@
<artifactId>thumbnailator</artifactId>
<version>0.4.8</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
</dependencies>


Expand Down
12 changes: 8 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FastDFS-Client 1.25.3-RELEASE(2017-03-11)
FastDFS-Client 1.25.4-RELEASE(2017-06-14)
---

This is a java client lib for [FastDFS](https://github.com/happyfish100/fastdfs).
Expand Down Expand Up @@ -62,13 +62,13 @@ Maven依赖为
<dependency>
<groupId>com.github.tobato</groupId>
<artifactId>fastdfs-client</artifactId>
<version>1.25.3-RELEASE</version>
<version>1.25.4-RELEASE</version>
</dependency>


### 2.将Fdfs配置引入项目

将FastDFS-Client客户端引入本地化项目的方式非常简单,在SpringBoot项目当中
将FastDFS-Client客户端引入本地化项目的方式非常简单,在SpringBoot项目`/src/[com.xxx.主目录]/conf`当中配置

/**
* 导入FastDFS-Client组件
Expand All @@ -78,11 +78,15 @@ Maven依赖为
*/
@Configuration
@Import(FdfsClientConfig.class)
// 解决jmx重复注册bean的问题
@EnableMBeanExport(registration = RegistrationPolicy.IGNORE_EXISTING)
public class ComponetImport {
// 导入依赖组件
}

是的,只需要一行注解 @Import(FdfsClientConfig.class)
对的,只需要一行注解 @Import(FdfsClientConfig.class)就可以拥有带有连接池的FastDFS Java客户端了。

>注意:`@EnableMBeanExport`解决问题JMX重复注册问题,[issue #8](./issues/8) [issue #18](./issues/8),不要再配置 `spring.jmx.enabled=false`,以免影响SpringBoot默认的JMX监控。
### 3.在application.yml当中配置Fdfs相关参数
# ===================================================================
Expand Down
55 changes: 55 additions & 0 deletions src/doc/01_Release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
项目发布
----

记录项目发布的过程,免得每次发布都重新想一遍。

## Docker环境准备

启动Docker以后需要把FDFS服务打开

bash
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf

## 发布流程

### 1.修改文档

发布前先调整Readme.md 和 Changelog.md

### 2.项目发布准备

mvn release:prepare -P release

>回滚失败的发布
>
> mvn release:rollback
### 3.正式发布提交

mvn release:peform -P release

## 参考资料

Maven Release Plugin that is used to automate release management. Releasing a project is done in two steps: prepare and perform.

* Preparing a release goes through the following release phases:

* Check that there are no uncommitted changes in the sources
* Check that there are no SNAPSHOT dependencies
* Change the version in the POMs from x-SNAPSHOT to a new version (you will be prompted for the versions to use)
* Transform the SCM information in the POM to include the final destination of the tag
* Run the project tests against the modified POMs to confirm everything is in working order
* Commit the modified POMs
* Tag the code in the SCM with a version name (this will be prompted for)
* Bump the version in the POMs to a new value y-SNAPSHOT (these values will also be prompted for)
* Commit the modified POMs

* Performing a release runs the following release phases:

* Checkout from an SCM URL with optional tag
* Run the predefined Maven goals to release the project (by default, deploy site-deploy)




Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ public class ConnectionPoolConfig extends GenericKeyedObjectPoolConfig {
*/
public static final int FDFS_NUM_TESTS_PEREVICTION_RUN = -1;

/** 默认jmx域名 */
public static final String FDFS_JMX_NAME_BASE = "com.github.tobato.fastdfs.conn:type=FdfsConnectionPool";

/** 默认jmx prefix名称 */
public static final String FDFS_JMX_NAME_PREFIX = "fdfsPool";

public ConnectionPoolConfig() {
// 从池中借出的对象的最大数目
setMaxTotal(FDFS_MAX_TOTAL);
Expand All @@ -63,6 +69,9 @@ public ConnectionPoolConfig() {
setTimeBetweenEvictionRunsMillis(FDFS_TIME_BETWEEN_EVICTION_RUNS_MILLIS);
// 清理时候检查所有线程
setNumTestsPerEvictionRun(FDFS_NUM_TESTS_PEREVICTION_RUN);
// 配置jmx
this.setJmxNameBase(FDFS_JMX_NAME_BASE);
this.setJmxNamePrefix(FDFS_JMX_NAME_PREFIX);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.EnableMBeanExport;
import org.springframework.jmx.support.RegistrationPolicy;

/**
* 测试驱动类
Expand All @@ -10,6 +12,7 @@
*
*/
@SpringBootApplication
@EnableMBeanExport(registration = RegistrationPolicy.IGNORE_EXISTING)
public class FastdfsTestApplication {
public static void main(String[] args) {
SpringApplication.run(FastdfsTestApplication.class, args);
Expand Down
7 changes: 0 additions & 7 deletions src/test/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ fdfs:
# - 192.168.174.42:22122
# - 192.168.174.48:22122

spring.jmx.enabled: false

---
spring:
profiles: customized_pool
Expand All @@ -31,8 +29,3 @@ fdfs:
maxTotal: 153
#获取连接时的最大等待毫秒数100
maxWaitMillis: 102


spring.jmx.enabled: false


0 comments on commit 8396c28

Please sign in to comment.