Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.0.x] enhance: improve show segment & distribution result output #212

Merged
merged 1 commit into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ birdwatcher-build

# logs
audit.log
audit_*.log
bw_debug.log

# vim
Expand Down
12 changes: 9 additions & 3 deletions states/distribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/spf13/cobra"
clientv3 "go.etcd.io/etcd/client/v3"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)

// GetDistributionCommand returns command to iterate all querynodes to list distribution.
Expand All @@ -20,6 +21,7 @@ func GetDistributionCommand(cli clientv3.KV, basePath string) *cobra.Command {
Short: "list segments loaded information",
RunE: func(cmd *cobra.Command, args []string) error {
collectionID, err := cmd.Flags().GetInt64("collection")
var sealedCnt int64
if err != nil {
return err
}
Expand All @@ -30,16 +32,18 @@ func GetDistributionCommand(cli clientv3.KV, basePath string) *cobra.Command {

for _, session := range sessions {
opts := []grpc.DialOption{
grpc.WithInsecure(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithBlock(),
grpc.WithTimeout(2 * time.Second),
}

conn, err := grpc.DialContext(context.Background(), session.Address, opts...)
dialCtx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
conn, err := grpc.DialContext(dialCtx, session.Address, opts...)
cancel()
if err != nil {
fmt.Printf("failed to connect %s(%d), err: %s\n", session.ServerName, session.ServerID, err.Error())
continue
}

if session.ServerName == "querynode" {
fmt.Println("===========")
fmt.Printf("ServerID %d\n", session.ServerID)
Expand Down Expand Up @@ -81,8 +85,10 @@ func GetDistributionCommand(cli clientv3.KV, basePath string) *cobra.Command {
sealedNum++
}
fmt.Println("Sealed segments number:", sealedNum)
sealedCnt += int64(sealedNum)
}
}
fmt.Printf("==== total loaded sealed segment number: %d\n", sealedCnt)

return nil
},
Expand Down
16 changes: 14 additions & 2 deletions states/etcd/show/segment.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ func (c *ComponentShow) SegmentCommand(ctx context.Context, p *SegmentParam) err
totalRC := int64(0)
healthy := 0
var statslogSize int64
var growing, sealed, flushed int
var growing, sealed, flushed, dropped int
var small, other int
var smallCnt, otherCnt int64
fieldSize := make(map[int64]int64)
for _, info := range segments {

Expand All @@ -54,6 +56,15 @@ func (c *ComponentShow) SegmentCommand(ctx context.Context, p *SegmentParam) err
sealed++
case models.SegmentStateFlushing, models.SegmentStateFlushed:
flushed++
if float64(info.NumOfRows)/float64(info.MaxRowNum) < 0.2 {
small++
smallCnt += info.NumOfRows
} else {
other++
otherCnt += info.NumOfRows
}
case models.SegmentStateDropped:
dropped++
}

switch p.Format {
Expand Down Expand Up @@ -88,7 +99,8 @@ func (c *ComponentShow) SegmentCommand(ctx context.Context, p *SegmentParam) err
fmt.Printf("--- Total statslog size: %s\n", hrSize(statslogSize))
}

fmt.Printf("--- Growing: %d, Sealed: %d, Flushed: %d\n", growing, sealed, flushed)
fmt.Printf("--- Growing: %d, Sealed: %d, Flushed: %d, Dropped: %d\n", growing, sealed, flushed, dropped)
fmt.Printf("--- Small Segments: %d, row count: %d\t Other Segments: %d, row count: %d\n", small, smallCnt, other, otherCnt)
fmt.Printf("--- Total Segments: %d, row count: %d\n", healthy, totalRC)
return nil
}
Expand Down