Configuration Management System

Source: Internet
Author: User
Tags gz file

Project Address: Https://github.com/melin/super-diamond

Super-diamond
    • Configuration management system to provide system parameters configuration management, such as database configuration information, configuration parameters can be pushed to the client in real time (based on Netty4), to facilitate the system to dynamically modify the operating parameters.
    • Multiple projects can be built, each of which is divided into three profiles (development, test, production) to control profile level permissions.
    • All parameters are configured by the development profile, and test and production profiles inherit the development profile configuration, or they can be overwritten. Test and production profile only provide modification functionality.
    • The client backs up the configuration information to the local file system and can use a local backup if the server is unavailable. The client can periodically re-connect the server to ensure that the client is highly available.
    • The client provides Configurationlistener, and when a property changes (add, update, clear), Configurationlistener can receive configurationevent.
    • The server backs up the profile system and ensures that the data is available to the client if the database is not used (to be perfected).
    • Supports PHP projects to get configuration parameters from Superdiamond.

System functions:

Project Profile Please refer to: http://melin.iteye.com/blog/1339060

Super-diamond-server Installation
    1. Download Super-diamond code: Git clone https://github.com/melin/super-diamond.git
    2. Enter Super-diamond directory, build super-diamond Parent project: mvn Install
    3. Super-diamond-server Embedded jetty Run, build deployment package: mvn install assembly:single-pproduction, build super-diamond-server-${version}- bin.tar.gz file, unzip run bin/server.sh start command.
    4. In the conf\meta-inf\scripts directory, MySQL and Oracle build table scripts are available, and the theory supports other databases in conf\meta-inf\res\ Modify the database configuration in the Config-production.properties file.
    5. In the Conf_user table, add user admin, password 000000 encryption value is: 670B14728AD9902AECBA32E22FA4F6BD, MySQL script: INSERT into Conf_user (Id,user_code, User_name,password,create_time) VALUES (1, ' admin ', ' admin ', ' 670b14728ad9902aecba32e22fa4f6bd ', Current_timestamp () );
      Commit
    6. Access Super-diamond-server,jetty default port is 8090 and can be modified in: Conf/meta-inf/res/jetty.properties. Http://localhost:8090/superdiamond
Super-diamond-client

The client references the Apache configuration to implement some of these features. For example:

