acelyc111 commented on code in PR #2162:
URL:
https://github.com/apache/incubator-pegasus/pull/2162#discussion_r1869788786
##########
admin-cli/executor/client.go:
##########
@@ -67,3 +69,46 @@ func NewClient(writer io.Writer, metaAddrs []string) *Client
{
Perf: aggregate.NewPerfClient(metaAddrs),
}
}
+
+// NewClientWithoutExit creates a client for accessing Pegasus cluster for use
of admin-cli.
+// This function will not call os.Exit.
+func NewClientWithoutExit(writer io.Writer, metaAddrs []string) (*Client,
error) {
+ meta := client.NewRPCBasedMeta(metaAddrs)
+
+ nodes, err := meta.ListNodes()
+ if err != nil {
+ fmt.Fprintf(writer, "fatal: failed to list nodes [%s]\n", err)
Review Comment:
The "fatal" level log is conventional considered as unacceptable condition,
and will be used before exit the process. It's better to use error or warning
level here.
##########
admin-cli/executor/client.go:
##########
@@ -67,3 +69,46 @@ func NewClient(writer io.Writer, metaAddrs []string) *Client
{
Perf: aggregate.NewPerfClient(metaAddrs),
}
}
+
+// NewClientWithoutExit creates a client for accessing Pegasus cluster for use
of admin-cli.
+// This function will not call os.Exit.
+func NewClientWithoutExit(writer io.Writer, metaAddrs []string) (*Client,
error) {
Review Comment:
This fucntion is similar to the function above, how about unify them?
##########
admin-cli/executor/disk_info.go:
##########
@@ -97,6 +99,31 @@ func QueryAllNodesDiskInfo(client *Client, tableName string)
(map[string]*radmin
return respMap, nil
}
+func QueryAliveNodesDiskInfo(client *Client, tableName string)
(map[string]*radmin.QueryDiskInfoResponse, error) {
Review Comment:
Is it related to the subject of this patch?
##########
admin-cli/executor/client.go:
##########
@@ -67,3 +69,46 @@ func NewClient(writer io.Writer, metaAddrs []string) *Client
{
Perf: aggregate.NewPerfClient(metaAddrs),
}
}
+
+// NewClientWithoutExit creates a client for accessing Pegasus cluster for use
of admin-cli.
+// This function will not call os.Exit.
+func NewClientWithoutExit(writer io.Writer, metaAddrs []string) (*Client,
error) {
+ meta := client.NewRPCBasedMeta(metaAddrs)
+
+ nodes, err := meta.ListNodes()
+ if err != nil {
+ fmt.Fprintf(writer, "fatal: failed to list nodes [%s]\n", err)
+ return nil, fmt.Errorf("fatal: failed to list nodes [%s]", err)
+ }
+
+ var replicaAddrs []string
+ for _, node := range nodes {
+ replicaAddrs = append(replicaAddrs, node.Address.GetAddress())
+ }
+
+ return &Client{
+ Writer: writer,
+ Meta: meta,
+ Nodes: util.NewPegasusNodeManager(metaAddrs, replicaAddrs),
+ Perf: aggregate.NewPerfClient(metaAddrs),
+ }, nil
+}
+
+func CloseClient(writer io.Writer, client *Client) error {
Review Comment:
Where are the functions used?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]