Purchasing a Reserved Node Offering Using
AWS SDK for Java
The following example demonstrates how to use the AWS SDK for Java to do the following:
• List existing reserved nodes.
• Search for a new reserved node offering based on specified node criteria.
• Purchase a reserved node.
In this example, all the reserved node offerings that match a specified node type and fixed price value
are selected. Then, the program goes through each found offering and allows you to purchase the offering.
Important
If you run this program and accept the offer to purchase a reserved node offering, you will be
charged for the offering.
For step-by-step instructions to run the following example, see
Running Java Examples for Amazon
Redshift Using Eclipse (p. 118)
. You need to update the code and provide a different node type and fixed
price.
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.IOException;
import java.util.ArrayList;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.PropertiesCredentials;
import com.amazonaws.services.redshift.AmazonRedshiftClient;
import com.amazonaws.services.redshift.model.DescribeReservedNodeOfferings
Request;
import com.amazonaws.services.redshift.model.DescribeReservedNodeOfferingsResult;
import com.amazonaws.services.redshift.model.DescribeReservedNodesResult;
import com.amazonaws.services.redshift.model.PurchaseReservedNodeOfferingRequest;
import com.amazonaws.services.redshift.model.ReservedNode;
import com.amazonaws.services.redshift.model.ReservedNodeAlreadyExistsException;
import com.amazonaws.services.redshift.model.ReservedNodeOffering;
import com.amazonaws.services.redshift.model.ReservedNodeOfferingNotFoundExcep
tion;
import com.amazonaws.services.redshift.model.ReservedNodeQuotaExceededException;
public class ListAndPurchaseReservedNodeOffering {
public static AmazonRedshiftClient client;
API Version 2012-12-01
86
Amazon Redshift Management Guide
Purchasing a Reserved Node Offering Using Java