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.

35 lines
1.1 KiB

  1. package cluster
  2. import (
  3. "context"
  4. "github.com/seaweedfs/seaweedfs/weed/glog"
  5. "github.com/seaweedfs/seaweedfs/weed/pb"
  6. "github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
  7. "google.golang.org/grpc"
  8. )
  9. func ListExistingPeerUpdates(master pb.ServerAddress, grpcDialOption grpc.DialOption, filerGroup string, clientType string) (existingNodes []*master_pb.ClusterNodeUpdate) {
  10. if grpcErr := pb.WithMasterClient(false, master, grpcDialOption, false, func(client master_pb.SeaweedClient) error {
  11. resp, err := client.ListClusterNodes(context.Background(), &master_pb.ListClusterNodesRequest{
  12. ClientType: clientType,
  13. FilerGroup: filerGroup,
  14. })
  15. glog.V(0).Infof("the cluster has %d %s\n", len(resp.ClusterNodes), clientType)
  16. for _, node := range resp.ClusterNodes {
  17. existingNodes = append(existingNodes, &master_pb.ClusterNodeUpdate{
  18. NodeType: FilerType,
  19. Address: node.Address,
  20. IsLeader: node.IsLeader,
  21. IsAdd: true,
  22. CreatedAtNs: node.CreatedAtNs,
  23. })
  24. }
  25. return err
  26. }); grpcErr != nil {
  27. glog.V(0).Infof("connect to %s: %v", master, grpcErr)
  28. }
  29. return
  30. }