AWSCredentials credentials = new PropertiesCredentials(
CreateAndModifyClusterParameterGroup.class
.getResourceAsStream("AwsCredentials.properties"));
client = new AmazonRedshiftClient(credentials);
try {
createClusterParameterGroup();
modifyClusterParameterGroup();
associateParameterGroupWithCluster();
describeClusterParameterGroups();
} catch (Exception e) {
System.err.println("Operation failed: " + e.getMessage());
}
}
private static void createClusterParameterGroup() {
CreateClusterParameterGroupRequest request = new CreateClusterParamet
erGroupRequest()
.withDescription("my cluster parameter group")
.withParameterGroupName(clusterParameterGroupName)
.withParameterGroupFamily(parameterGroupFamily);
client.createClusterParameterGroup(request);
System.out.println("Created cluster parameter group.");
}
private static void describeClusterParameterGroups() {
DescribeClusterParameterGroupsResult result = client.describeClusterPara
meterGroups();
printResultClusterParameterGroups(result);
}
private static void modifyClusterParameterGroup() {
List<Parameter> parameters = new ArrayList<Parameter>();
parameters.add(new Parameter()
.withParameterName("extra_float_digits")
.withParameterValue("2"));
// Replace WLM configuration. The new configuration defines a queue (in
addition to the default).
parameters.add(new Parameter()
.withParameterName("wlm_json_configuration")
.withParameterValue("[{\"user_group\":[\"ex
ample_user_group1\"],\"query_group\":[\"example_query_group1\"],\"query_concur
rency\":7},{\"query_concurrency\":5}]"));
ModifyClusterParameterGroupRequest request = new ModifyClusterParamet
erGroupRequest()
.withParameterGroupName(clusterParameterGroupName)
.withParameters(parameters);
client.modifyClusterParameterGroup(request);
}
private static void associateParameterGroupWithCluster() {
ModifyClusterRequest request = new ModifyClusterRequest()
.withClusterIdentifier(clusterIdentifier)
.withClusterParameterGroupName(clusterParameterGroupName);
API Version 2012-12-01
49
Amazon Redshift Management Guide
Managing Parameter Groups Using AWS SDK for Java