List of usage examples for com.amazonaws.regions Regions AP_SOUTHEAST_1
Regions AP_SOUTHEAST_1
To view the source code for com.amazonaws.regions Regions AP_SOUTHEAST_1.
Click Source Link
From source file:SimpleQueueServiceMultiThread.java
License:Open Source License
public static void main(String[] args) throws Exception { /*/* w w w . j av a 2 s . com*/ * The ProfileCredentialsProvider will return your [default] * credential profile by reading from the credentials file located at * (~/.aws/credentials). */ AWSCredentials credentials = null; try { credentials = new ProfileCredentialsProvider().getCredentials(); } 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 (~/.aws/credentials), and is in valid format.", e); } //AmazonSQS sqs = new AmazonSQSClient(credentials,clientConfig); sqs = new AmazonSQSClient(credentials); Region apSouthEast1 = Region.getRegion(Regions.AP_SOUTHEAST_1); sqs.setRegion(apSouthEast1); System.out.println("==========================================="); System.out.println("Getting Started with Amazon SQS"); System.out.println("===========================================\n"); //Define thread pool size ExecutorService executor = Executors.newFixedThreadPool(poolSize); //create a list to hold the Future object associated with Callable List<Future<Long>> list = new ArrayList<Future<Long>>(); //Create Callable instance Callable<Long> callable = new SimpleQueueServiceMultiThread(); for (int i = 0; i < threadSize; i++) { //submit Callable tasks to be executed by thread pool Future<Long> future = executor.submit(callable); //add Future to the list, we can get return value using Future list.add(future); } for (Future<Long> fut : list) { try { // Future.get() waits for task to get completed System.out.println("Time difference : " + fut.get()); long timeDiff = fut.get().longValue(); totalTime = Long.valueOf(totalTime + timeDiff); if (timeDiff >= maxTime) { maxTime = timeDiff; } if (minTime == 0L && timeDiff >= minTime) { minTime = timeDiff; //}else if (timeDiff <= minTime && timeDiff != 0L) { } else if (timeDiff <= minTime) { minTime = timeDiff; } } catch (InterruptedException | ExecutionException e) { e.printStackTrace(); } } if (totalTime >= 0L) { averageTime = totalTime / threadSize; } System.out.println("Total Time : " + Long.valueOf(totalTime).toString()); System.out.println("Max Time : " + Long.valueOf(maxTime).toString()); System.out.println("Min Time : " + Long.valueOf(minTime).toString()); System.out.println("Average Time : " + Long.valueOf(averageTime).toString()); //shut down the executor service now executor.shutdown(); }
From source file:SimpleQueueServiceMultiThread1.java
License:Open Source License
public static void main(String[] args) throws Exception { /*// w w w . j a va 2 s. c o m * The ProfileCredentialsProvider will return your [default] * credential profile by reading from the credentials file located at * (~/.aws/credentials). */ AWSCredentials credentials = null; try { credentials = new ProfileCredentialsProvider().getCredentials(); } 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 (~/.aws/credentials), and is in valid format.", e); } //AmazonSQS sqs = new AmazonSQSClient(credentials,clientConfig); sqs = new AmazonSQSClient(credentials); Region apSouthEast1 = Region.getRegion(Regions.AP_SOUTHEAST_1); sqs.setRegion(apSouthEast1); System.out.println("==========================================="); System.out.println("Getting Started with Amazon SQS"); System.out.println("===========================================\n"); //Define thread pool size ExecutorService executor = Executors.newFixedThreadPool(poolSize); //create a list to hold the Future object associated with Callable List<Future<Long>> list = new ArrayList<Future<Long>>(); //Create Callable instance Callable<Long> callable = new SimpleQueueServiceMultiThread1(); for (int i = 0; i < threadSize; i++) { //submit Callable tasks to be executed by thread pool Future<Long> future = executor.submit(callable); //add Future to the list, we can get return value using Future list.add(future); } for (Future<Long> fut : list) { try { // Future.get() waits for task to get completed System.out.println("Time difference : " + fut.get()); long timeDiff = fut.get().longValue(); totalTime = Long.valueOf(totalTime + timeDiff); if (timeDiff >= maxTime) { maxTime = timeDiff; } if (minTime == 0L && timeDiff >= minTime) { minTime = timeDiff; //}else if (timeDiff <= minTime && timeDiff != 0L) { } else if (timeDiff <= minTime) { minTime = timeDiff; } } catch (InterruptedException | ExecutionException e) { e.printStackTrace(); } } if (totalTime >= 0L) { averageTime = totalTime / threadSize; } System.out.println("Total Time : " + Long.valueOf(totalTime).toString()); System.out.println("Max Time : " + Long.valueOf(maxTime).toString()); System.out.println("Min Time : " + Long.valueOf(minTime).toString()); System.out.println("Average Time : " + Long.valueOf(averageTime).toString()); //shut down the executor service now executor.shutdown(); }
From source file:SimpleQueueServiceMultiThread4.java
License:Open Source License
public static void main(String[] args) throws Exception { /*// w w w. java 2 s . c om * The ProfileCredentialsProvider will return your [default] * credential profile by reading from the credentials file located at * (~/.aws/credentials). */ AWSCredentials credentials = null; try { credentials = new ProfileCredentialsProvider().getCredentials(); } 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 (~/.aws/credentials), and is in valid format.", e); } //AmazonSQS sqs = new AmazonSQSClient(credentials,clientConfig); sqs = new AmazonSQSClient(credentials); Region apSouthEast1 = Region.getRegion(Regions.AP_SOUTHEAST_1); sqs.setRegion(apSouthEast1); System.out.println("==========================================="); System.out.println("Getting Started with Amazon SQS"); System.out.println("===========================================\n"); //Define thread pool size ExecutorService executor = Executors.newFixedThreadPool(poolSize); //create a list to hold the Future object associated with Callable List<Future<Long>> list = new ArrayList<Future<Long>>(); //Create Callable instance Callable<Long> callable = new SimpleQueueServiceMultiThread4(); for (int i = 0; i < threadSize; i++) { //submit Callable tasks to be executed by thread pool Future<Long> future = executor.submit(callable); //add Future to the list, we can get return value using Future list.add(future); } for (Future<Long> fut : list) { try { // Future.get() waits for task to get completed System.out.println("Time difference : " + fut.get()); long timeDiff = fut.get().longValue(); totalTime = Long.valueOf(totalTime + timeDiff); if (timeDiff >= maxTime) { maxTime = timeDiff; } if (minTime == 0L && timeDiff >= minTime) { minTime = timeDiff; //}else if (timeDiff <= minTime && timeDiff != 0L) { } else if (timeDiff <= minTime) { minTime = timeDiff; } } catch (InterruptedException | ExecutionException e) { e.printStackTrace(); } } if (totalTime >= 0L) { averageTime = totalTime / threadSize; } System.out.println("Total Time : " + Long.valueOf(totalTime).toString()); System.out.println("Max Time : " + Long.valueOf(maxTime).toString()); System.out.println("Min Time : " + Long.valueOf(minTime).toString()); System.out.println("Average Time : " + Long.valueOf(averageTime).toString()); //shut down the executor service now executor.shutdown(); }
From source file:SimpleQueueServiceMultiThread2.java
License:Open Source License
public static void main(String[] args) throws Exception { /*//from w w w . j a va 2 s .c om * The ProfileCredentialsProvider will return your [default] * credential profile by reading from the credentials file located at * (~/.aws/credentials). */ AWSCredentials credentials = null; try { credentials = new ProfileCredentialsProvider().getCredentials(); } 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 (~/.aws/credentials), and is in valid format.", e); } //AmazonSQS sqs = new AmazonSQSClient(credentials,clientConfig); sqs = new AmazonSQSClient(credentials); Region apSouthEast1 = Region.getRegion(Regions.AP_SOUTHEAST_1); sqs.setRegion(apSouthEast1); System.out.println("==========================================="); System.out.println("Getting Started with Amazon SQS"); System.out.println("===========================================\n"); //Define thread pool size ExecutorService executor = Executors.newFixedThreadPool(poolSize); //create a list to hold the Future object associated with Callable List<Future<Long>> list = new ArrayList<Future<Long>>(); //Create Callable instance Callable<Long> callable = new SimpleQueueServiceMultiThread2(); for (int i = 0; i < threadSize; i++) { //submit Callable tasks to be executed by thread pool Future<Long> future = executor.submit(callable); //add Future to the list, we can get return value using Future list.add(future); } for (Future<Long> fut : list) { try { // Future.get() waits for task to get completed System.out.println("Time difference : " + fut.get()); long timeDiff = fut.get().longValue(); totalTime = Long.valueOf(totalTime + timeDiff); if (timeDiff >= maxTime) { maxTime = timeDiff; } if (minTime == 0L && timeDiff >= minTime) { minTime = timeDiff; //}else if (timeDiff <= minTime && timeDiff != 0L) { } else if (timeDiff <= minTime) { minTime = timeDiff; } } catch (InterruptedException | ExecutionException e) { e.printStackTrace(); } } if (totalTime >= 0L) { averageTime = totalTime / threadSize; } System.out.println("Total Time : " + Long.valueOf(totalTime).toString()); System.out.println("Max Time : " + Long.valueOf(maxTime).toString()); System.out.println("Min Time : " + Long.valueOf(minTime).toString()); System.out.println("Average Time : " + Long.valueOf(averageTime).toString()); //shut down the executor service now executor.shutdown(); }
From source file:SimpleQueueServiceMultiThread3.java
License:Open Source License
public static void main(String[] args) throws Exception { /*// w w w .j a va2s. c om * The ProfileCredentialsProvider will return your [default] * credential profile by reading from the credentials file located at * (~/.aws/credentials). */ AWSCredentials credentials = null; try { credentials = new ProfileCredentialsProvider().getCredentials(); } 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 (~/.aws/credentials), and is in valid format.", e); } //AmazonSQS sqs = new AmazonSQSClient(credentials,clientConfig); sqs = new AmazonSQSClient(credentials); Region apSouthEast1 = Region.getRegion(Regions.AP_SOUTHEAST_1); sqs.setRegion(apSouthEast1); System.out.println("==========================================="); System.out.println("Getting Started with Amazon SQS"); System.out.println("===========================================\n"); //Define thread pool size ExecutorService executor = Executors.newFixedThreadPool(poolSize); //create a list to hold the Future object associated with Callable List<Future<Long>> list = new ArrayList<Future<Long>>(); //Create Callable instance Callable<Long> callable = new SimpleQueueServiceMultiThread3(); for (int i = 0; i < threadSize; i++) { //submit Callable tasks to be executed by thread pool Future<Long> future = executor.submit(callable); //add Future to the list, we can get return value using Future list.add(future); } for (Future<Long> fut : list) { try { // Future.get() waits for task to get completed System.out.println("Time difference : " + fut.get()); long timeDiff = fut.get().longValue(); totalTime = Long.valueOf(totalTime + timeDiff); if (timeDiff >= maxTime) { maxTime = timeDiff; } if (minTime == 0L && timeDiff >= minTime) { minTime = timeDiff; //}else if (timeDiff <= minTime && timeDiff != 0L) { } else if (timeDiff <= minTime) { minTime = timeDiff; } } catch (InterruptedException | ExecutionException e) { e.printStackTrace(); } } if (totalTime >= 0L) { averageTime = totalTime / threadSize; } System.out.println("Total Time : " + Long.valueOf(totalTime).toString()); System.out.println("Max Time : " + Long.valueOf(maxTime).toString()); System.out.println("Min Time : " + Long.valueOf(minTime).toString()); System.out.println("Average Time : " + Long.valueOf(averageTime).toString()); //shut down the executor service now executor.shutdown(); }
From source file:com.amazon.AmazonClientManager.java
License:Apache License
public void validateCredentials() { if (sdbClient == null) { Log.i(LOG_TAG, "Creating New Clients."); Region region = Region.getRegion(Regions.AP_SOUTHEAST_1); AWSCredentials credentials = new BasicAWSCredentials(PropertyLoader.getInstance().getAccessKey(), PropertyLoader.getInstance().getSecretKey()); sdbClient = new AmazonSimpleDBClient(credentials); sdbClient.setRegion(region);//from w w w . j ava2 s . c o m } }
From source file:com.imos.sample.S3SampleCheck.java
License:Open Source License
public static void main(String[] args) throws IOException { /*// w w w. j a va 2 s. c om * The ProfileCredentialsProvider will return your [default] * credential profile by reading from the credentials file located at * (/home/alok/.aws/credentials). */ AWSCredentials credentials = null; try { credentials = new ProfileCredentialsProvider("default").getCredentials(); } 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 (/home/alok/.aws/credentials), and is in valid format.", e); } AmazonS3 s3 = new AmazonS3Client(credentials); // Region usWest2 = Region.getRegion(Regions.US_WEST_2); Region usWest2 = Region.getRegion(Regions.AP_SOUTHEAST_1); s3.setRegion(usWest2); String bucketName = "alok-test"; String key = "sample.json"; System.out.println("==========================================="); System.out.println("Getting Started with Amazon S3"); System.out.println("===========================================\n"); try { /* * Create a new S3 bucket - Amazon S3 bucket names are globally unique, * so once a bucket name has been taken by any user, you can't create * another bucket with that same name. * * You can optionally specify a location for your bucket if you want to * keep your data closer to your applications or users. */ // System.out.println("Creating bucket " + bucketName + "\n"); // s3.createBucket(bucketName); /* * List the buckets in your account */ // System.out.println("Listing buckets"); // for (Bucket bucket : s3.listBuckets()) { // System.out.println(" - " + bucket.getName()); // } System.out.println(); /* * Upload an object to your bucket - You can easily upload a file to * S3, or upload directly an InputStream if you know the length of * the data in the stream. You can also specify your own metadata * when uploading to S3, which allows you set a variety of options * like content-type and content-encoding, plus additional metadata * specific to your applications. */ System.out.println("Uploading a new object to S3 from a file\n"); //s3.putObject(new PutObjectRequest(bucketName, key, createSampleFile())); s3.putObject(new PutObjectRequest(bucketName, key, createSampleFile())); /* * Download an object - When you download an object, you get all of * the object's metadata and a stream from which to read the contents. * It's important to read the contents of the stream as quickly as * possibly since the data is streamed directly from Amazon S3 and your * network connection will remain open until you read all the data or * close the input stream. * * GetObjectRequest also supports several other options, including * conditional downloading of objects based on modification times, * ETags, and selectively downloading a range of an object. */ System.out.println("Downloading an object"); // S3Object object = s3.getObject(new GetObjectRequest(bucketName, key)); S3Object object = s3.getObject(new GetObjectRequest("alok-test", key)); System.out.println("Content-Type: " + object.getObjectMetadata().getContentType()); displayTextInputStream(object.getObjectContent()); /* * List objects in your bucket by prefix - There are many options for * listing the objects in your bucket. Keep in mind that buckets with * many objects might truncate their results when listing their objects, * so be sure to check if the returned object listing is truncated, and * use the AmazonS3.listNextBatchOfObjects(...) operation to retrieve * additional results. */ System.out.println("Listing objects"); ObjectListing objectListing = s3.listObjects(new ListObjectsRequest() // .withBucketName(bucketName) .withBucketName("alok-test")); // .withPrefix("My")); objectListing.getObjectSummaries().forEach((objectSummary) -> { System.out.println( " - " + objectSummary.getKey() + " " + "(size = " + objectSummary.getSize() + ")"); }); System.out.println(); /* * Delete an object - Unless versioning has been turned on for your bucket, * there is no way to undelete an object, so use caution when deleting objects. */ // System.out.println("Deleting an object\n"); // s3.deleteObject(bucketName, key); /* * Delete a bucket - A bucket must be completely empty before it can be * deleted, so remember to delete any objects from your buckets before * you try to delete them. */ // System.out.println("Deleting bucket " + bucketName + "\n"); // s3.deleteBucket(bucketName); } 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()); } }
From source file:com.kirana.services.ProductServicesImpl.java
public AmazonS3 getS3Client() { AmazonS3 s3client = new AmazonS3Client(new ProfileCredentialsProvider("kirana-s3")); s3client.setRegion(Region.getRegion(Regions.AP_SOUTHEAST_1)); return s3client; }
From source file:com.kirana.utils.GeneratePresignedUrlAndUploadObject.java
public static void main(String[] args) throws IOException { System.setProperty(SDKGlobalConfiguration.ENABLE_S3_SIGV4_SYSTEM_PROPERTY, "true"); System.setProperty(SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR, "AKIAJ666LALJZHA6THGQ"); System.setProperty(SDKGlobalConfiguration.SECRET_KEY_ENV_VAR, "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"); // AmazonS3 s3client = new AmazonS3Client(new ProfileCredentialsProvider("kirana")); ProfilesConfigFile profile = new ProfilesConfigFile("AwsCredentials.properties"); AmazonS3 s3client = new AmazonS3Client(new ProfileCredentialsProvider()); s3client.setRegion(Region.getRegion(Regions.AP_SOUTHEAST_1)); try {/*ww w. ja v a 2 s . co m*/ System.out.println("Generating pre-signed URL."); java.util.Date expiration = new java.util.Date(); long milliSeconds = expiration.getTime(); milliSeconds += 1000 * 60 * 60; // Add 1 hour. expiration.setTime(milliSeconds); GeneratePresignedUrlRequest generatePresignedUrlRequest = new GeneratePresignedUrlRequest(bucketName, objectKey); generatePresignedUrlRequest.setMethod(HttpMethod.PUT); generatePresignedUrlRequest.setExpiration(expiration); // s3client.putObject(bucketName, objectKey, null); URL url = s3client.generatePresignedUrl(generatePresignedUrlRequest); UploadObject(url); System.out.println("Pre-Signed URL = " + url.toString()); } catch (AmazonServiceException exception) { 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: " + exception.getMessage()); System.out.println("HTTP Code: " + exception.getStatusCode()); System.out.println("AWS Error Code:" + exception.getErrorCode()); System.out.println("Error Type: " + exception.getErrorType()); System.out.println("Request ID: " + exception.getRequestId()); } catch (AmazonClientException ace) { System.out.println("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."); System.out.println("Error Message: " + ace.getMessage()); } }
From source file:com.kpbird.aws.Main.java
private void init() { credentials = new BasicAWSCredentials(accessKey, secretKey); // end point for singapore endPoint = "https://rds.ap-southeast-1.amazonaws.com"; // regions for singapore region = Region.getRegion(Regions.AP_SOUTHEAST_1); // EC2Client object ec2client = new AmazonEC2Client(credentials); ec2client.setEndpoint(endPoint);/* w w w . j a v a 2 s. c om*/ ec2client.setRegion(region); // RDSClient object rdsclient = new AmazonRDSClient(credentials); rdsclient.setRegion(region); rdsclient.setEndpoint(endPoint); }