mirror of https://github.com/milvus-io/milvus.git
Fix get component states
Signed-off-by: neza2017 <yefu.chen@zilliz.com>pull/4973/head^2
parent
2be8cc1c4b
commit
2ebeade25e
|
@ -106,6 +106,7 @@ func CreateServer(ctx context.Context) (*Server, error) {
|
|||
registerFinishCh: ch,
|
||||
cluster: newDataNodeCluster(ch),
|
||||
}
|
||||
s.state.Store(internalpb2.StateCode_INITIALIZING)
|
||||
return s, nil
|
||||
}
|
||||
|
||||
|
@ -114,7 +115,6 @@ func (s *Server) SetMasterClient(masterClient MasterClient) {
|
|||
}
|
||||
|
||||
func (s *Server) Init() error {
|
||||
s.state.Store(internalpb2.StateCode_INITIALIZING)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -247,7 +247,7 @@ func (it *IndexBuildTask) Execute() error {
|
|||
}
|
||||
|
||||
var indexCodec storage.IndexCodec
|
||||
serializedIndexBlobs, err := indexCodec.Serialize(getStorageBlobs(indexBlobs), indexParams)
|
||||
serializedIndexBlobs, err := indexCodec.Serialize(getStorageBlobs(indexBlobs))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package storage
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strconv"
|
||||
|
@ -15,9 +14,8 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
Ts = "ts"
|
||||
DDL = "ddl"
|
||||
indexParamsFile = "indexParams"
|
||||
Ts = "ts"
|
||||
DDL = "ddl"
|
||||
)
|
||||
|
||||
type (
|
||||
|
@ -635,29 +633,10 @@ func NewIndexCodec() *IndexCodec {
|
|||
return &IndexCodec{}
|
||||
}
|
||||
|
||||
func (indexCodec *IndexCodec) Serialize(blobs []*Blob, params map[string]string) ([]*Blob, error) {
|
||||
paramsBytes, err := json.Marshal(params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
blobs = append(blobs, &Blob{Key: indexParamsFile, Value: paramsBytes})
|
||||
func (indexCodec *IndexCodec) Serialize(blobs []*Blob) ([]*Blob, error) {
|
||||
return blobs, nil
|
||||
}
|
||||
|
||||
func (indexCodec *IndexCodec) Deserialize(blobs []*Blob) ([]*Blob, map[string]string, error) {
|
||||
var params map[string]string
|
||||
for i := 0; i < len(blobs); i++ {
|
||||
if blobs[i].Key != indexParamsFile {
|
||||
continue
|
||||
}
|
||||
if err := json.Unmarshal(blobs[i].Value, ¶ms); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
blobs = append(blobs[:i], blobs[i+1:]...)
|
||||
break
|
||||
}
|
||||
if params == nil {
|
||||
return nil, nil, errors.New("can not find params blob")
|
||||
}
|
||||
return blobs, params, nil
|
||||
func (indexCodec *IndexCodec) Deserialize(blobs []*Blob) ([]*Blob, error) {
|
||||
return blobs, nil
|
||||
}
|
||||
|
|
|
@ -307,18 +307,10 @@ func TestIndexCodec(t *testing.T) {
|
|||
[]byte{8, 8, 8, 8, 8, 8, 8, 8, 2, 3, 4, 5, 6, 7},
|
||||
},
|
||||
}
|
||||
indexParams := map[string]string{
|
||||
"k1": "v1", "k2": "v2",
|
||||
}
|
||||
blobsInput, err := indexCodec.Serialize(blobs, indexParams)
|
||||
blobsInput, err := indexCodec.Serialize(blobs)
|
||||
assert.Nil(t, err)
|
||||
assert.EqualValues(t, 4, len(blobsInput))
|
||||
assert.EqualValues(t, indexParamsFile, blobsInput[3])
|
||||
blobsOutput, indexParamsOutput, err := indexCodec.Deserialize(blobsInput)
|
||||
assert.Equal(t, blobs, blobsInput)
|
||||
blobsOutput, err := indexCodec.Deserialize(blobs)
|
||||
assert.Nil(t, err)
|
||||
assert.EqualValues(t, 3, len(blobsOutput))
|
||||
for i := 0; i < 3; i++ {
|
||||
assert.EqualValues(t, blobs[i], blobsOutput[i])
|
||||
}
|
||||
assert.EqualValues(t, indexParams, indexParamsOutput)
|
||||
assert.Equal(t, blobsOutput, blobsInput)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue