-
Notifications
You must be signed in to change notification settings - Fork 1
ER Diagram
downgoon edited this page Sep 28, 2019
·
1 revision

CREATE TABLE `app_desc` (
`appid` bigint(20) NOT NULL AUTO_INCREMENT,
`name` varchar(16) NOT NULL,
`owner_uid` bigint(20) NOT NULL,
`status` tinyint(4) NOT NULL,
`descr` varchar(64) NOT NULL,
`create_time` bigint(20) NOT NULL,
`passed_time` bigint(20) DEFAULT NULL,
`notify_emails` varchar(128) DEFAULT NULL,
`notify_mobiles` varchar(128) DEFAULT NULL,
PRIMARY KEY (`appid`),
UNIQUE KEY `uidx_app_name` (`name`),
KEY `idx_app_uid` (`owner_uid`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8;
- MemInstance:
CREATE TABLE `mem_instance` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'memcached instance id',
`host_id` bigint(20) NOT NULL,
`host_ip` varchar(32) NOT NULL,
`port` int(11) NOT NULL,
`repc_port` int(11) NOT NULL,
`peer_ip` varchar(32) NOT NULL,
`status` int(11) NOT NULL,
`arg_mem` int(11) NOT NULL,
`arg_conn` int(11) DEFAULT NULL,
`role_in_peer` tinyint(4) NOT NULL COMMENT '0 no twin, 1 elder , -1 young',
`mem_cmd` text,
PRIMARY KEY (`id`),
UNIQUE KEY `uidx_inst_ipport` (`host_ip`,`port`),
UNIQUE KEY `uidx_inst_iprepc` (`host_id`,`repc_port`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;
- MemHost:
CREATE TABLE `mem_host` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`ip` varchar(16) NOT NULL,
`ssh_user` varchar(32) DEFAULT NULL,
`ssh_pwd` varchar(32) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `uidx_host_ip` (`ip`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
- MemPool: unallocated men-instances and its allocation algorithm
SELECT * FROM mem_instance
WHERE status = $unallocated AND arg_mem >= $applyMemSize
ORDER BY arg_mem ASC, id ASC
LIMIT $applyPartitionCount
NOTE: mem-sharding, with alias name of app_mem_group, is refered to the mem-instance and its peer both allocated to the same AppId.
CREATE TABLE `app_mem_group` ( -- alias name of mem-sharding
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`appid` bigint(20) NOT NULL, -- appId of mem-sharding
`master_ip` varchar(32) NOT NULL, -- master of mem-sharding
`master_port` int(11) NOT NULL,
`slave_ip` varchar(32) NOT NULL, -- slave of mem-sharding
`slave_port` int(11) NOT NULL,
`status` tinyint(4) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `uidx_group_master` (`master_ip`,`master_port`),
UNIQUE KEY `uidx_group_slave` (`slave_ip`,`slave_port`),
KEY `idx_group_app` (`appid`)
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8;
CREATE TABLE `user` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`name` varchar(64) NOT NULL,
`pwd` varchar(32) NOT NULL,
`email` varchar(64) DEFAULT NULL,
`mobile` varchar(16) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `uidx_user_name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=10002 DEFAULT CHARSET=utf8;