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

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

Introduction

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

Prototype


public void setMasterUsername(String masterUsername) 

Source Link

Document

The user name associated with the master user account for the cluster that is being 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 ww  . j  av 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;
    }
    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
 * /*w w  w  .j a v  a2s. 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;
    }
    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");
}