2020-12-29 18:02:44 +08:00
|
|
|
|
|
|
|
|
|
|
|
## 8. Data Service
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#### 8.1 Overview
|
|
|
|
|
2021-01-14 15:12:08 +08:00
|
|
|
<img src="./figs/data_service.png" width=700>
|
2020-12-29 18:02:44 +08:00
|
|
|
|
2021-01-13 11:08:03 +08:00
|
|
|
#### 8.2 Data Service Interface
|
2020-12-29 18:02:44 +08:00
|
|
|
|
|
|
|
```go
|
2021-01-13 11:08:03 +08:00
|
|
|
type DataService interface {
|
|
|
|
Service
|
|
|
|
|
|
|
|
RegisterNode(req RegisterNodeRequest) (RegisterNodeResponse, error)
|
2021-01-11 18:35:54 +08:00
|
|
|
Flush(req FlushRequest) error
|
2021-01-13 11:08:03 +08:00
|
|
|
|
|
|
|
AssignSegmentID(req AssignSegIDRequest) (AssignSegIDResponse, error)
|
2021-01-12 18:03:24 +08:00
|
|
|
ShowSegments(req ShowSegmentRequest) (ShowSegmentResponse, error)
|
|
|
|
GetSegmentStates(req SegmentStatesRequest) (SegmentStatesResponse, error)
|
2020-12-29 18:02:44 +08:00
|
|
|
GetInsertBinlogPaths(req InsertBinlogPathRequest) (InsertBinlogPathsResponse, error)
|
2021-01-12 18:03:24 +08:00
|
|
|
|
2020-12-29 18:02:44 +08:00
|
|
|
GetInsertChannels(req InsertChannelRequest) ([]string, error)
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-01-15 11:53:22 +08:00
|
|
|
* *RequestBase*
|
2021-01-13 11:08:03 +08:00
|
|
|
|
|
|
|
```go
|
2021-01-15 11:53:22 +08:00
|
|
|
type RequestBase struct {
|
2021-01-13 11:08:03 +08:00
|
|
|
MsgType MsgType
|
2021-01-15 11:53:22 +08:00
|
|
|
ReqID UniqueID
|
2021-01-13 11:08:03 +08:00
|
|
|
Timestamp Timestamp
|
2021-01-15 11:53:22 +08:00
|
|
|
RequestorID UniqueID
|
2021-01-13 11:08:03 +08:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2021-01-11 18:35:54 +08:00
|
|
|
* *RegisterNode*
|
|
|
|
|
|
|
|
```go
|
2021-01-13 11:08:03 +08:00
|
|
|
type RegisterNodeRequest struct {
|
2021-01-15 11:53:22 +08:00
|
|
|
RequestBase
|
2021-01-13 11:08:03 +08:00
|
|
|
Address string
|
|
|
|
Port int64
|
|
|
|
}
|
2021-01-11 18:35:54 +08:00
|
|
|
|
2021-01-13 11:08:03 +08:00
|
|
|
type RegisterNodeResponse struct {
|
|
|
|
//InitParams
|
|
|
|
}
|
2021-01-11 18:35:54 +08:00
|
|
|
```
|
|
|
|
|
2020-12-29 18:02:44 +08:00
|
|
|
* *AssignSegmentID*
|
|
|
|
|
|
|
|
```go
|
|
|
|
type SegIDRequest struct {
|
|
|
|
Count uint32
|
2021-01-14 20:30:27 +08:00
|
|
|
ChannelName string
|
2020-12-29 18:02:44 +08:00
|
|
|
CollectionID UniqueID
|
|
|
|
PartitionID UniqueID
|
|
|
|
}
|
|
|
|
|
|
|
|
type AssignSegIDRequest struct {
|
2021-01-15 11:53:22 +08:00
|
|
|
RequestBase
|
2020-12-29 18:02:44 +08:00
|
|
|
PerChannelRequest []SegIDRequest
|
|
|
|
}
|
|
|
|
|
|
|
|
type SegIDAssignment struct {
|
2021-01-13 11:08:03 +08:00
|
|
|
SegmentID UniqueID
|
2021-01-14 20:30:27 +08:00
|
|
|
ChannelName string
|
2020-12-29 18:02:44 +08:00
|
|
|
Count uint32
|
|
|
|
CollectionID UniqueID
|
|
|
|
PartitionID UniqueID
|
|
|
|
ExpireTime Timestamp
|
|
|
|
}
|
|
|
|
|
|
|
|
type AssignSegIDResponse struct {
|
|
|
|
PerChannelResponse []SegIDAssignment
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* *Flush*
|
|
|
|
|
|
|
|
```go
|
|
|
|
type FlushRequest struct {
|
2021-01-15 11:53:22 +08:00
|
|
|
RequestBase
|
2020-12-29 18:02:44 +08:00
|
|
|
DbID UniqueID
|
|
|
|
CollectionID UniqueID
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-01-12 18:03:24 +08:00
|
|
|
* *ShowSegments*
|
|
|
|
|
|
|
|
```go
|
|
|
|
type ShowSegmentRequest struct {
|
2021-01-15 11:53:22 +08:00
|
|
|
RequestBase
|
2021-01-12 18:03:24 +08:00
|
|
|
CollectionID UniqueID
|
|
|
|
PartitionID UniqueID
|
|
|
|
}
|
|
|
|
|
|
|
|
type ShowSegmentResponse struct {
|
|
|
|
SegmentIDs []UniqueID
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* *GetSegmentStates*
|
|
|
|
|
|
|
|
```go
|
|
|
|
enum SegmentState {
|
|
|
|
NONE = 0;
|
|
|
|
NOT_EXIST = 1;
|
|
|
|
GROWING = 2;
|
|
|
|
SEALED = 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
type SegmentStatesRequest struct {
|
2021-01-15 11:53:22 +08:00
|
|
|
RequestBase
|
2021-01-12 18:03:24 +08:00
|
|
|
SegmentID UniqueID
|
|
|
|
}
|
|
|
|
|
|
|
|
type SegmentStatesResponse struct {
|
|
|
|
State SegmentState
|
|
|
|
CreateTime Timestamp
|
|
|
|
SealedTime Timestamp
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-12-29 18:02:44 +08:00
|
|
|
* *GetInsertBinlogPaths*
|
|
|
|
|
|
|
|
```go
|
|
|
|
type InsertBinlogPathRequest struct {
|
2021-01-15 11:53:22 +08:00
|
|
|
RequestBase
|
2021-01-12 18:03:24 +08:00
|
|
|
SegmentID UniqueID
|
2020-12-29 18:02:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type InsertBinlogPathsResponse struct {
|
2021-01-12 18:03:24 +08:00
|
|
|
FieldIDToPaths map[int64][]string
|
2020-12-29 18:02:44 +08:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* *GetInsertChannels*
|
|
|
|
|
|
|
|
```go
|
|
|
|
type InsertChannelRequest struct {
|
2021-01-15 14:02:12 +08:00
|
|
|
RequestBase
|
|
|
|
DbID UniqueID
|
|
|
|
CollectionID UniqueID
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-01-13 11:08:03 +08:00
|
|
|
#### 8.2 Data Node Interface
|
2021-01-11 18:35:54 +08:00
|
|
|
|
|
|
|
```go
|
|
|
|
type DataNode interface {
|
2021-01-13 11:08:03 +08:00
|
|
|
Service
|
2021-01-11 18:35:54 +08:00
|
|
|
|
2021-01-13 11:08:03 +08:00
|
|
|
WatchDmChannels(req WatchDmChannelRequest) error
|
2021-01-14 20:30:27 +08:00
|
|
|
//WatchDdChannel(channelName string) error
|
|
|
|
//SetTimeTickChannel(channelName string) error
|
|
|
|
//SetStatsChannel(channelName string) error
|
2021-01-11 18:35:54 +08:00
|
|
|
|
2021-01-13 11:08:03 +08:00
|
|
|
FlushSegments(req FlushSegRequest) error
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* *WatchDmChannels*
|
|
|
|
|
|
|
|
```go
|
|
|
|
type WatchDmChannelRequest struct {
|
2021-01-15 11:53:22 +08:00
|
|
|
RequestBase
|
2021-01-14 20:30:27 +08:00
|
|
|
InsertChannelNames []string
|
2021-01-13 11:08:03 +08:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
* *FlushSegments*
|
|
|
|
|
|
|
|
```go
|
|
|
|
type FlushSegRequest struct {
|
2021-01-15 11:53:22 +08:00
|
|
|
RequestBase
|
2021-01-13 11:08:03 +08:00
|
|
|
DbID UniqueID
|
|
|
|
CollectionID UniqueID
|
|
|
|
SegmentID []UniqueID
|
2021-01-11 18:35:54 +08:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|