Java Code Examples for com.amazonaws.AmazonClientException#getMessage()
The following examples show how to use
com.amazonaws.AmazonClientException#getMessage() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CreateS3BucketTask.java From aws-ant-tasks with Apache License 2.0 | 6 votes |
public void execute() { AmazonS3Client client = getOrCreateClient(AmazonS3Client.class); try { System.out.println("Creating bucket with name " + bucketName + "..."); client.createBucket(bucketName); System.out .println("Bucket " + bucketName + " successfuly created."); } catch (AmazonServiceException ase) { throw new BuildException( "AmazonServiceException: Errors in S3 while processing request." + ase.getMessage()); } catch (AmazonClientException ace) { throw new BuildException( "AmazonClientException: Errors encountered in the client while" + " making the request or handling the response. " + ace.getMessage()); } catch (Exception e) { throw new BuildException(e.getMessage()); } }
Example 2
Source File: AwsAutoScalingDeployUtils.java From vertx-deploy-tools with Apache License 2.0 | 5 votes |
public List<Ec2Instance> getInstancesForAutoScalingGroup(Log log, AutoScalingGroup autoScalingGroup) throws MojoFailureException { log.info("retrieving list of instanceId's for auto scaling group with id : " + activeConfiguration.getAutoScalingGroupId()); activeConfiguration.getHosts().clear(); log.debug("describing instances in auto scaling group"); if (autoScalingGroup.getInstances().isEmpty()) { return new ArrayList<>(); } Map<String, Instance> instanceMap = autoScalingGroup.getInstances().stream().collect(Collectors.toMap(Instance::getInstanceId, Function.identity())); try { DescribeInstancesResult instancesResult = awsEc2Client.describeInstances(new DescribeInstancesRequest().withInstanceIds(autoScalingGroup.getInstances().stream().map(Instance::getInstanceId).collect(Collectors.toList()))); List<Ec2Instance> ec2Instances = instancesResult.getReservations().stream().flatMap(r -> r.getInstances().stream()).map(this::toEc2Instance).collect(Collectors.toList()); log.debug("describing elb status"); autoScalingGroup.getLoadBalancerNames().forEach(elb -> this.updateInstancesStateOnLoadBalancer(elb, ec2Instances)); ec2Instances.forEach(i -> i.updateAsState(AwsState.map(instanceMap.get(i.getInstanceId()).getLifecycleState()))); ec2Instances.sort((o1, o2) -> { int sComp = o1.getAsState().compareTo(o2.getAsState()); if (sComp != 0) { return sComp; } else { return o1.getElbState().compareTo(o2.getElbState()); } }); if (activeConfiguration.isIgnoreInStandby()) { return ec2Instances.stream().filter(i -> i.getAsState() != AwsState.STANDBY).collect(Collectors.toList()); } return ec2Instances; } catch (AmazonClientException e) { log.error(e.getMessage(), e); throw new MojoFailureException(e.getMessage()); } }
Example 3
Source File: S3BlobContainer.java From crate with Apache License 2.0 | 5 votes |
@Override public InputStream readBlob(String blobName) throws IOException { try (AmazonS3Reference clientReference = blobStore.clientReference()) { final S3Object s3Object = clientReference.client().getObject(blobStore.bucket(), buildKey(blobName)); return s3Object.getObjectContent(); } catch (final AmazonClientException e) { if (e instanceof AmazonS3Exception) { if (404 == ((AmazonS3Exception) e).getStatusCode()) { throw new NoSuchFileException("Blob object [" + blobName + "] not found: " + e.getMessage()); } } throw e; } }
Example 4
Source File: AWSHelper.java From attic-stratos with Apache License 2.0 | 4 votes |
/** * Returns the security group id for the given region if it is already * present. If it is not already present then creates a new security group * in that region. * * @param region * @param vpcId * @return Id of the security group * @throws LoadBalancerExtensionException */ public String getSecurityGroupIdForRegion(String region, String vpcId) throws LoadBalancerExtensionException { // if (region == null) // return null; // // if (this.regionToSecurityGroupIdMap.contains(region)) { // return this.regionToSecurityGroupIdMap.get(region); // } else { // // Get the the security group id if it is already present. // String securityGroupId = getSecurityGroupId( // this.lbSecurityGroupName, region); // // if (securityGroupId == null) { // securityGroupId = createSecurityGroup(this.lbSecurityGroupName, // this.lbSecurityGroupDescription, region, vpcId); // } // // this.regionToSecurityGroupIdMap.put(region, securityGroupId); // // return securityGroupId; // } // if lb security group id is defined, use that, do not create a new security group if (lbSecurityGroupId != null && !lbSecurityGroupId.isEmpty()) { return lbSecurityGroupId; } // check if the security group is already exists DescribeSecurityGroupsRequest describeSecurityGroupsReq = new DescribeSecurityGroupsRequest(); // set filter for vpc id if (vpcId != null) { Set<Filter> filters = getFilters(vpcId, lbSecurityGroupName); describeSecurityGroupsReq.setFilters(filters); } else { // no vpc id defined, assume default vpc List<String> groupNames = new ArrayList<String>(); groupNames.add(lbSecurityGroupName); describeSecurityGroupsReq.setGroupNames(groupNames); } DescribeSecurityGroupsResult describeSecurityGroupsRes = null; try { ec2Client.setEndpoint(String.format( Constants.EC2_ENDPOINT_URL_FORMAT, region)); describeSecurityGroupsRes = ec2Client.describeSecurityGroups(describeSecurityGroupsReq); if (describeSecurityGroupsRes != null && describeSecurityGroupsRes.getSecurityGroups() != null) { // already exists, return the id if(describeSecurityGroupsRes.getSecurityGroups().size() > 0) { return describeSecurityGroupsRes.getSecurityGroups().get(0).getGroupId(); } } } catch (AmazonClientException e) { throw new LoadBalancerExtensionException(e.getMessage(), e); } return createSecurityGroup(this.lbSecurityGroupName, this.lbSecurityGroupDescription, region, vpcId); }