List of usage examples for com.amazonaws AmazonServiceException getMessage
@Override
public String getMessage()
From source file:com.cloudbees.gasp.services.APNRegistrationService.java
License:Apache License
@POST @Path("register") @Consumes(MediaType.APPLICATION_FORM_URLENCODED) public Response doRegister(@FormParam("token") String token) { try {//from ww w. j ava 2s .c o m // Create an SNS app endpoint CreatePlatformEndpointResult platformEndpointResult = snsMobile .createPlatformEndpoint("Gasp APN Platform Endpoint", token, snsMobile.getApnPlatformArn()); APNDataStore.registerArn(token, platformEndpointResult.getEndpointArn()); LOGGER.info("Registered: " + platformEndpointResult.getEndpointArn()); } catch (AmazonServiceException ase) { LOGGER.debug("AmazonServiceException"); LOGGER.debug(" Error Message: " + ase.getMessage()); LOGGER.debug(" HTTP Status Code: " + ase.getStatusCode()); LOGGER.debug(" AWS Error Code: " + ase.getErrorCode()); LOGGER.debug(" Error Type: " + ase.getErrorType()); LOGGER.debug(" Request ID: " + ase.getRequestId()); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } catch (AmazonClientException ace) { LOGGER.debug("AmazonClientException"); LOGGER.debug(" Error Message: " + ace.getMessage()); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } return Response.status(Response.Status.OK).build(); }
From source file:com.cloudbees.gasp.services.APNRegistrationService.java
License:Apache License
@POST @Path("unregister") @Consumes(MediaType.APPLICATION_FORM_URLENCODED) public Response doUnregister(@FormParam("token") String token) { try {// w w w .j ava 2 s. c o m // Delete the SNS app endpoint snsMobile.deleteEndpointArn(APNDataStore.getEndpointArn(token)); LOGGER.info("Deleted endpoint: " + APNDataStore.getEndpointArn(token)); APNDataStore.unregisterArn(token); LOGGER.info("Unregistered device: " + token); } catch (AmazonServiceException ase) { LOGGER.debug("AmazonServiceException"); LOGGER.debug(" Error Message: " + ase.getMessage()); LOGGER.debug(" HTTP Status Code: " + ase.getStatusCode()); LOGGER.debug(" AWS Error Code: " + ase.getErrorCode()); LOGGER.debug(" Error Type: " + ase.getErrorType()); LOGGER.debug(" Request ID: " + ase.getRequestId()); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } catch (AmazonClientException ace) { LOGGER.debug("AmazonClientException"); LOGGER.debug(" Error Message: " + ace.getMessage()); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } return Response.status(Response.Status.OK).build(); }
From source file:com.cloudbees.gasp.services.DataSyncService.java
License:Apache License
private void sendPushNotifications(String messageText) { try {/*from w ww. ja v a 2s .c o m*/ SNSMobile snsMobile = new SNSMobile(); // Send update to all registered APN endpoints for (String endpointArn : APNDataStore.getEndpoints()) { LOGGER.info("Sending update to APN endpoint ARN: " + endpointArn); snsMobile.pushNotification(SNSMobile.Platform.APNS_SANDBOX, endpointArn, getApnMessage(messageText)); } // Send update to all registered GCM endpoints for (String endpointArn : GCMDataStore.getEndpoints()) { LOGGER.info("Sending update to GCM endpoint ARN: " + endpointArn); snsMobile.pushNotification(SNSMobile.Platform.GCM, endpointArn, getGcmMessage(messageText)); } } catch (AmazonServiceException ase) { LOGGER.debug("AmazonServiceException"); LOGGER.debug(" Error Message: " + ase.getMessage()); LOGGER.debug(" HTTP Status Code: " + ase.getStatusCode()); LOGGER.debug(" AWS Error Code: " + ase.getErrorCode()); LOGGER.debug(" Error Type: " + ase.getErrorType()); LOGGER.debug(" Request ID: " + ase.getRequestId()); } catch (AmazonClientException ace) { LOGGER.debug("AmazonClientException"); LOGGER.debug(" Error Message: " + ace.getMessage()); } catch (Exception e) { return; } }
From source file:com.cloudbees.gasp.services.GCMRegistrationService.java
License:Apache License
@POST @Path("register") @Consumes(MediaType.APPLICATION_FORM_URLENCODED) public Response doRegister(@FormParam("regId") String regId) { try {//from www. ja v a2s .c o m CreatePlatformEndpointResult platformEndpointResult = snsMobile .createPlatformEndpoint("Gasp GCM Platform Endpoint", regId, snsMobile.getGcmPlatformArn()); GCMDataStore.registerArn(regId, platformEndpointResult.getEndpointArn()); LOGGER.info("Registered: " + platformEndpointResult.getEndpointArn()); } catch (AmazonServiceException ase) { LOGGER.debug("AmazonServiceException"); LOGGER.debug(" Error Message: " + ase.getMessage()); LOGGER.debug(" HTTP Status Code: " + ase.getStatusCode()); LOGGER.debug(" AWS Error Code: " + ase.getErrorCode()); LOGGER.debug(" Error Type: " + ase.getErrorType()); LOGGER.debug(" Request ID: " + ase.getRequestId()); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } catch (AmazonClientException ace) { LOGGER.debug("AmazonClientException"); LOGGER.debug(" Error Message: " + ace.getMessage()); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } return Response.status(Response.Status.OK).build(); }
From source file:com.cloudbees.gasp.services.GCMRegistrationService.java
License:Apache License
@POST @Path("unregister") @Consumes(MediaType.APPLICATION_FORM_URLENCODED) public Response doUnregister(@FormParam("regId") String regId) { try {//from ww w. j a v a 2 s .c o m // Delete the SNS app endpoint snsMobile.deleteEndpointArn(GCMDataStore.getEndpointArn(regId)); LOGGER.info("Deleted endpoint: " + GCMDataStore.getEndpointArn(regId)); GCMDataStore.unregisterArn(regId); LOGGER.info("Unregistered device: " + regId); } catch (AmazonServiceException ase) { LOGGER.debug("AmazonServiceException"); LOGGER.debug(" Error Message: " + ase.getMessage()); LOGGER.debug(" HTTP Status Code: " + ase.getStatusCode()); LOGGER.debug(" AWS Error Code: " + ase.getErrorCode()); LOGGER.debug(" Error Type: " + ase.getErrorType()); LOGGER.debug(" Request ID: " + ase.getRequestId()); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } catch (AmazonClientException ace) { LOGGER.debug("AmazonClientException"); LOGGER.debug(" Error Message: " + ace.getMessage()); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } return Response.status(Response.Status.OK).build(); }
From source file:com.clouddrive.parth.NewClass.java
public static String runCluster() throws Exception { long start = System.currentTimeMillis(); String temp = ""; // Configure the job flow //RunJobFlowRequest request = new RunJobFlowRequest().withName("parth"); // if (request == null) { RunJobFlowRequest request = new RunJobFlowRequest(FLOW_NAME, configInstance()); request.setLogUri(S3N_LOG_URI); // }// w w w . j av a2 s . c om // Configure the Hadoop jar to use HadoopJarStepConfig jarConfig = new HadoopJarStepConfig(S3N_HADOOP_JAR); jarConfig.setArgs(ARGS_AS_LIST); try { StepConfig enableDebugging = new StepConfig().withName("Enable debugging") .withActionOnFailure("TERMINATE_JOB_FLOW") .withHadoopJarStep(new StepFactory().newEnableDebuggingStep()); StepConfig runJar = new StepConfig(S3N_HADOOP_JAR.substring(S3N_HADOOP_JAR.indexOf('/') + 1), jarConfig); request.setSteps(Arrays.asList(new StepConfig[] { enableDebugging, runJar })); // Run the job flow RunJobFlowResult result = emr.runJobFlow(request); // Check the status of the running job String lastState = ""; STATUS_LOOP: while (true) { DescribeJobFlowsRequest desc = new DescribeJobFlowsRequest( Arrays.asList(new String[] { result.getJobFlowId() })); DescribeJobFlowsResult descResult = emr.describeJobFlows(desc); for (JobFlowDetail detail : descResult.getJobFlows()) { String state = detail.getExecutionStatusDetail().getState(); if (isDone(state)) { System.out.println("Job " + state + ": " + detail.toString()); break STATUS_LOOP; } else if (!lastState.equals(state)) { lastState = state; System.out.println("Job " + state + " at " + new Date().toString()); } } Thread.sleep(10000); } temp = FLOW_NAME; long end = System.currentTimeMillis(); System.out.println("Computation " + (end - start)); } catch (AmazonServiceException ase) { System.out.println("Caught Exception: " + ase.getMessage()); System.out.println("Reponse Status Code: " + ase.getStatusCode()); System.out.println("Error Code: " + ase.getErrorCode()); System.out.println("Request ID: " + ase.getRequestId()); } return temp; }
From source file:com.cloudera.director.aws.ec2.EC2InstanceTemplateConfigurationValidator.java
License:Apache License
/** * Validates the configured availability zone. * * @param client the EC2 client * @param configuration the configuration to be validated * @param accumulator the exception condition accumulator * @param localizationContext the localization context */// w ww. j a v a 2s . com @VisibleForTesting void checkAvailabilityZone(AmazonEC2Client client, Configured configuration, PluginExceptionConditionAccumulator accumulator, LocalizationContext localizationContext) { String zoneName = configuration.getConfigurationValue(AVAILABILITY_ZONE, localizationContext); if (zoneName != null) { LOG.info(">> Describing zone '{}'", zoneName); try { DescribeAvailabilityZonesResult result = client .describeAvailabilityZones(new DescribeAvailabilityZonesRequest().withZoneNames(zoneName)); checkCount(accumulator, AVAILABILITY_ZONE, localizationContext, "Availability zone", result.getAvailabilityZones()); } catch (AmazonServiceException e) { if (e.getErrorCode().equals(INVALID_PARAMETER_VALUE) && e.getMessage().contains(INVALID_AVAILABILITY_ZONE)) { addError(accumulator, AVAILABILITY_ZONE, localizationContext, null, INVALID_AVAILABILITY_ZONE_MSG, zoneName); } else { throw Throwables.propagate(e); } } } }
From source file:com.cloudhub.aws.extractor.AWSCSVExtractor.java
License:Apache License
/** * Requests billing information from Amazon S3. * This method may spawn multiple threads as needed to complete the task. * *//*from w w w .j a va 2 s. c om*/ @Override public String getTotalCost() { String totalCost = null; try { log.debug("Listing objects ..."); final ListObjectsRequest listObjectsRequest = new ListObjectsRequest().withBucketName(bucketName); ObjectListing objectListing; do { objectListing = s3client.listObjects(listObjectsRequest); for (final S3ObjectSummary objectSummary : objectListing.getObjectSummaries()) { log.debug(" - " + objectSummary.getKey() + " " + "(size = " + objectSummary.getSize() + ")"); if (objectSummary.getKey().contains(Constants.MATCHER_BILLING_CSV.getKeyPattern())) { totalCost = persist(Constants.MATCHER_BILLING_CSV, objectSummary); } else if (objectSummary.getKey().contains(Constants.MATCHER_COST_ALLOCATION.getKeyPattern())) { totalCost = persist(Constants.MATCHER_COST_ALLOCATION, objectSummary); } } listObjectsRequest.setMarker(objectListing.getNextMarker()); } while (objectListing.isTruncated()); } catch (AmazonServiceException ase) { log.error("Caught an AmazonServiceException, " + "which means your request made it " + "to Amazon S3, but was rejected with an error response " + "for some reason."); log.error("Error Message: " + ase.getMessage()); log.error("HTTP Status Code: " + ase.getStatusCode()); log.error("AWS Error Code: " + ase.getErrorCode()); log.error("Error Type: " + ase.getErrorType()); log.error("Request ID: " + ase.getRequestId()); } catch (AmazonClientException ace) { log.error("Caught an AmazonClientException, " + "which means the client encountered " + "an internal error while trying to communicate" + " with S3, " + "such as not being able to access the network."); log.error("Error Message: " + ace.getMessage()); } catch (IOException ioe) { log.error("Caught an IOException while writing to disk."); log.error("Error Message: " + ioe.getMessage()); } return totalCost; }
From source file:com.crickdata.upload.s3.UploadLiveData.java
License:Open Source License
public Map<String, Date> uploadToS3(String fileName, boolean type) throws IOException { Statistics statistics = new Statistics(); Map<String, Date> perfMap = new HashMap<String, Date>(); AWSCredentials credentials = null;//ww w .j ava 2 s .c o m try { credentials = new BasicAWSCredentials("AKIAI6QKTRAQE7MXQOIQ", "wIG6u1yI5ZaseeJbvYSUmD98qelIJNSCVBzt5k2q"); } catch (Exception e) { throw new AmazonClientException("Cannot load the credentials from the credential profiles file. " + "Please make sure that your credentials file is at the correct " + "location (C:\\Users\\bssan_000\\.aws\\credentials), and is in valid format.", e); } AmazonS3 s3 = new AmazonS3Client(credentials); Region usWest2 = Region.getRegion(Regions.US_WEST_2); s3.setRegion(usWest2); String bucketName; if (!type) bucketName = "cricmatchinfo"; else bucketName = "cricmatchinfoseries"; String key = fileName.replace(".json", "").trim(); try { perfMap.put("S3INSERTREQ", new Date()); statistics.setS3Req(new Date()); File f = readMatchFile(fileName); double bytes = f.length(); double kilobytes = (bytes / 1024); System.out.println("Details :" + kilobytes); s3.putObject(new PutObjectRequest(bucketName, key, f)); statistics.setSize(String.valueOf(kilobytes)); S3Object object = s3.getObject(new GetObjectRequest(bucketName, key)); perfMap.put("S3SAVERES", object.getObjectMetadata().getLastModified()); statistics.setKey(key); statistics.setS3Res(object.getObjectMetadata().getLastModified()); MyUI.stats.add(statistics); displayTextInputStream(object.getObjectContent()); ObjectListing objectListing = s3 .listObjects(new ListObjectsRequest().withBucketName(bucketName).withPrefix("My")); for (S3ObjectSummary objectSummary : objectListing.getObjectSummaries()) { System.out.println( " - " + objectSummary.getKey() + " " + "(size = " + objectSummary.getSize() + ")"); } } catch (AmazonServiceException ase) { System.out.println("Caught an AmazonServiceException, which means your request made it " + "to Amazon S3, but was rejected with an error response for some reason."); System.out.println("Error Message: " + ase.getMessage()); System.out.println("HTTP Status Code: " + ase.getStatusCode()); System.out.println("AWS Error Code: " + ase.getErrorCode()); System.out.println("Error Type: " + ase.getErrorType()); System.out.println("Request ID: " + ase.getRequestId()); } catch (AmazonClientException ace) { System.out.println("Caught an AmazonClientException, which means the client encountered " + "a serious internal problem while trying to communicate with S3, " + "such as not being able to access the network."); System.out.println("Error Message: " + ace.getMessage()); } return perfMap; }
From source file:com.davidgildeh.hadoop.input.simpledb.SimpleDBDAO.java
License:Apache License
/** * Does a paged query in SimpleDB/* w ww .j a va 2 s.com*/ * * @param query The Select Query * @param nextToken If there is a paging token to start from, or null if none * @return The SelectResult from the query */ private SelectResult doQuery(String query, String nextToken) { SelectResult results = null; try { if (LOG.isDebugEnabled()) { LOG.debug("Running Query: " + query); } SelectRequest selectRequest = new SelectRequest(query); if (nextToken != null) { selectRequest.setNextToken(nextToken); } results = sdb.select(selectRequest); } catch (AmazonServiceException ase) { LOG.error("Caught an AmazonServiceException, which means your request made it " + "to Amazon SimpleDB, but was rejected with an error response for some reason."); LOG.error("Select Query: " + query); LOG.error("Error Message: " + ase.getMessage()); LOG.error("HTTP Status Code: " + ase.getStatusCode()); LOG.error("AWS Error Code: " + ase.getErrorCode()); LOG.error("Error Type: " + ase.getErrorType()); LOG.error("Request ID: " + ase.getRequestId()); } catch (AmazonClientException ace) { LOG.error("Caught an AmazonClientException, which means the client encountered " + "a serious internal problem while trying to communicate with SimpleDB, " + "such as not being able to access the network."); LOG.error("Error Message: " + ace.getMessage()); } finally { return results; } }