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

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

Introduction

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

Prototype


public void setDBName(String dBName) 

Source Link

Document

The name of the first database to be created when the cluster is created.

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  w w . ja va2 s.  co  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 ww  .j  a  v  a  2  s  .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;
    }
    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");
}