Skip to content

Commit

Permalink
merge from dev
Browse files Browse the repository at this point in the history
  • Loading branch information
knightliao committed May 31, 2016
2 parents 96dc9f4 + 45d2a0f commit a7ef3de
Show file tree
Hide file tree
Showing 60 changed files with 411 additions and 222 deletions.
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Disconf [![Build Status](https://travis-ci.org/knightliao/disconf.svg?branch=master)](https://travis-ci.org/knightliao/disconf) [![Coverage Status](https://coveralls.io/repos/knightliao/disconf/badge.png?branch=master)](https://coveralls.io/r/knightliao/disconf?branch=master)
=======

Distributed Configuration Management Platform(分布式配置管理平台)
Distributed Configuration Management Platform(分布式配置管理平台)

专注于各种 `分布式系统配置管理``通用组件`/`通用平台`, 提供统一的`配置管理服务`

Expand Down Expand Up @@ -37,8 +37,8 @@ https://github.com/knightliao/disconf-demos-java

disconf.git branches and Maven version:

- dev(develop branch): 2.6.33-SNAPSHOT
- master(stable branch):2.6.33
- dev(develop branch): 2.6.34
- master(stable branch):2.6.34
- [更新日志](https://github.com/knightliao/disconf/wiki/updates)
- 在Maven Central Repository里查看 [com.baidu.disconf](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.baidu.disconf%22 )

Expand Down Expand Up @@ -100,7 +100,7 @@ Disconf的功能特点描述图:
<dependency>
<groupId>com.baidu.disconf</groupId>
<artifactId>disconf-client</artifactId>
<version>2.6.33</version>
<version>2.6.34</version>
</dependency>

### server: disconf-web 使用 ###
Expand Down Expand Up @@ -147,7 +147,6 @@ APP+环境+版本+ZK查询:

- [Tutorial 6 disconf-web 功能详解](https://github.com/knightliao/disconf/wiki/Tutorial6)
- [Tutorial 7 可自定义的部分托管的分布式配置](https://github.com/knightliao/disconf/wiki/Tutorial7)
- [Tutorial disconf与dubbo的集成 demo](https://github.com/knightliao/disconf/tree/master/disconf-demos/disconf-standalone-dubbo-demo)
- [Tutorial 9 实现真正意义上的统一上线包](https://github.com/knightliao/disconf/wiki/Tutorial9)
- [Tutorial 10 实现一个配置更新下载器agent](https://github.com/knightliao/disconf/wiki/Tutorial10)
- [Tutorial 13 增加统一的回调类,unify-notify模式:灵活处理更新配置通知](https://github.com/knightliao/disconf/wiki/Tutorial13-unify-notify)
Expand Down Expand Up @@ -191,4 +190,4 @@ APP+环境+版本+ZK查询:

- 搜索引擎推荐:[sov5搜索引擎, 支持谷歌网页搜索/电影搜索/资源搜索/问答搜索](http://sov5.com)
- python论坛推荐:[Django中国社区](http://www.django-china.cn/)
- [联系与赞助作者](https://github.com/knightliao/disconf/wiki/sponsor) 捐助者会留名
- [联系与赞助作者](https://github.com/knightliao/disconf/wiki/sponsor)
6 changes: 3 additions & 3 deletions disconf-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<parent>
<groupId>com.baidu.disconf</groupId>
<artifactId>disconf-base</artifactId>
<version>2.6.33</version>
<version>2.6.34</version>
</parent>

<licenses>
Expand Down Expand Up @@ -70,8 +70,8 @@
</dependency>

<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
Expand Down Expand Up @@ -146,55 +147,55 @@ protected synchronized void secondScan() {
isSecondInit = true;

//
// 不开启 则不要启动timer和打印变量map
// 不开启 则不要打印变量map
//
if (DisClientConfig.getInstance().ENABLE_DISCONF) {
//
// start timer
//
//startTimer();

//
LOGGER.info("Conf File Map: {}", DisconfStoreProcessorFactory.getDisconfStoreFileProcessor()
.confToString());
String data = DisconfStoreProcessorFactory.getDisconfStoreFileProcessor()
.confToString();
if (!StringUtils.isEmpty(data)) {
LOGGER.info("Conf File Map: {}", data);
}

//
LOGGER.info("Conf Item Map: {}", DisconfStoreProcessorFactory.getDisconfStoreItemProcessor()
.confToString());
data = DisconfStoreProcessorFactory.getDisconfStoreItemProcessor()
.confToString();
if (!StringUtils.isEmpty(data)) {
LOGGER.info("Conf Item Map: {}", data);
}
}
LOGGER.info("******************************* DISCONF END *******************************");
}

/**
* reloadable config file scan, for xml config
*/
public synchronized void reloadableScan(String filename) {
public synchronized void reloadableScan(String fileName) {

if (!isFirstInit) {
return;
}

if (!DisClientConfig.getInstance().ENABLE_DISCONF) {
return;
}

//
//
//
if (DisClientConfig.getInstance().ENABLE_DISCONF) {
try {

try {
if (!DisClientConfig.getInstance().getIgnoreDisconfKeySet().contains(fileName)) {

if (scanMgr != null) {
scanMgr.reloadableScan(filename);
}
if (scanMgr != null) {
scanMgr.reloadableScan(fileName);
}

if (disconfCoreMgr != null) {
disconfCoreMgr.processFile(filename);
}
LOGGER.debug("disconf reloadable file: {}", filename);
if (disconfCoreMgr != null) {
disconfCoreMgr.processFile(fileName);
}
LOGGER.debug("disconf reloadable file: {}", fileName);
}

} catch (Exception e) {
} catch (Exception e) {

LOGGER.error(e.toString(), e);
LOGGER.error(e.toString(), e);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import com.baidu.disconf.client.store.aspect.DisconfAspectJ;
import com.baidu.disconf.client.store.inner.DisconfCenterHostFilesStore;
import com.baidu.disconf.client.utils.StringUtil;
import com.baidu.disconf.client.support.utils.StringUtil;

/**
* 第一次扫描,静态扫描
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.baidu.disconf.client.common.constants;

import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;

/**
* 支持的文件后缀类型
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import com.baidu.disconf.client.common.constants.SupportFileTypeEnum;
import com.baidu.disconf.client.config.DisClientConfig;
import com.baidu.disconf.client.utils.ClassUtils;
import com.baidu.disconf.client.support.utils.ClassUtils;
import com.baidu.disconf.core.common.utils.ClassLoaderUtil;
import com.baidu.disconf.core.common.utils.OsUtil;

Expand All @@ -32,6 +32,9 @@ public class DisconfCenterFile extends DisconfCenterBaseModel {
// 额外的配置数据,非注解式使用它来存储
private Map<String, Object> additionalKeyMaps = new HashMap<String, Object>();

// 是否是非注解注入方式
private boolean isTaggedWithNonAnnotationFile = false;

// 配置文件类
private Class<?> cls;

Expand Down Expand Up @@ -83,6 +86,14 @@ public void setSupportFileTypeEnum(SupportFileTypeEnum supportFileTypeEnum) {
this.supportFileTypeEnum = supportFileTypeEnum;
}

public boolean isTaggedWithNonAnnotationFile() {
return isTaggedWithNonAnnotationFile;
}

public void setIsTaggedWithNonAnnotationFile(boolean isTaggedWithNonAnnotationFile) {
this.isTaggedWithNonAnnotationFile = isTaggedWithNonAnnotationFile;
}

public String getCopy2TargetDirPath() {
return copy2TargetDirPath;
}
Expand Down Expand Up @@ -203,21 +214,30 @@ public boolean isStatic() {
*/
public Object setValue4StaticFileItem(Object value) throws Exception {

if (setMethod != null) {
setMethod.invoke(null, value);
} else {
field.set(null, value);
try {
if (setMethod != null) {
setMethod.invoke(null, value);
} else {
field.set(null, value);
}

} catch (Exception e) {
LOGGER.warn(e.toString());
}

return value;
}

public Object setValue4FileItem(Object object, Object value) throws Exception {

if (setMethod != null) {
setMethod.invoke(object, value);
} else {
field.set(object, value);
try {
if (setMethod != null) {
setMethod.invoke(object, value);
} else {
field.set(object, value);
}
} catch (Exception e) {
LOGGER.warn(e.toString());
}

return value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

import com.baidu.disconf.client.utils.ClassUtils;
import com.baidu.disconf.client.support.utils.ClassUtils;

/**
* 配置项表示
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public static DisClientConfig getInstance() {

protected static final String filename = "disconf.properties";

// disconf.properties 的路径 -D 传入
private static final String DISCONF_CONF_FILE_PATH_ARG = "disconf.conf";

private boolean isLoaded = false;

private DisClientConfig() {
Expand All @@ -52,11 +55,18 @@ public synchronized void loadConfig(String filePath) throws Exception {

String filePathInternal = filename;

// 指定的路径
if (filePath != null) {

filePathInternal = filePath;
}

// -d 的路径
// 优先使用 系统参数或命令行导入
String disconfFilePath = System.getProperty(DISCONF_CONF_FILE_PATH_ARG);
if (disconfFilePath != null) {
filePathInternal = disconfFilePath;
}

try {
DisconfAutowareConfig.autowareConfig(INSTANCE, filePathInternal);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import java.util.List;
import java.util.Set;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.baidu.disconf.client.config.DisClientConfig;
import com.baidu.disconf.client.config.DisClientSysConfig;
import com.baidu.disconf.client.utils.StringUtil;
import com.baidu.disconf.client.support.utils.StringUtil;
import com.baidu.disconf.core.common.utils.ClassLoaderUtil;
import com.baidu.disconf.core.common.utils.OsUtil;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import java.util.Properties;

import com.baidu.disconf.client.core.filetype.DisconfFileTypeProcessor;
import com.baidu.disconf.client.utils.ConfigLoaderUtils;
import com.baidu.disconf.client.support.utils.ConfigLoaderUtils;

/**
* Properties 处理器
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,6 @@ public void secondScan() throws Exception {
@Override
public void reloadableScan(String fileName) throws Exception {

if (DisClientConfig.getInstance().getIgnoreDisconfKeySet().contains(fileName)) {
return;
}

StaticScannerNonAnnotationFileMgrImpl.scanData2Store(fileName);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.baidu.disconf.client.common.model.DisconfKey;
import com.baidu.disconf.client.common.update.IDisconfUpdate;
import com.baidu.disconf.client.common.update.IDisconfUpdatePipeline;
import com.baidu.disconf.client.config.DisClientConfig;
import com.baidu.disconf.client.scan.inner.common.ScanVerify;
import com.baidu.disconf.client.scan.inner.dynamic.model.ScanDynamicModel;
import com.baidu.disconf.client.scan.inner.statically.model.ScanStaticModel;
Expand Down Expand Up @@ -194,6 +195,11 @@ private static IDisconfUpdatePipeline getIDisconfUpdatePipelineInstance(
private static void addOne2InverseMap(DisconfKey disconfKey, Map<DisconfKey, List<IDisconfUpdate>> inverseMap,
IDisconfUpdate iDisconfUpdate) {

// 忽略的key 应该忽略掉
if (DisClientConfig.getInstance().getIgnoreDisconfKeySet().contains(disconfKey.getKey())) {
return;
}

List<IDisconfUpdate> serviceList;

if (inverseMap.containsKey(disconfKey)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import com.baidu.disconf.client.scan.inner.statically.StaticScannerMgr;
import com.baidu.disconf.client.scan.inner.statically.model.ScanStaticModel;
import com.baidu.disconf.client.store.DisconfStoreProcessorFactory;
import com.baidu.disconf.client.utils.MethodUtils;
import com.baidu.disconf.client.support.utils.MethodUtils;
import com.baidu.disconf.core.common.constants.DisConfigTypeEnum;
import com.baidu.disconf.core.common.path.DisconfWebPathMgr;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import com.baidu.disconf.client.scan.inner.statically.StaticScannerMgr;
import com.baidu.disconf.client.scan.inner.statically.model.ScanStaticModel;
import com.baidu.disconf.client.store.DisconfStoreProcessorFactory;
import com.baidu.disconf.client.utils.MethodUtils;
import com.baidu.disconf.client.support.utils.MethodUtils;
import com.baidu.disconf.core.common.constants.DisConfigTypeEnum;
import com.baidu.disconf.core.common.path.DisconfWebPathMgr;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ public static DisconfCenterBaseModel getDisconfCenterFile(String fileName) {
// file name
disconfCenterFile.setFileName(fileName);

// 非注解式
disconfCenterFile.setIsTaggedWithNonAnnotationFile(true);

// file type
disconfCenterFile.setSupportFileTypeEnum(SupportFileTypeEnum.getByFileName(fileName));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,9 @@ private void analysis4DisconfFile(ScanStaticModel scanModel) {

} else {

LOGGER
.error("cannot find CLASS ANNOTATION " + DisconfFile.class.getName()
+ " for disconf file item: " +
method.toString());
LOGGER.error("cannot find CLASS ANNOTATION " + DisconfFile.class.getName()
+ " for disconf file item: " +
method.toString());
}
}

Expand All @@ -155,7 +154,7 @@ private void analysis4DisconfFile(ScanStaticModel scanModel) {

// 校验是否所有配置文件都含有配置
if (disconfFileItemMap.get(classFile).isEmpty()) {
LOGGER.warn("disconf file hasn't any items: " + classFile.getName());
LOGGER.info("disconf file hasn't any items: " + classFile.getName());
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import com.baidu.disconf.client.config.DisClientConfig;
import com.baidu.disconf.client.store.DisconfStoreProcessor;
import com.baidu.disconf.client.store.DisconfStoreProcessorFactory;
import com.baidu.disconf.client.utils.MethodUtils;
import com.baidu.disconf.client.support.utils.MethodUtils;
import com.baidu.disconf.core.common.constants.DisConfigTypeEnum;

/**
Expand Down
Loading

0 comments on commit a7ef3de

Please sign in to comment.