-- 创建Diamond数据库
CREATE DATABASE IF NOT EXISTS `diamond` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `diamond`;
-- 配置表
CREATE TABLE IF NOT EXISTS `config_info` (
`id` bigint(64) unsigned NOT NULL AUTO_INCREMENT,
`data_id` varchar(255) NOT NULL DEFAULT '',
`group_id` varchar(128) NOT NULL DEFAULT '',
`content` longtext NOT NULL,
`md5` varchar(32) NOT NULL DEFAULT '',
`src_ip` varchar(20) DEFAULT NULL,
`src_user` varchar(20) DEFAULT NULL,
`gmt_create` datetime NOT NULL DEFAULT '2010-05-05 00:00:00',
`gmt_modified` datetime NOT NULL DEFAULT '2010-05-05 00:00:00',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_config_datagroup` (`data_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- 组表
CREATE TABLE IF NOT EXISTS `group_info` (
`id` bigint(64) unsigned NOT NULL AUTO_INCREMENT,
`address` varchar(70) NOT NULL DEFAULT '',
`data_id` varchar(255) NOT NULL DEFAULT '',
`group_id` varchar(128) NOT NULL DEFAULT '',
`src_ip` varchar(20) DEFAULT NULL,
`src_user` varchar(20) DEFAULT NULL,
`gmt_create` datetime NOT NULL DEFAULT '2010-05-05 00:00:00',
`gmt_modified` datetime NOT NULL DEFAULT '2010-05-05 00:00:00',
PRIMARY KEY (`id`), UNIQUE KEY `uk_group_address` (`address`,`data_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
git clone https://github.com/gzllol/diamond.git
mvn clean package -Dmaven.test.skip=true
mvn clean deploy -Dmaven.test.skip=true
<dependency>
<groupId>com.taobao.diamond</groupId>
<artifactId>diamond-client</artifactId>
<version>2.0.5.4.taocode-SNAPSHOT</version>
</dependency>
DiamondManager manager = new DefaultDiamondManager("${your_config_data_id}", new ManagerListener() {
@Override
public Executor getExecutor() {
return null;
}
@Override
public void receiveConfigInfo(String configInfo) {
System.out.println("receive config: " + configInfo);
}
});