Example usage for com.amazonaws.regions ServiceAbbreviations RedShift

List of usage examples for com.amazonaws.regions ServiceAbbreviations RedShift

Introduction

In this page you can find the example usage for com.amazonaws.regions ServiceAbbreviations RedShift.

Prototype

String RedShift

To view the source code for com.amazonaws.regions ServiceAbbreviations RedShift.

Click Source Link

Usage

From source file:com.optimalbi.AmazonAccount.java

License:Apache License

private void populateRedshift() throws AmazonClientException {
    for (Region region : getRegions()) {
        try {//from w w w  .j a  v a 2s .c o  m
            if (region.isServiceSupported(ServiceAbbreviations.RedShift)) {
                //                    services.addAll(RedshiftService.populateServices(region, getCredentials(), getLogger()));
                AmazonRedshiftClient redshift = new AmazonRedshiftClient(getCredentials().getCredentials());
                redshift.setRegion(region);

                DescribeClustersResult clusterResult;
                List<Cluster> clusters;
                try {
                    clusterResult = redshift.describeClusters();
                    clusters = clusterResult.getClusters();
                } catch (Exception e) {
                    throw new AmazonClientException("Failed to get clusters " + e.getMessage());
                }

                getLogger().info("Redshift, Adding " + clusters.size() + " clusters from " + region.getName());
                for (Cluster cluster : clusters) {
                    getLogger().info("Cluster: " + cluster.getClusterIdentifier());
                    LocalRedshiftService temp = new LocalRedshiftService(cluster.getDBName(), getCredentials(),
                            region, cluster, getLogger());
                    if (servicePricings != null && servicePricings.size() > 0) {
                        temp.attachPricing(servicePricings.get(region).getRedshiftPricing());
                    }
                    services.add(temp);
                }
            } else {
                getLogger().info("Redshift, NOPE from " + region.getName());
            }
        } catch (AmazonClientException e) {
            throw new AmazonClientException(region.getName() + " " + e.getMessage());
        }
        completed.set(completed.get() + 1);
    }
}

From source file:com.optimalbi.Controller.AmazonAccount.java

License:Apache License

private void populateRedshift() throws AmazonClientException {
    for (Region region : getRegions()) {
        try {/* w  ww .j  av a  2s. c  o  m*/
            if (region.isServiceSupported(ServiceAbbreviations.RedShift)) {
                //                    services.addAll(RedshiftService.populateServices(region, getCredentials(), getLogger()));
                AmazonRedshiftClient redshift = new AmazonRedshiftClient(getCredentials().getCredentials());
                redshift.setRegion(region);

                DescribeClustersResult clusterResult;
                List<Cluster> clusters;
                try {
                    clusterResult = redshift.describeClusters();
                    clusters = clusterResult.getClusters();
                } catch (Exception e) {
                    throw new AmazonClientException("Failed to get clusters " + e.getMessage());
                }

                getLogger().info("Redshift, Adding " + clusters.size() + " clusters from " + region.getName());
                for (Cluster cluster : clusters) {
                    getLogger().info("Cluster: " + cluster.getClusterIdentifier());
                    services.add(new LocalRedshiftService(cluster.getClusterIdentifier(), getCredentials(),
                            region, cluster, getLogger()));
                }
            } else {
                getLogger().info("Redshift, NOPE from " + region.getName());

            }
        } catch (AmazonClientException e) {
            throw new AmazonClientException(region.getName() + " " + e.getMessage());
        }
        completed.set(completed.get() + 1);
    }
}