-
Notifications
You must be signed in to change notification settings - Fork 317
Master详细设计
zhanchao edited this page Aug 20, 2020
·
1 revision
vearch 是一个对向量进行存储和相似度检索的分布式系统。由三个模块组成,master、router、partitionServer。master 主要负责对元数据进行存储和管理,以及资源的协调管理。
key | value | 备注 |
---|---|---|
/id/node | 1 | 当前最大的id值,下次产生nodeId为当前值+1 |
/id/space | 1 | |
/id/db | 1 | |
/id/partition | 1 |
key | value | 备注 |
---|---|---|
/user/ | ||
/lock/ | ||
/lock/_cluster | ||
/server/ | /server/$noidId →Server struct | 相应的nodeId存储server结构体类型的数据 |
/space/ | /space/$spaceId →Space struct | |
/partition/ | /partition/$spaceId →Partition struct | |
/db/ | /db/$dbId →DB struct | |
/db/body/ |
//server/id:\[body\] ttl 3m 3s
type Server struct {
ID NodeID \`json:\"name,omitempty\"\` //unique name for raft
RpcPort uint16 \`json:\"rpc\_port\"\`
RaftHeartbeatPort uint16 \`json:\"raft\_heartbeat\_port\"\`
RaftReplicatePort uint16 \`json:\"raft\_replicate\_port\"\`
Ip string \`json:\"ip,omitempty\"\`
PartitionIds \[\]PartitionID \`json:\"p\_ids,omitempty\"\`
Size uint64 \`json:\"size,omitempty\"\`
Private bool \`json:\"private\"\`
Version \*BuildVersion \`json:\"version\"\`
}
//space/\[dbId\]/\[spaceId\]:\[spaceBody\]
type Space struct {
Id SpaceID \`json:\"id,omitempty\"\`
Name string \`json:\"name,omitempty\"\` //user setting
Version Version \`json:\"version,omitempty\"\`
DBId DBID \`json:\"db\_id,omitempty\"\`
Enabled \*bool \`json:\"enabled\"\` //Enabled flag whether the space can
work
Partitions \[\]\*Partition \`json:\"partitions\"\` // partitionids not
sorted
PartitionNum int \`json:\"partition\_num\"\`
ReplicaNum uint8 \`json:\"replica\_num\"\`
Properties json.RawMessage \`json:\"properties\"\`
Engine \*Engine \`json:\"engine\"\`
Models json.RawMessage \`json:\"models,omitempty\"\` //json model config
for python plugin
}
//partition/\[id\]:\[body\]
type Partition struct {
Id PartitionID \`json:\"id,omitempty\"\`
SpaceId SpaceID \`json:\"space\_id,omitempty\"\`
DBId DBID \`json:\"db\_id,omitempty\"\`
//Slot stores the lower limit of the slot range
Slot SlotID \`json:\"partition\_slot\"\`
LeaderID NodeID \`json:\"leader\_name,omitempty\"\`
Replicas \[\]NodeID \`json:\"replicas,omitempty\"\` //leader in replicas
UpdateTime int64 \`json:\"update\_time,omitempty\"\`
Path string \`json:\"-\"\`
status PartitionStatus
lock sync.RWMutex
}
//db/id/\[dbId\]:\[dbName\]
//db/name/\[dbName\]:\[dbId\]
//db/body/\[dbId\]:\[dbBody\]
type DB struct {
Id DBID \`json:\"id,omitempty\"\`
Name string \`json:\"name,omitempty\"\`
Ps \[\]string \`json:\"ps,omitempty\"\` //if set this , your db only use
you config ps
}
接口地址 | 用途 | 备注 |
---|---|---|
/ | vearch 版本信息 | |
/clean_lock | ||
/list/server | 获取当前ps节点信息 | |
/list/db | 列出全部的库 | |
/list/space | 列出全部的表 | |
/list/partition | 列出全部的分区 | |
/register | ps启动,与master沟通,获取ps上应该有的partitionID | |
/register_partition | ps注册分区,更新/partition/元数据 | |
/db/_create | 创建库 | |
delete /db/$dbId | 删除库 | |
get /db/$dbId | 查询库 | |
put /space/_create | 创建表 | |
delete /space/$spaceId | 删除表 | |
get /space/$spaceId | 获取表 | |
post /space/$spaceId | 更新表 | |
/partition/change_member | 在指定节点添加或删除指定分区 | |
/_cluster/health | 集群健康状态 | |
/_cluster/stats | 集群ps状态 |
master主要负责元数据的管理和系统资源的协调。其中,元数据存储依赖etcd,并提供restful 接口进行库、表元数据的管理。Master代码启动流程如下:
总结如下: 1、初始化master配置。2、所有master启动etcd服务。3、初始化etcd client,与etcd进行交互。4、启动http服务,开放db、space 相关的restful 操作接口。5、开启定时任务清理 etcd元数据中失效的partition,space。