diff --git a/pkg/master/README.md b/pkg/master/README.md index 01c1caeb84..30aca7743c 100644 --- a/pkg/master/README.md +++ b/pkg/master/README.md @@ -11,3 +11,14 @@ go run cmd/master.go ``` ## Start with docker + + +## What rules does master use to write data to kv storage? +1.find the root path variable ```ETCD_ROOT_PATH ```which defined in common/config.go +2.add prefix path ```segment``` if the resource is a segement +3.add prefix path ```collection``` if the resource is a collection +4.add resource uuid + +### example +if master create a collection with uuid ```46e468ee-b34a-419d-85ed-80c56bfa4e90``` +the corresponding key in etcd is /$(ETCD_ROOT_PATH)/collection/46e468ee-b34a-419d-85ed-80c56bfa4e90 diff --git a/pkg/master/mock/segment.go b/pkg/master/mock/segment.go index 59bf1c66c7..65bfa3a9b9 100644 --- a/pkg/master/mock/segment.go +++ b/pkg/master/mock/segment.go @@ -35,19 +35,19 @@ func SegmentUnMarshal(data []byte) (SegmentStats, error) { } type Segment struct { - SegmentID uint64 `json:"segment_id"` - Collection Collection `json:"collection"` - PartitionTag string `json:"partition_tag"` - ChannelStart int `json:"channel_start"` - ChannelEnd int `json:"channel_end"` - OpenTimeStamp uint64 `json:"open_timestamp"` - CloseTimeStamp uint64 `json:"close_timestamp"` + SegmentID uint64 `json:"segment_id"` + CollectionID uint64 `json:"collection_id"` + PartitionTag string `json:"partition_tag"` + ChannelStart int `json:"channel_start"` + ChannelEnd int `json:"channel_end"` + OpenTimeStamp uint64 `json:"open_timestamp"` + CloseTimeStamp uint64 `json:"close_timestamp"` } -func NewSegment(id uuid.UUID, collection Collection, ptag string, chStart int, chEnd int, openTime time.Time, closeTime time.Time) Segment { +func NewSegment(id uuid.UUID, collectioID uuid.UUID, ptag string, chStart int, chEnd int, openTime time.Time, closeTime time.Time) Segment { return Segment{ SegmentID: uint64(id.ID()), - Collection: collection, + CollectionID: uint64(id.ID()), PartitionTag: ptag, ChannelStart: chStart, ChannelEnd: chEnd, diff --git a/pkg/master/mock/segment_test.go b/pkg/master/mock/segment_test.go index 610b93aff5..0ad2030469 100644 --- a/pkg/master/mock/segment_test.go +++ b/pkg/master/mock/segment_test.go @@ -30,14 +30,8 @@ func TestSegmentMarshal(t *testing.T) { } var Ts = Segment{ - SegmentID: uint64(101111), - Collection: Collection{ - ID: uint64(11111), - Name: "test-collection", - CreateTime: uint64(time.Now().Unix()), - SegmentIDs: []uint64{uint64(10111)}, - PartitionTags: []string{"default"}, - }, + SegmentID: uint64(101111), + CollectionID: uint64(12010101), PartitionTag: "default", ChannelStart: 1, ChannelEnd: 100, diff --git a/pkg/master/server.go b/pkg/master/server.go index 2469015fd5..27024b0db6 100644 --- a/pkg/master/server.go +++ b/pkg/master/server.go @@ -129,7 +129,7 @@ func CollectionController(ch chan *messagepb.Mapping) { time.Now(), fieldMetas, []uuid.UUID{sID}, []string{"default"}) cm := mock.GrpcMarshal(&c) - s := mock.NewSegment(sID, c, "default", 0, 100, time.Now(), time.Unix(1<<36-1, 0)) + s := mock.NewSegment(sID, cID, "default", 0, 100, time.Now(), time.Unix(1<<36-1, 0)) collectionData, _ := mock.Collection2JSON(*cm) segmentData, err := mock.Segment2JSON(s) if err != nil {