Example usage for com.amazonaws.services.redshift.model CreateClusterRequest CreateClusterRequest

List of usage examples for com.amazonaws.services.redshift.model CreateClusterRequest CreateClusterRequest

Introduction

In this page you can find the example usage for com.amazonaws.services.redshift.model CreateClusterRequest CreateClusterRequest.

Prototype

CreateClusterRequest

Source Link

Usage

From source file:com.amazon.services.awsrum.utils.RedshiftUtils.java

License:Open Source License

/**
 * Creates a Redshift cluster if it does not exist and waits for it to become active
 * /*from   w ww.java  2s  . c  o  m*/
 * @param client
 *            The {@link AmazonRedshiftClient} with read and write permissions
 * @param clusterIdentifier
 *            The unique identifier of the Redshift cluster to create
 * @param databaseName
 *            The database name associated with the Redshift cluster
 * @param masterUsername
 *            The master username for the Redshift database
 * @param masterUserPassword
 *            The master password for the Redshift database
 * @param clusterType
 *            dw.hs1.xlarge or dw.hs1.8xlarge
 * @param numberOfNodes
 *            The number of nodes for the Redshift cluster
 */
public static void createCluster(AmazonRedshiftClient client, String clusterIdentifier, String databaseName,
        String masterUsername, String masterUserPassword, String clusterType, int numberOfNodes) {
    if (clusterExists(client, clusterIdentifier)) {
        LOG.info("Cluster " + clusterIdentifier + " is available");
        return;
    }
    LOG.info(databaseName);
    CreateClusterRequest createClusterRequest = new CreateClusterRequest();
    createClusterRequest.setClusterIdentifier(clusterIdentifier);
    createClusterRequest.setMasterUsername(masterUsername);
    createClusterRequest.setMasterUserPassword(masterUserPassword);
    createClusterRequest.setNodeType(clusterType);
    createClusterRequest.setNumberOfNodes(numberOfNodes);
    createClusterRequest.setDBName(databaseName);
    client.createCluster(createClusterRequest);
    LOG.info("Created cluster " + clusterIdentifier);
    String state = null;
    while (!(state = clusterState(client, clusterIdentifier)).equals("available")) {
        try {
            Thread.sleep(10 * 1000);
            LOG.info(clusterIdentifier + " is " + state + ". Waiting for cluster to become available.");
        } catch (InterruptedException e) {

        }
    }
    LOG.info("Cluster " + clusterIdentifier + " is available");
}

From source file:com.elsevier.utils.RedshiftUtils.java

License:Open Source License

/**
 * Creates a Redshift cluster if it does not exist and waits for it to become active
 * /*from  w w w.j a  va 2  s  . c om*/
 * @param client
 *            The {@link AmazonRedshiftClient} with read and write permissions
 * @param clusterIdentifier
 *            The unique identifier of the Redshift cluster to create
 * @param databaseName
 *            The database name associated with the Redshift cluster
 * @param masterUsername
 *            The master username for the Redshift database
 * @param masterUserPassword
 *            The master password for the Redshift database
 * @param clusterType
 *            dw.hs1.xlarge or dw.hs1.8xlarge
 * @param numberOfNodes
 *            The number of nodes for the Redshift cluster
 */
public static void createCluster(AmazonRedshiftClient client, String clusterIdentifier, String databaseName,
        String masterUsername, String masterUserPassword, String clusterType, int numberOfNodes) {
    if (clusterExists(client, clusterIdentifier)) {
        LOG.info("Cluster " + clusterIdentifier + " is available");
        return;
    }
    CreateClusterRequest createClusterRequest = new CreateClusterRequest();
    createClusterRequest.setClusterIdentifier(clusterIdentifier);
    createClusterRequest.setMasterUsername(masterUsername);
    createClusterRequest.setMasterUserPassword(masterUserPassword);
    createClusterRequest.setNodeType(clusterType);
    createClusterRequest.setNumberOfNodes(numberOfNodes);
    createClusterRequest.setDBName(databaseName);
    client.createCluster(createClusterRequest);
    LOG.info("Created cluster " + clusterIdentifier);
    String state = null;
    while (!(state = clusterState(client, clusterIdentifier)).equals("available")) {
        try {
            Thread.sleep(10 * 1000);
            LOG.info(clusterIdentifier + " is " + state + ". Waiting for cluster to become available.");
        } catch (InterruptedException e) {

        }
    }
    LOG.info("Cluster " + clusterIdentifier + " is available");
}

From source file:com.gs.obevo.amazon.RedshiftInstanceUtil.java

License:Apache License

private void create(String dbInstanceIdentifier) throws Exception {
    // http://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_CreateDBInstance.html
    CreateClusterRequest request = new CreateClusterRequest().withClusterIdentifier(INSTANCE_ID)
            .withNodeType("dc2.large").withDBName("dbdeploy").withPubliclyAccessible(true)
            .withAvailabilityZone("us-east-1").withClusterType("single-node")
            .withMasterUsername("deploybuilddbo").withMasterUserPassword("Deploybuilddb0");
    Cluster response = client.createCluster(request);
    System.out.println(response);

    describe(dbInstanceIdentifier);//from   w ww  .  j a va  2  s.  co  m
}