You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
1.7 KiB

Merge accumulated changes related to message queue (#5098) * balance partitions on brokers * prepare topic partition first and then publish, move partition * purge unused APIs * clean up * adjust logs * add BalanceTopics() grpc API * configure topic * configure topic command * refactor * repair missing partitions * sequence of operations to ensure ordering * proto to close publishers and consumers * rename file * topic partition versioned by unixTimeNs * create local topic partition * close publishers * randomize the client name * wait until no publishers * logs * close stop publisher channel * send last ack * comments * comment * comments * support list of brokers * add cli options * Update .gitignore * logs * return io.eof directly * refactor * optionally create topic * refactoring * detect consumer disconnection * sub client wait for more messages * subscribe by time stamp * rename * rename to sub_balancer * rename * adjust comments * rename * fix compilation * rename * rename * SubscriberToSubCoordinator * sticky rebalance * go fmt * add tests * balance partitions on brokers * prepare topic partition first and then publish, move partition * purge unused APIs * clean up * adjust logs * add BalanceTopics() grpc API * configure topic * configure topic command * refactor * repair missing partitions * sequence of operations to ensure ordering * proto to close publishers and consumers * rename file * topic partition versioned by unixTimeNs * create local topic partition * close publishers * randomize the client name * wait until no publishers * logs * close stop publisher channel * send last ack * comments * comment * comments * support list of brokers * add cli options * Update .gitignore * logs * return io.eof directly * refactor * optionally create topic * refactoring * detect consumer disconnection * sub client wait for more messages * subscribe by time stamp * rename * rename to sub_balancer * rename * adjust comments * rename * fix compilation * rename * rename * SubscriberToSubCoordinator * sticky rebalance * go fmt * add tests * tracking topic=>broker * merge * comment
1 year ago
3 months ago
Merge accumulated changes related to message queue (#5098) * balance partitions on brokers * prepare topic partition first and then publish, move partition * purge unused APIs * clean up * adjust logs * add BalanceTopics() grpc API * configure topic * configure topic command * refactor * repair missing partitions * sequence of operations to ensure ordering * proto to close publishers and consumers * rename file * topic partition versioned by unixTimeNs * create local topic partition * close publishers * randomize the client name * wait until no publishers * logs * close stop publisher channel * send last ack * comments * comment * comments * support list of brokers * add cli options * Update .gitignore * logs * return io.eof directly * refactor * optionally create topic * refactoring * detect consumer disconnection * sub client wait for more messages * subscribe by time stamp * rename * rename to sub_balancer * rename * adjust comments * rename * fix compilation * rename * rename * SubscriberToSubCoordinator * sticky rebalance * go fmt * add tests * balance partitions on brokers * prepare topic partition first and then publish, move partition * purge unused APIs * clean up * adjust logs * add BalanceTopics() grpc API * configure topic * configure topic command * refactor * repair missing partitions * sequence of operations to ensure ordering * proto to close publishers and consumers * rename file * topic partition versioned by unixTimeNs * create local topic partition * close publishers * randomize the client name * wait until no publishers * logs * close stop publisher channel * send last ack * comments * comment * comments * support list of brokers * add cli options * Update .gitignore * logs * return io.eof directly * refactor * optionally create topic * refactoring * detect consumer disconnection * sub client wait for more messages * subscribe by time stamp * rename * rename to sub_balancer * rename * adjust comments * rename * fix compilation * rename * rename * SubscriberToSubCoordinator * sticky rebalance * go fmt * add tests * tracking topic=>broker * merge * comment
1 year ago
  1. package shell
  2. import (
  3. "context"
  4. "fmt"
  5. "github.com/seaweedfs/seaweedfs/weed/mq/pub_balancer"
  6. "github.com/seaweedfs/seaweedfs/weed/pb"
  7. "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
  8. "github.com/seaweedfs/seaweedfs/weed/pb/mq_pb"
  9. "io"
  10. )
  11. func init() {
  12. Commands = append(Commands, &commandMqTopicList{})
  13. }
  14. type commandMqTopicList struct {
  15. }
  16. func (c *commandMqTopicList) Name() string {
  17. return "mq.topic.list"
  18. }
  19. func (c *commandMqTopicList) Help() string {
  20. return `print out all topics`
  21. }
  22. func (c *commandMqTopicList) HasTag(CommandTag) bool {
  23. return false
  24. }
  25. func (c *commandMqTopicList) Do(args []string, commandEnv *CommandEnv, writer io.Writer) error {
  26. brokerBalancer, err := findBrokerBalancer(commandEnv)
  27. if err != nil {
  28. return err
  29. }
  30. fmt.Fprintf(writer, "current balancer: %s\n", brokerBalancer)
  31. return pb.WithBrokerGrpcClient(false, brokerBalancer, commandEnv.option.GrpcDialOption, func(client mq_pb.SeaweedMessagingClient) error {
  32. resp, err := client.ListTopics(context.Background(), &mq_pb.ListTopicsRequest{})
  33. if err != nil {
  34. return err
  35. }
  36. if len(resp.Topics) == 0 {
  37. fmt.Fprintf(writer, "no topics found\n")
  38. return nil
  39. }
  40. for _, topic := range resp.Topics {
  41. fmt.Fprintf(writer, " %+v\n", topic)
  42. }
  43. return nil
  44. })
  45. }
  46. func findBrokerBalancer(commandEnv *CommandEnv) (brokerBalancer string, err error) {
  47. err = commandEnv.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
  48. resp, err := client.FindLockOwner(context.Background(), &filer_pb.FindLockOwnerRequest{
  49. Name: pub_balancer.LockBrokerBalancer,
  50. })
  51. if err != nil {
  52. return fmt.Errorf("FindLockOwner: %v", err)
  53. }
  54. brokerBalancer = resp.Owner
  55. return nil
  56. })
  57. return
  58. }