Advertisement
Guest User

Untitled

a guest
Nov 24th, 2013
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.86 KB | None | 0 0
  1. AmazonS3 s3 = new AmazonS3Client(new PropertiesCredentials(MyClass.class.getResourceAsStream("AwsCredentials.properties")));
  2.  
  3. String s3Key = "folder1/folder2";
  4.  
  5.  
  6. String bucketName = Constantes.S3_BUCKET;
  7. String key = s3Key +"/input_chopped/";
  8.  
  9. ObjectListing current = s3.listObjects(new ListObjectsRequest()
  10. .withBucketName(bucketName)
  11. .withPrefix(key));
  12.  
  13. boolean siguiente = true;
  14.  
  15. while (siguiente) {
  16.  
  17. siguiente &= current.isTruncated();
  18. contador += current.getObjectSummaries().size();
  19.  
  20. for (S3ObjectSummary objectSummary : current.getObjectSummaries()) {
  21. S3Object object = s3.getObject(new GetObjectRequest(bucketName, objectSummary.getKey()));
  22. System.out.println(object.getKey());
  23. }
  24.  
  25. current=s3.listNextBatchOfObjects(current);
  26.  
  27. }
  28.  
  29. INFO (AmazonHttpClient.java:358) - Unable to execute HTTP request: Timeout waiting for connection from pool
  30. org.apache.http.conn.ConnectionPoolTimeoutException: Timeout waiting for connection from pool
  31. at org.apache.http.impl.conn.PoolingClientConnectionManager.leaseConnection(PoolingClientConnectionManager.java:232)
  32. at org.apache.http.impl.conn.PoolingClientConnectionManager$1.getConnection(PoolingClientConnectionManager.java:199)
  33. at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:456)
  34. at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
  35. at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
  36. at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:784)
  37. at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:315)
  38. at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:199)
  39. at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:2994)
  40. at com.amazonaws.services.s3.AmazonS3Client.getObject(AmazonS3Client.java:918)
  41. at com.madiva.segmentacion.tests.ListaS3.main(ListaS3.java:177)
  42. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  43. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  44. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  45. at java.lang.reflect.Method.invoke(Method.java:597)
  46. at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
  47. 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.
  48. Error Message: Unable to execute HTTP request: Timeout waiting for connection from pool
  49.  
  50. for (S3ObjectSummary objectSummary : current.getObjectSummaries()) {
  51. S3Object object = s3.getObject(new GetObjectRequest(bucketName, objectSummary.getKey()));
  52. System.out.println(object.getKey());
  53. object.close();
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement