com.amazonaws.services.redshift.model.DescribeClustersResult Java Examples

The following examples show how to use com.amazonaws.services.redshift.model.DescribeClustersResult. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InventoryUtilTest.java    From pacbot with Apache License 2.0 6 votes vote down vote up
/**
 * Fetch redshift info test.
 *
 * @throws Exception the exception
 */
@SuppressWarnings("static-access")
@Test
public void fetchRedshiftInfoTest() throws Exception {
    
    mockStatic(AmazonRedshiftClientBuilder.class);
    AmazonRedshift redshiftClient = PowerMockito.mock(AmazonRedshift.class);
    AmazonRedshiftClientBuilder amazonRedshiftClientBuilder = PowerMockito.mock(AmazonRedshiftClientBuilder.class);
    AWSStaticCredentialsProvider awsStaticCredentialsProvider = PowerMockito.mock(AWSStaticCredentialsProvider.class);
    PowerMockito.whenNew(AWSStaticCredentialsProvider.class).withAnyArguments().thenReturn(awsStaticCredentialsProvider);
    when(amazonRedshiftClientBuilder.standard()).thenReturn(amazonRedshiftClientBuilder);
    when(amazonRedshiftClientBuilder.withCredentials(anyObject())).thenReturn(amazonRedshiftClientBuilder);
    when(amazonRedshiftClientBuilder.withRegion(anyString())).thenReturn(amazonRedshiftClientBuilder);
    when(amazonRedshiftClientBuilder.build()).thenReturn(redshiftClient);
    
    DescribeClustersResult describeClustersResult = new DescribeClustersResult();
    List<com.amazonaws.services.redshift.model.Cluster> redshiftList = new ArrayList<>();
    redshiftList.add(new com.amazonaws.services.redshift.model.Cluster());
    describeClustersResult.setClusters(redshiftList);
    when(redshiftClient.describeClusters(anyObject())).thenReturn(describeClustersResult);
    assertThat(inventoryUtil.fetchRedshiftInfo(new BasicSessionCredentials("awsAccessKey", "awsSecretKey", "sessionToken"), 
            "skipRegions", "account","accountName").size(), is(1));
}
 
Example #2
Source File: RedshiftInstanceUtil.java    From obevo with Apache License 2.0 6 votes vote down vote up
private void describe(String dbInstanceIdentifier) throws Exception {
    while (true) {
        DescribeDBInstancesRequest request = new DescribeDBInstancesRequest()
                .withDBInstanceIdentifier(dbInstanceIdentifier);

        DescribeClustersResult response = client.describeClusters(new DescribeClustersRequest()
                .withClusterIdentifier(INSTANCE_ID)
        );
        Cluster dbInstance = response.getClusters().get(0);
        if (!dbInstance.getClusterStatus().equalsIgnoreCase("creating")) {
            System.out.println("Done! " + response);
            System.out.println(dbInstance.getEndpoint().getAddress());
            System.out.println(dbInstance.getEndpoint().getPort());
            break;
        }

        System.out.println("Not done - will wait 10s: " + response);
        Thread.sleep(10000L);
    }
}
 
Example #3
Source File: PublicAccessAutoFix.java    From pacbot with Apache License 2.0 5 votes vote down vote up
/**
   * Gets the cluster for redhift resource.
   *
   * @param clientMap the client map
   * @param resourceId the resource id
   * @return the cluster for redhift resource
   * @throws Exception the exception
   */
  public static List<Cluster> getClusterForRedhiftResource(Map<String,Object> clientMap,String resourceId) throws Exception {
  	AmazonRedshift amazonRedshift = (AmazonRedshift) clientMap.get("client");
DescribeClustersRequest describeClustersRequest = new DescribeClustersRequest();
describeClustersRequest.setClusterIdentifier(resourceId);
DescribeClustersResult clustersResult = amazonRedshift.describeClusters(describeClustersRequest);

return clustersResult.getClusters();
  }
 
Example #4
Source File: RedshiftUtils.java    From amazon-kinesis-connectors with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the JDBC URL associated with an active Amazon Redshift cluster.
 * 
 * @param client
 *        The {@link AmazonRedshiftClient} with read permissions
 * @param clusterIdentifier
 *        The unique Amazon Redshift cluster identifier
 * @return JDBC URL for the Amazon Redshift cluster
 */
public static String getClusterURL(AmazonRedshiftClient client, String clusterIdentifier) {
    DescribeClustersRequest describeClustersRequest = new DescribeClustersRequest();
    describeClustersRequest.setClusterIdentifier(clusterIdentifier);
    DescribeClustersResult describeClustersResult = client.describeClusters(describeClustersRequest);
    List<Cluster> clusters = describeClustersResult.getClusters();
    if (!clusters.isEmpty()) {
        return toJDBC(clusters.get(0).getEndpoint(), clusters.get(0).getDBName());
    }
    return null;
}