jets3t and Walrus [Simple Java Application]

33 views
Skip to first unread message

Thoba Lose

unread,
Jun 27, 2013, 11:09:01 AM6/27/13
to jets3t...@googlegroups.com
Hello! Thought I should share my experience:  Below is a simple Java application that prints out the number of 'buckets' you have on Walrus and their names :-)

import org.jets3t.service.Jets3tProperties;
import org.jets3t.service.S3Service;
import org.jets3t.service.S3ServiceException;
import org.jets3t.service.impl.rest.httpclient.RestS3Service;
import org.jets3t.service.model.S3Bucket;
import org.jets3t.service.model.S3Object;
import org.jets3t.service.security.AWSCredentials;

/**
 *
 * @author thoba
 */
public class ConnectWalrus {

    public static void main(String[] args) throws S3ServiceException {
       
        String awsAccessKey = "VKPK98DL9HEUUTISURTRS";
        String awsSecretKey = "0R4Af2nVDeUYjiEzb52zX9MGCU3MCyCqAi7R4bHw";
        AWSCredentials awsCredentials =
                new AWSCredentials(awsAccessKey, awsSecretKey);
        Jets3tProperties props = new Jets3tProperties();
        String endPoint = "172.20.56.90:8773";
        props.setProperty("s3service.s3-endpoint", endPoint);
        props.setProperty("s3service.s3-endpoint-virtual-path",
                "/services/Walrus");
      
        props.setProperty("s3service.https-only", "false");
        S3Service s3Service = new RestS3Service(awsCredentials, null, null,
                props);

        System.out.println("My EndPoint: " + s3Service.getEndpoint());
     
        S3Bucket[] myBuckets = s3Service.listAllBuckets();
        System.out.println("How many buckets do I have in Walrus?  You have: "
                + myBuckets.length + " buckets");

        for (int i = 0; i < myBuckets.length; i++) {
            System.out.println("Bucket [" + i + "] is '" + myBuckets[i].getName()+"'");
        }

        System.out.println("My EndPoint: " + s3Service.getEndpoint());

    }
}

karishma tiwari

unread,
Sep 28, 2014, 10:41:34 PM9/28/14
to jets3t...@googlegroups.com
followed your method but i am getting the below error:

Exception in thread "main" org.jets3t.service.S3ServiceException: Request Error: Host name may not be null
at org.jets3t.service.S3Service.listAllBuckets(S3Service.java:1316)
at WalrusConnection.main(WalrusConnection.java:34)
Caused by: java.lang.IllegalArgumentException: Host name may not be null
at org.apache.http.HttpHost.<init>(HttpHost.java:79)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:501)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
at org.jets3t.service.impl.rest.httpclient.RestStorageService.performRequest(RestStorageService.java:320)
at org.jets3t.service.impl.rest.httpclient.RestStorageService.performRequest(RestStorageService.java:265)
at org.jets3t.service.impl.rest.httpclient.RestStorageService.performRestGet(RestStorageService.java:966)
at org.jets3t.service.impl.rest.httpclient.RestStorageService.performRestGet(RestStorageService.java:938)
at org.jets3t.service.impl.rest.httpclient.RestStorageService.listAllBucketsImpl(RestStorageService.java:1344)
at org.jets3t.service.StorageService.listAllBucketsImpl(StorageService.java:1406)
at org.jets3t.service.StorageService.listAllBuckets(StorageService.java:590)
at org.jets3t.service.S3Service.listAllBuckets(S3Service.java:1313)
... 1 more

Any idea? 
Reply all
Reply to author
Forward
0 new messages