如何确定 Redshift 集群中的节点数?

How to determine the number of nodes in a Redshift cluster?

我需要以编程方式确定 Redshift 集群中的节点数。我希望 AWS Java API 会在集群描述中提供它,但我找不到它。谁能指出我正确的方向?

是的,可以通过具有 NumberOfNodes 属性的 DescribeCluster. Each cluster within the region passed to the client is listed as a Cluster 项目。例如:

final AmazonRedshiftClient client = new AmazonRedshiftClient(credentials).withRegion(com.amazonaws.regions.Regions.US_WEST_2);
final DescribeClustersResult describeResult = client.describeClusters();
describeResult.getClusters()
              .stream()
              .forEach(cluster -> System.out.println(String.format("Cluster: %s \nNumber of nodes: %d",
                                                                   cluster.getClusterIdentifier(),
                                                                   cluster.getNumberOfNodes())));

给我:

Cluster: cluster-22gsextori36
Number of nodes: 1
Cluster: cluster-22gsextori38 
Number of nodes: 1
Cluster: cluster-22gsextori40 
Number of nodes: 1