PublicClasspropertiesconfigurationtest {@TestPublicvoidTestconfig ()Throwsconfigurationruntimeexception {String Config="Username = Melin\ r \ n"; Config+="port=8000\ r \ n"; Config+="Reload=true\ r \ n";Propertiesconfiguration Configuration=NewPropertiesconfiguration (); Configuration. load (config);Assert. Assertequals ("Melin", Configuration. getString ("Username"));Assert. Assertequals (8000, configuration. GETINT (The port"));Assert. Asserttrue (Configuration. Getboolean ("Reload")); }@TestPublicvoidTestinterpolator ()Throwsconfigurationruntimeexception {String Config="App.home =/tmp/home\ r \ n"; Config+="Zk.home=${app.home}/zk\ r \ n"; Config+="Hbase.home=${app.home}/hbase\ r \ n";Propertiesconfiguration Configuration=NewPropertiesconfiguration (); Configuration. load (config);Assert. Assertequals ("/tmp/home", Configuration. getString ("App.home"));Assert. Assertequals ("/tmp/home/zk", Configuration. getString ("Zk.home"));Assert. Assertequals ("/tmp/home/hbase", Configuration. getString ("Hbase.home")); }@TestPublicvoidTestsysproperties ()Throwsconfigurationruntimeexception {String Config="Javaversion = ${sys:java.version}\ r \ n";Propertiesconfiguration Configuration=NewPropertiesconfiguration (); Configuration. load (config);Assert. Assertequals (System. GetProperty ("Java.version"), Configuration. getString ("Javaversion")); }@TestPublicvoidTestsysevns ()Throwsconfigurationruntimeexception {String config = "javahome = ${env:java_home}/lib \ r \ n"; propertiesconfiguration Configuration = new propertiesconfiguration (), Configuration. Load ( config); Assert. Assertequals (System. getenv ("Java_home") + "/lib", Configuration. getString ("Javahome"));}}           
Client Connection server-side mode:
Propertiesconfiguration ("localhost" test"Development"); config. Addconfigurationlistener (configurationlistenertest ()); config. getString ("Jdbc.url") 

How to use Spring

<Beanclass="Org.springframework.context.support.PropertySourcesPlaceholderConfigurer"> <PropertyName="Properties"ref="Propertiesconfiguration"/></bean><BeanId="Propertiesconfiguration"class="Com.github.diamond.client.PropertiesConfigurationFactoryBean"> <Constructor-argindex="0"Value="LocalHost "/> <constructor-arg index=  "1" value=  "5001"/> <constructor-arg index= "2"  Value= "Test"/> < Constructor-arg index= "3" value= "Development"/></BEAN>              

The parameters Projcode, profile, host, and port of the client link service can be set in both the environment variable and JVM parameters, avoiding pinning in the project configuration file.

Export Superdiamond_projcode=javademoexport superdiamond_profile=production#多个模块之用逗号分隔, can be set to empty, get all module configuration. Export spuerdiamond_host=192.168.0.1export spuerdiamond_port=8283   

Or

<BeanId="Propertiesconfiguration"class="Com.github.diamond.client.PropertiesConfigurationFactoryBean "> <constructor-arg index=  "0" value=  "Test"/> <constructor-arg index= "1"  Value= "Development"/> < constructor-arg index= 2 "value=" development  "/></BEAN>          
Classpathxmlapplicationcontext ("Bean.xml");  Propertiesconfigurationfactorybean. getpropertiesconfiguration (); config. getString ("Jdbc.url  ")
The Rest interface gets the configuration:

To get configuration information via HTTP, the HTTP URL format is:

    • Properties format

      http://host:port/superdiamond/preview/${Project Code}/${profile} http://host:port/superdiamond/preview/${Project Code}/${module }[,${module}]/${profile}//supports setting multiple module values, separating http://host:port/superdiamond/preview/${item codes with commas}/${module}/${key}/${ Profile

    • PHP config format

      http://host:port/superdiamond/preview/${Project Code}/${profile}?format=php http://host:port/superdiamond/preview/${ Project Code}/${module}[,${module}]/${profile}? format=php//Support setting multiple module values, separated by commas

    • JSON config format

      http://host:port/superdiamond/preview/${Project Code}/${profile}?format=json http://host:port/superdiamond/preview/${ Project Code}/${module}[,${module}]/${profile}? Support to set multiple module values, separated by commas Format=json

PHP Project Application:

Combine phing to get configuration parameters from Superdiamond. For a complete phing build.xml configuration please refer to: https://gist.github.com/melin/fa4818acc9fd55666b77

<!--Target:configDescription: Gets the system configuration parameter information from the Superdiamond in HTTP mode.Development Profile acquisition configuration is stored in the application/common/conf/user-config.php file (thinkphp 3.2)The test & production profile get configuration is stored in the build/user-config.php file, and when you execute the build target,Copy the build/application/common/conf/user-config.php location in the build/user-config.php file--><TargetName=The Config"depends=The profile"> <If> <equalsarg1="Development"Arg2="${project.profile}"trim="True"/> <Then> <HttpGetUrl="Http://172.16.81.73:8001/superdiamond/preview/app.edusns/${project.profile}?format=php"dir= "Application/common/conf" filename= "User-config.php"/ > </then> <else> <httpget url= "http://172.16.81.73:8001/superdiamond/preview/ App.edusns/${project.profile}?format=php "dir= "Build" filename=  "User-config.php"/> </else> </if></TARGET>         

Configuration Management System

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.