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

时间:2016-03-12 18:32:02

标签: amazon-web-services amazon-redshift aws-java-sdk

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

1 个答案:

答案 0 :(得分:1)

是的,可以通过DescribeCluster来实现。传递给客户端的区域内的每个群集都列为Cluster项,其具有NumberOfNodes属性。例如:

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