forked from milvus-io/birdwatcher
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enhance: Add
partition-loaded
and make force-release
selectable
See also milvus-io#255 This PR: - Add `show partition-loaded` command to list partitions loaded - Make `force-release` able to specify collection id - Rewrite `force-release` command with new framework - Some minor format/parameter usage fix Signed-off-by: Congqi Xia <[email protected]>
- Loading branch information
Showing
14 changed files
with
215 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package models | ||
|
||
import ( | ||
querypbv2 "github.com/milvus-io/birdwatcher/proto/v2.2/querypb" | ||
) | ||
|
||
type PartitionLoaded struct { | ||
CollectionID int64 | ||
PartitionID int64 | ||
ReplicaNumber int32 | ||
|
||
Status LoadStatus | ||
|
||
Key string | ||
Version string | ||
} | ||
|
||
func NewPartitionLoaded(info *querypbv2.PartitionLoadInfo, key string) *PartitionLoaded { | ||
return &PartitionLoaded{ | ||
CollectionID: info.GetCollectionID(), | ||
PartitionID: info.GetPartitionID(), | ||
ReplicaNumber: info.GetReplicaNumber(), | ||
Status: LoadStatus(info.GetStatus()), | ||
Version: GTEVersion2_2, | ||
Key: key, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package common | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"path" | ||
|
||
"github.com/milvus-io/birdwatcher/models" | ||
querypbv2 "github.com/milvus-io/birdwatcher/proto/v2.2/querypb" | ||
"github.com/samber/lo" | ||
clientv3 "go.etcd.io/etcd/client/v3" | ||
) | ||
|
||
func ListPartitionLoadedInfo(ctx context.Context, cli clientv3.KV, basePath string, version string, filters ...func(*models.PartitionLoaded) bool) ([]*models.PartitionLoaded, error) { | ||
switch version { | ||
case models.GTEVersion2_2: | ||
prefix := path.Join(basePath, PartitionLoadedPrefix) | ||
infos, paths, err := ListProtoObjects(ctx, cli, prefix, func(info *querypbv2.PartitionLoadInfo) bool { | ||
pl := models.NewPartitionLoaded(info, "") | ||
for _, filter := range filters { | ||
if !filter(pl) { | ||
return false | ||
} | ||
} | ||
return true | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return lo.Map(infos, func(info querypbv2.PartitionLoadInfo, idx int) *models.PartitionLoaded { | ||
return models.NewPartitionLoaded(&info, paths[idx]) | ||
}), nil | ||
default: | ||
return nil, errors.New("version not supported") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package show | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/milvus-io/birdwatcher/framework" | ||
"github.com/milvus-io/birdwatcher/models" | ||
"github.com/milvus-io/birdwatcher/states/etcd/common" | ||
etcdversion "github.com/milvus-io/birdwatcher/states/etcd/version" | ||
) | ||
|
||
type PartitionLoadedParam struct { | ||
framework.ParamBase `use:"show partition-loaded" desc:"display the information of loaded partition(s) from querycoord meta"` | ||
CollectionID int64 `name:"collection" default:"0" desc:"collection id to filter with"` | ||
PartitionID int64 `name:"partition" default:"0" desc:"partition id to filter with"` | ||
} | ||
|
||
func (c *ComponentShow) PartitionLoadedCommand(ctx context.Context, p *PartitionLoadedParam) (*PartitionsLoaded, error) { | ||
partitions, err := common.ListPartitionLoadedInfo(ctx, c.client, c.basePath, etcdversion.GetVersion(), func(pl *models.PartitionLoaded) bool { | ||
return (p.CollectionID == 0 || p.CollectionID == pl.CollectionID) && | ||
(p.PartitionID == 0 || p.PartitionID == pl.PartitionID) | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return framework.NewListResult[PartitionsLoaded](partitions), nil | ||
} | ||
|
||
type PartitionsLoaded struct { | ||
framework.ListResultSet[*models.PartitionLoaded] | ||
} | ||
|
||
func (rs *PartitionsLoaded) PrintAs(format framework.Format) string { | ||
switch format { | ||
case framework.FormatDefault, framework.FormatPlain: | ||
sb := &strings.Builder{} | ||
for _, info := range rs.Data { | ||
rs.printPartitionLoaded(sb, info) | ||
} | ||
fmt.Fprintf(sb, "--- Partitions Loaded: %d\n", len(rs.Data)) | ||
return sb.String() | ||
default: | ||
} | ||
return "" | ||
} | ||
|
||
func (rs *PartitionsLoaded) printPartitionLoaded(sb *strings.Builder, info *models.PartitionLoaded) { | ||
fmt.Fprintf(sb, "CollectionID: %d\tPartitionID: %d\n", info.CollectionID, info.PartitionID) | ||
fmt.Fprintf(sb, "ReplicaNumber: %d", info.ReplicaNumber) | ||
switch info.Version { | ||
case models.LTEVersion2_1: | ||
case models.GTEVersion2_2: | ||
fmt.Fprintf(sb, "\tLoadStatus: %s\n", info.Status.String()) | ||
} | ||
} |
Oops, something went wrong.