├── disconf-web ├── bin │ ├── .gitignore │ ├── __init__.py │ └── sql │ │ ├── __init__.py │ │ └── get_create_one_user_sql.sql.py ├── src │ ├── main │ │ ├── .gitignore │ │ ├── resources │ │ │ ├── .gitignore │ │ │ ├── messages │ │ │ │ ├── app-service-info.properties │ │ │ │ ├── app-controller-info.properties │ │ │ │ ├── sign-service-info.properties │ │ │ │ ├── sign-controller-info.properties │ │ │ │ └── config-controller-info.properties │ │ │ ├── spring-cache.properties │ │ │ └── ehcache.xml │ │ ├── webapp │ │ │ ├── Release │ │ │ └── jpaas_control │ │ └── java │ │ │ └── com │ │ │ └── baidu │ │ │ ├── disconf │ │ │ └── web │ │ │ │ ├── tools │ │ │ │ └── .gitignore │ │ │ │ ├── service │ │ │ │ ├── user │ │ │ │ │ ├── constant │ │ │ │ │ │ ├── validation-user.properties │ │ │ │ │ │ └── UserConstant.java │ │ │ │ │ ├── facade │ │ │ │ │ │ ├── UserFacade.java │ │ │ │ │ │ └── impl │ │ │ │ │ │ │ └── UserFacadeImpl.java │ │ │ │ │ ├── service │ │ │ │ │ │ ├── AuthMgr.java │ │ │ │ │ │ ├── UserInnerMgr.java │ │ │ │ │ │ └── impl │ │ │ │ │ │ │ └── AuthMgrImpl.java │ │ │ │ │ ├── form │ │ │ │ │ │ ├── UserListForm.java │ │ │ │ │ │ └── PasswordModifyForm.java │ │ │ │ │ └── dao │ │ │ │ │ │ ├── UserDao.java │ │ │ │ │ │ └── impl │ │ │ │ │ │ └── UserDaoImpl.java │ │ │ │ ├── role │ │ │ │ │ ├── constant │ │ │ │ │ │ └── RoleConstant.java │ │ │ │ │ ├── dao │ │ │ │ │ │ ├── RoleDao.java │ │ │ │ │ │ └── impl │ │ │ │ │ │ │ └── RoleDaoImpl.java │ │ │ │ │ ├── service │ │ │ │ │ │ ├── RoleMgr.java │ │ │ │ │ │ └── impl │ │ │ │ │ │ │ └── RoleMgrImpl.java │ │ │ │ │ └── bo │ │ │ │ │ │ └── RoleEnum.java │ │ │ │ ├── config │ │ │ │ │ ├── service │ │ │ │ │ │ └── ConfigHistoryMgr.java │ │ │ │ │ ├── resource │ │ │ │ │ │ └── config-service-info.properties │ │ │ │ │ ├── dao │ │ │ │ │ │ ├── ConfigHistoryDao.java │ │ │ │ │ │ └── impl │ │ │ │ │ │ │ └── ConfigHistoryDaoImpl.java │ │ │ │ │ ├── utils │ │ │ │ │ │ └── ConfigUtils.java │ │ │ │ │ ├── form │ │ │ │ │ │ ├── ConfListForm.java │ │ │ │ │ │ └── VersionListForm.java │ │ │ │ │ └── bo │ │ │ │ │ │ └── ConfigHistory.java │ │ │ │ ├── sign │ │ │ │ │ ├── dao │ │ │ │ │ │ ├── SignDao.java │ │ │ │ │ │ └── impl │ │ │ │ │ │ │ └── SignDaoImpl.java │ │ │ │ │ ├── service │ │ │ │ │ │ └── SignMgr.java │ │ │ │ │ └── utils │ │ │ │ │ │ └── SignUtils.java │ │ │ │ ├── roleres │ │ │ │ │ ├── dao │ │ │ │ │ │ ├── RoleResourceDao.java │ │ │ │ │ │ └── impl │ │ │ │ │ │ │ └── RoleResourceDaoImpl.java │ │ │ │ │ └── service │ │ │ │ │ │ └── RoleResourceMgr.java │ │ │ │ ├── app │ │ │ │ │ ├── form │ │ │ │ │ │ ├── AppListForm.java │ │ │ │ │ │ └── AppNewForm.java │ │ │ │ │ ├── vo │ │ │ │ │ │ └── AppListVo.java │ │ │ │ │ └── dao │ │ │ │ │ │ ├── AppDao.java │ │ │ │ │ │ └── impl │ │ │ │ │ │ └── AppDaoImpl.java │ │ │ │ ├── env │ │ │ │ │ ├── dao │ │ │ │ │ │ ├── EnvDao.java │ │ │ │ │ │ └── impl │ │ │ │ │ │ │ └── EnvDaoImpl.java │ │ │ │ │ ├── vo │ │ │ │ │ │ └── EnvListVo.java │ │ │ │ │ ├── service │ │ │ │ │ │ └── EnvMgr.java │ │ │ │ │ └── bo │ │ │ │ │ │ └── Env.java │ │ │ │ └── zookeeper │ │ │ │ │ ├── config │ │ │ │ │ └── ZooConfig.java │ │ │ │ │ ├── form │ │ │ │ │ └── ZkDeployForm.java │ │ │ │ │ └── service │ │ │ │ │ └── ZkDeployMgr.java │ │ │ │ ├── tasks │ │ │ │ └── IConfigConsistencyMonitorService.java │ │ │ │ ├── common │ │ │ │ ├── Constants.java │ │ │ │ └── email │ │ │ │ │ └── MyAuthenticator.java │ │ │ │ └── web │ │ │ │ └── auth │ │ │ │ ├── constant │ │ │ │ └── LoginConstant.java │ │ │ │ └── login │ │ │ │ └── RedisLogin.java │ │ │ ├── dsp │ │ │ └── common │ │ │ │ ├── dao │ │ │ │ └── DB.java │ │ │ │ ├── exception │ │ │ │ ├── base │ │ │ │ │ ├── GlobalExceptionAware.java │ │ │ │ │ ├── Codeable.java │ │ │ │ │ └── DspException.java │ │ │ │ ├── DocumentNotFoundException.java │ │ │ │ ├── AccessDeniedException.java │ │ │ │ ├── DaoException.java │ │ │ │ ├── UnExpectedException.java │ │ │ │ ├── RemoteException.java │ │ │ │ └── FileUploadException.java │ │ │ │ ├── annotation │ │ │ │ └── NoAuth.java │ │ │ │ ├── utils │ │ │ │ ├── DataTransfer.java │ │ │ │ ├── IpUtils.java │ │ │ │ └── DaoUtils.java │ │ │ │ ├── context │ │ │ │ └── ContextReader.java │ │ │ │ ├── constant │ │ │ │ ├── DataFormatConstants.java │ │ │ │ ├── WebConstants.java │ │ │ │ └── ModuleCode.java │ │ │ │ ├── form │ │ │ │ └── RequestFormBase.java │ │ │ │ ├── vo │ │ │ │ ├── JsonObject.java │ │ │ │ └── JsonSimpleObject.java │ │ │ │ ├── constraint │ │ │ │ ├── PasswordConstraint.java │ │ │ │ ├── PageOrderConstraint.java │ │ │ │ ├── validation │ │ │ │ │ ├── PasswordValidator.java │ │ │ │ │ ├── PageOrderValidator.java │ │ │ │ │ ├── MaxValidatorForDouble.java │ │ │ │ │ ├── MinValidatorForDouble.java │ │ │ │ │ └── ListInValidator.java │ │ │ │ ├── CommonNameConstraint.java │ │ │ │ ├── ListInConstraint.java │ │ │ │ └── UserNameConstraint.java │ │ │ │ └── listener │ │ │ │ ├── ContextListener.java │ │ │ │ └── StartupListener.java │ │ │ ├── unbiz │ │ │ └── common │ │ │ │ └── genericdao │ │ │ │ ├── param │ │ │ │ ├── ExpressionParam.java │ │ │ │ ├── IncrParam.java │ │ │ │ ├── LikeParam.java │ │ │ │ ├── NotParam.java │ │ │ │ ├── GteParam.java │ │ │ │ ├── LteParam.java │ │ │ │ ├── LessThanParam.java │ │ │ │ ├── GreaterThanParam.java │ │ │ │ └── BetweenParam.java │ │ │ │ ├── bo │ │ │ │ └── InsertOption.java │ │ │ │ ├── operator │ │ │ │ ├── Pair.java │ │ │ │ ├── Match.java │ │ │ │ ├── Order.java │ │ │ │ ├── Modify.java │ │ │ │ └── Query.java │ │ │ │ ├── annotation │ │ │ │ ├── Sequence.java │ │ │ │ └── Column.java │ │ │ │ └── sequence │ │ │ │ └── SequenceGenerator.java │ │ │ └── ub │ │ │ └── common │ │ │ ├── dbmanage │ │ │ ├── rule │ │ │ │ └── DBShardingRule.java │ │ │ └── router │ │ │ │ └── Router.java │ │ │ └── db │ │ │ └── DaoPage.java │ └── test │ │ ├── resources │ │ ├── file2 │ │ │ ├── confA.properties │ │ │ ├── utf-file.pml │ │ │ └── utf-file.properties │ │ ├── files │ │ │ ├── originalFile.txt │ │ │ └── revisedFile.txt │ │ ├── datasource-test.properties │ │ ├── sql │ │ │ └── base │ │ │ │ └── goldendata │ │ │ │ └── 1_0_0 │ │ │ │ └── disconf.sql │ │ └── application.properties │ │ └── java │ │ └── com │ │ └── baidu │ │ └── disconf │ │ └── web │ │ └── test │ │ ├── AllTestSuite.java │ │ └── common │ │ ├── BaseNoMockTC.java │ │ ├── BaseTestBeforeClass.java │ │ └── BaseTestCase.java ├── html │ ├── tools │ │ ├── node_modules │ │ │ ├── ejs │ │ │ │ ├── .gitmodules │ │ │ │ ├── test │ │ │ │ │ └── fixtures │ │ │ │ │ │ ├── backslash.ejs │ │ │ │ │ │ ├── backslash.html │ │ │ │ │ │ ├── para.ejs │ │ │ │ │ │ ├── user.ejs │ │ │ │ │ │ ├── pet.ejs │ │ │ │ │ │ ├── double-quote.html │ │ │ │ │ │ ├── fail.ejs │ │ │ │ │ │ ├── single-quote.html │ │ │ │ │ │ ├── single-quote.ejs │ │ │ │ │ │ ├── style.css │ │ │ │ │ │ ├── includes │ │ │ │ │ │ ├── menu-item.ejs │ │ │ │ │ │ └── menu │ │ │ │ │ │ │ └── item.ejs │ │ │ │ │ │ ├── double-quote.ejs │ │ │ │ │ │ ├── messed.html │ │ │ │ │ │ ├── include.css.html │ │ │ │ │ │ ├── include.css.ejs │ │ │ │ │ │ ├── messed.ejs │ │ │ │ │ │ ├── error.ejs │ │ │ │ │ │ ├── no.newlines.html │ │ │ │ │ │ ├── include.ejs │ │ │ │ │ │ ├── menu.html │ │ │ │ │ │ ├── newlines.ejs │ │ │ │ │ │ ├── include.html │ │ │ │ │ │ ├── newlines.html │ │ │ │ │ │ ├── no.newlines.ejs │ │ │ │ │ │ ├── comments.html │ │ │ │ │ │ ├── error.out │ │ │ │ │ │ ├── comments.ejs │ │ │ │ │ │ └── menu.ejs │ │ │ │ ├── index.js │ │ │ │ ├── .npmignore │ │ │ │ ├── .travis.yml │ │ │ │ ├── examples │ │ │ │ │ ├── list.ejs │ │ │ │ │ ├── functions.ejs │ │ │ │ │ ├── list.js │ │ │ │ │ ├── functions.js │ │ │ │ │ └── client.html │ │ │ │ ├── benchmark.js │ │ │ │ ├── Makefile │ │ │ │ └── lib │ │ │ │ │ └── utils.js │ │ │ └── eventproxy │ │ │ │ ├── index.js │ │ │ │ ├── node_modules │ │ │ │ └── debug │ │ │ │ │ ├── .npmignore │ │ │ │ │ ├── index.js │ │ │ │ │ ├── example │ │ │ │ │ ├── wildcards.js │ │ │ │ │ ├── app.js │ │ │ │ │ ├── worker.js │ │ │ │ │ └── browser.html │ │ │ │ │ └── component.json │ │ │ │ ├── .npmignore │ │ │ │ └── component.json │ │ ├── gen_html.sh │ │ └── gen_html.bat │ ├── .gitignore │ ├── dep │ │ ├── bootstrap │ │ │ ├── css │ │ │ │ └── noie.css │ │ │ ├── img │ │ │ │ ├── glyphicons-halflings.png │ │ │ │ └── glyphicons-halflings-white.png │ │ │ └── fonts │ │ │ │ ├── glyphicons-halflings-regular.eot │ │ │ │ ├── glyphicons-halflings-regular.ttf │ │ │ │ └── glyphicons-halflings-regular.woff │ │ └── jquery-ui-1.10.4.custom │ │ │ ├── css │ │ │ └── ui-lightness │ │ │ │ └── images │ │ │ │ ├── animated-overlay.gif │ │ │ │ ├── ui-icons_222222_256x240.png │ │ │ │ ├── ui-icons_228ef1_256x240.png │ │ │ │ ├── ui-icons_ef8c08_256x240.png │ │ │ │ ├── ui-icons_ffd27a_256x240.png │ │ │ │ ├── ui-icons_ffffff_256x240.png │ │ │ │ ├── ui-bg_flat_10_000000_40x100.png │ │ │ │ ├── ui-bg_glass_100_f6f6f6_1x400.png │ │ │ │ ├── ui-bg_glass_100_fdf5ce_1x400.png │ │ │ │ ├── ui-bg_glass_65_ffffff_1x400.png │ │ │ │ ├── ui-bg_gloss-wave_35_f6a828_500x100.png │ │ │ │ ├── ui-bg_highlight-soft_75_ffe45c_1x100.png │ │ │ │ ├── ui-bg_diagonals-thick_18_b81900_40x40.png │ │ │ │ ├── ui-bg_diagonals-thick_20_666666_40x40.png │ │ │ │ └── ui-bg_highlight-soft_100_eeeeee_1x100.png │ │ │ └── datePicker.html │ ├── assets │ │ ├── img │ │ │ ├── bohemian.jpg │ │ │ ├── header-bg.png │ │ │ ├── index-big.jpg │ │ │ └── index-big.psd │ │ └── js │ │ │ ├── index.js │ │ │ ├── footer.js │ │ │ ├── zkinfo.js │ │ │ ├── newapp.js │ │ │ ├── modify_password.js │ │ │ └── newconfigitem.js │ ├── unitTpl │ │ ├── basefoot.html.tpl │ │ ├── basehead.html.tpl │ │ ├── leftbar.html.tpl │ │ └── nav.html.tpl │ ├── build.sh │ └── mainTpl │ │ └── index.tpl.html ├── sql │ ├── 201512 │ │ └── 20151225.sql │ ├── 20160701 │ │ └── 20160701.sql │ ├── deprecated │ │ ├── 20141201 │ │ │ └── .gitignore │ │ ├── 20141226 │ │ │ └── .gitignore │ │ ├── 20150101 │ │ │ └── disconf.sql │ │ ├── 20150320 │ │ │ └── disconf.sql │ │ ├── 20150611 │ │ │ └── .gitignore │ │ ├── .gitignore │ │ └── readme.txt │ └── readme.md ├── profile │ └── rd │ │ ├── .gitignore │ │ ├── zoo.properties │ │ ├── jdbc-mysql.properties │ │ ├── application-demo.properties │ │ ├── redis-config.properties │ │ └── log4j.properties ├── .gitignore └── deploy │ └── build_java.sh ├── docs ├── .gitignore ├── source │ ├── others │ │ ├── index.rst │ │ ├── sponsor.md │ │ └── src │ │ │ ├── sponsor.rst │ │ │ └── users.rst │ ├── config │ │ └── index.rst │ ├── quick │ │ └── index.rst │ ├── question │ │ ├── index.rst │ │ ├── src │ │ │ ├── disconf-web-question.rst │ │ │ └── disconf-question.rst │ │ ├── disconf-web-question.md │ │ └── disconf-question.md │ ├── install │ │ ├── index.rst │ │ ├── 01.md │ │ └── src │ │ │ └── 01.rst │ ├── tutorial-web │ │ ├── index.rst │ │ └── Tutorial6.md │ ├── design │ │ ├── index.rst │ │ ├── 局限性和注意事项.md │ │ └── src │ │ │ └── 局限性和注意事项.rst │ ├── tutorial-client │ │ ├── Tutorial10.md │ │ ├── src │ │ │ ├── Tutorial10.rst │ │ │ └── Tutorial7.rst │ │ ├── Tutorial7.md │ │ ├── index.rst │ │ ├── Tutorial9.md │ │ └── Tutorial13-unify-notify.md │ └── index.rst ├── README.md └── myMake.sh ├── sql └── .gitignore ├── disconf-core ├── README.md ├── .gitignore └── src │ ├── main │ └── java │ │ └── com │ │ └── baidu │ │ └── disconf │ │ └── core │ │ └── common │ │ ├── restful │ │ ├── core │ │ │ └── UnreliableInterface.java │ │ ├── retry │ │ │ └── RetryStrategy.java │ │ └── RestfulFactory.java │ │ ├── utils │ │ ├── http │ │ │ ├── HttpResponseCallbackHandler.java │ │ │ └── impl │ │ │ │ └── HttpResponseCallbackHandlerJsonHandler.java │ │ ├── MyStringUtils.java │ │ ├── ZooUtils.java │ │ └── GsonUtils.java │ │ └── json │ │ └── ValueVo.java │ └── test │ └── java │ └── com │ └── baidu │ └── disconf │ └── core │ └── test │ ├── path │ └── ZooPathMgrTestCase.java │ ├── utils │ └── MyStringUtilsTestCase.java │ └── TestSuite.java ├── disconf-client ├── src │ ├── test │ │ ├── resources │ │ │ ├── testJson.json │ │ │ ├── testProperties.properties │ │ │ ├── res │ │ │ │ └── testXml.xml │ │ │ ├── testXml.xml │ │ │ └── applicationContext.xml │ │ └── java │ │ │ └── com │ │ │ └── baidu │ │ │ └── disconf │ │ │ └── client │ │ │ └── test │ │ │ ├── watch │ │ │ ├── WatchMgrTestCase.java │ │ │ └── mock │ │ │ │ └── WatchMgrMock.java │ │ │ ├── config │ │ │ └── ConfigMgrTestCase.java │ │ │ ├── core │ │ │ └── DisconfCoreMgrTestCase.java │ │ │ ├── store │ │ │ └── DisconfStoreMgrTestCase.java │ │ │ ├── model │ │ │ ├── EmptyConf.java │ │ │ ├── ServiceA2UpdateCallback.java │ │ │ ├── ServiceA.java │ │ │ └── ServiceAUpdateCallback.java │ │ │ ├── scan │ │ │ └── ScanMgrTestCase.java │ │ │ ├── support │ │ │ └── utils │ │ │ │ └── DirUtils.java │ │ │ └── TestSuite.java │ └── main │ │ ├── java │ │ └── com │ │ │ └── baidu │ │ │ └── disconf │ │ │ └── client │ │ │ ├── addons │ │ │ └── properties │ │ │ │ ├── ReconfigurableBean.java │ │ │ │ ├── IReloadablePropertiesListener.java │ │ │ │ ├── IReconfigurationAware.java │ │ │ │ ├── ReloadableProperties.java │ │ │ │ ├── PropertiesReloadedEvent.java │ │ │ │ └── ReloadConfiguration.java │ │ │ ├── common │ │ │ ├── update │ │ │ │ ├── IDisconfUpdate.java │ │ │ │ ├── IDisconfUpdatePipeline.java │ │ │ │ └── IDisconfSysUpdate.java │ │ │ ├── constants │ │ │ │ └── Constants.java │ │ │ ├── annotations │ │ │ │ ├── DisconfFileItem.java │ │ │ │ ├── DisconfActiveBackupService.java │ │ │ │ ├── DisconfUpdateService.java │ │ │ │ ├── DisconfItem.java │ │ │ │ └── DisconfFile.java │ │ │ └── model │ │ │ │ └── DisConfCommonModel.java │ │ │ ├── store │ │ │ ├── DisconfStorePipelineProcessor.java │ │ │ ├── processor │ │ │ │ ├── impl │ │ │ │ │ └── DisconfStorePipelineProcessorImpl.java │ │ │ │ └── model │ │ │ │ │ └── DisconfValue.java │ │ │ └── DisconfStoreProcessorFactory.java │ │ │ ├── core │ │ │ ├── filetype │ │ │ │ ├── DisconfFileTypeProcessor.java │ │ │ │ └── impl │ │ │ │ │ ├── DisconfXmlProcessorImpl.java │ │ │ │ │ └── DisconfAnyFileProcessorImpl.java │ │ │ ├── processor │ │ │ │ └── DisconfCoreProcessor.java │ │ │ └── DisconfCoreMgr.java │ │ │ ├── DisconfMgrBeanSecond.java │ │ │ ├── scan │ │ │ ├── inner │ │ │ │ └── statically │ │ │ │ │ ├── StaticScannerMgr.java │ │ │ │ │ ├── strategy │ │ │ │ │ ├── ScanStaticStrategy.java │ │ │ │ │ └── impl │ │ │ │ │ │ └── SpringScanStatic.java │ │ │ │ │ └── StaticScannerMgrFactory.java │ │ │ ├── ScanFactory.java │ │ │ └── ScanMgr.java │ │ │ ├── config │ │ │ └── inner │ │ │ │ └── DisInnerConfigAnnotation.java │ │ │ ├── fetcher │ │ │ └── FetcherMgr.java │ │ │ ├── support │ │ │ └── registry │ │ │ │ ├── RegistryFactory.java │ │ │ │ └── Registry.java │ │ │ ├── usertools │ │ │ └── IDisconfDataGetter.java │ │ │ └── watch │ │ │ ├── inner │ │ │ └── DisconfSysUpdateCallback.java │ │ │ └── WatchMgr.java │ │ └── resources │ │ └── disconf_sys.properties ├── README.md ├── .gitignore └── deploy │ └── package-jar.xml ├── .travis.yml └── .gitignore /disconf-web/bin/.gitignore: -------------------------------------------------------------------------------- 1 | db -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | *.iml 3 | *.pyc -------------------------------------------------------------------------------- /disconf-web/src/main/.gitignore: -------------------------------------------------------------------------------- 1 | online-resources -------------------------------------------------------------------------------- /sql/.gitignore: -------------------------------------------------------------------------------- 1 | didi/2016-06-21-2.sql 2 | didi -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/ejs/.gitmodules: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /disconf-web/sql/deprecated/20150611/.gitignore: -------------------------------------------------------------------------------- 1 | *.sql -------------------------------------------------------------------------------- /disconf-web/bin/__init__.py: -------------------------------------------------------------------------------- 1 | __author__ = 'knightliao' 2 | -------------------------------------------------------------------------------- /disconf-web/bin/sql/__init__.py: -------------------------------------------------------------------------------- 1 | __author__ = 'knightliao' 2 | -------------------------------------------------------------------------------- /disconf-web/html/tools/gen_html.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | node parse.js -------------------------------------------------------------------------------- /disconf-web/sql/deprecated/.gitignore: -------------------------------------------------------------------------------- 1 | /20150301 2 | /20150420 -------------------------------------------------------------------------------- /disconf-web/html/.gitignore: -------------------------------------------------------------------------------- 1 | /output 2 | /.idea 3 | /.DS_Store 4 | -------------------------------------------------------------------------------- /disconf-web/sql/deprecated/20141201/.gitignore: -------------------------------------------------------------------------------- 1 | /disconf-*.sql 2 | -------------------------------------------------------------------------------- /disconf-web/sql/deprecated/20141226/.gitignore: -------------------------------------------------------------------------------- 1 | /disconf-*.sql 2 | -------------------------------------------------------------------------------- /disconf-core/README.md: -------------------------------------------------------------------------------- 1 | disconf-core 2 | ============ 3 | 4 | 分布式配置基础包模块 -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/ejs/test/fixtures/backslash.ejs: -------------------------------------------------------------------------------- 1 | \foo -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/ejs/test/fixtures/backslash.html: -------------------------------------------------------------------------------- 1 | \foo -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/ejs/test/fixtures/para.ejs: -------------------------------------------------------------------------------- 1 |

hey

-------------------------------------------------------------------------------- /disconf-client/src/test/resources/testJson.json: -------------------------------------------------------------------------------- 1 | {"message": {}, "success": "true"} -------------------------------------------------------------------------------- /disconf-web/html/dep/bootstrap/css/noie.css: -------------------------------------------------------------------------------- 1 | .wmd-show { 2 | width: 628px; 3 | } -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/ejs/test/fixtures/user.ejs: -------------------------------------------------------------------------------- 1 |

{= name}

-------------------------------------------------------------------------------- /disconf-web/profile/rd/.gitignore: -------------------------------------------------------------------------------- 1 | /application.properties 2 | /logclient.properties -------------------------------------------------------------------------------- /disconf-web/src/test/resources/file2/confA.properties: -------------------------------------------------------------------------------- 1 | varA=200000 2 | varA2=300000 -------------------------------------------------------------------------------- /disconf-client/README.md: -------------------------------------------------------------------------------- 1 | disconf-client 2 | ======= 3 | 4 | 分布式配置管理客户端模块 5 | 6 | 7 | -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/ejs/test/fixtures/pet.ejs: -------------------------------------------------------------------------------- 1 |
  • [[= pet.name ]]
  • -------------------------------------------------------------------------------- /disconf-client/src/test/resources/testProperties.properties: -------------------------------------------------------------------------------- 1 | staticvar=50 2 | staticvar2=100 -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/ejs/index.js: -------------------------------------------------------------------------------- 1 | 2 | module.exports = require('./lib/ejs'); -------------------------------------------------------------------------------- /disconf-web/src/main/resources/.gitignore: -------------------------------------------------------------------------------- 1 | /application.properties 2 | /logclient.properties -------------------------------------------------------------------------------- /disconf-web/src/main/webapp/Release: -------------------------------------------------------------------------------- 1 | default_process_types: 2 | web: bash jpaas_control 3 | -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/ejs/test/fixtures/double-quote.html: -------------------------------------------------------------------------------- 1 |

    loki's "wheelchair"

    -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/ejs/test/fixtures/fail.ejs: -------------------------------------------------------------------------------- 1 | <% function foo() return 'foo'; %> -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/ejs/test/fixtures/single-quote.html: -------------------------------------------------------------------------------- 1 |

    loki's wheelchair

    -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/tools/.gitignore: -------------------------------------------------------------------------------- 1 | /UserCreateToolsInner.java 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | 3 | after_success: 4 | - mvn clean cobertura:cobertura coveralls:report -------------------------------------------------------------------------------- /disconf-web/html/tools/gen_html.bat: -------------------------------------------------------------------------------- 1 | 2 | 3 | echo %~dp0 4 | 5 | cd %~dp0 6 | 7 | node parse.js 8 | -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/ejs/test/fixtures/single-quote.ejs: -------------------------------------------------------------------------------- 1 |

    <%= 'loki' %>'s wheelchair

    -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/ejs/test/fixtures/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | foo: '<%= value %>'; 3 | } -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/ejs/test/fixtures/includes/menu-item.ejs: -------------------------------------------------------------------------------- 1 |
  • <% include menu/item %>
  • -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/eventproxy/index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./lib/eventproxy'); 2 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/user/constant/validation-user.properties: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/ejs/test/fixtures/double-quote.ejs: -------------------------------------------------------------------------------- 1 |

    <%= "lo" + 'ki' %>'s "wheelchair"

    -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/ejs/test/fixtures/messed.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/ejs/test/fixtures/include.css.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/ejs/test/fixtures/includes/menu/item.ejs: -------------------------------------------------------------------------------- 1 | <%= title %> -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/eventproxy/node_modules/debug/.npmignore: -------------------------------------------------------------------------------- 1 | support 2 | test 3 | examples 4 | *.sock 5 | -------------------------------------------------------------------------------- /disconf-web/src/main/resources/messages/app-service-info.properties: -------------------------------------------------------------------------------- 1 | 2 | desc.empty=APP\u8bf4\u660e\u4e0d\u80fd\u4e3a\u7a7a! -------------------------------------------------------------------------------- /docs/source/others/index.rst: -------------------------------------------------------------------------------- 1 | 其它资源 2 | ============ 3 | 4 | 5 | .. toctree:: 6 | :maxdepth: 2 7 | :numbered: 2 8 | -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/ejs/.npmignore: -------------------------------------------------------------------------------- 1 | # ignore any vim files: 2 | *.sw[a-z] 3 | vim/.netrwhist 4 | node_modules 5 | -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/ejs/test/fixtures/include.css.ejs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /disconf-web/html/assets/img/bohemian.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/knightliao/disconf/HEAD/disconf-web/html/assets/img/bohemian.jpg -------------------------------------------------------------------------------- /disconf-web/html/assets/img/header-bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/knightliao/disconf/HEAD/disconf-web/html/assets/img/header-bg.png -------------------------------------------------------------------------------- /disconf-web/html/assets/img/index-big.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/knightliao/disconf/HEAD/disconf-web/html/assets/img/index-big.jpg -------------------------------------------------------------------------------- /disconf-web/html/assets/img/index-big.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/knightliao/disconf/HEAD/disconf-web/html/assets/img/index-big.psd -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/ejs/test/fixtures/messed.ejs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /disconf-web/html/unitTpl/basefoot.html.tpl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/ejs/test/fixtures/error.ejs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/source/config/index.rst: -------------------------------------------------------------------------------- 1 | 配置项 2 | ===== 3 | 4 | .. toctree:: 5 | :maxdepth: 2 6 | :numbered: 2 7 | 8 | src/client-config 9 | -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/ejs/.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - 0.11 4 | - 0.10 5 | - 0.9 6 | - 0.6 7 | - 0.8 8 | -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/ejs/test/fixtures/no.newlines.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /disconf-web/html/assets/js/index.js: -------------------------------------------------------------------------------- 1 | (function ($) { 2 | 3 | $("#indexMain").attr("href", "/"); 4 | 5 | getSession2Redirect(); 6 | 7 | })(jQuery); -------------------------------------------------------------------------------- /docs/source/quick/index.rst: -------------------------------------------------------------------------------- 1 | Quick Start 2 | =========== 3 | 4 | .. toctree:: 5 | :maxdepth: 2 6 | :numbered: 2 7 | 8 | src/TutorialSummary 9 | -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/ejs/test/fixtures/include.ejs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # disconf-readthedocs 2 | 3 | readthedocs for disconf 4 | 5 | - docs: http://disconf.readthedocs.io 6 | - source: https://github.com/knightliao/disconf -------------------------------------------------------------------------------- /disconf-web/html/dep/bootstrap/img/glyphicons-halflings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/knightliao/disconf/HEAD/disconf-web/html/dep/bootstrap/img/glyphicons-halflings.png -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/ejs/test/fixtures/menu.html: -------------------------------------------------------------------------------- 1 |
  • Foo
  • 2 |
  • Bar
  • 3 |
  • Baz
  • -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/ejs/test/fixtures/newlines.ejs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /disconf-web/src/main/resources/messages/app-controller-info.properties: -------------------------------------------------------------------------------- 1 | 2 | app.exist=APP\u5DF2\u7ECF\u5B58\u5728! 3 | upload.file.error=\u4E0A\u4F20\u6587\u4EF6\u9519\u8BEF -------------------------------------------------------------------------------- /disconf-web/src/test/resources/files/originalFile.txt: -------------------------------------------------------------------------------- 1 | Line 1 2 | Line 2 3 | Line 3 4 | Line 4 5 | Line 5 6 | Line 6 7 | Line 7 8 | Line 8 9 | Line 9 10 | Line 10 -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/ejs/test/fixtures/include.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/ejs/test/fixtures/newlines.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/ejs/test/fixtures/no.newlines.ejs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /disconf-web/html/unitTpl/basehead.html.tpl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /disconf-web/profile/rd/zoo.properties: -------------------------------------------------------------------------------- 1 | 2 | hosts=127.0.0.1:8581,127.0.0.1:8582,127.0.0.1:8583 3 | 4 | # zookeeper\u7684\u524D\u7F00\u8DEF\u5F84\u540D 5 | zookeeper_url_prefix=/disconf -------------------------------------------------------------------------------- /disconf-web/html/dep/bootstrap/img/glyphicons-halflings-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/knightliao/disconf/HEAD/disconf-web/html/dep/bootstrap/img/glyphicons-halflings-white.png -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/ejs/test/fixtures/comments.html: -------------------------------------------------------------------------------- 1 |
  • foo
  • 2 |
  • bar
  • 3 |
  • baz
  • 4 |
  • qux
  • -------------------------------------------------------------------------------- /disconf-web/html/dep/bootstrap/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/knightliao/disconf/HEAD/disconf-web/html/dep/bootstrap/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /disconf-web/html/dep/bootstrap/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/knightliao/disconf/HEAD/disconf-web/html/dep/bootstrap/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/eventproxy/.npmignore: -------------------------------------------------------------------------------- 1 | test/ 2 | coverage.html 3 | Makefile 4 | .travis.yml 5 | logo.png 6 | jsdoc/ 7 | .jshintrc 8 | build/ 9 | components/ 10 | -------------------------------------------------------------------------------- /disconf-web/html/dep/bootstrap/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/knightliao/disconf/HEAD/disconf-web/html/dep/bootstrap/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /disconf-web/src/main/resources/messages/sign-service-info.properties: -------------------------------------------------------------------------------- 1 | 2 | 3 | name.empty=\u7528\u6237\u540d\u4e0d\u80fd\u4e3a\u7a7a! 4 | 5 | password.empty=\u5bc6\u7801\u4e0d\u80fd\u4e3a\u7a7a! 6 | -------------------------------------------------------------------------------- /disconf-web/src/main/resources/spring-cache.properties: -------------------------------------------------------------------------------- 1 | 2 | #cache config 3 | cache_name=dspCache 4 | role_res_cache_name=roleResCache 5 | 6 | cache_directory=cachetmpdir 7 | ehcache_path=ehcache.xml -------------------------------------------------------------------------------- /disconf-web/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /.settings 3 | /.classpath 4 | /.project 5 | /log 6 | /pom.xml.releaseBackup 7 | /output 8 | /.pydevproject 9 | /*tmp 10 | /*.iml 11 | *.DS_Store 12 | .idea 13 | -------------------------------------------------------------------------------- /docs/source/question/index.rst: -------------------------------------------------------------------------------- 1 | 常问问题 2 | ======= 3 | 4 | .. toctree:: 5 | :maxdepth: 2 6 | :numbered: 2 7 | 8 | src/异常考虑 9 | src/disconf-question 10 | src/disconf-web-question -------------------------------------------------------------------------------- /docs/source/question/src/disconf-web-question.rst: -------------------------------------------------------------------------------- 1 | Disconf-Web常问问题 2 | =================== 3 | 4 | 找不到 get/set方法 5 | ------------------ 6 | 7 | 请使用 Lombok https://github.com/knightliao/disconf/issues/38 8 | -------------------------------------------------------------------------------- /docs/source/question/disconf-web-question.md: -------------------------------------------------------------------------------- 1 | Disconf-Web常问问题 2 | ======= 3 | 4 | ## 找不到 get/set方法 5 | 6 | 请使用 Lombok [https://github.com/knightliao/disconf/issues/38](https://github.com/knightliao/disconf/issues/38) -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/eventproxy/node_modules/debug/index.js: -------------------------------------------------------------------------------- 1 | if ('undefined' == typeof window) { 2 | module.exports = require('./lib/debug'); 3 | } else { 4 | module.exports = require('./debug'); 5 | } 6 | -------------------------------------------------------------------------------- /disconf-web/sql/readme.md: -------------------------------------------------------------------------------- 1 | 为了方便大家开发,统一了所有SQL,请先后执行: 2 | 3 | - 0-init_table.sql create db,tables 4 | - 1-init_data.sql create data 5 | - 201512/20151225.sql patch 6 | - 20160701/20160701.sql patch 7 | -------------------------------------------------------------------------------- /disconf-web/html/dep/jquery-ui-1.10.4.custom/css/ui-lightness/images/animated-overlay.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/knightliao/disconf/HEAD/disconf-web/html/dep/jquery-ui-1.10.4.custom/css/ui-lightness/images/animated-overlay.gif -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/ejs/examples/list.ejs: -------------------------------------------------------------------------------- 1 | <% if (names.length) { %> 2 | 7 | <% } %> -------------------------------------------------------------------------------- /disconf-web/src/test/resources/files/revisedFile.txt: -------------------------------------------------------------------------------- 1 | Line 2 2 | Line 3 with changes 3 | Line 4 4 | Line 5 with changes and 5 | a new line 6 | Line 6 7 | new line 6.1 8 | Line 7 9 | Line 8 10 | Line 9 11 | Line 10 with changes -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/ejs/test/fixtures/error.out: -------------------------------------------------------------------------------- 1 | ReferenceError: error.ejs:2 2 | 1| 7 | 8 | users is not defined -------------------------------------------------------------------------------- /disconf-web/src/test/resources/datasource-test.properties: -------------------------------------------------------------------------------- 1 | datasource_location=jdbc:h2:mem:disconf;MODE=MYSQL;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;DB_CLOSE_ON_EXIT=FALSE; 2 | driver_class_name=org.h2.Driver 3 | username= 4 | password= -------------------------------------------------------------------------------- /disconf-client/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /bin 3 | /.settings 4 | /.classpath 5 | /.project 6 | /disconf 7 | /log 8 | /.pydevproject 9 | /pom.xml.releaseBackup 10 | /coverage-report 11 | /tmp 12 | /*.iml 13 | /.DS_Store 14 | .idea 15 | -------------------------------------------------------------------------------- /disconf-client/src/test/resources/res/testXml.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | George 4 | John 5 | Reminder 6 | Don't forget the meeting! 7 | -------------------------------------------------------------------------------- /disconf-client/src/test/resources/testXml.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | George 4 | John 5 | Reminder 6 | Don't forget the meeting! 7 | -------------------------------------------------------------------------------- /disconf-web/src/main/webapp/jpaas_control: -------------------------------------------------------------------------------- 1 | #!/bin/env bash 2 | export LANG=zh_CN.UTF-8 3 | export JAVA_OPTS="-XX:MaxNewSize=500M -XX:PermSize=64m -XX:MaxPermSize=256M -XX:SurvivorRatio=4 -Xss256K $JAVA_OPTS" 4 | cd bin && sh catalina.sh run 5 | -------------------------------------------------------------------------------- /docs/source/install/index.rst: -------------------------------------------------------------------------------- 1 | Install 2 | ======= 3 | 4 | 目前项目包含了 客户端disconf-Client和 管理端disconf-Web两个模块。目前所有模块代码均是Java实现。 5 | 6 | 7 | .. toctree:: 8 | :maxdepth: 2 9 | :numbered: 2 10 | 11 | src/01 12 | src/02 -------------------------------------------------------------------------------- /docs/source/tutorial-web/index.rst: -------------------------------------------------------------------------------- 1 | Tutorial-web 2 | ============ 3 | 4 | .. toctree:: 5 | :maxdepth: 2 6 | :numbered: 2 7 | 8 | src/Tutorial6 9 | src/12-open-api-for-web 10 | src/12-open-api-for-web-client 11 | -------------------------------------------------------------------------------- /disconf-core/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /bin 3 | /.settings 4 | /.classpath 5 | /.project 6 | /pom.xml.releaseBackup 7 | /hs_err_pid1904.log 8 | /confA.properties 9 | /disconf 10 | /coverage-report 11 | /*.iml 12 | /.DS_Store 13 | .idea 14 | -------------------------------------------------------------------------------- /disconf-web/html/dep/jquery-ui-1.10.4.custom/css/ui-lightness/images/ui-icons_222222_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/knightliao/disconf/HEAD/disconf-web/html/dep/jquery-ui-1.10.4.custom/css/ui-lightness/images/ui-icons_222222_256x240.png -------------------------------------------------------------------------------- /disconf-web/html/dep/jquery-ui-1.10.4.custom/css/ui-lightness/images/ui-icons_228ef1_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/knightliao/disconf/HEAD/disconf-web/html/dep/jquery-ui-1.10.4.custom/css/ui-lightness/images/ui-icons_228ef1_256x240.png -------------------------------------------------------------------------------- /disconf-web/html/dep/jquery-ui-1.10.4.custom/css/ui-lightness/images/ui-icons_ef8c08_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/knightliao/disconf/HEAD/disconf-web/html/dep/jquery-ui-1.10.4.custom/css/ui-lightness/images/ui-icons_ef8c08_256x240.png -------------------------------------------------------------------------------- /disconf-web/html/dep/jquery-ui-1.10.4.custom/css/ui-lightness/images/ui-icons_ffd27a_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/knightliao/disconf/HEAD/disconf-web/html/dep/jquery-ui-1.10.4.custom/css/ui-lightness/images/ui-icons_ffd27a_256x240.png -------------------------------------------------------------------------------- /disconf-web/html/dep/jquery-ui-1.10.4.custom/css/ui-lightness/images/ui-icons_ffffff_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/knightliao/disconf/HEAD/disconf-web/html/dep/jquery-ui-1.10.4.custom/css/ui-lightness/images/ui-icons_ffffff_256x240.png -------------------------------------------------------------------------------- /disconf-web/src/main/resources/messages/sign-controller-info.properties: -------------------------------------------------------------------------------- 1 | password.not.right=\u5BC6\u7801\u4E0D\u6B63\u786E 2 | two.password.not.equal=\u4E24\u4E2A\u65B0\u5BC6\u7801\u4E0D\u4E00\u81F4 3 | user.not.exist=\u7528\u6237\u4E0D\u5B58\u5728 4 | -------------------------------------------------------------------------------- /disconf-web/html/dep/jquery-ui-1.10.4.custom/css/ui-lightness/images/ui-bg_flat_10_000000_40x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/knightliao/disconf/HEAD/disconf-web/html/dep/jquery-ui-1.10.4.custom/css/ui-lightness/images/ui-bg_flat_10_000000_40x100.png -------------------------------------------------------------------------------- /disconf-web/html/dep/jquery-ui-1.10.4.custom/css/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/knightliao/disconf/HEAD/disconf-web/html/dep/jquery-ui-1.10.4.custom/css/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png -------------------------------------------------------------------------------- /disconf-web/html/dep/jquery-ui-1.10.4.custom/css/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/knightliao/disconf/HEAD/disconf-web/html/dep/jquery-ui-1.10.4.custom/css/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png -------------------------------------------------------------------------------- /disconf-web/html/dep/jquery-ui-1.10.4.custom/css/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/knightliao/disconf/HEAD/disconf-web/html/dep/jquery-ui-1.10.4.custom/css/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/dsp/common/dao/DB.java: -------------------------------------------------------------------------------- 1 | package com.baidu.dsp.common.dao; 2 | 3 | /** 4 | * @author liaoqiqi 5 | * @version 2014-1-14 6 | */ 7 | public class DB { 8 | 9 | public final static String DB_NAME = ""; 10 | } 11 | -------------------------------------------------------------------------------- /disconf-web/html/dep/jquery-ui-1.10.4.custom/css/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/knightliao/disconf/HEAD/disconf-web/html/dep/jquery-ui-1.10.4.custom/css/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/role/constant/RoleConstant.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.role.constant; 2 | 3 | /** 4 | * @author liaoqiqi 5 | * @version 2014-1-13 6 | */ 7 | public class RoleConstant { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/user/facade/UserFacade.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.user.facade; 2 | 3 | /** 4 | * @author liaoqiqi 5 | * @version 2014-1-13 6 | */ 7 | public interface UserFacade { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /disconf-web/html/dep/jquery-ui-1.10.4.custom/css/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/knightliao/disconf/HEAD/disconf-web/html/dep/jquery-ui-1.10.4.custom/css/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png -------------------------------------------------------------------------------- /docs/source/install/01.md: -------------------------------------------------------------------------------- 1 | #### disconf-client Install ### 2 | 3 | 在您的 Maven POM 文件里加入: 4 | 5 | 6 | com.baidu.disconf 7 | disconf-client 8 | 2.6.36 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /bin 2 | /.classpath 3 | /.project 4 | /target 5 | /.settings 6 | /doc 7 | /*.class 8 | /.README.md.html 9 | /pom.xml.releaseBackup 10 | /.pydevproject 11 | /.idea 12 | /*.iml 13 | /.DS_Store 14 | /*-baidu.xml 15 | /log 16 | .idea 17 | BCLOUD 18 | build.sh -------------------------------------------------------------------------------- /disconf-web/html/dep/jquery-ui-1.10.4.custom/css/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/knightliao/disconf/HEAD/disconf-web/html/dep/jquery-ui-1.10.4.custom/css/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png -------------------------------------------------------------------------------- /disconf-web/html/dep/jquery-ui-1.10.4.custom/css/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/knightliao/disconf/HEAD/disconf-web/html/dep/jquery-ui-1.10.4.custom/css/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png -------------------------------------------------------------------------------- /disconf-web/html/dep/jquery-ui-1.10.4.custom/css/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/knightliao/disconf/HEAD/disconf-web/html/dep/jquery-ui-1.10.4.custom/css/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/ejs/examples/functions.ejs: -------------------------------------------------------------------------------- 1 |

    Users

    2 | 3 | <% function user(user) { %> 4 |
  • <%= user.name %> is a <%= user.age %> year old <%= user.species %>.
  • 5 | <% } %> 6 | 7 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/user/service/AuthMgr.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.user.service; 2 | 3 | /** 4 | * @author knightliao 5 | */ 6 | public interface AuthMgr { 7 | 8 | boolean verifyApp4CurrentUser(Long appId); 9 | } 10 | -------------------------------------------------------------------------------- /docs/source/design/index.rst: -------------------------------------------------------------------------------- 1 | Disconf设计 2 | ========= 3 | 4 | .. toctree:: 5 | :maxdepth: 2 6 | :numbered: 2 7 | 8 | src/分布式配置管理平台Disconf 9 | src/disconf-client详细设计文档 10 | src/disconf-web详细设计文档 11 | src/局限性和注意事项 12 | src/Zookeeper异常考虑 13 | src/细节讨论 -------------------------------------------------------------------------------- /disconf-client/src/main/java/com/baidu/disconf/client/addons/properties/ReconfigurableBean.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.addons.properties; 2 | 3 | /** 4 | * 5 | */ 6 | public interface ReconfigurableBean { 7 | 8 | void reloadConfiguration() throws Exception; 9 | } 10 | -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/eventproxy/node_modules/debug/example/wildcards.js: -------------------------------------------------------------------------------- 1 | 2 | var debug = { 3 | foo: require('../')('test:foo'), 4 | bar: require('../')('test:bar'), 5 | baz: require('../')('test:baz') 6 | }; 7 | 8 | debug.foo('foo') 9 | debug.bar('bar') 10 | debug.baz('baz') -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/tasks/IConfigConsistencyMonitorService.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.tasks; 2 | 3 | /** 4 | * @author knightliao 5 | */ 6 | public interface IConfigConsistencyMonitorService { 7 | 8 | void myTest(); 9 | 10 | void check(); 11 | } 12 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/unbiz/common/genericdao/param/ExpressionParam.java: -------------------------------------------------------------------------------- 1 | package com.baidu.unbiz.common.genericdao.param; 2 | 3 | /** 4 | * 封装表达式的参数 5 | * 6 | * @author Darwin(Tianxin) 7 | */ 8 | public final class ExpressionParam { 9 | public ExpressionParam() { 10 | } 11 | } -------------------------------------------------------------------------------- /disconf-web/html/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "${0%/*}" 4 | 5 | # 6 | # 打包FE包 7 | # 8 | 9 | # 10 | if [ -d "output" ]; then 11 | printf '%s\n' "Removing output" 12 | rm -rf output 13 | fi 14 | 15 | mkdir -p output 16 | 17 | cp -rp assets output 18 | cp -rp dep output 19 | cp -rp *.html output 20 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/role/dao/RoleDao.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.role.dao; 2 | 3 | import com.baidu.disconf.web.service.role.bo.Role; 4 | import com.baidu.unbiz.common.genericdao.dao.BaseDao; 5 | 6 | public interface RoleDao extends BaseDao { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /docs/source/install/src/01.rst: -------------------------------------------------------------------------------- 1 | disconf-client Install 2 | ^^^^^^^^^^^^^^^^^^^^^^ 3 | 4 | 在您的 Maven POM 文件里加入: 5 | 6 | :: 7 | 8 | 9 | com.baidu.disconf 10 | disconf-client 11 | 2.6.36 12 | 13 | -------------------------------------------------------------------------------- /disconf-web/sql/deprecated/20150101/disconf.sql: -------------------------------------------------------------------------------- 1 | use `disconf`; 2 | 3 | INSERT INTO `config` (`config_id`, `type`, `name`, `value`, `app_id`, `version`, `env_id`, `create_time`, `update_time`) 4 | VALUES 5 | (147, 0, 'testJson.json', '{\"message\": {}, \"success\": \"true\"}', 2, '1_0_0_0', 1, '20150121150626', '20150121153650'); 6 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/common/Constants.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.common; 2 | 3 | /** 4 | * Created by knightliao on 15/12/25. 5 | */ 6 | public class Constants { 7 | 8 | public final static Integer STATUS_NORMAL = 1; 9 | public final static Integer STATUS_DELETE = 0; 10 | } 11 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/dsp/common/exception/base/GlobalExceptionAware.java: -------------------------------------------------------------------------------- 1 | package com.baidu.dsp.common.exception.base; 2 | 3 | /** 4 | * 全局异常处理识别器,凡是实现该接口的exception都能被系统统一的ExceptionHandler处理 5 | * 6 | * @version 2013-5-13 下午5:00:09 7 | */ 8 | public interface GlobalExceptionAware extends Codeable { 9 | } 10 | -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/ejs/examples/list.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Module dependencies. 4 | */ 5 | 6 | var ejs = require('../') 7 | , fs = require('fs') 8 | , str = fs.readFileSync(__dirname + '/list.ejs', 'utf8'); 9 | 10 | var ret = ejs.render(str, { 11 | names: ['foo', 'bar', 'baz'] 12 | }); 13 | 14 | console.log(ret); -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/config/service/ConfigHistoryMgr.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.config.service; 2 | 3 | /** 4 | * Created by knightliao on 15/12/25. 5 | */ 6 | public interface ConfigHistoryMgr { 7 | 8 | void createOne(Long configId, String oldValue, String newValue); 9 | } 10 | -------------------------------------------------------------------------------- /disconf-client/src/main/java/com/baidu/disconf/client/addons/properties/IReloadablePropertiesListener.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.addons.properties; 2 | 3 | /** 4 | * property reload listener 5 | */ 6 | public interface IReloadablePropertiesListener { 7 | 8 | void propertiesReloaded(PropertiesReloadedEvent event); 9 | } 10 | -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/eventproxy/node_modules/debug/component.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "debug", 3 | "repo": "visionmedia/debug", 4 | "description": "small debugging utility", 5 | "version": "0.7.2", 6 | "keywords": ["debug", "log", "debugger"], 7 | "scripts": ["index.js", "debug.js"], 8 | "dependencies": {} 9 | } 10 | -------------------------------------------------------------------------------- /disconf-client/src/main/java/com/baidu/disconf/client/common/update/IDisconfUpdate.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.common.update; 2 | 3 | /** 4 | * 当配置更新 时,用户可以实现此接口,用以来实现回调函数 5 | * 6 | * @author liaoqiqi 7 | * @version 2014-5-20 8 | */ 9 | public interface IDisconfUpdate { 10 | 11 | void reload() throws Exception; 12 | } 13 | -------------------------------------------------------------------------------- /disconf-core/src/main/java/com/baidu/disconf/core/common/restful/core/UnreliableInterface.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.core.common.restful.core; 2 | 3 | /** 4 | * 一个可重试可执行方法 5 | * 6 | * @author liaoqiqi 7 | * @version 2014-6-10 8 | */ 9 | public interface UnreliableInterface { 10 | 11 | T call() throws Exception; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /disconf-core/src/test/java/com/baidu/disconf/core/test/path/ZooPathMgrTestCase.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.core.test.path; 2 | 3 | import com.baidu.disconf.core.test.common.BaseCoreTestCase; 4 | 5 | /** 6 | * @author liaoqiqi 7 | * @version 2014-6-16 8 | */ 9 | public class ZooPathMgrTestCase extends BaseCoreTestCase { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/ejs/test/fixtures/comments.ejs: -------------------------------------------------------------------------------- 1 |
  • <% // double-slash comment %>foo
  • 2 |
  • <% /* C-style comment */ %>bar
  • 3 |
  • <% // double-slash comment with newline 4 | %>baz
  • 5 |
  • <% var x = 'qux'; // double-slash comment @ end of line %><%= x %>
  • -------------------------------------------------------------------------------- /docs/source/others/sponsor.md: -------------------------------------------------------------------------------- 1 | 联系和赞助 2 | ======== 3 | 4 | ## 赞助 5 | 6 | 如果您觉得disconf不错,可以资助作者, 资助公司或个人会留下名字。 7 | 8 | ![](http://ww4.sinaimg.cn/mw690/006pzvAPgw1fam2shzciqj30no0zkq54.jpg) 9 | 10 | ## 联系我 11 | 12 | - weibo: [http://weibo.com/knightliao](http://weibo.com/knightliao) 13 | - wechat: knightliao 14 | - 主页: http://liaoqiqi.com 15 | -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/ejs/test/fixtures/menu.ejs: -------------------------------------------------------------------------------- 1 | <% var url = '/foo' -%> 2 | <% var title = 'Foo' -%> 3 | <% include includes/menu-item -%> 4 | 5 | <% var url = '/bar' -%> 6 | <% var title = 'Bar' -%> 7 | <% include includes/menu-item -%> 8 | 9 | <% var url = '/baz' -%> 10 | <% var title = 'Baz' -%> 11 | <% include includes/menu-item -%> -------------------------------------------------------------------------------- /disconf-client/src/test/java/com/baidu/disconf/client/test/watch/WatchMgrTestCase.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.test.watch; 2 | 3 | import com.baidu.disconf.client.test.common.BaseSpringTestCase; 4 | 5 | /** 6 | * @author liaoqiqi 7 | * @version 2014-6-16 8 | */ 9 | public class WatchMgrTestCase extends BaseSpringTestCase { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /disconf-client/src/test/java/com/baidu/disconf/client/test/config/ConfigMgrTestCase.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.test.config; 2 | 3 | import com.baidu.disconf.client.test.common.BaseSpringTestCase; 4 | 5 | /** 6 | * @author liaoqiqi 7 | * @version 2014-6-17 8 | */ 9 | public class ConfigMgrTestCase extends BaseSpringTestCase { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /disconf-client/src/main/java/com/baidu/disconf/client/addons/properties/IReconfigurationAware.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.addons.properties; 2 | 3 | /** 4 | * 配置更新时 的拦截 5 | */ 6 | public interface IReconfigurationAware { 7 | 8 | void beforeReconfiguration() throws Exception; 9 | 10 | void afterReconfiguration() throws Exception; 11 | } 12 | -------------------------------------------------------------------------------- /disconf-client/src/test/java/com/baidu/disconf/client/test/core/DisconfCoreMgrTestCase.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.test.core; 2 | 3 | import com.baidu.disconf.client.test.common.BaseSpringTestCase; 4 | 5 | /** 6 | * @author liaoqiqi 7 | * @version 2014-6-17 8 | */ 9 | public class DisconfCoreMgrTestCase extends BaseSpringTestCase { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /disconf-client/src/test/java/com/baidu/disconf/client/test/store/DisconfStoreMgrTestCase.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.test.store; 2 | 3 | import com.baidu.disconf.client.test.common.BaseSpringTestCase; 4 | 5 | /** 6 | * @author liaoqiqi 7 | * @version 2014-6-16 8 | */ 9 | public class DisconfStoreMgrTestCase extends BaseSpringTestCase { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /docs/source/others/src/sponsor.rst: -------------------------------------------------------------------------------- 1 | 联系和赞助 2 | ========== 3 | 4 | 赞助 5 | ---- 6 | 7 | 如果您觉得disconf不错,可以资助作者, 资助公司或个人会留下名字。 8 | 9 | |image0| 10 | 11 | 联系我 12 | ------ 13 | 14 | - weibo: http://weibo.com/knightliao 15 | - wechat: knightliao 16 | - 主页: http://liaoqiqi.com 17 | 18 | .. |image0| image:: http://ww4.sinaimg.cn/mw690/006pzvAPgw1fam2shzciqj30no0zkq54.jpg 19 | 20 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/ub/common/dbmanage/rule/DBShardingRule.java: -------------------------------------------------------------------------------- 1 | package com.baidu.ub.common.dbmanage.rule; 2 | 3 | public interface DBShardingRule { 4 | 5 | /** 6 | * 根据数据库分库规则,计算数据库的sharding,如果sharding数为1,则返回null 7 | * 8 | * @param userid 9 | * 10 | * @return 11 | */ 12 | String calculateDatabaseNo(int userid); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /disconf-core/src/main/java/com/baidu/disconf/core/common/utils/http/HttpResponseCallbackHandler.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.core.common.utils.http; 2 | 3 | import java.io.IOException; 4 | 5 | import org.apache.http.HttpEntity; 6 | 7 | public interface HttpResponseCallbackHandler { 8 | 9 | T handleResponse(String requestBody, HttpEntity entity) throws IOException; 10 | } 11 | -------------------------------------------------------------------------------- /disconf-web/sql/deprecated/readme.txt: -------------------------------------------------------------------------------- 1 | 目录已经废弃 2 | 3 | 此目录有所有SQL改动记录 4 | 5 | 请先后执行: 6 | 7 | 1-init_table.sql 主要是生成tables 8 | 2-data.sql 主要是生成测试数据 9 | 20141201/disconf.sql 升级,支持 管理员角色、用户邮箱 10 | 20141226/disconf.sql 升级,支持 URL权限控制 11 | 20150101/disconf.sql 增加一个测试数据 12 | 20150320/disconf.sql 增加reloadable config的测试文件 -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/sign/dao/SignDao.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.sign.dao; 2 | 3 | import com.baidu.disconf.web.service.user.bo.User; 4 | import com.baidu.unbiz.common.genericdao.dao.BaseDao; 5 | 6 | /** 7 | * @author liaoqiqi 8 | * @version 2013-11-28 9 | */ 10 | public interface SignDao extends BaseDao { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /docs/source/tutorial-client/Tutorial10.md: -------------------------------------------------------------------------------- 1 | Tutorial 10 实现一个配置更新下载器agent 2 | ======= 3 | 4 | ### 问题 5 | 6 | 我想在我的机器上做一个配置下载器agent, 可以实现以下功能: 7 | 8 | - 启动时下载配置 9 | - 配置被更新时,可以感知并下载下来 10 | 11 | ### 解决方法 12 | 13 | 可以修改一下 disconf-demos/disconf-standalone-demo 这个项目,让其变成一个 长驻进程,并指定 14 | [disconf.user_define_download_dir](../../config/client-config.html) 这个配置到你想指定的路径。 15 | 16 | done. 17 | -------------------------------------------------------------------------------- /disconf-client/src/main/java/com/baidu/disconf/client/store/DisconfStorePipelineProcessor.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.store; 2 | 3 | import com.baidu.disconf.client.common.update.IDisconfUpdatePipeline; 4 | 5 | /** 6 | * 7 | */ 8 | public interface DisconfStorePipelineProcessor { 9 | 10 | void setDisconfUpdatePipeline(IDisconfUpdatePipeline iDisconfUpdatePipeline); 11 | } 12 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/unbiz/common/genericdao/param/IncrParam.java: -------------------------------------------------------------------------------- 1 | package com.baidu.unbiz.common.genericdao.param; 2 | 3 | /** 4 | * 加法参数 5 | */ 6 | public class IncrParam { 7 | 8 | Number value; 9 | 10 | public IncrParam(Number value) { 11 | this.value = value; 12 | } 13 | 14 | public Number getValue() { 15 | return value; 16 | } 17 | } -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/config/resource/config-service-info.properties: -------------------------------------------------------------------------------- 1 | 2 | 3 | app.empty=APP\u4e0d\u80fd\u4e3a\u7a7a! 4 | 5 | version.empty=\u7248\u672c\u4e0d\u80fd\u4e3a\u7a7a! 6 | 7 | key.empty=\u914d\u7f6eKEY\u4e0d\u80fd\u4e3a\u7a7a! 8 | 9 | env.empty=\u73af\u5883\u4e0d\u80fd\u4e3a\u7a7a! 10 | 11 | value.empty=\u914d\u7f6e\u503c\u4e0d\u80fd\u4e3a\u7a7a! 12 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/unbiz/common/genericdao/bo/InsertOption.java: -------------------------------------------------------------------------------- 1 | package com.baidu.unbiz.common.genericdao.bo; 2 | 3 | /** 4 | * @version create on 2014年8月13日 下午5:39:32 5 | */ 6 | public enum InsertOption { 7 | 8 | LOW_PRIORITY, DELAYED, HIGH_PRIORITY, IGNORE; 9 | 10 | public String toString() { 11 | return this.name().toLowerCase(); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /disconf-web/sql/20160701/20160701.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE `config_history` 2 | ADD COLUMN `update_by` BIGINT(20) NULL DEFAULT NULL 3 | AFTER `create_time`; 4 | 5 | INSERT INTO `role_resource` (`role_id`, `url_pattern`, `url_description`, `method_mask`) VALUES 6 | (1,'/api/account/password' , '修改密码' , '0100'), 7 | (2,'/api/account/password' , '修改密码' , '0100'), 8 | (3,'/api/account/password' , '修改密码' , '0000'); 9 | -------------------------------------------------------------------------------- /disconf-web/src/test/resources/file2/utf-file.pml: -------------------------------------------------------------------------------- 1 | com.xiaomi.zookeeper.zkfactory.host=127.0.0.1:8080 2 | com.xiaomi.host.host.group=xiaomi 3 | com.xiaomi.host.host.name=小米 4 | com.xiaomi.host.host.tag=xiaomi 5 | 6 | com.xiaomi.config.profile.enabled=true 7 | com.xiaomi.trace.trace.enabled=true 8 | com.xiaomi.header.headers.enabled=true 9 | 10 | #spring root xml 11 | com.xiaomi.main.impl.start.xml=spring.xml -------------------------------------------------------------------------------- /disconf-web/sql/deprecated/20150320/disconf.sql: -------------------------------------------------------------------------------- 1 | use `disconf`; 2 | 3 | INSERT INTO `config` (`config_id`, `type`, `name`, `value`, `app_id`, `version`, `env_id`, `create_time`, `update_time`) 4 | VALUES 5 | (148, 0, 'autoconfig.properties', 'auto=bbdxxjdccd', 2, '1_0_0_0', 1, '20150320130619', '20150320224956'), 6 | (149, 0, 'autoconfig2.properties', 'auto2=cd', 2, '1_0_0_0', 1, '20150320130625', '20150320203808'); 7 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/unbiz/common/genericdao/operator/Pair.java: -------------------------------------------------------------------------------- 1 | /** 2 | * adx-common#com.baidu.ub.common.generic.dao.operator.Pair.java 3 | * 下午4:56:23 created by Darwin(Tianxin) 4 | */ 5 | package com.baidu.unbiz.common.genericdao.operator; 6 | 7 | /** 8 | * @author Darwin(Tianxin) 9 | */ 10 | public interface Pair { 11 | 12 | String getColumn(); 13 | 14 | Object getValue(); 15 | } 16 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/config/dao/ConfigHistoryDao.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.config.dao; 2 | 3 | import com.baidu.disconf.web.service.config.bo.ConfigHistory; 4 | import com.baidu.unbiz.common.genericdao.dao.BaseDao; 5 | 6 | /** 7 | * Created by knightliao on 15/12/25. 8 | */ 9 | 10 | public interface ConfigHistoryDao extends BaseDao { 11 | } 12 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/ub/common/dbmanage/router/Router.java: -------------------------------------------------------------------------------- 1 | package com.baidu.ub.common.dbmanage.router; 2 | 3 | public interface Router { 4 | 5 | /** 6 | * locate target virtualdatasource by routing rule 7 | * 8 | * @param userid 9 | * @param readMaster 10 | * 11 | * @return 12 | */ 13 | String getTargetDataSourceKey(int userid, boolean readMaster); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/unbiz/common/genericdao/param/LikeParam.java: -------------------------------------------------------------------------------- 1 | package com.baidu.unbiz.common.genericdao.param; 2 | 3 | /** 4 | * 封装like参数 5 | * 6 | * @author Darwin(Tianxin) 7 | */ 8 | public class LikeParam { 9 | String word; 10 | 11 | public LikeParam(String word) { 12 | this.word = word; 13 | } 14 | 15 | public String getWord() { 16 | return word; 17 | } 18 | } -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/unbiz/common/genericdao/param/NotParam.java: -------------------------------------------------------------------------------- 1 | package com.baidu.unbiz.common.genericdao.param; 2 | 3 | /** 4 | * 反向参数 5 | * 6 | * @author Darwin(Tianxin) 7 | */ 8 | public class NotParam { 9 | Object value; 10 | 11 | public NotParam(Object value) { 12 | this.value = value; 13 | } 14 | 15 | public Object getValue() { 16 | return value; 17 | } 18 | } -------------------------------------------------------------------------------- /disconf-web/src/test/resources/file2/utf-file.properties: -------------------------------------------------------------------------------- 1 | com.xiaomi.zookeeper.zkfactory.host=127.0.0.1:8080 2 | com.xiaomi.host.host.group=xiaomi 3 | com.xiaomi.host.host.name=\u5C0F\u7C73 4 | com.xiaomi.host.host.tag=xiaomi 5 | 6 | com.xiaomi.config.profile.enabled=true 7 | com.xiaomi.trace.trace.enabled=true 8 | com.xiaomi.header.headers.enabled=true 9 | 10 | #spring root xml 11 | com.xiaomi.main.impl.start.xml=spring.xml -------------------------------------------------------------------------------- /docs/source/design/局限性和注意事项.md: -------------------------------------------------------------------------------- 1 | 局限性和注意事项 2 | ======= 3 | 4 | ## 局限性和注意事项 ## 5 | 6 | - 配置文件类、配置项所在的类、回调函数类 都必须是JavaBean,并且它们的"scope" 都必须是[singleton](http://docs.spring.io/spring/docs/3.0.0.M3/reference/html/ch04s04.html)的。 7 | - 本系统实现的注解方案具有些局限性,具体如下: 8 | - 用户标注配置时略有些不习惯。目前注解是放在get方法之上的,而不是放在域上。 9 | - 注解放在get方法上,一般情况下是没有问题的。但是对于"call self"的方法调用,AOP无法拦截得到,这样就无法统一处理这些配置。一旦出现这种情况,“非一致性读问题”就会产生。 10 | 11 | 12 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/unbiz/common/genericdao/param/GteParam.java: -------------------------------------------------------------------------------- 1 | package com.baidu.unbiz.common.genericdao.param; 2 | 3 | /** 4 | * 封装大于等於的参数 5 | * 6 | * @author Darwin(Tianxin) 7 | */ 8 | public class GteParam { 9 | Object value; 10 | 11 | public GteParam(Object value) { 12 | this.value = value; 13 | } 14 | 15 | public Object getValue() { 16 | return value; 17 | } 18 | } -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/unbiz/common/genericdao/param/LteParam.java: -------------------------------------------------------------------------------- 1 | package com.baidu.unbiz.common.genericdao.param; 2 | 3 | /** 4 | * 封装小于等於的参数 5 | * 6 | * @author Darwin(Tianxin) 7 | */ 8 | public class LteParam { 9 | Object value; 10 | 11 | public LteParam(Object value) { 12 | this.value = value; 13 | } 14 | 15 | public Object getValue() { 16 | return value; 17 | } 18 | } -------------------------------------------------------------------------------- /disconf-web/html/assets/js/footer.js: -------------------------------------------------------------------------------- 1 | (function ($) { 2 | 3 | // 登出 4 | $("#signout").on("click", function () { 5 | $.ajax({ 6 | type: "GET", 7 | url: "/api/account/signout" 8 | }).done(function (data) { 9 | if (data.success === "true") { 10 | VISITOR = {}; 11 | getSession(); 12 | } 13 | }); 14 | }); 15 | 16 | })(jQuery); -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/ejs/benchmark.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | var ejs = require('./lib/ejs'), 4 | str = '<% if (foo) { %>

    <%= foo %>

    <% } %>', 5 | times = 50000; 6 | 7 | console.log('rendering ' + times + ' times'); 8 | 9 | var start = new Date; 10 | while (times--) { 11 | ejs.render(str, { cache: true, filename: 'test', locals: { foo: 'bar' }}); 12 | } 13 | 14 | console.log('took ' + (new Date - start) + 'ms'); -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/role/service/RoleMgr.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.role.service; 2 | 3 | import java.util.List; 4 | 5 | import com.baidu.disconf.web.service.role.bo.Role; 6 | 7 | /** 8 | * @author weiwei 9 | * @date 2013-12-24 10 | */ 11 | public interface RoleMgr { 12 | 13 | public Role get(Integer roleId); 14 | 15 | public List findAll(); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/dsp/common/annotation/NoAuth.java: -------------------------------------------------------------------------------- 1 | package com.baidu.dsp.common.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target(value = ElementType.METHOD) 9 | @Retention(value = RetentionPolicy.RUNTIME) 10 | public @interface NoAuth { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /disconf-client/src/main/java/com/baidu/disconf/client/core/filetype/DisconfFileTypeProcessor.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.core.filetype; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * 文件类型处理器 7 | * 8 | * @author knightliao 9 | */ 10 | public interface DisconfFileTypeProcessor { 11 | 12 | /** 13 | * 输入文件名,返回其相应的k-v数据 14 | */ 15 | Map getKvMap(String fileName) throws Exception; 16 | } 17 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/roleres/dao/RoleResourceDao.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.roleres.dao; 2 | 3 | import com.baidu.disconf.web.service.roleres.bo.RoleResource; 4 | import com.baidu.unbiz.common.genericdao.dao.BaseDao; 5 | 6 | /** 7 | * @author weiwei 8 | * @date 2013-12-20 涓嬪崍6:16:31 9 | */ 10 | public interface RoleResourceDao extends BaseDao { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/unbiz/common/genericdao/param/LessThanParam.java: -------------------------------------------------------------------------------- 1 | package com.baidu.unbiz.common.genericdao.param; 2 | 3 | /** 4 | * 封装小于的参数 5 | * 6 | * @author Darwin(Tianxin) 7 | */ 8 | public class LessThanParam { 9 | Object value; 10 | 11 | public LessThanParam(Object value) { 12 | this.value = value; 13 | } 14 | 15 | public Object getValue() { 16 | return value; 17 | } 18 | } -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/dsp/common/utils/DataTransfer.java: -------------------------------------------------------------------------------- 1 | package com.baidu.dsp.common.utils; 2 | 3 | /** 4 | * 数据转接接口 5 | * 6 | * @author liaoqiqi 7 | * @version 2014-2-20 8 | */ 9 | public interface DataTransfer { 10 | 11 | /** 12 | * 转换规则定义 13 | * 14 | * @param inputList 15 | * 16 | * @return 17 | */ 18 | public ENTITYTO transfer(ENTITYFROM input); 19 | } 20 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/app/form/AppListForm.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.app.form; 2 | 3 | import com.baidu.dsp.common.form.RequestListBase; 4 | 5 | /** 6 | * @author liaoqiqi 7 | * @version 2014-1-24 8 | */ 9 | public class AppListForm extends RequestListBase { 10 | 11 | /** 12 | * 13 | */ 14 | private static final long serialVersionUID = 4329463343279659715L; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/unbiz/common/genericdao/param/GreaterThanParam.java: -------------------------------------------------------------------------------- 1 | package com.baidu.unbiz.common.genericdao.param; 2 | 3 | /** 4 | * 封装大于的参数 5 | * 6 | * @author Darwin(Tianxin) 7 | */ 8 | public class GreaterThanParam { 9 | Object value; 10 | 11 | public GreaterThanParam(Object value) { 12 | this.value = value; 13 | } 14 | 15 | public Object getValue() { 16 | return value; 17 | } 18 | } -------------------------------------------------------------------------------- /disconf-web/profile/rd/jdbc-mysql.properties: -------------------------------------------------------------------------------- 1 | jdbc.driverClassName=com.mysql.jdbc.Driver 2 | 3 | jdbc.db_0.url=jdbc:mysql://127.0.0.1:3306/disconf?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&rewriteBatchedStatements=false 4 | jdbc.db_0.username=root 5 | jdbc.db_0.password=123456 6 | 7 | jdbc.maxPoolSize=20 8 | jdbc.minPoolSize=10 9 | jdbc.initialPoolSize=10 10 | jdbc.idleConnectionTestPeriod=1200 11 | jdbc.maxIdleTime=3600 -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/user/form/UserListForm.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.user.form; 2 | 3 | import com.baidu.dsp.common.form.RequestListBase; 4 | 5 | /** 6 | * @author liaoqiqi 7 | * @version 2014-1-24 8 | */ 9 | public class UserListForm extends RequestListBase { 10 | 11 | /** 12 | * 13 | */ 14 | private static final long serialVersionUID = 4329463343279659715L; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /disconf-client/src/main/java/com/baidu/disconf/client/DisconfMgrBeanSecond.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client; 2 | 3 | /** 4 | * 第二次扫描,动态扫描 5 | * 6 | * @author liaoqiqi 7 | * @version 2014-6-18 8 | */ 9 | public class DisconfMgrBeanSecond { 10 | 11 | public void init() { 12 | 13 | DisconfMgr.getInstance().secondScan(); 14 | } 15 | 16 | public void destroy() { 17 | DisconfMgr.getInstance().close(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /docs/source/tutorial-client/src/Tutorial10.rst: -------------------------------------------------------------------------------- 1 | Tutorial 10 实现一个配置更新下载器agent 2 | ======================================= 3 | 4 | 问题 5 | ~~~~ 6 | 7 | 我想在我的机器上做一个配置下载器agent, 可以实现以下功能: 8 | 9 | - 启动时下载配置 10 | - 配置被更新时,可以感知并下载下来 11 | 12 | 解决方法 13 | ~~~~~~~~ 14 | 15 | | 可以修改一下 disconf-demos/disconf-standalone-demo 16 | 这个项目,让其变成一个 长驻进程,并指定 17 | | `disconf.user\_define\_download\_dir <../../config/client-config.html>`__ 18 | 这个配置到你想指定的路径。 19 | 20 | done. 21 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/sign/service/SignMgr.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.sign.service; 2 | 3 | import com.baidu.disconf.web.service.user.bo.User; 4 | 5 | /** 6 | * @author liaoqiqi 7 | * @version 2014-2-6 8 | */ 9 | public interface SignMgr { 10 | 11 | User getUserByName(String name); 12 | 13 | boolean validate(String userPassword, String passwordToBeValidate); 14 | 15 | User signin(String phone); 16 | } 17 | -------------------------------------------------------------------------------- /docs/source/design/src/局限性和注意事项.rst: -------------------------------------------------------------------------------- 1 | 局限性和注意事项 2 | ================ 3 | 4 | 局限性和注意事项 5 | ---------------- 6 | 7 | - 配置文件类、配置项所在的类、回调函数类 8 | 都必须是JavaBean,并且它们的"scope" 9 | 都必须是\ `singleton `__\ 的。 10 | - 本系统实现的注解方案具有些局限性,具体如下: 11 | 12 | - 用户标注配置时略有些不习惯。目前注解是放在get方法之上的,而不是放在域上。 13 | - 注解放在get方法上,一般情况下是没有问题的。但是对于"call 14 | self"的方法调用,AOP无法拦截得到,这样就无法统一处理这些配置。一旦出现这种情况,“非一致性读问题”就会产生。 15 | -------------------------------------------------------------------------------- /disconf-client/src/test/java/com/baidu/disconf/client/test/model/EmptyConf.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.test.model; 2 | 3 | import org.springframework.stereotype.Service; 4 | 5 | import com.baidu.disconf.client.common.annotations.DisconfFile; 6 | 7 | /** 8 | * 空的分布式配置文件,用途有两种:
    9 | * 1. 对配置文件里的内容不感兴趣,只是单纯的下载
    10 | * 2. 当配置文件更新时,可以自动下载到本地 11 | */ 12 | @Service 13 | @DisconfFile(filename = "empty.properties") 14 | public class EmptyConf { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /disconf-web/sql/201512/20151225.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `config_history` ( 2 | `id` BIGINT NOT NULL AUTO_INCREMENT, 3 | `config_id` BIGINT NOT NULL, 4 | `old_value` LONGTEXT NOT NULL, 5 | `new_value` LONGTEXT NOT NULL, 6 | `create_time` VARCHAR(14) NOT NULL DEFAULT '99991231235959', 7 | PRIMARY KEY (`id`) 8 | )DEFAULT CHARSET=utf8 ENGINE=InnoDB; 9 | 10 | ALTER TABLE `config` 11 | ADD COLUMN `status` TINYINT(4) NOT NULL DEFAULT '1' COMMENT '状态:1是正常 0是删除' AFTER `type`; 12 | -------------------------------------------------------------------------------- /docs/source/tutorial-client/Tutorial7.md: -------------------------------------------------------------------------------- 1 | Tutorial 7 可自定义的部分托管的分布式配置 2 | ======= 3 | 4 | 假设我们已经将所有配置文件和配置项都使用Disconf进行托管了。 5 | 6 | 在多人开发情况下,可能会有一两个配置文件需要经常改动,且每个人的配置都不大一样,在这种情况下,当然希望此配置文件(或多个配置) 7 | 均不要使用Disconf托管。 8 | 9 | Disconf考虑到了此种情况。举个实例,数据库配置文件,每个人的数据库可能不大一样,那么,你可以修改 disconf.properties : 10 | 11 | # 忽略哪些分布式配置,用逗号分隔 12 | disconf.ignore=jdbc-mysql.properties 13 | 14 | 将此配置文件添加到ignore的列表里。这样,程序运行时,Disconf就会忽略托管此配置文件,而改为读取你本地的配置文件 jdbc-mysql.properties。 15 | 16 | -------------------------------------------------------------------------------- /disconf-core/src/main/java/com/baidu/disconf/core/common/restful/retry/RetryStrategy.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.core.common.restful.retry; 2 | 3 | import com.baidu.disconf.core.common.restful.core.UnreliableInterface; 4 | 5 | /** 6 | * 重试的策略 7 | * 8 | * @author liaoqiqi 9 | * @version 2014-6-10 10 | */ 11 | public interface RetryStrategy { 12 | 13 | T retry(UnreliableInterface unreliableImpl, int retryTimes, int sleepSeconds) throws Exception; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/ejs/Makefile: -------------------------------------------------------------------------------- 1 | 2 | SRC = $(shell find lib -name "*.js" -type f) 3 | UGLIFY_FLAGS = --no-mangle 4 | 5 | all: ejs.min.js 6 | 7 | test: 8 | @./node_modules/.bin/mocha \ 9 | --reporter spec 10 | 11 | ejs.js: $(SRC) 12 | @node support/compile.js $^ 13 | 14 | ejs.min.js: ejs.js 15 | @uglifyjs $(UGLIFY_FLAGS) $< > $@ \ 16 | && du ejs.min.js \ 17 | && du ejs.js 18 | 19 | clean: 20 | rm -f ejs.js 21 | rm -f ejs.min.js 22 | 23 | .PHONY: test -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/eventproxy/node_modules/debug/example/app.js: -------------------------------------------------------------------------------- 1 | 2 | var debug = require('../')('http') 3 | , http = require('http') 4 | , name = 'My App'; 5 | 6 | // fake app 7 | 8 | debug('booting %s', name); 9 | 10 | http.createServer(function(req, res){ 11 | debug(req.method + ' ' + req.url); 12 | res.end('hello\n'); 13 | }).listen(3000, function(){ 14 | debug('listening'); 15 | }); 16 | 17 | // fake worker of some kind 18 | 19 | require('./worker'); -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/user/dao/UserDao.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.user.dao; 2 | 3 | import com.baidu.disconf.web.service.user.bo.User; 4 | import com.baidu.unbiz.common.genericdao.dao.BaseDao; 5 | 6 | /** 7 | * @author liaoqiqi 8 | * @version 2013-11-28 9 | */ 10 | public interface UserDao extends BaseDao { 11 | 12 | void executeSql(String sql); 13 | 14 | User getUserByName(String name); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /disconf-client/src/main/resources/disconf_sys.properties: -------------------------------------------------------------------------------- 1 | 2 | 3 | # \u4ED3\u5E93 URL 4 | disconf.conf_server_store_action=/api/config 5 | 6 | # zoo URL 7 | disconf.conf_server_zoo_action=/api/zoo 8 | 9 | # \u83B7\u53D6\u8FDC\u7A0B\u4E3B\u673A\u4E2A\u6570\u7684URL 10 | disconf.conf_server_master_num_action=/api/getmasterinfo 11 | 12 | # \u4E0B\u8F7D\u6587\u4EF6\u5939, \u8FDC\u7A0B\u6587\u4EF6\u4E0B\u8F7D\u540E\u4F1A\u653E\u5728\u8FD9\u91CC 13 | disconf.local_download_dir=./disconf/download 14 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/env/dao/EnvDao.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.env.dao; 2 | 3 | import com.baidu.disconf.web.service.env.bo.Env; 4 | import com.baidu.unbiz.common.genericdao.dao.BaseDao; 5 | 6 | /** 7 | * @author liaoqiqi 8 | * @version 2014-6-16 9 | */ 10 | public interface EnvDao extends BaseDao { 11 | 12 | /** 13 | * @param name 14 | * 15 | * @return 16 | */ 17 | Env getByName(String name); 18 | } 19 | -------------------------------------------------------------------------------- /disconf-client/src/main/java/com/baidu/disconf/client/scan/inner/statically/StaticScannerMgr.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.scan.inner.statically; 2 | 3 | import java.util.Set; 4 | 5 | import com.baidu.disconf.client.scan.inner.statically.model.ScanStaticModel; 6 | 7 | /** 8 | * @author liaoqiqi 9 | * @version 2014-9-9 10 | */ 11 | public interface StaticScannerMgr { 12 | 13 | void scanData2Store(ScanStaticModel scanModel); 14 | 15 | void exclude(Set keySet); 16 | } 17 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/user/service/UserInnerMgr.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.user.service; 2 | 3 | import java.util.Set; 4 | 5 | import com.baidu.disconf.web.service.user.dto.Visitor; 6 | 7 | public interface UserInnerMgr { 8 | 9 | /** 10 | * 获取用户的基本信息(登录用户) 11 | * 12 | * @return 13 | */ 14 | Visitor getVisitor(Long userId); 15 | 16 | /** 17 | * @return 18 | */ 19 | Set getVisitorAppIds(); 20 | } 21 | -------------------------------------------------------------------------------- /disconf-client/src/main/java/com/baidu/disconf/client/scan/inner/statically/strategy/ScanStaticStrategy.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.scan.inner.statically.strategy; 2 | 3 | import java.util.List; 4 | 5 | import com.baidu.disconf.client.scan.inner.statically.model.ScanStaticModel; 6 | 7 | /** 8 | * 扫描静态注解,并且进行分析整合数据 9 | * 10 | * @author liaoqiqi 11 | * @version 2014-6-6 12 | */ 13 | public interface ScanStaticStrategy { 14 | 15 | ScanStaticModel scan(List packNameList); 16 | } 17 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/dsp/common/exception/DocumentNotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.baidu.dsp.common.exception; 2 | 3 | /** 4 | * 文档不存在错误 5 | * 6 | * @author liaoqiqi 7 | * @version 2014-6-10 8 | */ 9 | public class DocumentNotFoundException extends RuntimeException { 10 | 11 | private static final long serialVersionUID = 545280194497047918L; 12 | 13 | public DocumentNotFoundException(String fileName) { 14 | super(fileName + " file does not exist!"); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /disconf-web/src/test/java/com/baidu/disconf/web/test/AllTestSuite.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.test; 2 | 3 | import org.junit.runner.RunWith; 4 | import org.junit.runners.Suite; 5 | import org.junit.runners.Suite.SuiteClasses; 6 | 7 | import com.baidu.disconf.web.test.service.config.dao.ConfigDaoTestCase; 8 | 9 | /** 10 | * 11 | * @author liaoqiqi 12 | * @version 2014-1-14 13 | */ 14 | @RunWith(Suite.class) 15 | @SuiteClasses({ ConfigDaoTestCase.class }) 16 | public class AllTestSuite { 17 | 18 | } 19 | -------------------------------------------------------------------------------- /disconf-core/src/test/java/com/baidu/disconf/core/test/utils/MyStringUtilsTestCase.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.core.test.utils; 2 | 3 | import org.junit.Test; 4 | 5 | import com.baidu.disconf.core.common.utils.MyStringUtils; 6 | 7 | /** 8 | * MyStringUtilsTestCase 9 | * 10 | * @author knightliao 11 | */ 12 | public class MyStringUtilsTestCase { 13 | 14 | @Test 15 | public void getRandomName() { 16 | 17 | System.out.println(MyStringUtils.getRandomName("abc.properties")); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /docs/source/tutorial-client/index.rst: -------------------------------------------------------------------------------- 1 | Tutorial-client 2 | =============== 3 | 4 | .. toctree:: 5 | :maxdepth: 2 6 | :numbered: 2 7 | 8 | src/Tutorial1 9 | src/Tutorial2 10 | src/Tutorial3 11 | src/Tutorial4 12 | src/Tutorial5 13 | src/Tutorial7 14 | src/Tutorial8 15 | src/Tutorial9 16 | src/Tutorial10 17 | src/Tutorial11-config-download-path 18 | src/Tutorial13-unify-notify 19 | src/Tutorial14-bean-setter-mode 20 | src/jar-start-up 21 | src/config-getter 22 | -------------------------------------------------------------------------------- /docs/source/tutorial-client/src/Tutorial7.rst: -------------------------------------------------------------------------------- 1 | Tutorial 7 可自定义的部分托管的分布式配置 2 | ========================================= 3 | 4 | 假设我们已经将所有配置文件和配置项都使用Disconf进行托管了。 5 | 6 | | 在多人开发情况下,可能会有一两个配置文件需要经常改动,且每个人的配置都不大一样,在这种情况下,当然希望此配置文件(或多个配置) 7 | | 均不要使用Disconf托管。 8 | 9 | Disconf考虑到了此种情况。举个实例,数据库配置文件,每个人的数据库可能不大一样,那么,你可以修改 10 | disconf.properties : 11 | 12 | :: 13 | 14 | # 忽略哪些分布式配置,用逗号分隔 15 | disconf.ignore=jdbc-mysql.properties 16 | 17 | 将此配置文件添加到ignore的列表里。这样,程序运行时,Disconf就会忽略托管此配置文件,而改为读取你本地的配置文件 18 | jdbc-mysql.properties。 19 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/sign/dao/impl/SignDaoImpl.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.sign.dao.impl; 2 | 3 | import org.springframework.stereotype.Repository; 4 | 5 | import com.baidu.disconf.web.service.sign.dao.SignDao; 6 | import com.baidu.disconf.web.service.user.bo.User; 7 | import com.baidu.dsp.common.dao.AbstractDao; 8 | 9 | /** 10 | * @author liaoqiqi 11 | * @version 2013-11-28 12 | */ 13 | @Repository 14 | public class SignDaoImpl extends AbstractDao implements SignDao { 15 | 16 | } -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/role/dao/impl/RoleDaoImpl.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.role.dao.impl; 2 | 3 | import org.springframework.stereotype.Repository; 4 | 5 | import com.baidu.disconf.web.service.role.bo.Role; 6 | import com.baidu.disconf.web.service.role.dao.RoleDao; 7 | import com.baidu.dsp.common.dao.AbstractDao; 8 | 9 | /** 10 | * @author liaoqiqi 11 | * @version 2014-1-14 12 | */ 13 | @Repository 14 | public class RoleDaoImpl extends AbstractDao implements RoleDao { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /disconf-web/profile/rd/application-demo.properties: -------------------------------------------------------------------------------- 1 | 2 | # 3 | # \u670d\u52a1\u5668\u7684domain 4 | # 5 | 6 | domain=disconf.com 7 | 8 | # 9 | # \u90ae\u7bb1\u8bbe\u7f6e 10 | # 11 | 12 | EMAIL_MONITOR_ON = true 13 | EMAIL_HOST = smtp.163.com 14 | EMAIL_HOST_PASSWORD = password 15 | EMAIL_HOST_USER = sender@163.com 16 | EMAIL_PORT = 25 17 | DEFAULT_FROM_EMAIL = disconf@163.com 18 | 19 | # 20 | # \u5b9a\u65f6\u6821\u9a8c\u4e2d\u5fc3\u7684\u914d\u7f6e\u4e0e\u6240\u6709\u5ba2\u6237\u7aef\u914d\u7f6e\u7684\u4e00\u81f4\u6027 21 | # 22 | CHECK_CONSISTENCY_ON= true -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/ejs/lib/utils.js: -------------------------------------------------------------------------------- 1 | 2 | /*! 3 | * EJS 4 | * Copyright(c) 2010 TJ Holowaychuk 5 | * MIT Licensed 6 | */ 7 | 8 | /** 9 | * Escape the given string of `html`. 10 | * 11 | * @param {String} html 12 | * @return {String} 13 | * @api private 14 | */ 15 | 16 | exports.escape = function(html){ 17 | return String(html) 18 | .replace(/&(?!#?[a-zA-Z0-9]+;)/g, '&') 19 | .replace(//g, '>') 21 | .replace(/'/g, ''') 22 | .replace(/"/g, '"'); 23 | }; 24 | 25 | -------------------------------------------------------------------------------- /disconf-client/src/main/java/com/baidu/disconf/client/common/constants/Constants.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.common.constants; 2 | 3 | /** 4 | * 常量定义 5 | * 6 | * @author liaoqiqi 7 | * @version 2014-6-6 8 | */ 9 | public class Constants { 10 | 11 | /** 12 | * Disconf本身Package 13 | */ 14 | public static final String DISCONF_PACK_NAME = "com.baidu.disconf"; 15 | 16 | /** 17 | */ 18 | public static final String HOST_PROPERTIES_KEY = "VCAP_APP_HOST"; 19 | public static final String PORT_PROPERTIES_KEY = "VCAP_APP_PORT"; 20 | } 21 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/dsp/common/context/ContextReader.java: -------------------------------------------------------------------------------- 1 | package com.baidu.dsp.common.context; 2 | 3 | import org.springframework.context.MessageSourceResolvable; 4 | import org.springframework.context.NoSuchMessageException; 5 | 6 | public interface ContextReader { 7 | 8 | String getMessage(String resourceMessage) throws NoSuchMessageException; 9 | 10 | String getMessage(String resourceMessage, Object []args) throws NoSuchMessageException; 11 | 12 | String getMessage(MessageSourceResolvable resolvable) throws NoSuchMessageException; 13 | } 14 | -------------------------------------------------------------------------------- /disconf-web/html/assets/js/zkinfo.js: -------------------------------------------------------------------------------- 1 | (function ($) { 2 | 3 | getSession(); 4 | 5 | fetchConfigUsage(); 6 | 7 | // 8 | // 渲染主列表 9 | // 10 | function fetchConfigUsage() { 11 | 12 | url = "/api/usage/list"; 13 | 14 | $.ajax({ 15 | type: "GET", 16 | url: url 17 | }).done(function (data) { 18 | if (data.success === "true") { 19 | var html = data.result.hostInfo; 20 | $("#hostInfo").html(html); 21 | } 22 | }); 23 | 24 | } 25 | 26 | })(jQuery); 27 | -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/ejs/examples/functions.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Module dependencies. 4 | */ 5 | 6 | var ejs = require('../') 7 | , fs = require('fs') 8 | , path = __dirname + '/functions.ejs' 9 | , str = fs.readFileSync(path, 'utf8'); 10 | 11 | var users = []; 12 | 13 | users.push({ name: 'Tobi', age: 2, species: 'ferret' }) 14 | users.push({ name: 'Loki', age: 2, species: 'ferret' }) 15 | users.push({ name: 'Jane', age: 6, species: 'ferret' }) 16 | 17 | var ret = ejs.render(str, { 18 | users: users, 19 | filename: path 20 | }); 21 | 22 | console.log(ret); -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/config/dao/impl/ConfigHistoryDaoImpl.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.config.dao.impl; 2 | 3 | import org.springframework.stereotype.Service; 4 | 5 | import com.baidu.disconf.web.service.config.bo.ConfigHistory; 6 | import com.baidu.disconf.web.service.config.dao.ConfigHistoryDao; 7 | import com.baidu.dsp.common.dao.AbstractDao; 8 | 9 | /** 10 | * Created by knightliao on 15/12/25. 11 | */ 12 | @Service 13 | public class ConfigHistoryDaoImpl extends AbstractDao implements ConfigHistoryDao { 14 | } 15 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/dsp/common/constant/DataFormatConstants.java: -------------------------------------------------------------------------------- 1 | package com.baidu.dsp.common.constant; 2 | 3 | public class DataFormatConstants { 4 | 5 | // 后端通用的时间格式 6 | public static String COMMON_TIME_FORMAT = "yyyyMMddHHmmss"; 7 | 8 | // 后端通用的时间格式 9 | public static String COMMON_DATE_FORMAT = "yyyyMMdd"; 10 | 11 | /** 12 | * 日期开始时间后缀 13 | */ 14 | public static final String DATE_DAY_START_SUFFIX = "000000"; 15 | /** 16 | * 日期结束时间后缀 17 | */ 18 | public static final String DATE_DAY_END_SUFFIX = "235959"; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/eventproxy/node_modules/debug/example/worker.js: -------------------------------------------------------------------------------- 1 | 2 | // DEBUG=* node example/worker 3 | // DEBUG=worker:* node example/worker 4 | // DEBUG=worker:a node example/worker 5 | // DEBUG=worker:b node example/worker 6 | 7 | var a = require('../')('worker:a') 8 | , b = require('../')('worker:b'); 9 | 10 | function work() { 11 | a('doing lots of uninteresting work'); 12 | setTimeout(work, Math.random() * 1000); 13 | } 14 | 15 | work(); 16 | 17 | function workb() { 18 | b('doing some work'); 19 | setTimeout(workb, Math.random() * 2000); 20 | } 21 | 22 | workb(); -------------------------------------------------------------------------------- /docs/source/question/disconf-question.md: -------------------------------------------------------------------------------- 1 | Client常问问题 2 | ======= 3 | 4 | ## **异常:** ERROR c.b.d.c.c.processor.impl.DisconfCoreProcessUtils - Spring Context is null. Cannot autowire com.szzjcs.commons.thirdapi.push.config.JpushConfig 5 | 6 | **可能原因:** 7 | 8 | - 程序没有使用spring环境 9 | - `` 放在 disconfMgrBean 定义的后面 10 | - 对于版本2.6.28(包括此版本)之前的版本, component-scan 可能没有扫描 `com.baidu.disconf` 11 | 12 | **解决办法:** 13 | 14 | - 非静态配置 必须使用spring环境 15 | - `` 必须出现在disconfMgrBean之前 16 | - 对于版本2.6.28(包括此版本)之前的版本,必须使 component-scan 增加扫描项 `com.baidu.disconf` 17 | 18 | -------------------------------------------------------------------------------- /disconf-client/src/test/java/com/baidu/disconf/client/test/scan/ScanMgrTestCase.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.test.scan; 2 | 3 | import org.junit.Test; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | import com.baidu.disconf.client.test.common.BaseSpringTestCase; 8 | 9 | /** 10 | * @author liaoqiqi 11 | * @version 2014-7-30 12 | */ 13 | public class ScanMgrTestCase extends BaseSpringTestCase { 14 | 15 | protected static final Logger LOGGER = LoggerFactory.getLogger(ScanMgrTestCase.class); 16 | 17 | @Test 18 | public void scan() { 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /disconf-web/profile/rd/redis-config.properties: -------------------------------------------------------------------------------- 1 | redis.group1.retry.times=2 2 | 3 | redis.group1.client1.name=BeidouRedis1 4 | redis.group1.client1.host=127.0.0.1 5 | redis.group1.client1.port=6379 6 | redis.group1.client1.timeout=5000 7 | redis.group1.client1.password=foobared 8 | 9 | redis.group1.client2.name=BeidouRedis2 10 | redis.group1.client2.host=127.0.0.1 11 | redis.group1.client2.port=6380 12 | redis.group1.client2.timeout=5000 13 | redis.group1.client2.password=foobared 14 | 15 | redis.evictor.delayCheckSeconds=300 16 | redis.evictor.checkPeriodSeconds=30 17 | redis.evictor.failedTimesToBeTickOut=6 -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/app/vo/AppListVo.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.app.vo; 2 | 3 | /** 4 | * @author liaoqiqi 5 | * @version 2014-6-22 6 | */ 7 | public class AppListVo { 8 | 9 | private long id; 10 | private String name; 11 | 12 | public long getId() { 13 | return id; 14 | } 15 | 16 | public void setId(long id) { 17 | this.id = id; 18 | } 19 | 20 | public String getName() { 21 | return name; 22 | } 23 | 24 | public void setName(String name) { 25 | this.name = name; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/env/vo/EnvListVo.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.env.vo; 2 | 3 | /** 4 | * @author liaoqiqi 5 | * @version 2014-6-22 6 | */ 7 | public class EnvListVo { 8 | 9 | private long id; 10 | private String name; 11 | 12 | public long getId() { 13 | return id; 14 | } 15 | 16 | public void setId(long id) { 17 | this.id = id; 18 | } 19 | 20 | public String getName() { 21 | return name; 22 | } 23 | 24 | public void setName(String name) { 25 | this.name = name; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /disconf-client/src/main/java/com/baidu/disconf/client/scan/ScanFactory.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.scan; 2 | 3 | import com.baidu.disconf.client.scan.impl.ScanMgrImpl; 4 | import com.baidu.disconf.client.support.registry.Registry; 5 | 6 | /** 7 | * 扫描器工厂 8 | * 9 | * @author liaoqiqi 10 | * @version 2014-7-29 11 | */ 12 | public class ScanFactory { 13 | 14 | /** 15 | * @throws Exception 16 | */ 17 | public static ScanMgr getScanMgr(Registry registry) throws Exception { 18 | 19 | ScanMgr scanMgr = new ScanMgrImpl(registry); 20 | return scanMgr; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/roleres/dao/impl/RoleResourceDaoImpl.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.roleres.dao.impl; 2 | 3 | import org.springframework.stereotype.Repository; 4 | 5 | import com.baidu.disconf.web.service.roleres.bo.RoleResource; 6 | import com.baidu.disconf.web.service.roleres.dao.RoleResourceDao; 7 | import com.baidu.dsp.common.dao.AbstractDao; 8 | 9 | /** 10 | * @author weiwei 11 | * @date 2013-12-20 涓嬪崍6:35:04 12 | */ 13 | @Repository 14 | public class RoleResourceDaoImpl extends AbstractDao implements RoleResourceDao { 15 | 16 | } -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/dsp/common/constant/WebConstants.java: -------------------------------------------------------------------------------- 1 | package com.baidu.dsp.common.constant; 2 | 3 | /** 4 | * @author liaoqiqi 5 | * @version 2013-11-26 6 | */ 7 | public class WebConstants { 8 | 9 | /** 10 | * 与FE的通信时间格式统一使用yyyyMMddHHmmss 11 | */ 12 | public static final String TIME_FORMAT = "yyyyMMddHHmmss"; 13 | 14 | /** 15 | * 与FE通信的表单的Field List名称 16 | */ 17 | public static final String FIELD_LIST_NAME = "fieldList"; 18 | 19 | /** 20 | * 服务端Controller前缀 21 | */ 22 | public static final String API_PREFIX = "/api"; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /disconf-web/src/test/resources/sql/base/goldendata/1_0_0/disconf.sql: -------------------------------------------------------------------------------- 1 | 2 | 3 | INSERT INTO `env` VALUES (1, 'rd'); 4 | INSERT INTO `env` VALUES (2, 'qa'); 5 | INSERT INTO `env` VALUES (3, 'local'); 6 | 7 | 8 | INSERT INTO `app` VALUES (1, 'disconf_demo', 'disconf_demo', '20140415155127', '20140415155127', 9 | 'knightliao@gmail.com'); 10 | 11 | 12 | INSERT INTO `config` VALUES (2, 1, 1, 'keyA', '8888', 1, '1_0_0_0', 1, '99991231235959', '99991231235959'); 13 | INSERT INTO `config` VALUES (1, 0, 1, 'confA.properties', 'varA=200000\\r\\nvarA2=300000', 1, '1_0_0_0', 1, 14 | '20140415155127', '20140415155127'); 15 | -------------------------------------------------------------------------------- /disconf-client/src/main/java/com/baidu/disconf/client/core/filetype/impl/DisconfXmlProcessorImpl.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.core.filetype.impl; 2 | 3 | import java.util.Map; 4 | 5 | import com.baidu.disconf.client.core.filetype.DisconfFileTypeProcessor; 6 | 7 | /** 8 | * xml 处理器 9 | * 10 | * @author knightliao 11 | */ 12 | public class DisconfXmlProcessorImpl implements DisconfFileTypeProcessor { 13 | 14 | @Override 15 | public Map getKvMap(String fileName) throws Exception { 16 | // TODO Auto-generated method stub 17 | return null; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/eventproxy/node_modules/debug/example/browser.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | debug() 4 | 5 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /disconf-web/html/mainTpl/index.tpl.html: -------------------------------------------------------------------------------- 1 | <%= page.basehead %> 2 | 3 | Disconf - 分布式配置管理平台 4 | 5 | <%= page.head %> 6 | 7 |
    8 |
    9 |
    10 | 11 |
    12 |
    13 | 14 |
    15 |
    16 |
    17 |
    18 |
    19 | 20 | <%= page.foot %> 21 | 22 | 23 | 24 | <%= page.basefoot %> 25 | -------------------------------------------------------------------------------- /disconf-client/src/main/java/com/baidu/disconf/client/core/filetype/impl/DisconfAnyFileProcessorImpl.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.core.filetype.impl; 2 | 3 | import java.util.Map; 4 | 5 | import com.baidu.disconf.client.core.filetype.DisconfFileTypeProcessor; 6 | 7 | /** 8 | * Created by knightliao on 15/1/21. 9 | *

    10 | * 任意文件的处理 11 | */ 12 | public class DisconfAnyFileProcessorImpl implements DisconfFileTypeProcessor { 13 | 14 | @Override 15 | public Map getKvMap(String fileName) throws Exception { 16 | // TODO Auto-generated method stub 17 | return null; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/eventproxy/component.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "eventproxy", 3 | "repo": "JacksonTian/eventproxy", 4 | "description": "An implementation of task/event based asynchronous pattern.", 5 | "version": "0.2.5", 6 | "keywords": [ 7 | "event", 8 | "task-base", 9 | "event machine", 10 | "nested callback terminator" 11 | ], 12 | "dependencies": { 13 | "visionmedia/debug": "*" 14 | }, 15 | "development": { 16 | "chaijs/chai": "*", 17 | "fengmk2/pedding": "*" 18 | }, 19 | "main": "index.js", 20 | "scripts": ["index.js", "lib/eventproxy.js"], 21 | "license": "MIT" 22 | } 23 | -------------------------------------------------------------------------------- /disconf-web/src/test/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | # 3 | # Copyright (C) 2015 KNIGHT, Inc. All Rights Reserved. 4 | # 5 | 6 | # 7 | # \u670D\u52A1\u5668\u7684domain 8 | # 9 | 10 | domain=disconf.com 11 | 12 | # 13 | # \u90AE\u7BB1\u8BBE\u7F6E 14 | # 15 | 16 | EMAIL_MONITOR_ON = false 17 | EMAIL_HOST = smtp.163.com 18 | EMAIL_HOST_PASSWORD = password 19 | EMAIL_HOST_USER = sender@163.com 20 | EMAIL_PORT = 25 21 | DEFAULT_FROM_EMAIL = disconf@163.com 22 | 23 | # 24 | # \u5B9A\u65F6\u6821\u9A8C\u4E2D\u5FC3\u7684\u914D\u7F6E\u4E0E\u6240\u6709\u5BA2\u6237\u7AEF\u914D\u7F6E\u7684\u4E00\u81F4\u6027 25 | # 26 | CHECK_CONSISTENCY_ON= false -------------------------------------------------------------------------------- /disconf-web/src/main/resources/messages/config-controller-info.properties: -------------------------------------------------------------------------------- 1 | 2 | app.not.exist=APP\u627E\u4E0D\u5230! 3 | app.auth.noright=\u4F60\u6CA1\u6709\u6B64app\u7684\u6743\u9650 4 | 5 | version.not.exist=\u7248\u672C\u627E\u4E0D\u5230! 6 | 7 | key.exist=\u914D\u7F6EKEY\u5DF2\u7ECF\u5B58\u5728! 8 | 9 | env.not.exist=\u73AF\u5883\u627E\u4E0D\u5230! 10 | 11 | config.not.exist=\u914D\u7F6E\u4E0D\u5B58\u5728 12 | 13 | conf.item.value.null=\u66F4\u65B0\u5931\u8D25\uFF0C\u914D\u7F6E\u9879\u8F93\u5165\u4E3A\u7A7A 14 | conf.file.name.not.equal=\u4E0A\u4F20\u7684\u914D\u7F6E\u6587\u4EF6\u540D\u5FC5\u987B\u4E0E\u539F\u914D\u7F6E\u6587\u4EF6\u540D\u4E00\u6837 15 | -------------------------------------------------------------------------------- /disconf-client/src/main/java/com/baidu/disconf/client/scan/ScanMgr.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.scan; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * @author liaoqiqi 7 | * @version 2014-7-29 8 | */ 9 | public interface ScanMgr { 10 | 11 | /** 12 | * @throws Exception 13 | */ 14 | void firstScan(List packageNameLit) throws Exception; 15 | 16 | /** 17 | * @throws Exception 18 | */ 19 | void secondScan() throws Exception; 20 | 21 | /** 22 | * reloadable for specify files 23 | * 24 | * @throws Exception 25 | */ 26 | void reloadableScan(String fileName) throws Exception; 27 | } 28 | -------------------------------------------------------------------------------- /disconf-client/src/main/java/com/baidu/disconf/client/core/processor/DisconfCoreProcessor.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.core.processor; 2 | 3 | /** 4 | * 处理算子 5 | * 6 | * @author liaoqiqi 7 | * @version 2014-8-4 8 | */ 9 | public interface DisconfCoreProcessor { 10 | 11 | /** 12 | * 处理所有配置 13 | */ 14 | void processAllItems(); 15 | 16 | /** 17 | * 处理one配置 18 | */ 19 | void processOneItem(String key); 20 | 21 | /** 22 | * 更新指定的配置并进行回调 23 | */ 24 | void updateOneConfAndCallback(String key) throws Exception; 25 | 26 | /** 27 | * 特殊的,将数据注入到配置实体中 28 | */ 29 | void inject2Conf(); 30 | } 31 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/web/auth/constant/LoginConstant.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.web.auth.constant; 2 | 3 | /** 4 | * @author liaoqiqi 5 | * @version 2013-11-28 6 | */ 7 | public class LoginConstant { 8 | 9 | /** 10 | * 存在Redis中的过期时间 30分钟 11 | */ 12 | public static final int SESSION_EXPIRE_TIME = 1800; 13 | 14 | // 30天 15 | public static final int SESSION_EXPIRE_TIME2 = 3600 * 24 * 30; 16 | 17 | public static final String XONE_COOKIE_NAME_STRING = "DISCONF"; 18 | 19 | /** 20 | * 在Cookie的时间,一年 21 | */ 22 | public static final int XONE_COOKIE_AGE = 60 * 60 * 24 * 365; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /disconf-core/src/main/java/com/baidu/disconf/core/common/utils/MyStringUtils.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.core.common.utils; 2 | 3 | import java.util.UUID; 4 | 5 | /** 6 | * 7 | */ 8 | public class MyStringUtils { 9 | 10 | /** 11 | * 12 | */ 13 | private static String getUUID() { 14 | 15 | String s = UUID.randomUUID().toString(); 16 | // 去掉“-”符号 17 | return s.substring(0, 8) + s.substring(9, 13) + s.substring(14, 18) + s.substring(19, 23) + s.substring(24); 18 | } 19 | 20 | /** 21 | * 22 | */ 23 | public static String getRandomName(String name) { 24 | 25 | return name + "-" + getUUID(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/config/utils/ConfigUtils.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.config.utils; 2 | 3 | import com.baidu.disconf.core.common.constants.Constants; 4 | import com.baidu.disconf.core.common.json.ValueVo; 5 | 6 | public class ConfigUtils { 7 | 8 | /** 9 | * @param errorMsg 10 | * 11 | * @return 12 | */ 13 | public static ValueVo getErrorVo(String errorMsg) { 14 | 15 | ValueVo confItemVo = new ValueVo(); 16 | confItemVo.setStatus(Constants.NOTOK); 17 | confItemVo.setValue(""); 18 | confItemVo.setMessage(errorMsg); 19 | 20 | return confItemVo; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/unbiz/common/genericdao/param/BetweenParam.java: -------------------------------------------------------------------------------- 1 | package com.baidu.unbiz.common.genericdao.param; 2 | 3 | /** 4 | * 封装between参数 5 | * 6 | * @author Darwin(Tianxin) 7 | */ 8 | public class BetweenParam { 9 | Object start; 10 | Object end; 11 | 12 | public BetweenParam(Object start, Object end) { 13 | this.start = start; 14 | this.end = end; 15 | } 16 | 17 | /** 18 | * @return the start 19 | */ 20 | public Object getStart() { 21 | return start; 22 | } 23 | 24 | /** 25 | * @return the end 26 | */ 27 | public Object getEnd() { 28 | return end; 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/app/dao/AppDao.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.app.dao; 2 | 3 | import java.util.List; 4 | import java.util.Set; 5 | 6 | import com.baidu.disconf.web.service.app.bo.App; 7 | import com.baidu.unbiz.common.genericdao.dao.BaseDao; 8 | 9 | /** 10 | * @author liaoqiqi 11 | * @version 2014-6-16 12 | */ 13 | public interface AppDao extends BaseDao { 14 | 15 | /** 16 | * @param name 17 | * 18 | * @return 19 | */ 20 | App getByName(String name); 21 | 22 | /** 23 | * @param ids 24 | * 25 | * @return 26 | */ 27 | List getByIds(Set ids); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/dsp/common/form/RequestFormBase.java: -------------------------------------------------------------------------------- 1 | package com.baidu.dsp.common.form; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | 6 | /** 7 | * @author liaoqiqi 8 | */ 9 | public abstract class RequestFormBase implements Serializable { 10 | 11 | /** 12 | * 13 | */ 14 | private static final long serialVersionUID = -7484305986335855048L; 15 | 16 | // 用于存储 修改操作时 修改的字段名列表 17 | private List fieldList; 18 | 19 | public List getFieldList() { 20 | return fieldList; 21 | } 22 | 23 | public void setFieldList(List fieldList) { 24 | this.fieldList = fieldList; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /disconf-client/src/main/java/com/baidu/disconf/client/config/inner/DisInnerConfigAnnotation.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.config.inner; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | /** 10 | * Disconf 自己的配置文件中的项标注 11 | * 12 | * @author liaoqiqi 13 | * @version 2014-6-16 14 | */ 15 | @Target(ElementType.FIELD) 16 | @Retention(RetentionPolicy.RUNTIME) 17 | @Documented 18 | public @interface DisInnerConfigAnnotation { 19 | 20 | String name(); 21 | 22 | String defaultValue() default ""; 23 | } 24 | -------------------------------------------------------------------------------- /disconf-client/src/main/java/com/baidu/disconf/client/fetcher/FetcherMgr.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.fetcher; 2 | 3 | /** 4 | * 下载模块 5 | * 6 | * @author liaoqiqi 7 | * @version 2014-6-12 8 | */ 9 | public interface FetcherMgr { 10 | 11 | /** 12 | * 根据 URL 从远程 获取Value值 13 | */ 14 | String getValueFromServer(String url) throws Exception; 15 | 16 | /** 17 | * 下载配置文件, remoteUrl是目标 url, 下载到预定义的文件夹,并 下载到 targetDirPath 目录下 18 | * 19 | * @throws Exception 20 | */ 21 | String downloadFileFromServer(String url, String fileName, String targetDirPath) throws Exception; 22 | 23 | /** 24 | * 释放资源 25 | */ 26 | void release(); 27 | } 28 | -------------------------------------------------------------------------------- /disconf-client/src/main/java/com/baidu/disconf/client/addons/properties/ReloadableProperties.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.addons.properties; 2 | 3 | import java.util.Properties; 4 | 5 | /** 6 | * For Properties maps that notify about changes. 7 | * Would extend interface java.util.Properties if it were an interface. 8 | * Classes implementing this interface should consider extending {@link DelegatingProperties}. 9 | */ 10 | public interface ReloadableProperties { 11 | 12 | Properties getProperties(); 13 | 14 | void addReloadablePropertiesListener(IReloadablePropertiesListener l); 15 | 16 | boolean removeReloadablePropertiesListener(IReloadablePropertiesListener l); 17 | } 18 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/config/form/ConfListForm.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.config.form; 2 | 3 | import javax.validation.constraints.NotNull; 4 | 5 | import com.baidu.dsp.common.form.RequestListBase; 6 | 7 | import lombok.Data; 8 | 9 | /** 10 | * @author liaoqiqi 11 | * @version 2014-6-23 12 | */ 13 | @Data 14 | public class ConfListForm extends RequestListBase { 15 | 16 | /** 17 | * 18 | */ 19 | private static final long serialVersionUID = -2498128894396346299L; 20 | 21 | @NotNull 22 | private Long appId; 23 | 24 | @NotNull 25 | private String version; 26 | 27 | @NotNull 28 | private Long envId; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /disconf-client/src/main/java/com/baidu/disconf/client/common/update/IDisconfUpdatePipeline.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.common.update; 2 | 3 | /** 4 | * 通用型的配置更新接口。当配置更新 时,用户可以实现此接口,用以来实现回调函数. 5 | */ 6 | public interface IDisconfUpdatePipeline { 7 | 8 | /** 9 | * 配置文件 10 | * 11 | * @param key 12 | * @param filePath 13 | * 14 | * @throws Exception 15 | */ 16 | void reloadDisconfFile(String key, String filePath) throws Exception; 17 | 18 | /** 19 | * 配置项 20 | * 21 | * @param key 22 | * @param content 23 | * 24 | * @throws Exception 25 | */ 26 | void reloadDisconfItem(String key, Object content) throws Exception; 27 | } 28 | -------------------------------------------------------------------------------- /disconf-client/src/main/java/com/baidu/disconf/client/support/registry/RegistryFactory.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.support.registry; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | 5 | import com.baidu.disconf.client.support.registry.impl.SpringRegistry; 6 | 7 | /** 8 | * Created by knightliao on 15/11/26. 9 | */ 10 | public class RegistryFactory { 11 | 12 | /** 13 | * 14 | */ 15 | public static Registry getSpringRegistry(ApplicationContext applicationContext) throws Exception { 16 | 17 | SpringRegistry registry = new SpringRegistry(); 18 | registry.setApplicationContext(applicationContext); 19 | 20 | return registry; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/dsp/common/constant/ModuleCode.java: -------------------------------------------------------------------------------- 1 | package com.baidu.dsp.common.constant; 2 | 3 | /** 4 | * @author liaoqiqi 5 | * @version 2013-12-2 6 | */ 7 | public enum ModuleCode { 8 | 9 | OTHER(0, "Other"), REMOTE(3, "Remote"), EXCEPTION(5, "EXCEPTION"), FILE(6, "FILEUPLOAD"); 10 | ; 11 | 12 | private int code = 0; 13 | private String modelName = null; 14 | 15 | private ModuleCode(int code, String modelName) { 16 | this.code = code; 17 | this.modelName = modelName; 18 | } 19 | 20 | public int getCode() { 21 | return code; 22 | } 23 | 24 | public String getModelName() { 25 | return modelName; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /disconf-client/src/main/java/com/baidu/disconf/client/addons/properties/PropertiesReloadedEvent.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.addons.properties; 2 | 3 | import java.util.Properties; 4 | 5 | public class PropertiesReloadedEvent { 6 | 7 | final ReloadableProperties target; 8 | final Properties oldProperties; 9 | 10 | public PropertiesReloadedEvent(ReloadableProperties target, Properties oldProperties) { 11 | this.target = target; 12 | this.oldProperties = oldProperties; 13 | } 14 | 15 | public ReloadableProperties getTarget() { 16 | return target; 17 | } 18 | 19 | public Properties getOldProperties() { 20 | return oldProperties; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /disconf-web/src/test/java/com/baidu/disconf/web/test/common/BaseNoMockTC.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.test.common; 2 | 3 | import org.springframework.test.context.ActiveProfiles; 4 | import org.springframework.test.context.ContextConfiguration; 5 | import org.springframework.test.context.TestExecutionListeners; 6 | import org.springframework.test.context.transaction.TransactionConfiguration; 7 | 8 | @TestExecutionListeners(BaseTestBeforeClass.class) 9 | @ContextConfiguration(locations = "classpath:applicationContext.xml") 10 | @TransactionConfiguration(transactionManager = "onedbTransactionManagerTest") 11 | @ActiveProfiles({"api-normal", "db-test"}) 12 | public class BaseNoMockTC extends AbstractTestCase { 13 | 14 | } 15 | -------------------------------------------------------------------------------- /disconf-core/src/main/java/com/baidu/disconf/core/common/restful/RestfulFactory.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.core.common.restful; 2 | 3 | import com.baidu.disconf.core.common.restful.impl.RestfulMgrImpl; 4 | import com.baidu.disconf.core.common.restful.retry.impl.RetryStrategyRoundBin; 5 | 6 | /** 7 | * @author liaoqiqi 8 | * @version 2014-8-4 9 | */ 10 | public class RestfulFactory { 11 | 12 | /** 13 | * 获取一个默认的抓取器 14 | * 15 | * @return 16 | * 17 | * @throws Exception 18 | */ 19 | public static RestfulMgr getRestfulMgrNomal() throws Exception { 20 | 21 | RestfulMgr restfulMgr = new RestfulMgrImpl(new RetryStrategyRoundBin()); 22 | 23 | return restfulMgr; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /disconf-web/html/tools/node_modules/ejs/examples/client.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/dsp/common/exception/base/Codeable.java: -------------------------------------------------------------------------------- 1 | package com.baidu.dsp.common.exception.base; 2 | 3 | import java.io.Serializable; 4 | 5 | import com.baidu.dsp.common.constant.ErrorCode; 6 | import com.baidu.dsp.common.constant.ModuleCode; 7 | 8 | /** 9 | * @author liaoqiqi 10 | * @version 2013-12-2 11 | */ 12 | public interface Codeable extends Serializable { 13 | 14 | /** 15 | * 获取异常编码 16 | * 17 | * @return 18 | */ 19 | ErrorCode getErrorCode(); 20 | 21 | /** 22 | * 获取异常消息 23 | * 24 | * @return 25 | */ 26 | String getErrorMessage(); 27 | 28 | /** 29 | * 获取Module代码 30 | * 31 | * @return 32 | */ 33 | ModuleCode getModuleCode(); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/user/facade/impl/UserFacadeImpl.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.user.facade.impl; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import com.baidu.disconf.web.service.user.facade.UserFacade; 9 | import com.baidu.disconf.web.service.user.service.UserMgr; 10 | 11 | /** 12 | * @author liaoqiqi 13 | * @version 2014-1-13 14 | */ 15 | @Service 16 | public class UserFacadeImpl implements UserFacade { 17 | 18 | protected static final Logger LOG = LoggerFactory.getLogger(UserFacadeImpl.class); 19 | 20 | @Autowired 21 | private UserMgr userMgr; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /disconf-client/src/main/java/com/baidu/disconf/client/common/annotations/DisconfFileItem.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.common.annotations; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | /** 10 | * 分布式的配置文件中的ITEM 11 | * 12 | * @author liaoqiqi 13 | * @version 2014-5-16 14 | */ 15 | @Target(ElementType.METHOD) 16 | @Retention(RetentionPolicy.RUNTIME) 17 | @Documented 18 | public @interface DisconfFileItem { 19 | 20 | /** 21 | * 配置文件里的KEY的名字 22 | */ 23 | String name(); 24 | 25 | /** 26 | * 所关联的域 27 | */ 28 | String associateField() default ""; 29 | } 30 | -------------------------------------------------------------------------------- /disconf-client/src/main/java/com/baidu/disconf/client/common/update/IDisconfSysUpdate.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.common.update; 2 | 3 | import com.baidu.disconf.client.core.processor.DisconfCoreProcessor; 4 | import com.baidu.disconf.core.common.constants.DisConfigTypeEnum; 5 | 6 | /** 7 | * 当发生 配置更新 时 此回调会首先被调用 8 | * 9 | * @author liaoqiqi 10 | * @version 2014-5-20 11 | */ 12 | public interface IDisconfSysUpdate { 13 | 14 | /** 15 | * @param disconfCoreMgr 处理算子 16 | * @param disConfigTypeEnum 配置类型 17 | * @param keyName 配置KEY 18 | * 19 | * @throws Exception 20 | */ 21 | void reload(DisconfCoreProcessor disconfCoreMgr, DisConfigTypeEnum disConfigTypeEnum, String keyName) 22 | throws Exception; 23 | } 24 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/env/dao/impl/EnvDaoImpl.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.env.dao.impl; 2 | 3 | import org.springframework.stereotype.Service; 4 | 5 | import com.baidu.disconf.web.service.env.bo.Env; 6 | import com.baidu.disconf.web.service.env.dao.EnvDao; 7 | import com.baidu.dsp.common.dao.AbstractDao; 8 | import com.baidu.dsp.common.dao.Columns; 9 | import com.baidu.unbiz.common.genericdao.operator.Match; 10 | 11 | /** 12 | * @author liaoqiqi 13 | * @version 2014-6-16 14 | */ 15 | @Service 16 | public class EnvDaoImpl extends AbstractDao implements EnvDao { 17 | 18 | @Override 19 | public Env getByName(String name) { 20 | 21 | return findOne(new Match(Columns.NAME, name)); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /docs/source/question/src/disconf-question.rst: -------------------------------------------------------------------------------- 1 | Client常问问题 2 | ============== 3 | 4 | **异常:** ERROR c.b.d.c.c.processor.impl.DisconfCoreProcessUtils - Spring Context is null. Cannot autowire com.szzjcs.commons.thirdapi.push.config.JpushConfig 5 | -------------------------------------------------------------------------------------------------------------------------------------------------------------- 6 | 7 | **可能原因:** 8 | 9 | - 程序没有使用spring环境 10 | - ```` 放在 disconfMgrBean 定义的后面 11 | - 对于版本2.6.28(包括此版本)之前的版本, component-scan 可能没有扫描 12 | ``com.baidu.disconf`` 13 | 14 | **解决办法:** 15 | 16 | - 非静态配置 必须使用spring环境 17 | - ```` 必须出现在disconfMgrBean之前 18 | - 对于版本2.6.28(包括此版本)之前的版本,必须使 component-scan 19 | 增加扫描项 ``com.baidu.disconf`` 20 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/zookeeper/config/ZooConfig.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.zookeeper.config; 2 | 3 | /** 4 | * @author liaoqiqi 5 | * @version 2014-6-24 6 | */ 7 | public class ZooConfig { 8 | 9 | private String zooHosts = ""; 10 | 11 | public String zookeeperUrlPrefix = ""; 12 | 13 | public String getZooHosts() { 14 | return zooHosts; 15 | } 16 | 17 | public void setZooHosts(String zooHosts) { 18 | this.zooHosts = zooHosts; 19 | } 20 | 21 | public String getZookeeperUrlPrefix() { 22 | return zookeeperUrlPrefix; 23 | } 24 | 25 | public void setZookeeperUrlPrefix(String zookeeperUrlPrefix) { 26 | this.zookeeperUrlPrefix = zookeeperUrlPrefix; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/unbiz/common/genericdao/annotation/Sequence.java: -------------------------------------------------------------------------------- 1 | package com.baidu.unbiz.common.genericdao.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * 配置Sequence的annotation 10 | */ 11 | @Retention(RetentionPolicy.RUNTIME) 12 | @Target(ElementType.TYPE) 13 | public @interface Sequence { 14 | 15 | /** 16 | * sequence的名字 17 | * 18 | * @return 下午1:22:37 created by Darwin(Tianxin) 19 | */ 20 | String name(); 21 | 22 | /** 23 | * 该Sequence每次缓存多少个ID 24 | * 25 | * @return 下午1:22:49 created by Darwin(Tianxin) 26 | */ 27 | int size() default 1000; 28 | } 29 | -------------------------------------------------------------------------------- /docs/source/index.rst: -------------------------------------------------------------------------------- 1 | Disconf 2 | ======= 3 | 4 | Distributed Configuration Management Platform(分布式配置管理平台) 5 | 6 | 专注于各种「分布式系统配置管理」的「通用组件」和「通用平台」, 提供统一的「配置管理服务」。 7 | 8 | - disconf: https://github.com/knightliao/disconf 9 | - demos: https://github.com/knightliao/disconf-demos-java 10 | - wiki: https://github.com/knightliao/disconf/wiki 11 | 12 | 推荐 13 | 14 | - 有态度无广告的搜索引擎: https://www.sov5.com 15 | - 高质量的微信公众号阅读: http://www.100weidu.com 16 | - Python中国社区: http://www.python88.com 17 | 18 | .. toctree:: 19 | :maxdepth: 2 20 | :glob: 21 | 22 | install/index 23 | quick/index 24 | tutorial-client/index 25 | tutorial-web/index 26 | config/index 27 | question/index 28 | others/src/contribute 29 | others/src/sponsor 30 | others/src/update 31 | design/index 32 | -------------------------------------------------------------------------------- /disconf-web/src/test/java/com/baidu/disconf/web/test/common/BaseTestBeforeClass.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.test.common; 2 | 3 | import org.springframework.test.context.TestContext; 4 | import org.springframework.test.context.support.AbstractTestExecutionListener; 5 | 6 | /** 7 | * 8 | * @author liaoqiqi 9 | * @version 2014-1-14 10 | */ 11 | public class BaseTestBeforeClass extends AbstractTestExecutionListener { 12 | 13 | /** 14 | * The default implementation is empty. Can be overridden by 15 | * subclasses as necessary. 16 | */ 17 | public void prepareTestInstance(TestContext testContext) throws Exception { 18 | 19 | } 20 | 21 | @Override 22 | public void afterTestClass(TestContext testContext) throws Exception { 23 | 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /docs/myMake.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | md_list=`find source -iname '*.md'` 4 | 5 | for md_item in ${md_list} 6 | do 7 | echo "============== process" ${md_item} "==============" 8 | 9 | target_file=$(echo ${md_item}| cut -d'.' -f 1 ) 10 | target_file_dir=$(dirname ${target_file} ) 11 | target_file_name=$(basename ${target_file}) 12 | target_file_name=${target_file_dir}/src/${target_file_name} 13 | 14 | target_file=${target_file_name}".rst" 15 | if [ -f ${target_file} ] 16 | then 17 | echo rm ${target_file} 18 | rm ${target_file} 19 | fi 20 | echo pandoc --from=markdown --to=rst --output=${target_file} ${md_item} 21 | pandoc -V lang=zh_CN --from=markdown_github --to=rst --output=${target_file} ${md_item} 22 | done 23 | 24 | make html 25 | 26 | -------------------------------------------------------------------------------- /disconf-web/src/test/java/com/baidu/disconf/web/test/common/BaseTestCase.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.test.common; 2 | 3 | import org.springframework.test.context.ActiveProfiles; 4 | import org.springframework.test.context.ContextConfiguration; 5 | import org.springframework.test.context.TestExecutionListeners; 6 | import org.springframework.test.context.transaction.TransactionConfiguration; 7 | 8 | /** 9 | * 所有测试类的基类 10 | * 11 | * @author liaoqiqi 12 | * @version 2013-12-13 13 | */ 14 | @TestExecutionListeners(BaseTestBeforeClass.class) 15 | @ContextConfiguration(locations = "classpath:applicationContext.xml") 16 | @TransactionConfiguration(transactionManager = "onedbTransactionManagerTest") 17 | @ActiveProfiles({ "db-test" }) 18 | public class BaseTestCase extends AbstractTestCase { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /disconf-web/html/dep/jquery-ui-1.10.4.custom/datePicker.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | jQuery UI Example Page 6 | 7 | 8 | 9 | 19 | 20 | 21 | 22 |

    Date:

    23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/dsp/common/exception/AccessDeniedException.java: -------------------------------------------------------------------------------- 1 | package com.baidu.dsp.common.exception; 2 | 3 | import com.baidu.dsp.common.constant.ErrorCode; 4 | import com.baidu.dsp.common.constant.ModuleCode; 5 | import com.baidu.dsp.common.exception.base.RuntimeGlobalException; 6 | 7 | /** 8 | * @author weiwei 9 | * @Description: the method is not accessible to current user 10 | */ 11 | public class AccessDeniedException extends RuntimeGlobalException { 12 | 13 | private static final long serialVersionUID = 1L; 14 | 15 | public AccessDeniedException(String exceptionMessage) { 16 | super(ErrorCode.GLOBAL_ERROR, exceptionMessage); 17 | } 18 | 19 | @Override 20 | public ModuleCode getModuleCode() { 21 | return ModuleCode.OTHER; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/unbiz/common/genericdao/annotation/Column.java: -------------------------------------------------------------------------------- 1 | package com.baidu.unbiz.common.genericdao.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * 标记其对应的数据库字段信息的annotation 10 | */ 11 | @Retention(RetentionPolicy.RUNTIME) 12 | @Target({ElementType.FIELD, ElementType.METHOD}) 13 | public @interface Column { 14 | 15 | /** 16 | * 字段名, 17 | * 18 | * @return 19 | */ 20 | String value(); 21 | 22 | /** 23 | * 是否需要update 24 | * 25 | * @return 上午10:15:15 created by Darwin(Tianxin) 26 | */ 27 | boolean maybeModified() default true; 28 | 29 | boolean ignore() default false; 30 | } 31 | -------------------------------------------------------------------------------- /disconf-client/src/main/java/com/baidu/disconf/client/core/DisconfCoreMgr.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.core; 2 | 3 | /** 4 | * 核心处理模块:包括第一次扫描时配置入库; 第二次扫描时配置注入; 5 | * 6 | * @author liaoqiqi 7 | * @version 2014-6-10 8 | */ 9 | public interface DisconfCoreMgr { 10 | 11 | /** 12 | * (第一次扫描时使用)
    13 | * 1. 获取远程的所有配置数据
    14 | * 2. 注入到仓库中
    15 | * 3. Watch 配置 16 | */ 17 | void process(); 18 | 19 | /** 20 | * (第一次、或额外 扫描时使用)
    21 | * 1. 获取远程的所有配置数据
    22 | * 2. 注入到仓库中
    23 | * 3. Watch 配置 24 | */ 25 | void processFile(String fileName); 26 | 27 | /** 28 | * 特殊的,将数据注入到 配置项、配置文件 的实体中(第二次扫描时使用) 29 | */ 30 | void inject2DisconfInstance(); 31 | 32 | /** 33 | * 释放一些资源 34 | */ 35 | void release(); 36 | } 37 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/common/email/MyAuthenticator.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.common.email; 2 | 3 | import javax.mail.Authenticator; 4 | import javax.mail.PasswordAuthentication; 5 | 6 | /** 7 | * @author liaoqiqi 8 | * @version 2014-3-2 9 | */ 10 | public class MyAuthenticator extends Authenticator { 11 | 12 | String username = null; 13 | String password = null; 14 | 15 | // 通过构造方法接受外部传入的用户信息 16 | public MyAuthenticator(String user, String pass) { 17 | this.username = user; 18 | this.password = pass; 19 | } 20 | 21 | // 覆盖Authenticator类中的getPasswordAuthentication方法 22 | protected PasswordAuthentication getPasswordAuthentication() { 23 | // 使用外部传入的用户名和密码创建对象 24 | return new PasswordAuthentication(username, password); 25 | } 26 | } -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/sign/utils/SignUtils.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.sign.utils; 2 | 3 | import java.util.UUID; 4 | 5 | import org.apache.commons.codec.digest.DigestUtils; 6 | 7 | public class SignUtils { 8 | 9 | /** 10 | * 生成密码, 使用shaHex加密 11 | * 12 | * @return 13 | */ 14 | public static String createPassword(String password) { 15 | 16 | String data = DigestUtils.shaHex(password); 17 | return data; 18 | } 19 | 20 | /** 21 | * 生成token ,使用 UUID + 手机生成 22 | * 23 | * @return 24 | */ 25 | public static String createToken(String phone) { 26 | 27 | String uuid = UUID.randomUUID().toString(); 28 | 29 | String data = DigestUtils.shaHex(uuid + phone); 30 | return data; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /disconf-client/src/main/java/com/baidu/disconf/client/common/annotations/DisconfActiveBackupService.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.common.annotations; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | /** 10 | * 标识需要进行主备切换的服务,需要指定它影响的配置数据,
    11 | * 包括了配置文件和配置项 12 | * 13 | * @author liaoqiqi 14 | * @version 2014-5-16 15 | */ 16 | @Target(ElementType.TYPE) 17 | @Retention(RetentionPolicy.RUNTIME) 18 | @Documented 19 | public @interface DisconfActiveBackupService { 20 | 21 | /** 22 | * 配置文件 23 | */ 24 | Class[] classes() default {}; 25 | 26 | /** 27 | * 配置项 28 | */ 29 | String[] itemKeys() default {}; 30 | } 31 | -------------------------------------------------------------------------------- /disconf-core/src/main/java/com/baidu/disconf/core/common/utils/ZooUtils.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.core.common.utils; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | /** 7 | * ZooUtils 8 | * 9 | * @author liaoqiqi 10 | * @version 2014-7-30 11 | */ 12 | public final class ZooUtils { 13 | 14 | protected static final Logger LOGGER = LoggerFactory 15 | .getLogger(ZooUtils.class); 16 | 17 | private ZooUtils() { 18 | 19 | } 20 | 21 | /** 22 | * 一个可读性良好的路径Value 23 | * 24 | * @return 25 | */ 26 | public static String getIp() { 27 | 28 | try { 29 | return MachineInfo.getHostIp(); 30 | } catch (Exception e) { 31 | LOGGER.error("cannot get host info", e); 32 | return ""; 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /disconf-client/src/test/java/com/baidu/disconf/client/test/support/utils/DirUtils.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.test.support.utils; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | 6 | /** 7 | * @author liaoqiqi 8 | * @version 2014-6-17 9 | */ 10 | public class DirUtils { 11 | 12 | public static File createTempDirectory() throws IOException { 13 | 14 | final File temp; 15 | 16 | temp = File.createTempFile("temp", Long.toString(System.nanoTime())); 17 | 18 | if (!(temp.delete())) { 19 | throw new IOException("Could not delete temp file: " + temp.getAbsolutePath()); 20 | } 21 | 22 | if (!(temp.mkdir())) { 23 | throw new IOException("Could not create temp directory: " + temp.getAbsolutePath()); 24 | } 25 | 26 | return (temp); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /disconf-web/html/unitTpl/leftbar.html.tpl: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /disconf-web/profile/rd/log4j.properties: -------------------------------------------------------------------------------- 1 | 2 | log4j.rootLogger=INFO,dailyRolling,CONSOLE 3 | 4 | log4j.logger.org.apache.zookeeper=WARN 5 | log4j.logger.org.springframework=INFO 6 | log4j.logger.org.springframework.aop.framework.Cglib2AopProxy = INFO 7 | 8 | log4j.appender.dailyRolling=org.apache.log4j.DailyRollingFileAppender 9 | log4j.appender.dailyRolling.File=../log/disconf-log4j.log 10 | log4j.appender.dailyRolling.layout=org.apache.log4j.PatternLayout 11 | log4j.appender.dailyRolling.layout.ConversionPattern=%d [%t] %-5p %-17c{2} (%13F:%L) %3x - %m%n 12 | 13 | log4j.appender.Threshold=WARN 14 | log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender 15 | log4j.appender.CONSOLE.Target=System.out 16 | log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout 17 | log4j.appender.CONSOLE.layout.ConversionPattern=%d [%t] %-5p %-17c{2} (%13F:%L) %3x - %m%n 18 | 19 | 20 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/role/service/impl/RoleMgrImpl.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.role.service.impl; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import com.baidu.disconf.web.service.role.bo.Role; 9 | import com.baidu.disconf.web.service.role.dao.RoleDao; 10 | import com.baidu.disconf.web.service.role.service.RoleMgr; 11 | 12 | /** 13 | * 14 | */ 15 | @Service 16 | public class RoleMgrImpl implements RoleMgr { 17 | 18 | @Autowired 19 | private RoleDao roleDao; 20 | 21 | @Override 22 | public Role get(Integer roleId) { 23 | return roleDao.get(roleId); 24 | } 25 | 26 | @Override 27 | public List findAll() { 28 | return roleDao.findAll(); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/dsp/common/vo/JsonObject.java: -------------------------------------------------------------------------------- 1 | package com.baidu.dsp.common.vo; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import com.baidu.dsp.common.constant.FrontEndInterfaceConstant; 7 | 8 | import lombok.Data; 9 | 10 | /** 11 | * 多层结构的 成功返回 12 | * 13 | * @author liaoqiqi 14 | * @version 2013-12-3 15 | */ 16 | @Data 17 | public class JsonObject extends JsonObjectBase { 18 | 19 | /** 20 | * 21 | */ 22 | private static final long serialVersionUID = -7115209443980058705L; 23 | 24 | private Map result = new HashMap(); 25 | 26 | public JsonObject() { 27 | super(); 28 | success = FrontEndInterfaceConstant.RETURN_OK; 29 | } 30 | 31 | public void addData(String key, Object value) { 32 | result.put(key, value); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /disconf-core/src/test/java/com/baidu/disconf/core/test/TestSuite.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.core.test; 2 | 3 | import org.junit.runner.RunWith; 4 | import org.junit.runners.Suite; 5 | import org.junit.runners.Suite.SuiteClasses; 6 | 7 | import com.baidu.disconf.core.test.path.DisconfWebPathMgrTestCase; 8 | import com.baidu.disconf.core.test.path.ZooPathMgrTestCase; 9 | import com.baidu.disconf.core.test.restful.RestfulMgrTestCase; 10 | import com.baidu.disconf.core.test.utils.MyStringUtilsTestCase; 11 | import com.baidu.disconf.core.test.zookeeper.ZookeeperMgrTest; 12 | 13 | /** 14 | * @author liaoqiqi 15 | * @version 2014-7-30 16 | */ 17 | @RunWith(Suite.class) 18 | @SuiteClasses({DisconfWebPathMgrTestCase.class, ZooPathMgrTestCase.class, RestfulMgrTestCase.class, 19 | ZookeeperMgrTest.class, MyStringUtilsTestCase.class}) 20 | public class TestSuite { 21 | 22 | } -------------------------------------------------------------------------------- /disconf-client/deploy/package-jar.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | package 7 | 8 | 9 | jar 10 | 11 | 12 | false 13 | 14 | 15 | 16 | target/classes 17 | 18 | disconf.properties 19 | logback.xml 20 | 21 | / 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /disconf-client/src/main/java/com/baidu/disconf/client/support/registry/Registry.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.support.registry; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Created by knightliao on 15/11/26. 7 | */ 8 | public interface Registry { 9 | 10 | /** 11 | * 查找Bean 12 | * 13 | * @param type 类型 14 | * 15 | * @return 可找到的Bean的实例列表 16 | */ 17 | List findByType(Class type, boolean newInstance); 18 | 19 | /** 20 | * 查找Bean 21 | * 22 | * @param type 类型 23 | * 24 | * @return 可找到的Bean的实例列表 25 | */ 26 | T getFirstByType(Class type, boolean newInstance); 27 | 28 | /** 29 | * 查找Bean, 是否找proxy 30 | * 31 | * @param type 类型 32 | * 33 | * @return 可找到的Bean的实例列表 34 | */ 35 | T getFirstByType(Class type, boolean newInstance, boolean withProxy); 36 | } 37 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/unbiz/common/genericdao/operator/Match.java: -------------------------------------------------------------------------------- 1 | package com.baidu.unbiz.common.genericdao.operator; 2 | 3 | /** 4 | * 一对参数 5 | * 6 | * @author Darwin(Tianxin) 7 | */ 8 | public class Match implements Pair { 9 | 10 | /** 11 | * @param column 12 | * @param value 13 | */ 14 | public Match(String column, Object value) { 15 | super(); 16 | this.column = column; 17 | this.value = value; 18 | } 19 | 20 | private String column; 21 | private Object value; 22 | 23 | public String getColumn() { 24 | return column; 25 | } 26 | 27 | public void setColumn(String column) { 28 | this.column = column; 29 | } 30 | 31 | public Object getValue() { 32 | return value; 33 | } 34 | 35 | public void setValue(Object value) { 36 | this.value = value; 37 | } 38 | } -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/unbiz/common/genericdao/operator/Order.java: -------------------------------------------------------------------------------- 1 | /** 2 | * adx-common#com.baidu.ub.common.generic.dao.operator.Order.java 3 | * 下午2:53:44 created by Darwin(Tianxin) 4 | */ 5 | package com.baidu.unbiz.common.genericdao.operator; 6 | 7 | /** 8 | * 排序 9 | * 10 | * @author Darwin(Tianxin) 11 | */ 12 | public class Order implements Pair { 13 | 14 | private String column; 15 | 16 | private boolean asc; 17 | 18 | /** 19 | * @param column 20 | * @param asc 21 | */ 22 | public Order(String column, boolean asc) { 23 | this.column = column; 24 | this.asc = asc; 25 | } 26 | 27 | public boolean isAsc() { 28 | return asc; 29 | } 30 | 31 | public String getColumn() { 32 | return column; 33 | } 34 | 35 | public Object getValue() { 36 | return asc; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/config/form/VersionListForm.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.config.form; 2 | 3 | import javax.validation.constraints.NotNull; 4 | 5 | /** 6 | * @author liaoqiqi 7 | * @version 2014-6-22 8 | */ 9 | public class VersionListForm { 10 | 11 | @NotNull 12 | private Long appId; 13 | 14 | // 环境可以为空 15 | private Long envId; 16 | 17 | public Long getAppId() { 18 | return appId; 19 | } 20 | 21 | public void setAppId(Long appId) { 22 | this.appId = appId; 23 | } 24 | 25 | public Long getEnvId() { 26 | return envId; 27 | } 28 | 29 | public void setEnvId(Long envId) { 30 | this.envId = envId; 31 | } 32 | 33 | @Override 34 | public String toString() { 35 | return "VersionListForm [appId=" + appId + ", envId=" + envId + "]"; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/user/dao/impl/UserDaoImpl.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.user.dao.impl; 2 | 3 | import org.springframework.stereotype.Repository; 4 | 5 | import com.baidu.disconf.web.service.user.bo.User; 6 | import com.baidu.disconf.web.service.user.dao.UserDao; 7 | import com.baidu.dsp.common.dao.AbstractDao; 8 | import com.baidu.dsp.common.dao.Columns; 9 | 10 | /** 11 | * @author liaoqiqi 12 | * @version 2013-11-28 13 | */ 14 | @Repository 15 | public class UserDaoImpl extends AbstractDao implements UserDao { 16 | 17 | /** 18 | * 执行SQL 19 | */ 20 | public void executeSql(String sql) { 21 | 22 | executeSQL(sql, null); 23 | } 24 | 25 | /** 26 | */ 27 | @Override 28 | public User getUserByName(String name) { 29 | 30 | return findOne(match(Columns.NAME, name)); 31 | } 32 | 33 | } -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/dsp/common/constraint/PasswordConstraint.java: -------------------------------------------------------------------------------- 1 | package com.baidu.dsp.common.constraint; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | import javax.validation.Constraint; 9 | import javax.validation.Payload; 10 | 11 | import com.baidu.dsp.common.constraint.validation.PasswordValidator; 12 | 13 | /** 14 | * @author liaoqiqi 15 | * @version 2014-1-14 16 | */ 17 | @Target({ElementType.METHOD, ElementType.FIELD}) 18 | @Retention(RetentionPolicy.RUNTIME) 19 | @Constraint(validatedBy = PasswordValidator.class) 20 | public @interface PasswordConstraint { 21 | 22 | String message() default "password.not.right"; 23 | 24 | Class[] groups() default {}; 25 | 26 | Class[] payload() default {}; 27 | } 28 | -------------------------------------------------------------------------------- /disconf-client/src/main/java/com/baidu/disconf/client/usertools/IDisconfDataGetter.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.usertools; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * Created by knightliao on 16/5/28. 7 | *

    8 | * 配置数据获取总控 9 | */ 10 | public interface IDisconfDataGetter { 11 | 12 | /** 13 | * 根据 分布式配置文件 获取该配置文件的所有数据,以 map形式呈现 14 | * 15 | * @param fileName 16 | * 17 | * @return 18 | */ 19 | Map getByFile(String fileName); 20 | 21 | /** 22 | * 获取 分布式配置文件 获取该配置文件 中 某个配置项 的值 23 | * 24 | * @param fileName 25 | * @param fileItem 26 | * 27 | * @return 28 | */ 29 | Object getByFileItem(String fileName, String fileItem); 30 | 31 | /** 32 | * 根据 分布式配置 获取其值 33 | * 34 | * @param itemName 35 | * 36 | * @return 37 | */ 38 | Object getByItem(String itemName); 39 | } 40 | -------------------------------------------------------------------------------- /disconf-client/src/main/java/com/baidu/disconf/client/watch/inner/DisconfSysUpdateCallback.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.watch.inner; 2 | 3 | import com.baidu.disconf.client.common.update.IDisconfSysUpdate; 4 | import com.baidu.disconf.client.core.processor.DisconfCoreProcessor; 5 | import com.baidu.disconf.core.common.constants.DisConfigTypeEnum; 6 | 7 | /** 8 | * 当配置更新时,系统会自动 调用此回调函数
    9 | * 这个函数是系统调用的,当有配置更新时,便会进行回调 10 | * 11 | * @author liaoqiqi 12 | * @version 2014-5-16 13 | */ 14 | public class DisconfSysUpdateCallback implements IDisconfSysUpdate { 15 | 16 | /** 17 | * 18 | */ 19 | @Override 20 | public void reload(DisconfCoreProcessor disconfCoreMgr, DisConfigTypeEnum disConfigTypeEnum, String keyName) 21 | throws Exception { 22 | 23 | // 更新配置数据仓库 && 调用用户的回调函数列表 24 | disconfCoreMgr.updateOneConfAndCallback(keyName); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /disconf-web/html/unitTpl/nav.html.tpl: -------------------------------------------------------------------------------- 1 |

    2 |
    3 |
    4 | 18 |
    19 |
    20 |
    -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/role/bo/RoleEnum.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.role.bo; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | /** 7 | * 角色分配 8 | * 9 | * @author liaoqiqi 10 | * @version 2014-1-13 11 | */ 12 | public enum RoleEnum { 13 | 14 | NORMAL(1), ADMIN(2), READ_ADMIN(3); 15 | private static final Map intToEnum = new HashMap(); 16 | 17 | static { 18 | for (RoleEnum roleEnum : values()) { 19 | intToEnum.put(roleEnum.value, roleEnum); 20 | } 21 | } 22 | 23 | private final int value; 24 | 25 | RoleEnum(int value) { 26 | this.value = value; 27 | } 28 | 29 | public static RoleEnum fromInt(int symbol) { 30 | return intToEnum.get(symbol); 31 | } 32 | 33 | public int getValue() { 34 | return value; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/dsp/common/constraint/PageOrderConstraint.java: -------------------------------------------------------------------------------- 1 | package com.baidu.dsp.common.constraint; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | import javax.validation.Constraint; 9 | import javax.validation.Payload; 10 | 11 | import com.baidu.dsp.common.constraint.validation.PageOrderValidator; 12 | 13 | /** 14 | * \ 15 | * 16 | * @author liaoqiqi 17 | * @version 2014-1-14 18 | */ 19 | @Target({ElementType.METHOD, ElementType.FIELD}) 20 | @Retention(RetentionPolicy.RUNTIME) 21 | @Constraint(validatedBy = PageOrderValidator.class) 22 | public @interface PageOrderConstraint { 23 | 24 | String message() default "page.order.error"; 25 | 26 | Class[] groups() default {}; 27 | 28 | Class[] payload() default {}; 29 | } 30 | -------------------------------------------------------------------------------- /disconf-client/src/main/java/com/baidu/disconf/client/common/annotations/DisconfUpdateService.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.common.annotations; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | /** 10 | * 标识配置更新时需要进行更新的服务,需要指定它影响的配置数据,
    11 | * 可以是配置文件或者是配置项 12 | * 13 | * @author liaoqiqi 14 | * @version 2014-5-16 15 | */ 16 | @Target(ElementType.TYPE) 17 | @Retention(RetentionPolicy.RUNTIME) 18 | @Documented 19 | public @interface DisconfUpdateService { 20 | 21 | /** 22 | * 配置文件 23 | */ 24 | Class[] classes() default {}; 25 | 26 | /** 27 | * 配置文件key名 28 | */ 29 | String[] confFileKeys() default {}; 30 | 31 | /** 32 | * 配置项 33 | */ 34 | String[] itemKeys() default {}; 35 | } 36 | -------------------------------------------------------------------------------- /disconf-client/src/main/java/com/baidu/disconf/client/store/processor/impl/DisconfStorePipelineProcessorImpl.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.store.processor.impl; 2 | 3 | import static com.baidu.disconf.client.store.inner.DisconfCenterStore.getInstance; 4 | 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | import com.baidu.disconf.client.common.update.IDisconfUpdatePipeline; 9 | import com.baidu.disconf.client.store.DisconfStorePipelineProcessor; 10 | 11 | /** 12 | * 13 | */ 14 | public class DisconfStorePipelineProcessorImpl implements DisconfStorePipelineProcessor { 15 | 16 | protected static final Logger LOGGER = LoggerFactory.getLogger(DisconfStorePipelineProcessorImpl.class); 17 | 18 | @Override 19 | public void setDisconfUpdatePipeline(IDisconfUpdatePipeline iDisconfUpdatePipeline) { 20 | 21 | getInstance().setiDisconfUpdatePipeline(iDisconfUpdatePipeline); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/app/form/AppNewForm.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.app.form; 2 | 3 | import javax.validation.constraints.NotNull; 4 | 5 | import org.hibernate.validator.constraints.NotEmpty; 6 | 7 | import com.baidu.dsp.common.form.RequestFormBase; 8 | 9 | import lombok.Data; 10 | 11 | /** 12 | * @author liaoqiqi 13 | * @version 2014-1-24 14 | */ 15 | @Data 16 | public class AppNewForm extends RequestFormBase { 17 | 18 | /** 19 | * 20 | */ 21 | private static final long serialVersionUID = 4329463343279659715L; 22 | 23 | @NotNull(message = "app.empty") 24 | @NotEmpty(message = "app.empty") 25 | private String app; 26 | public final static String APP = "app"; 27 | 28 | @NotNull(message = "desc.empty") 29 | @NotEmpty(message = "desc.empty") 30 | private String desc; 31 | 32 | // 邮箱 33 | private String emails = ""; 34 | 35 | } 36 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/dsp/common/constraint/validation/PasswordValidator.java: -------------------------------------------------------------------------------- 1 | package com.baidu.dsp.common.constraint.validation; 2 | 3 | import javax.validation.ConstraintValidator; 4 | import javax.validation.ConstraintValidatorContext; 5 | 6 | import com.baidu.dsp.common.constraint.PasswordConstraint; 7 | 8 | /** 9 | * @author liaoqiqi 10 | * @version 2014-1-14 11 | */ 12 | public class PasswordValidator implements ConstraintValidator { 13 | 14 | @Override 15 | public void initialize(PasswordConstraint constraintAnnotation) { 16 | 17 | } 18 | 19 | @Override 20 | public boolean isValid(String value, ConstraintValidatorContext context) { 21 | 22 | if (value == null) { 23 | return false; 24 | } 25 | 26 | if (value.length() <= 2) { 27 | return false; 28 | } 29 | 30 | return true; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/dsp/common/exception/DaoException.java: -------------------------------------------------------------------------------- 1 | package com.baidu.dsp.common.exception; 2 | 3 | import com.baidu.dsp.common.constant.ErrorCode; 4 | import com.baidu.dsp.common.constant.ModuleCode; 5 | import com.baidu.dsp.common.exception.base.RuntimeGlobalException; 6 | 7 | /** 8 | * 数据库异常错误 9 | * 10 | * @author liaoqiqi 11 | * @version 2014-6-24 12 | */ 13 | public class DaoException extends RuntimeGlobalException { 14 | 15 | private static final long serialVersionUID = 1L; 16 | 17 | public DaoException(String exceptionMessage) { 18 | super(ErrorCode.DAO_ERROR, exceptionMessage); 19 | } 20 | 21 | @Override 22 | public ModuleCode getModuleCode() { 23 | return ModuleCode.EXCEPTION; 24 | } 25 | 26 | public DaoException(String exceptionMessage, Throwable throwable) { 27 | 28 | super(ErrorCode.DAO_ERROR, exceptionMessage, throwable); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /disconf-client/src/main/java/com/baidu/disconf/client/watch/WatchMgr.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.watch; 2 | 3 | import com.baidu.disconf.client.common.model.DisConfCommonModel; 4 | import com.baidu.disconf.client.core.processor.DisconfCoreProcessor; 5 | import com.baidu.disconf.core.common.constants.DisConfigTypeEnum; 6 | 7 | /** 8 | * 监控的接口 9 | * 10 | * @author liaoqiqi 11 | * @version 2014-7-29 12 | */ 13 | public interface WatchMgr { 14 | 15 | /** 16 | * 初始化 17 | * 18 | * @throws Exception 19 | */ 20 | void init(String hosts, String zooUrlPrefix, boolean debug) throws Exception; 21 | 22 | /** 23 | * 监控路径,监控前会事先创建路径,并且会新建一个自己的Temp子结点 24 | */ 25 | void watchPath(DisconfCoreProcessor disconfCoreMgr, DisConfCommonModel disConfCommonModel, String keyName, 26 | DisConfigTypeEnum disConfigTypeEnum, String value) throws Exception; 27 | 28 | void release(); 29 | } 30 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/env/service/EnvMgr.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.env.service; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | import java.util.Set; 6 | 7 | import com.baidu.disconf.web.service.env.bo.Env; 8 | import com.baidu.disconf.web.service.env.vo.EnvListVo; 9 | 10 | /** 11 | * @author liaoqiqi 12 | * @version 2014-6-16 13 | */ 14 | public interface EnvMgr { 15 | /** 16 | * @param name 17 | */ 18 | Env getByName(String name); 19 | 20 | /** 21 | * @return 22 | */ 23 | List getList(); 24 | 25 | /** 26 | * @return 27 | */ 28 | List getVoList(); 29 | 30 | /** 31 | * @param ids 32 | * 33 | * @return 34 | */ 35 | Map getByIds(Set ids); 36 | 37 | /** 38 | * @param id 39 | * 40 | * @return 41 | */ 42 | Env getById(Long id); 43 | } 44 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/dsp/common/exception/UnExpectedException.java: -------------------------------------------------------------------------------- 1 | package com.baidu.dsp.common.exception; 2 | 3 | import com.baidu.dsp.common.constant.ErrorCode; 4 | import com.baidu.dsp.common.constant.ModuleCode; 5 | import com.baidu.dsp.common.exception.base.RuntimeGlobalException; 6 | 7 | /** 8 | * @author liaoqiqi 9 | * @version 2014-6-24 10 | */ 11 | public class UnExpectedException extends RuntimeGlobalException { 12 | 13 | private static final long serialVersionUID = 1L; 14 | 15 | public UnExpectedException(String exceptionMessage) { 16 | super(ErrorCode.DAO_ERROR, exceptionMessage); 17 | } 18 | 19 | @Override 20 | public ModuleCode getModuleCode() { 21 | return ModuleCode.EXCEPTION; 22 | } 23 | 24 | public UnExpectedException(String exceptionMessage, Throwable throwable) { 25 | 26 | super(ErrorCode.UN_EXPECTED, exceptionMessage, throwable); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/dsp/common/exception/RemoteException.java: -------------------------------------------------------------------------------- 1 | package com.baidu.dsp.common.exception; 2 | 3 | import com.baidu.dsp.common.constant.ErrorCode; 4 | import com.baidu.dsp.common.constant.ModuleCode; 5 | import com.baidu.dsp.common.exception.base.RuntimeGlobalException; 6 | 7 | /** 8 | * 用于远程连接错误 9 | * 10 | * @author liaoqiqi 11 | * @version 2014-1-26 12 | */ 13 | public class RemoteException extends RuntimeGlobalException { 14 | 15 | private static final long serialVersionUID = 1L; 16 | 17 | public RemoteException(String exceptionMessage) { 18 | super(ErrorCode.REMOTE_ERROR, exceptionMessage); 19 | } 20 | 21 | @Override 22 | public ModuleCode getModuleCode() { 23 | return ModuleCode.REMOTE; 24 | } 25 | 26 | public RemoteException(String exceptionMessage, Throwable throwable) { 27 | 28 | super(ErrorCode.REMOTE_ERROR, exceptionMessage, throwable); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/dsp/common/vo/JsonSimpleObject.java: -------------------------------------------------------------------------------- 1 | package com.baidu.dsp.common.vo; 2 | 3 | import com.baidu.dsp.common.constant.FrontEndInterfaceConstant; 4 | 5 | /** 6 | * 顶层结构的成功返回 7 | * 8 | * @author liaoqiqi 9 | * @version 2014-1-21 10 | */ 11 | public class JsonSimpleObject extends JsonObjectBase { 12 | 13 | /** 14 | * 15 | */ 16 | private static final long serialVersionUID = -8022268276600397031L; 17 | 18 | private Object result = new Object(); 19 | 20 | public JsonSimpleObject() { 21 | super(); 22 | success = FrontEndInterfaceConstant.RETURN_OK; 23 | } 24 | 25 | @Override 26 | public String toString() { 27 | return "JsonSimpleObject [result=" + result + "]"; 28 | } 29 | 30 | public Object getResult() { 31 | return result; 32 | } 33 | 34 | public void setResult(Object result) { 35 | this.result = result; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/user/constant/UserConstant.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.user.constant; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | /** 7 | * @author liaoqiqi 8 | * @version 2014-1-13 9 | */ 10 | public class UserConstant { 11 | 12 | protected static final Logger LOG = LoggerFactory.getLogger(UserConstant.class); 13 | 14 | /** 15 | * 是白名单用户 16 | */ 17 | public static final int IS_WHITE_USER = 1; 18 | 19 | /** 20 | * 不是白名单用户 21 | */ 22 | public static final int IS_NOT_WHITE_USER = 0; 23 | 24 | /** 25 | * 在session中缓存visitor的key 26 | */ 27 | public static final String USER_KEY = "user_key"; 28 | 29 | /** 30 | * 系统更新的数据统一用这个 31 | */ 32 | public static final String USER_SYSTEM = "SYSTEM"; 33 | 34 | // 35 | // 36 | // 37 | public static final String USER_APP_SEP = ","; 38 | 39 | } 40 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/unbiz/common/genericdao/sequence/SequenceGenerator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * unbiz-genericdao#com.baidu.unbiz.common.genericdao.sequence.SequenceGenerator.java 3 | * 上午11:15:18 created by Darwin(Tianxin) 4 | */ 5 | package com.baidu.unbiz.common.genericdao.sequence; 6 | 7 | /** 8 | * id生成器 9 | * 10 | * @author Darwin(Tianxin) 11 | */ 12 | public interface SequenceGenerator { 13 | 14 | /** 15 | * @param sequenceName 16 | * 17 | * @return 上午11:27:22 created by Darwin(Tianxin) 18 | */ 19 | Integer getIntKey(String sequenceName); 20 | 21 | /** 22 | * @param sequenceName 23 | * 24 | * @return 上午11:27:34 created by Darwin(Tianxin) 25 | */ 26 | Long getKey(String sequenceName); 27 | 28 | /** 29 | * @param sequenceName 30 | * @param size 上午11:30:02 created by Darwin(Tianxin) 31 | */ 32 | void initialSequence(String sequenceName, int size); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/dsp/common/constraint/CommonNameConstraint.java: -------------------------------------------------------------------------------- 1 | package com.baidu.dsp.common.constraint; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | import javax.validation.Constraint; 9 | import javax.validation.Payload; 10 | import javax.validation.constraints.Pattern; 11 | 12 | /** 13 | * 中文正则匹配校验 14 | * 15 | * @author zhangbi 16 | * @date 2014年1月16日下午4:50:15 17 | */ 18 | @Target({ElementType.METHOD, ElementType.FIELD}) 19 | @Retention(RetentionPolicy.RUNTIME) 20 | @Constraint(validatedBy = {}) 21 | @Pattern(regexp = "^[a-zA-Z0-9\u4e00-\u9fa5\ufe30-\uffa0_-]+$", message = "chinese.pattern.error") 22 | public @interface CommonNameConstraint { 23 | 24 | String message() default ""; 25 | 26 | Class[] groups() default {}; 27 | 28 | Class[] payload() default {}; 29 | } 30 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/dsp/common/exception/FileUploadException.java: -------------------------------------------------------------------------------- 1 | package com.baidu.dsp.common.exception; 2 | 3 | import com.baidu.dsp.common.constant.ErrorCode; 4 | import com.baidu.dsp.common.constant.ModuleCode; 5 | import com.baidu.dsp.common.exception.base.RuntimeGlobalException; 6 | 7 | /** 8 | * 文件上传错误 9 | * 10 | * @author liaoqiqi 11 | * @version 2014-2-20 12 | */ 13 | public class FileUploadException extends RuntimeGlobalException { 14 | 15 | private static final long serialVersionUID = 1L; 16 | 17 | public FileUploadException(String exceptionMessage) { 18 | super(ErrorCode.FILEUPLOAD_ERROR, exceptionMessage); 19 | } 20 | 21 | @Override 22 | public ModuleCode getModuleCode() { 23 | return ModuleCode.FILE; 24 | } 25 | 26 | public FileUploadException(String exceptionMessage, Throwable throwable) { 27 | 28 | super(ErrorCode.FILEUPLOAD_ERROR, exceptionMessage, throwable); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /disconf-web/html/assets/js/newapp.js: -------------------------------------------------------------------------------- 1 | var appId = -1; 2 | var envId = -1; 3 | var version = ""; 4 | getSession(); 5 | 6 | // 提交 7 | $("#item_submit").on("click", function (e) { 8 | $("#error").addClass("hide"); 9 | var app = $("#app").val(); 10 | var desc = $("#desc").val(); 11 | var emails = $("#emails").val(); 12 | 13 | // 验证 14 | if (!desc || !app) { 15 | $("#error").removeClass("hide"); 16 | $("#error").html("表单不能为空或填写格式错误!"); 17 | return; 18 | } 19 | $.ajax({ 20 | type: "POST", 21 | url: "/api/app", 22 | data: { 23 | "app": app, 24 | "desc": desc, 25 | "emails": emails 26 | } 27 | }).done(function (data) { 28 | $("#error").removeClass("hide"); 29 | if (data.success === "true") { 30 | $("#error").html(data.result); 31 | } else { 32 | Util.input.whiteError($("#error"), data); 33 | } 34 | }); 35 | }); 36 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/roleres/service/RoleResourceMgr.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.roleres.service; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | import org.springframework.web.bind.annotation.RequestMethod; 7 | 8 | /** 9 | * 10 | */ 11 | public interface RoleResourceMgr { 12 | 13 | /** 14 | * get all role_resource info in db/cache info in the form of >> 16 | * 17 | * @return 18 | */ 19 | public Map>> getAllAsMap(); 20 | 21 | /** 22 | * evict dspRoleResourceCache so that the next query will get data from db 23 | */ 24 | public void evictCache(); 25 | 26 | /** 27 | * 检查用户是否有权限访问 28 | * 29 | * @param pattern 30 | * @param method 31 | * 32 | * @return 33 | */ 34 | public boolean checkUserPermission(String pattern, RequestMethod method); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /disconf-client/src/test/resources/applicationContext.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/unbiz/common/genericdao/operator/Modify.java: -------------------------------------------------------------------------------- 1 | /** 2 | * adx-common#com.baidu.ub.generic.dao.operator.Modify.java 3 | * 下午8:04:36 created by Darwin(Tianxin) 4 | */ 5 | package com.baidu.unbiz.common.genericdao.operator; 6 | 7 | /** 8 | * 一个字段的update操作 9 | * 10 | * @author Darwin(Tianxin) 11 | */ 12 | public class Modify implements Pair { 13 | 14 | /** 15 | * @param column 16 | * @param value 17 | */ 18 | public Modify(String column, Object value) { 19 | this.column = column; 20 | this.value = value; 21 | } 22 | 23 | private String column; 24 | private Object value; 25 | 26 | public String getColumn() { 27 | return column; 28 | } 29 | 30 | public void setColumn(String column) { 31 | this.column = column; 32 | } 33 | 34 | public Object getValue() { 35 | return value; 36 | } 37 | 38 | public void setValue(Object value) { 39 | this.value = value; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/dsp/common/constraint/validation/PageOrderValidator.java: -------------------------------------------------------------------------------- 1 | package com.baidu.dsp.common.constraint.validation; 2 | 3 | import javax.validation.ConstraintValidator; 4 | import javax.validation.ConstraintValidatorContext; 5 | 6 | import com.baidu.dsp.common.constraint.PageOrderConstraint; 7 | 8 | /** 9 | * @author liaoqiqi 10 | * @version 2014-1-14 11 | */ 12 | public class PageOrderValidator implements ConstraintValidator { 13 | 14 | public static final String ASC = "asc"; 15 | public static final String DESC = "desc"; 16 | 17 | @Override 18 | public void initialize(PageOrderConstraint constraintAnnotation) { 19 | 20 | } 21 | 22 | @Override 23 | public boolean isValid(String value, ConstraintValidatorContext context) { 24 | 25 | if (value.equals(ASC) || value.equals(DESC) || value.isEmpty()) { 26 | return true; 27 | } else { 28 | return false; 29 | } 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/web/auth/login/RedisLogin.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.web.auth.login; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | import javax.servlet.http.HttpSession; 5 | 6 | import com.baidu.disconf.web.service.user.bo.User; 7 | import com.baidu.disconf.web.service.user.dto.Visitor; 8 | 9 | /** 10 | * @author liaoqiqi 11 | * @version 2014-2-4 12 | */ 13 | public interface RedisLogin { 14 | 15 | /** 16 | * 判断是否登录 17 | * 18 | * @param request 19 | * 20 | * @return 21 | */ 22 | Visitor isLogin(HttpServletRequest request); 23 | 24 | /** 25 | * 登录 26 | * 27 | * @param request 28 | */ 29 | void login(HttpServletRequest request, User user, int expireTime); 30 | 31 | /** 32 | * 更新session数据 33 | * 34 | * @param session 35 | * @param visitor 36 | */ 37 | void updateSessionVisitor(HttpSession session, Visitor visitor); 38 | 39 | void logout(HttpServletRequest request); 40 | } 41 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/dsp/common/constraint/ListInConstraint.java: -------------------------------------------------------------------------------- 1 | package com.baidu.dsp.common.constraint; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | import javax.validation.Constraint; 9 | import javax.validation.Payload; 10 | 11 | import com.baidu.dsp.common.constraint.validation.ListInValidator; 12 | 13 | /** 14 | * in 操作,目前仅支持 Integer,用逗号分隔 15 | * 16 | * @author liaoqiqi 17 | * @version 2014-1-26 18 | */ 19 | @Target({ElementType.METHOD, ElementType.FIELD}) 20 | @Retention(RetentionPolicy.RUNTIME) 21 | @Constraint(validatedBy = ListInValidator.class) 22 | public @interface ListInConstraint { 23 | 24 | String message() default "in.list.error"; 25 | 26 | Class[] groups() default {}; 27 | 28 | Class[] payload() default {}; 29 | 30 | /** 31 | * @return 32 | */ 33 | String allowIntegerList() default ""; 34 | } 35 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/dsp/common/utils/IpUtils.java: -------------------------------------------------------------------------------- 1 | package com.baidu.dsp.common.utils; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | 5 | /** 6 | * @author liaoqiqi 7 | * @version 2014-4-23 8 | */ 9 | public class IpUtils { 10 | 11 | public static String getIp(HttpServletRequest request) { 12 | if (null == request) { 13 | return null; 14 | } 15 | String ip = request.getHeader("x-forwarded-for"); 16 | if (!validateIp(ip)) { 17 | ip = request.getHeader("Proxy-Client-IP"); 18 | if (!validateIp(ip)) { 19 | ip = request.getHeader("WL-Proxy-Client-IP"); 20 | if (!validateIp(ip)) { 21 | ip = request.getRemoteAddr(); 22 | } 23 | } 24 | } 25 | return ip; 26 | } 27 | 28 | private static boolean validateIp(String ip) { 29 | return (ip == null || ip.length() == 0 || ip.equalsIgnoreCase("unknown")) ? false : true; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /disconf-client/src/main/java/com/baidu/disconf/client/common/annotations/DisconfItem.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.common.annotations; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | /** 10 | * 分布式的配置项 11 | * 12 | * @author liaoqiqi 13 | * @version 2014-5-16 14 | */ 15 | @Target(ElementType.METHOD) 16 | @Retention(RetentionPolicy.RUNTIME) 17 | @Documented 18 | public @interface DisconfItem { 19 | 20 | /** 21 | * 配置项的KEY,不能为空 22 | */ 23 | String key(); 24 | 25 | /** 26 | * 所关联的域 27 | */ 28 | String associateField() default ""; 29 | 30 | /** 31 | * 环境,,默认为用户指定的环境 32 | */ 33 | String env() default ""; 34 | 35 | /** 36 | * 版本,默认为用户指定的app 37 | */ 38 | String app() default ""; 39 | 40 | /** 41 | * 版本,默认为用户指定的版本 42 | */ 43 | String version() default ""; 44 | } 45 | -------------------------------------------------------------------------------- /disconf-client/src/test/java/com/baidu/disconf/client/test/TestSuite.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.test; 2 | 3 | import org.junit.runner.RunWith; 4 | import org.junit.runners.Suite; 5 | import org.junit.runners.Suite.SuiteClasses; 6 | 7 | import com.baidu.disconf.client.test.config.ConfigMgrTestCase; 8 | import com.baidu.disconf.client.test.core.DisconfCoreMgrTestCase; 9 | import com.baidu.disconf.client.test.fetcher.FetcherMgrMgrTestCase; 10 | import com.baidu.disconf.client.test.json.JsonTranslate; 11 | import com.baidu.disconf.client.test.scan.ScanMgrTestCase; 12 | import com.baidu.disconf.client.test.scan.inner.ScanPackTestCase; 13 | import com.baidu.disconf.client.test.watch.WatchMgrTestCase; 14 | 15 | @RunWith(Suite.class) 16 | @SuiteClasses({ScanPackTestCase.class, DisconfMgrTestCase.class, WatchMgrTestCase.class, ScanMgrTestCase.class, 17 | JsonTranslate.class, FetcherMgrMgrTestCase.class, DisconfCoreMgrTestCase.class, 18 | ConfigMgrTestCase.class}) 19 | public class TestSuite { 20 | 21 | } -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/ub/common/db/DaoPage.java: -------------------------------------------------------------------------------- 1 | package com.baidu.ub.common.db; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import com.baidu.unbiz.common.genericdao.operator.Order; 7 | 8 | /** 9 | * 专门 用于DAO的Page 外部模块不能使用 10 | * 11 | * @author liaoqiqi 12 | */ 13 | public class DaoPage { 14 | 15 | private int pageNo = 1; 16 | private int pageSize = 99999999; 17 | private List orderList = new ArrayList(); 18 | 19 | public int getPageNo() { 20 | return pageNo; 21 | } 22 | 23 | public void setPageNo(int pageNo) { 24 | this.pageNo = pageNo; 25 | } 26 | 27 | public int getPageSize() { 28 | return pageSize; 29 | } 30 | 31 | public void setPageSize(int pageSize) { 32 | this.pageSize = pageSize; 33 | } 34 | 35 | public List getOrderList() { 36 | return orderList; 37 | } 38 | 39 | public void setOrderList(List orderList) { 40 | this.orderList = orderList; 41 | } 42 | 43 | } -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/dsp/common/listener/ContextListener.java: -------------------------------------------------------------------------------- 1 | package com.baidu.dsp.common.listener; 2 | 3 | import javax.servlet.ServletContextEvent; 4 | 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.web.context.ContextLoaderListener; 8 | 9 | public class ContextListener extends ContextLoaderListener { 10 | 11 | private static final Logger logger = LoggerFactory.getLogger(ContextListener.class); 12 | 13 | private static boolean isInitialized = false; 14 | 15 | public void contextDestroyed(ServletContextEvent arg0) { 16 | super.contextDestroyed(arg0); 17 | } 18 | 19 | public void contextInitialized(ServletContextEvent arg0) { 20 | 21 | super.contextInitialized(arg0); 22 | 23 | logger.info("start to load ContextListener"); 24 | 25 | isInitialized = true; 26 | logger.info("end of ContextListener"); 27 | } 28 | 29 | public static boolean isInitialized() { 30 | return isInitialized; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/dsp/common/constraint/UserNameConstraint.java: -------------------------------------------------------------------------------- 1 | package com.baidu.dsp.common.constraint; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | import javax.validation.Constraint; 9 | import javax.validation.Payload; 10 | import javax.validation.constraints.NotNull; 11 | import javax.validation.constraints.Pattern; 12 | import javax.validation.constraints.Size; 13 | 14 | /** 15 | * @author liaoqiqi 16 | * @version 2014-1-14 17 | */ 18 | @NotNull 19 | @Size(min = 3, max = 20) 20 | @Pattern(regexp = "^[a-zA-Z0-9]+$", message = "username.error") 21 | @Target({ElementType.METHOD, ElementType.FIELD}) 22 | @Retention(RetentionPolicy.RUNTIME) 23 | @Constraint(validatedBy = {}) 24 | public @interface UserNameConstraint { 25 | 26 | String message() default "username.error"; 27 | 28 | Class[] groups() default {}; 29 | 30 | Class[] payload() default {}; 31 | } 32 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/dsp/common/listener/StartupListener.java: -------------------------------------------------------------------------------- 1 | package com.baidu.dsp.common.listener; 2 | 3 | import java.util.Locale; 4 | 5 | import javax.servlet.ServletContextEvent; 6 | import javax.servlet.ServletContextListener; 7 | 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | 11 | public class StartupListener implements ServletContextListener { 12 | 13 | private static final Logger logger = LoggerFactory.getLogger(StartupListener.class); 14 | 15 | @Override 16 | public void contextDestroyed(ServletContextEvent arg0) { 17 | 18 | } 19 | 20 | @Override 21 | public void contextInitialized(ServletContextEvent arg0) { 22 | 23 | logger.info("Load StartupListener start..."); 24 | 25 | try { 26 | 27 | Locale.setDefault(Locale.SIMPLIFIED_CHINESE); 28 | 29 | } catch (Throwable t) { 30 | logger.error(t.getMessage(), t); 31 | 32 | System.exit(-1); 33 | } 34 | 35 | logger.info("Load StartupListener end..."); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /disconf-client/src/main/java/com/baidu/disconf/client/addons/properties/ReloadConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.addons.properties; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | /** 7 | * 线程方式的reload 8 | */ 9 | public class ReloadConfiguration implements Runnable { 10 | List reconfigurableBeans; 11 | 12 | public void setReconfigurableBeans(List reconfigurableBeans) { 13 | // early type check, and avoid aliassing 14 | this.reconfigurableBeans = new ArrayList(); 15 | for (Object o : reconfigurableBeans) { 16 | this.reconfigurableBeans.add((ReconfigurableBean) o); 17 | } 18 | } 19 | 20 | public void run() { 21 | for (ReconfigurableBean bean : reconfigurableBeans) { 22 | try { 23 | bean.reloadConfiguration(); 24 | } catch (Exception e) { 25 | throw new RuntimeException("while reloading configuration of " + bean, e); 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /docs/source/tutorial-client/Tutorial9.md: -------------------------------------------------------------------------------- 1 | Tutorial 9 实现真正意义上的统一上线包 2 | ======= 3 | 4 | ### 问题 5 | 6 | 一直以来,凡是使用 disconf的程序均需要 `disconf.properties` ,在这个文件里去控制 app/env/version。 7 | 8 | 因此,我们要部署到不同的环境中,还是需要 不同的 `disconf.properties`。 9 | 10 | 有一种解决方法是,通过 jenkins 来进行打包,准备多份 `disconf.properties` 文件。 11 | 12 | ### 解决方法 13 | 14 | 真正的解决方法是,使用 java 命令行参数 15 | 16 | 目前 disconf 已经支持 `disconf.properties` 中所有配置项 通过参数传入方式 启动。 17 | 18 | 支持的配置项具体可参见: [link](../../config/src/client-config.html) 19 | 20 | 这样的话,未来大家只要通过 Java 参数 就可以 动态的改变启动的 app/env/version 21 | 22 | #### standalone 启动示例 23 | 24 | java -Ddisconf.env=rd \ 25 | -Ddisconf.enable.remote.conf=true \ 26 | -Ddisconf.conf_server_host=127.0.0.1:8000 \ 27 | -Dlogback.configurationFile=logback.xml \ 28 | -Dlog4j.configuration=file:log4j.properties \ 29 | -Djava.ext.dirs=lib \ 30 | -Xms1g -Xmx2g -cp ampq-logback-client-0.0.1-SNAPSHOT.jar \ 31 | com.github.knightliao.consumer.ConsumerMain >/dev/null 2>&1 & 32 | 33 | 这里表示使用 disconf.env=rd 34 | 35 | #### tomcat 启动示例 -------------------------------------------------------------------------------- /disconf-core/src/main/java/com/baidu/disconf/core/common/utils/http/impl/HttpResponseCallbackHandlerJsonHandler.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.core.common.utils.http.impl; 2 | 3 | import java.io.IOException; 4 | 5 | import org.apache.http.HttpEntity; 6 | import org.apache.http.util.EntityUtils; 7 | 8 | import com.baidu.disconf.core.common.utils.http.HttpResponseCallbackHandler; 9 | 10 | /** 11 | * Created by knightliao on 16/1/7. 12 | */ 13 | public class HttpResponseCallbackHandlerJsonHandler implements HttpResponseCallbackHandler { 14 | 15 | private Class clazz = null; 16 | 17 | public HttpResponseCallbackHandlerJsonHandler(Class clazz) { 18 | this.clazz = clazz; 19 | } 20 | 21 | @Override 22 | public T handleResponse(String requestBody, HttpEntity entity) throws IOException { 23 | 24 | String json = EntityUtils.toString(entity, "UTF-8"); 25 | 26 | com.google.gson.Gson gson = new com.google.gson.Gson(); 27 | T response = gson.fromJson(json, clazz); 28 | 29 | return response; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/unbiz/common/genericdao/operator/Query.java: -------------------------------------------------------------------------------- 1 | package com.baidu.unbiz.common.genericdao.operator; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * 封装一个sql操作 7 | * 8 | * @author Darwin(Tianxin) 9 | */ 10 | public class Query { 11 | 12 | /** 13 | * 默认构造函数 14 | * 15 | * @param sql 16 | * @param params 17 | */ 18 | public Query(String sql, List params) { 19 | super(); 20 | this.sql = sql; 21 | this.params = params; 22 | } 23 | 24 | public String getSql() { 25 | return sql; 26 | } 27 | 28 | public List getParams() { 29 | return params; 30 | } 31 | 32 | /** 33 | * @param sql the sql to set 34 | */ 35 | public void setSql(String sql) { 36 | this.sql = sql; 37 | } 38 | 39 | /** 40 | * @param params the params to set 41 | */ 42 | public void setParams(List params) { 43 | this.params = params; 44 | } 45 | 46 | private String sql; 47 | 48 | private List params; 49 | 50 | } 51 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/env/bo/Env.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.env.bo; 2 | 3 | import com.baidu.dsp.common.dao.Columns; 4 | import com.baidu.dsp.common.dao.DB; 5 | import com.baidu.unbiz.common.genericdao.annotation.Column; 6 | import com.baidu.unbiz.common.genericdao.annotation.Table; 7 | import com.github.knightliao.apollo.db.bo.BaseObject; 8 | 9 | /** 10 | * @author liaoqiqi 11 | * @version 2014-6-16 12 | */ 13 | @Table(db = DB.DB_NAME, name = "env", keyColumn = Columns.ENV_ID) 14 | public class Env extends BaseObject { 15 | 16 | /** 17 | * 18 | */ 19 | private static final long serialVersionUID = -665241738023640732L; 20 | 21 | /** 22 | * 23 | */ 24 | @Column(value = Columns.NAME) 25 | private String name; 26 | 27 | public String getName() { 28 | return name; 29 | } 30 | 31 | public void setName(String name) { 32 | this.name = name; 33 | } 34 | 35 | @Override 36 | public String toString() { 37 | return "Env [name=" + name + "]"; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/user/service/impl/AuthMgrImpl.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.user.service.impl; 2 | 3 | import java.util.Set; 4 | 5 | import org.apache.commons.collections.CollectionUtils; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import com.baidu.disconf.web.service.user.service.AuthMgr; 10 | import com.baidu.disconf.web.service.user.service.UserInnerMgr; 11 | 12 | /** 13 | * @author knightliao 14 | */ 15 | @Service 16 | public class AuthMgrImpl implements AuthMgr { 17 | 18 | @Autowired 19 | private UserInnerMgr userInnerMgr; 20 | 21 | @Override 22 | public boolean verifyApp4CurrentUser(Long appId) { 23 | 24 | Set idsLongs = userInnerMgr.getVisitorAppIds(); 25 | 26 | if (CollectionUtils.isEmpty(idsLongs)) { 27 | return true; 28 | } 29 | 30 | if (idsLongs.contains(appId)) { 31 | return true; 32 | } else { 33 | return false; 34 | } 35 | 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /disconf-client/src/main/java/com/baidu/disconf/client/store/processor/model/DisconfValue.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.store.processor.model; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | /** 7 | * 配置的值,配置文件是properties, 配置项是string
    8 | * 这个类是为了做兼容 9 | * 10 | * @author liaoqiqi 11 | * @version 2014-8-4 12 | */ 13 | public class DisconfValue { 14 | 15 | // 配置项使用 16 | private String value; 17 | 18 | // 配置文件使用 19 | private Map fileData = new HashMap(); 20 | 21 | public String getValue() { 22 | return value; 23 | } 24 | 25 | public void setValue(String value) { 26 | this.value = value; 27 | } 28 | 29 | public DisconfValue(String value, Map fileData) { 30 | super(); 31 | this.value = value; 32 | this.fileData = fileData; 33 | } 34 | 35 | public Map getFileData() { 36 | return fileData; 37 | } 38 | 39 | public void setFileData(Map fileData) { 40 | this.fileData = fileData; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /disconf-client/src/test/java/com/baidu/disconf/client/test/model/ServiceA2UpdateCallback.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.test.model; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import com.baidu.disconf.client.common.annotations.DisconfUpdateService; 9 | import com.baidu.disconf.client.common.update.IDisconfUpdate; 10 | 11 | /** 12 | * 分布式配置服务回调函数
    13 | *

    14 | * 1. 使用了分布式配置文件 @DisconfUpdateService 15 | * 16 | * @author liaoqiqi 17 | * @version 2014-5-22 18 | */ 19 | @Service 20 | @DisconfUpdateService(classes = {ConfA.class}) 21 | public class ServiceA2UpdateCallback implements IDisconfUpdate { 22 | 23 | protected static final Logger LOGGER = LoggerFactory.getLogger(ServiceAUpdateCallback.class); 24 | 25 | @Autowired 26 | private ServiceA serviceA; 27 | 28 | /** 29 | * 30 | */ 31 | public void reload() throws Exception { 32 | 33 | LOGGER.info(String.valueOf(serviceA.calcMoneyA2())); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /docs/source/tutorial-web/Tutorial6.md: -------------------------------------------------------------------------------- 1 | Tutorial 6 disconf-web 功能详解 2 | ======= 3 | 4 | ## UI及架构 ## 5 | 6 | [disconf-web](../install/02.html) 7 | 8 | ## 主要功能 9 | 10 | ###新建功能 11 | 12 | - 新建APP 13 | - 新建配置文件、新建配置项 14 | 15 | ###修改功能 16 | 17 | - 修改配置文件 18 | - 修改配置项 19 | 20 | ###删除功能 21 | 22 | - 删除配置文件 23 | - 删除配置项 24 | 25 | ### 下载功能 26 | 27 | - 下载单个配置文件 28 | - 批量下载指定 APP、ENV、VERSION 下的所有配置文件 29 | 30 | ### 查询功能 31 | 32 | - 查询配置功能 33 | - 查询指定 APP、ENV、VERSION 下的所有配置文件列表 34 | - 查询配置文件内容 35 | - 查询配置项内容 36 | - 查询使用此配置的所有实例列表,并且 当实例使用的配置值与中心不一致时,会有飘红提示 37 | - 查询ZK功能 38 | - 查询 指定 APP、ENV、VERSION 下的ZK信息。 39 | 40 | ### 权限功能 41 | 42 | - 用户访问哪些APP可以控制(USER表里的 ownapps 字段) 43 | 44 | ### 手动触发的提醒功能 45 | 46 | - 当新建或修改配置时,会有邮件提醒(app表里的 email 字段) 47 | 48 | ![](http://ww3.sinaimg.cn/mw1024/60c9620fgw1emyv9b06rpj20r40c475i.jpg) 49 | 50 | ### 自动提醒功能 51 | 52 | - 系统可以自动监控 所有实例与 配置中心的值 是否一致,如果不一致,就会报警(app表里的 email 字段) 53 | 54 | ![](http://ww1.sinaimg.cn/mw1024/60c9620fgw1emyvhj84a4j20sq07awfc.jpg) 55 | 56 | ## 注 57 | 58 | - `手动触发的提醒功能` 与 `自动提醒功能` 两个功能的 DIFF 功能 采用的是 [java-diff](http://techv5.com/topic/979/) 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /disconf-client/src/main/java/com/baidu/disconf/client/common/model/DisConfCommonModel.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.common.model; 2 | 3 | /** 4 | * 通用的模型数据,包括 APP,版本,环境,Zookeeper上的URL表示 5 | * 6 | * @author liaoqiqi 7 | * @version 2014-5-20 8 | */ 9 | public class DisConfCommonModel { 10 | 11 | // app 名 12 | private String app; 13 | 14 | // 版本号 15 | private String version; 16 | 17 | // 环境 18 | private String env; 19 | 20 | public String getApp() { 21 | return app; 22 | } 23 | 24 | public void setApp(String app) { 25 | this.app = app; 26 | } 27 | 28 | public String getVersion() { 29 | return version; 30 | } 31 | 32 | public void setVersion(String version) { 33 | this.version = version; 34 | } 35 | 36 | public String getEnv() { 37 | return env; 38 | } 39 | 40 | public void setEnv(String env) { 41 | this.env = env; 42 | } 43 | 44 | @Override 45 | public String toString() { 46 | return "DisConfCommonModel [app=" + app + ", version=" + version + ", env=" + env + "]"; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /disconf-web/html/assets/js/modify_password.js: -------------------------------------------------------------------------------- 1 | var appId = -1; 2 | var envId = -1; 3 | var version = ""; 4 | getSession(); 5 | 6 | // 提交 7 | $("#item_submit").on("click", function (e) { 8 | $("#error").addClass("hide"); 9 | var old_password = $("#old_password").val(); 10 | var new_password = $("#new_password").val(); 11 | var new_password_2 = $("#new_password_2").val(); 12 | 13 | // 验证 14 | if (!old_password || !new_password || !new_password_2) { 15 | $("#error").removeClass("hide"); 16 | $("#error").html("表单不能为空或填写格式错误!"); 17 | return; 18 | } 19 | $.ajax({ 20 | type: "PUT", 21 | url: "/api/account/password", 22 | data: { 23 | "old_password": old_password, 24 | "new_password": new_password, 25 | "new_password_2": new_password_2 26 | } 27 | }).done(function (data) { 28 | $("#error").removeClass("hide"); 29 | if (data.success === "true") { 30 | $("#error").html(data.result); 31 | } else { 32 | Util.input.whiteError($("#error"), data); 33 | } 34 | }); 35 | }); 36 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/user/form/PasswordModifyForm.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.user.form; 2 | 3 | import javax.validation.constraints.NotNull; 4 | 5 | import org.hibernate.validator.constraints.NotEmpty; 6 | 7 | import com.baidu.dsp.common.form.RequestFormBase; 8 | 9 | import lombok.Data; 10 | 11 | /** 12 | * @author liaoqiqi 13 | * @version 2014-1-24 14 | */ 15 | @Data 16 | public class PasswordModifyForm extends RequestFormBase { 17 | 18 | /** 19 | * 20 | */ 21 | @NotNull(message = "password.empty") 22 | @NotEmpty(message = "password.empty") 23 | private String old_password; 24 | public static final String OLD_PASSWORD = "old_password"; 25 | 26 | @NotNull(message = "password.empty") 27 | @NotEmpty(message = "password.empty") 28 | private String new_password; 29 | public static final String NEW_PASSWORD = "new_password"; 30 | 31 | @NotNull(message = "password.empty") 32 | @NotEmpty(message = "password.empty") 33 | private String new_password_2; 34 | public static final String NEW_PASSWORD_2 = "new_password_2"; 35 | 36 | } 37 | -------------------------------------------------------------------------------- /disconf-client/src/main/java/com/baidu/disconf/client/scan/inner/statically/strategy/impl/SpringScanStatic.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.scan.inner.statically.strategy.impl; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.beans.factory.support.DefaultListableBeanFactory; 6 | import org.springframework.context.ApplicationContext; 7 | 8 | import com.baidu.disconf.client.scan.inner.statically.model.ScanStaticModel; 9 | import com.baidu.disconf.client.scan.inner.statically.strategy.ScanStaticStrategy; 10 | 11 | /** 12 | * Created by knightliao on 15/1/23. 13 | */ 14 | public class SpringScanStatic implements ScanStaticStrategy { 15 | 16 | private ApplicationContext context; 17 | private DefaultListableBeanFactory factory; 18 | 19 | /** 20 | * 构造函数 21 | */ 22 | public SpringScanStatic(ApplicationContext context) { 23 | this.context = context; 24 | } 25 | 26 | @Override 27 | public ScanStaticModel scan(List packNameList) { 28 | 29 | factory = (DefaultListableBeanFactory) context.getAutowireCapableBeanFactory(); 30 | return null; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/app/dao/impl/AppDaoImpl.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.app.dao.impl; 2 | 3 | import java.util.List; 4 | import java.util.Set; 5 | 6 | import org.apache.commons.collections.CollectionUtils; 7 | import org.springframework.stereotype.Service; 8 | 9 | import com.baidu.disconf.web.service.app.bo.App; 10 | import com.baidu.disconf.web.service.app.dao.AppDao; 11 | import com.baidu.dsp.common.dao.AbstractDao; 12 | import com.baidu.dsp.common.dao.Columns; 13 | import com.baidu.unbiz.common.genericdao.operator.Match; 14 | 15 | /** 16 | * @author liaoqiqi 17 | * @version 2014-6-16 18 | */ 19 | @Service 20 | public class AppDaoImpl extends AbstractDao implements AppDao { 21 | 22 | @Override 23 | public App getByName(String name) { 24 | 25 | return findOne(new Match(Columns.NAME, name)); 26 | } 27 | 28 | @Override 29 | public List getByIds(Set ids) { 30 | 31 | if (CollectionUtils.isEmpty(ids)) { 32 | return findAll(); 33 | } 34 | 35 | return find(match(Columns.APP_ID, ids)); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /disconf-client/src/main/java/com/baidu/disconf/client/scan/inner/statically/StaticScannerMgrFactory.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.scan.inner.statically; 2 | 3 | import com.baidu.disconf.client.scan.inner.statically.impl.StaticScannerFileMgrImpl; 4 | import com.baidu.disconf.client.scan.inner.statically.impl.StaticScannerItemMgrImpl; 5 | import com.baidu.disconf.client.scan.inner.statically.impl.StaticScannerNonAnnotationFileMgrImpl; 6 | 7 | /** 8 | * @author liaoqiqi 9 | * @version 2014-9-9 10 | */ 11 | public class StaticScannerMgrFactory { 12 | 13 | /** 14 | * 配置文件处理 15 | 16 | */ 17 | public static StaticScannerMgr getDisconfFileStaticScanner() { 18 | return new StaticScannerFileMgrImpl(); 19 | } 20 | 21 | /** 22 | * 配置项处理 23 | 24 | */ 25 | public static StaticScannerMgr getDisconfItemStaticScanner() { 26 | return new StaticScannerItemMgrImpl(); 27 | } 28 | 29 | /** 30 | * 非注解的配置文件处理 31 | 32 | */ 33 | public static StaticScannerMgr getDisconfNonAnnotationFileStaticScanner() { 34 | return new StaticScannerNonAnnotationFileMgrImpl(); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/dsp/common/constraint/validation/MaxValidatorForDouble.java: -------------------------------------------------------------------------------- 1 | package com.baidu.dsp.common.constraint.validation; 2 | 3 | import java.math.BigDecimal; 4 | 5 | import javax.validation.ConstraintValidator; 6 | import javax.validation.ConstraintValidatorContext; 7 | 8 | import com.baidu.dsp.common.constraint.DoubleMax; 9 | 10 | /** 11 | * @author liaoqiqi 12 | */ 13 | public class MaxValidatorForDouble implements ConstraintValidator { 14 | 15 | private double maxValue; 16 | 17 | public void initialize(DoubleMax maxValue) { 18 | this.maxValue = maxValue.value(); 19 | } 20 | 21 | public boolean isValid(Double value, ConstraintValidatorContext constraintValidatorContext) { 22 | 23 | // null values are valid 24 | if (value == null) { 25 | return true; 26 | } 27 | 28 | BigDecimal premium = BigDecimal.valueOf(value); 29 | BigDecimal netToCompany = BigDecimal.valueOf(maxValue); 30 | 31 | BigDecimal commission = premium.subtract(netToCompany); 32 | 33 | return commission.compareTo(BigDecimal.ZERO) <= 0; 34 | } 35 | } -------------------------------------------------------------------------------- /disconf-web/src/main/resources/ehcache.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 10 | 11 | 15 | 16 | 19 | 20 | 23 | 24 | -------------------------------------------------------------------------------- /docs/source/others/src/users.rst: -------------------------------------------------------------------------------- 1 | 用户列表 2 | ======== 3 | 4 | 使用公司列表 5 | ------------ 6 | 7 | - [百度](20+条产品线使用) 8 | - `滴滴出行(上海/北京) `__ 9 | - [银联] 10 | - `网易 `__ 11 | - `苏宁易购 `__ (搜索中心数据处理平台) 12 | - 顺丰科技 13 | - `润生活 `__ (千万融资,全线产品使用) 14 | - `拉勾网 `__ 15 | - `人脉通 `__ (目前已B轮融资,4条产品线使用) 16 | - `普联(Tp-link)技术有限公司 `__ 17 | - `杭州数梦工场科技有限公司 `__ 18 | - `众钱网 `__ 19 | - `快速递 `__ 20 | - `杭州同盾科技 `__ 21 | - `杭州趣维科技 `__ (数千万RMB A轮投资) 22 | - `百世物流科技 `__ 23 | (在全国建立了400多个运作中心和250万平米的仓库及转运中心,拥有30000多员工和上万个认证加盟商及合作伙伴) 24 | - `仙人掌股票 `__\ (2015年度最火app,所有产品线已全面接入disconf) 25 | - `多点APP `__ 26 | - `上海华禽网络科技有限公司 `__ 27 | (整个公司所有产品线均在使用) 28 | - 新东方在线 29 | - 深圳斯凯荣科技 30 | - `更多 `__ 31 | 32 | 正在关注 33 | -------- 34 | 35 | - 洋码头 36 | - 新意互动 37 | -------------------------------------------------------------------------------- /disconf-client/src/test/java/com/baidu/disconf/client/test/model/ServiceA.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.test.model; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.beans.factory.annotation.Value; 5 | import org.springframework.stereotype.Service; 6 | 7 | import com.baidu.disconf.client.common.annotations.DisconfItem; 8 | 9 | /** 10 | * 服务A,他使用的是 ConfA 11 | * 12 | * @author liaoqiqi 13 | * @version 2014-5-16 14 | */ 15 | @Service 16 | public class ServiceA { 17 | 18 | /** 19 | * 1. 分布式配置项,keyB是其全局Key名
    20 | */ 21 | @Value(value = "10") 22 | private int varAA; 23 | 24 | public static final String keyA = "keyA"; 25 | 26 | @Autowired 27 | private ConfA confA; 28 | 29 | public long calcMoneyA() { 30 | return confA.getVarA(); 31 | } 32 | 33 | public long calcMoneyA2() { 34 | return confA.getVarA2(); 35 | } 36 | 37 | @DisconfItem(key = ServiceA.keyA) 38 | public int getVarAA() { 39 | return varAA; 40 | } 41 | 42 | public void setVarAA(int varAA) { 43 | this.varAA = varAA; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/zookeeper/form/ZkDeployForm.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.zookeeper.form; 2 | 3 | import javax.validation.constraints.NotNull; 4 | 5 | /** 6 | * @author liaoqiqi 7 | * @version 2014-9-11 8 | */ 9 | public class ZkDeployForm { 10 | 11 | @NotNull 12 | private Long appId; 13 | 14 | @NotNull 15 | private String version; 16 | 17 | @NotNull 18 | private Long envId; 19 | 20 | public Long getAppId() { 21 | return appId; 22 | } 23 | 24 | public void setAppId(Long appId) { 25 | this.appId = appId; 26 | } 27 | 28 | public String getVersion() { 29 | return version; 30 | } 31 | 32 | public void setVersion(String version) { 33 | this.version = version; 34 | } 35 | 36 | public Long getEnvId() { 37 | return envId; 38 | } 39 | 40 | public void setEnvId(Long envId) { 41 | this.envId = envId; 42 | } 43 | 44 | @Override 45 | public String toString() { 46 | return "ZkDeployForm [appId=" + appId + ", version=" + version + ", envId=" + envId + "]"; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/dsp/common/constraint/validation/MinValidatorForDouble.java: -------------------------------------------------------------------------------- 1 | package com.baidu.dsp.common.constraint.validation; 2 | 3 | import java.math.BigDecimal; 4 | 5 | import javax.validation.ConstraintValidator; 6 | import javax.validation.ConstraintValidatorContext; 7 | 8 | import com.baidu.dsp.common.constraint.DoubleMin; 9 | 10 | /** 11 | * @author liaoqiqi 12 | */ 13 | public class MinValidatorForDouble implements ConstraintValidator { 14 | 15 | private double minValue; 16 | 17 | public void initialize(DoubleMin minValue) { 18 | this.minValue = minValue.value(); 19 | } 20 | 21 | public boolean isValid(Double value, ConstraintValidatorContext constraintValidatorContext) { 22 | 23 | // null values are valid 24 | if (value == null) { 25 | return true; 26 | } 27 | 28 | BigDecimal premium = BigDecimal.valueOf(value); 29 | BigDecimal netToCompany = BigDecimal.valueOf(minValue); 30 | 31 | BigDecimal commission = premium.subtract(netToCompany); 32 | 33 | return commission.compareTo(BigDecimal.ZERO) >= 0; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /disconf-client/src/main/java/com/baidu/disconf/client/store/DisconfStoreProcessorFactory.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.store; 2 | 3 | import com.baidu.disconf.client.store.processor.impl.DisconfStoreFileProcessorImpl; 4 | import com.baidu.disconf.client.store.processor.impl.DisconfStoreItemProcessorImpl; 5 | import com.baidu.disconf.client.store.processor.impl.DisconfStorePipelineProcessorImpl; 6 | 7 | /** 8 | * 仓库算子仓库 9 | * 10 | * @author liaoqiqi 11 | * @version 2014-8-4 12 | */ 13 | public class DisconfStoreProcessorFactory { 14 | 15 | /** 16 | * 获取配置文件仓库算子 17 | */ 18 | public static DisconfStoreProcessor getDisconfStoreFileProcessor() { 19 | 20 | return new DisconfStoreFileProcessorImpl(); 21 | } 22 | 23 | /** 24 | * 获取配置项仓库算子 25 | */ 26 | public static DisconfStoreProcessor getDisconfStoreItemProcessor() { 27 | 28 | return new DisconfStoreItemProcessorImpl(); 29 | } 30 | 31 | /** 32 | * 33 | */ 34 | public static DisconfStorePipelineProcessor getDisconfStorePipelineProcessor() { 35 | 36 | return new DisconfStorePipelineProcessorImpl(); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /disconf-client/src/test/java/com/baidu/disconf/client/test/model/ServiceAUpdateCallback.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.test.model; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import com.baidu.disconf.client.common.annotations.DisconfUpdateService; 9 | import com.baidu.disconf.client.common.update.IDisconfUpdate; 10 | 11 | /** 12 | * 分布式配置服务回调函数
    13 | *

    14 | * 1. 使用了分布式配置文件 @DisconfUpdateService 15 | * 16 | * @author liaoqiqi 17 | * @version 2014-5-22 18 | */ 19 | @Service("serviceAUpdateCallback") 20 | @DisconfUpdateService(classes = {ConfA.class}, itemKeys = {ServiceA.keyA}) 21 | public class ServiceAUpdateCallback implements IDisconfUpdate { 22 | 23 | protected static final Logger LOGGER = LoggerFactory.getLogger(ServiceAUpdateCallback.class); 24 | 25 | @Autowired 26 | private ServiceA serviceA; 27 | 28 | /** 29 | * 30 | */ 31 | public void reload() throws Exception { 32 | 33 | LOGGER.info(String.valueOf(serviceA.calcMoneyA())); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /disconf-core/src/main/java/com/baidu/disconf/core/common/utils/GsonUtils.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.core.common.utils; 2 | 3 | import java.lang.reflect.Type; 4 | import java.util.Map; 5 | 6 | import com.google.gson.Gson; 7 | import com.google.gson.reflect.TypeToken; 8 | 9 | /** 10 | * Google Json工具 11 | * 12 | * @author liaoqiqi 13 | * @version 2014-6-16 14 | */ 15 | public final class GsonUtils { 16 | 17 | private GsonUtils() { 18 | 19 | } 20 | 21 | /** 22 | * @param object 23 | * @return 24 | */ 25 | public static String toJson(Object object) { 26 | 27 | Gson gson = new Gson(); 28 | String json = gson.toJson(object); 29 | return json; 30 | } 31 | 32 | /** 33 | * Parse json to map 34 | * 35 | * @param json 36 | * @return 37 | */ 38 | public static Map parse2Map(String json) { 39 | 40 | Type stringStringMap = new TypeToken>() { 41 | }.getType(); 42 | 43 | Gson gson = new Gson(); 44 | Map map = gson.fromJson(json, stringStringMap); 45 | 46 | return map; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /disconf-web/deploy/build_java.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # War包的部署 5 | # 6 | 7 | # 8 | if [ $# -le 0 ];then 9 | echo "**********************************************" 10 | echo "use online profile" 11 | echo "**********************************************" 12 | mvn clean 13 | mvn package install -Dmaven.test.skip=true -Ponline -U 14 | else 15 | 16 | if [ "$1" == "rd" ];then 17 | echo "**********************************************" 18 | echo "use default profile(RD)" 19 | echo "**********************************************" 20 | mvn clean 21 | mvn package install -Dmaven.test.skip=true -U 22 | else 23 | echo "**********************************************" 24 | echo "use the following as profile" 25 | echo $1 26 | echo "**********************************************" 27 | mvn clean 28 | mvn package install -P$1 -U 29 | fi 30 | fi 31 | 32 | # 33 | # 34 | # 35 | if [ -d "output" ]; then 36 | printf '%s\n' "Removing output" 37 | rm -rf output 38 | fi 39 | 40 | mkdir -p output 41 | 42 | cp target/disconf-web.war output 43 | 44 | 45 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/dsp/common/exception/base/DspException.java: -------------------------------------------------------------------------------- 1 | package com.baidu.dsp.common.exception.base; 2 | 3 | import com.baidu.dsp.common.constant.ErrorCode; 4 | 5 | /** 6 | * 所有Exception异常类的基类 7 | * 8 | * @author liaoqiqi 9 | * @version 2013-12-2 10 | */ 11 | public abstract class DspException extends Exception implements GlobalExceptionAware { 12 | 13 | /** 14 | * 15 | */ 16 | private static final long serialVersionUID = 3700791594685854374L; 17 | protected String exceptionMessage; 18 | protected ErrorCode errorCode; 19 | 20 | public DspException() { 21 | super(); 22 | } 23 | 24 | public DspException(ErrorCode errorCode, String message, Throwable cause) { 25 | super(message, cause); 26 | this.errorCode = errorCode; 27 | } 28 | 29 | /** 30 | * 获取异常编码 31 | * 32 | * @return 33 | */ 34 | public ErrorCode getErrorCode() { 35 | return errorCode; 36 | } 37 | 38 | /** 39 | * 获取异常消息 40 | * 41 | * @return 42 | */ 43 | public String getErrorMessage() { 44 | 45 | return exceptionMessage; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /disconf-client/src/main/java/com/baidu/disconf/client/common/annotations/DisconfFile.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.common.annotations; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | /** 10 | * 分布式的配置文件 11 | * 12 | * @author liaoqiqi 13 | * @version 2014-5-16 14 | */ 15 | @Target(ElementType.TYPE) 16 | @Retention(RetentionPolicy.RUNTIME) 17 | @Documented 18 | public @interface DisconfFile { 19 | 20 | /** 21 | * 配置文件名,必须指定 22 | */ 23 | String filename(); 24 | 25 | /** 26 | * 环境,默认为用户指定的环境 27 | */ 28 | String env() default ""; 29 | 30 | /** 31 | * 版本,默认为用户指定的版本 32 | */ 33 | String version() default ""; 34 | 35 | /** 36 | * 版本,默认为用户指定的app 37 | */ 38 | String app() default ""; 39 | 40 | /** 41 | * 配置文件目标地址dir, 以"/"开头则是系统的全路径,否则则是相对于classpath的路径,默认是classpath根路径 42 | * 注意:根路径要注意是否有权限,否则会出现找不到路径,推荐采用相对路径 43 | * 44 | * @return 45 | */ 46 | String targetDirPath() default ""; 47 | } 48 | -------------------------------------------------------------------------------- /docs/source/tutorial-client/Tutorial13-unify-notify.md: -------------------------------------------------------------------------------- 1 | Tutorial 13 增加统一的回调类 (unify-notify模式) 灵活处理更新配置通知 2 | ======= 3 | 4 | ### 目的 5 | 6 | 当 任意的 配置文件 或 配置项 得到更新时,此类 就会被调用。 7 | 8 | 它与 [Tutorial2](Tutorial2.html) 不一样,不需要注解,不需要必须指定变更地象。更加freely,方便大家在这里统一的、自由的控制更新逻辑. 9 | 10 | ### 示例项目 11 | 12 | https://github.com/knightliao/disconf-demos-java/tree/master/disconf-standalone-demo 13 | 14 | ### demo 15 | 16 | 只要实现 `IDisconfUpdatePipeline` 接口即可。不要求必须是 java bean. 17 | 18 | - 函数 `reloadDisconfFile` 是针对分布式配置文件的。key是文件名;filePath是文件路径。用户可以在这里(read file freely)按你喜欢的解析文件的方式进行处理。 19 | - 函数 `reloadDisconfItem` 是针对分布式配置项的。key是配置项名;content是其值,并且含有类型信息。 20 | 21 | 示例代码: 22 | 23 | /** 24 | */ 25 | @Service 26 | public class UpdatePipelineCallback implements IDisconfUpdatePipeline { 27 | 28 | public void reloadDisconfFile(String key, String filePath) throws Exception { 29 | System.out.println(key + " : " + filePath); 30 | } 31 | 32 | public void reloadDisconfItem(String key, Object content) throws Exception { 33 | System.out.println(key + " : " + content); 34 | } 35 | } 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /disconf-web/bin/sql/get_create_one_user_sql.sql.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf8 3 | """ 4 | @author: liaoqiqi 5 | 6 | 93b9e2669a8965572610063d07559e6d 7 | 8 | a195225bc1867d6a15aff7859ca076198d1d97b2 9 | 10 | /* msoa msoaSH*/ 11 | INSERT INTO `user` (`user_id`, `name`, `password`, `token`, `ownapps`,`role_id`) VALUES (null, 'msoa', 'a195225bc1867d6a15aff7859ca076198d1d97b2', '3da70a83f9d386362fd5dfa369ddda3f95a86508','', '2'); 12 | 13 | 14 | """ 15 | 16 | import hashlib 17 | import uuid 18 | 19 | if __name__ == '__main__': 20 | user_name = raw_input('name:') 21 | password = raw_input('password:') 22 | ownApps = raw_input('ownapps(空表示所有app):') 23 | role_id = raw_input('role(正常角色(1);管理员(2);只读管理员(3)):') 24 | 25 | sha1 = hashlib.sha1() 26 | sha1.update(password) 27 | new_password = sha1.hexdigest() 28 | 29 | dat = str(uuid.uuid4()) 30 | sha1.update(dat + user_name) 31 | token = sha1.hexdigest() 32 | 33 | print "INSERT INTO `user` (`user_id`, `name`, `password`, `token`,`ownapps`,`role_id`) VALUES " \ 34 | + "(null,'" + user_name + "' , '" + new_password + "' , '" + token + "' , '" + ownApps + "' ," + role_id + ")" 35 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/config/bo/ConfigHistory.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.config.bo; 2 | 3 | import com.baidu.dsp.common.dao.Columns; 4 | import com.baidu.dsp.common.dao.DB; 5 | import com.baidu.unbiz.common.genericdao.annotation.Column; 6 | import com.baidu.unbiz.common.genericdao.annotation.Table; 7 | import com.github.knightliao.apollo.db.bo.BaseObject; 8 | 9 | import lombok.Data; 10 | 11 | @Data 12 | @Table(db = DB.DB_NAME, name = "config_history", keyColumn = "id") 13 | public class ConfigHistory extends BaseObject { 14 | 15 | /** 16 | * 17 | */ 18 | @Column(value = Columns.CONFIG_ID) 19 | private Long configId; 20 | 21 | /** 22 | * 23 | */ 24 | @Column(value = "old_value") 25 | private String oldValue; 26 | 27 | /** 28 | * 29 | */ 30 | @Column(value = "new_value") 31 | private String newValue; 32 | 33 | /** 34 | * 创建时间 35 | */ 36 | @Column(value = Columns.CREATE_TIME) 37 | private String createTime; 38 | 39 | /** 40 | * 41 | */ 42 | @Column(value = Columns.UPDATE_BY) 43 | private Long updateBy; 44 | 45 | } 46 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/dsp/common/utils/DaoUtils.java: -------------------------------------------------------------------------------- 1 | package com.baidu.dsp.common.utils; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.apache.commons.lang3.StringUtils; 7 | 8 | import com.baidu.dsp.common.form.RequestListBase.Page; 9 | import com.baidu.ub.common.db.DaoPage; 10 | import com.baidu.unbiz.common.genericdao.operator.Order; 11 | 12 | /** 13 | * DAO有用的Utils 14 | * 15 | * @author liaoqiqi 16 | */ 17 | public class DaoUtils { 18 | 19 | /** 20 | * 将业务的Page转成Dao的Page 21 | * 22 | * @param page 23 | * 24 | * @return 25 | */ 26 | public static DaoPage daoPageAdapter(Page page) { 27 | 28 | DaoPage daoPage = new DaoPage(); 29 | 30 | daoPage.setPageNo(page.getPageNo()); 31 | daoPage.setPageSize(page.getPageSize()); 32 | 33 | List orderList = new ArrayList(); 34 | if (!StringUtils.isEmpty(page.getOrderBy())) { 35 | Order order = new Order(page.getOrderBy(), page.isAsc()); 36 | orderList.add(order); 37 | } 38 | daoPage.setOrderList(orderList); 39 | 40 | return daoPage; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /disconf-web/html/assets/js/newconfigitem.js: -------------------------------------------------------------------------------- 1 | var appId = -1; 2 | var envId = -1; 3 | var version = ""; 4 | getSession(); 5 | 6 | // 提交 7 | $("#item_submit").on("click", function (e) { 8 | $("#error").addClass("hide"); 9 | 10 | if (version == '自定义版本') { 11 | version = $('#selfversion_value').val(); 12 | } 13 | 14 | var key = $("#key").val(); 15 | var value = $("#value").val(); 16 | 17 | // 验证 18 | if (appId < 1 || envId < 1 || version == "" || !value || !key) { 19 | $("#error").removeClass("hide"); 20 | $("#error").html("表单不能为空或填写格式错误!"); 21 | return; 22 | } 23 | $.ajax({ 24 | type: "POST", 25 | url: "/api/web/config/item", 26 | data: { 27 | "appId": appId, 28 | "version": version, 29 | "key": key, 30 | "envId": envId, 31 | "value": value 32 | } 33 | }).done(function (data) { 34 | $("#error").removeClass("hide"); 35 | if (data.success === "true") { 36 | $("#error").html(data.result); 37 | } else { 38 | Util.input.whiteError($("#error"), data); 39 | } 40 | }); 41 | }); 42 | -------------------------------------------------------------------------------- /disconf-client/src/test/java/com/baidu/disconf/client/test/watch/mock/WatchMgrMock.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.client.test.watch.mock; 2 | 3 | import com.baidu.disconf.client.common.model.DisConfCommonModel; 4 | import com.baidu.disconf.client.core.processor.DisconfCoreProcessor; 5 | import com.baidu.disconf.client.watch.WatchMgr; 6 | import com.baidu.disconf.core.common.constants.DisConfigTypeEnum; 7 | 8 | import mockit.Mock; 9 | import mockit.MockUp; 10 | 11 | /** 12 | * Watch MOckup 13 | * 14 | * @author liaoqiqi 15 | * @version 2014-7-31 16 | */ 17 | public class WatchMgrMock extends MockUp { 18 | 19 | @Mock 20 | public void init(String hosts, String zooUrlPrefix, boolean debug) throws Exception { 21 | return; 22 | } 23 | 24 | /** 25 | * 监控路径,监控前会事先创建路径,并且会新建一个自己的Temp子结点 26 | */ 27 | @Mock 28 | public void watchPath(DisconfCoreProcessor disconfCoreMgr, DisConfCommonModel disConfCommonModel, String keyName, 29 | DisConfigTypeEnum disConfigTypeEnum, String value) throws Exception { 30 | 31 | return; 32 | } 33 | 34 | @Mock 35 | public void release() { 36 | return; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/disconf/web/service/zookeeper/service/ZkDeployMgr.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.web.service.zookeeper.service; 2 | 3 | import java.util.Map; 4 | 5 | import com.baidu.disconf.core.common.constants.DisConfigTypeEnum; 6 | import com.baidu.disconf.web.service.zookeeper.dto.ZkDisconfData; 7 | 8 | /** 9 | * @author liaoqiqi 10 | * @version 2014-9-11 11 | */ 12 | public interface ZkDeployMgr { 13 | 14 | /** 15 | * @param appId 16 | * @param envId 17 | * @param version 18 | * 19 | * @return 20 | */ 21 | String getDeployInfo(String app, String env, String version); 22 | 23 | /** 24 | * @param app 25 | * @param env 26 | * @param version 27 | * 28 | * @return 29 | */ 30 | Map getZkDisconfDataMap(String app, String env, String version); 31 | 32 | /** 33 | * 获取指定的数据 34 | * 35 | * @param app 36 | * @param env 37 | * @param version 38 | * 39 | * @return 40 | */ 41 | ZkDisconfData getZkDisconfData(String app, String env, String version, DisConfigTypeEnum disConfigTypeEnum, 42 | String keyName); 43 | } 44 | -------------------------------------------------------------------------------- /disconf-core/src/main/java/com/baidu/disconf/core/common/json/ValueVo.java: -------------------------------------------------------------------------------- 1 | package com.baidu.disconf.core.common.json; 2 | 3 | import com.baidu.disconf.core.common.constants.Constants; 4 | 5 | /** 6 | * 通用的Value Vo 7 | * 8 | * @author liaoqiqi 9 | * @version 2014-6-10 10 | */ 11 | public class ValueVo { 12 | 13 | // 是否存在此KEy 14 | private Integer status = Constants.OK; 15 | 16 | // 17 | private String message = ""; 18 | 19 | // 20 | private String value = ""; 21 | 22 | public Integer getStatus() { 23 | return status; 24 | } 25 | 26 | public void setStatus(Integer status) { 27 | this.status = status; 28 | } 29 | 30 | public String getValue() { 31 | return value; 32 | } 33 | 34 | public void setValue(String value) { 35 | this.value = value; 36 | } 37 | 38 | public String getMessage() { 39 | return message; 40 | } 41 | 42 | public void setMessage(String message) { 43 | this.message = message; 44 | } 45 | 46 | @Override 47 | public String toString() { 48 | return "ValueVo [status=" + status + ", message=" + message + ", value=" + value + "]"; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /disconf-web/src/main/java/com/baidu/dsp/common/constraint/validation/ListInValidator.java: -------------------------------------------------------------------------------- 1 | package com.baidu.dsp.common.constraint.validation; 2 | 3 | import java.util.List; 4 | 5 | import javax.validation.ConstraintValidator; 6 | import javax.validation.ConstraintValidatorContext; 7 | 8 | import com.baidu.dsp.common.constraint.ListInConstraint; 9 | import com.github.knightliao.apollo.utils.common.StringUtil; 10 | 11 | public class ListInValidator implements ConstraintValidator { 12 | 13 | private String allowIntegerListStr; 14 | private List allowIntegerList; 15 | 16 | private static final String SEP = ","; 17 | 18 | @Override 19 | public void initialize(ListInConstraint constraintAnnotation) { 20 | 21 | this.allowIntegerListStr = constraintAnnotation.allowIntegerList(); 22 | 23 | allowIntegerList = StringUtil.parseStringToIntegerList(allowIntegerListStr, SEP); 24 | } 25 | 26 | @Override 27 | public boolean isValid(Integer value, ConstraintValidatorContext context) { 28 | 29 | if (value == null) { 30 | return false; 31 | } 32 | 33 | return allowIntegerList.contains(value); 34 | } 35 | } 36 | --------------------------------------------------------------------------------