Please have a look at the below code.
public class S3Test extends HttpServlet {
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
* methods.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String accessKey = "************";
String secretKey = "****************";
AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
AmazonS3 conn = new AmazonS3Client(credentials);
System.out.println("done");
// List<Bucket> buckets = conn.listBuckets();
//for (Bucket bucket : buckets) {
// System.out.println(bucket.getName() + "\t" +
// StringUtils.fromDate(bucket.getCreationDate()));
//}
}
}
I am using this code to list the buckets I have in amazon s3. However this process is extremely slow, it takes almost 1 minute or more. Not only that, this takes lot of memory, almost freezing the Google Chrome. My bucket is in US standard region and my application is running in a PC located in south asia.
The delay is in connection configuration.
I am using Netbeans IDE and the above code is a part of a servlet. The server I am using is apache tomcat 7.
Any ideas why this is taking this much of time? I added all the JAR files came with Amazon SDK for Java as well. It has no use to me if this takes this long.
SPECIAL NOTE
I noticed this is not taking any time delays when it is running in non web java applications. I ran this in a simple Main
class which is not web based, and it worked fine, fast. What is really happening here?
Aucun commentaire:
Enregistrer un commentaire