Search in sources :

Example 31 with S3Object

use of com.amazonaws.services.s3.model.S3Object in project XRTB by benmfaul.

the class AwsCommander method load.

/**
	 * Load the file or s3 object.
	 * @param parts String[]. An array of tokens.
	 * @return String. The message returned from the load command.
	 * @throws Exception on I/O errirs.
	 */
String load(String[] parts) throws Exception {
    String otype = null;
    String symbolName = null;
    String name;
    // file or S3
    String type = parts[1];
    //}
    if (type.equalsIgnoreCase("S3")) {
        // bloom, cache, cuckoo.
        otype = parts[2];
        name = parts[4];
        // name of the object
        symbolName = parts[3];
        if (!symbolName.startsWith("$"))
            symbolName = "$" + symbolName;
    } else
        // file name
        name = parts[2];
    if (type.equals("file")) {
        return Configuration.getInstance().readData(parts[2]);
    }
    S3Object object = Configuration.s3.getObject(new GetObjectRequest(Configuration.s3_bucket, name));
    long size = Configuration.s3.getObjectMetadata(Configuration.s3_bucket, name).getContentLength();
    return Configuration.getInstance().readData(otype, symbolName, object, size);
}
Also used : S3Object(com.amazonaws.services.s3.model.S3Object) GetObjectRequest(com.amazonaws.services.s3.model.GetObjectRequest)

Aggregations

S3Object (com.amazonaws.services.s3.model.S3Object)22 InputStream (java.io.InputStream)8 AmazonServiceException (com.amazonaws.AmazonServiceException)7 GetObjectRequest (com.amazonaws.services.s3.model.GetObjectRequest)7 AmazonS3 (com.amazonaws.services.s3.AmazonS3)6 ObjectMetadata (com.amazonaws.services.s3.model.ObjectMetadata)4 IOException (java.io.IOException)4 AmazonS3Exception (com.amazonaws.services.s3.model.AmazonS3Exception)3 S3ObjectSummary (com.amazonaws.services.s3.model.S3ObjectSummary)3 ByteArrayInputStream (java.io.ByteArrayInputStream)3 Exchange (org.apache.camel.Exchange)3 DataStoreException (org.apache.jackrabbit.core.data.DataStoreException)3 AmazonS3Client (com.amazonaws.services.s3.AmazonS3Client)2 ObjectListing (com.amazonaws.services.s3.model.ObjectListing)2 PutObjectResult (com.amazonaws.services.s3.model.PutObjectResult)2 S3ObjectInputStream (com.amazonaws.services.s3.model.S3ObjectInputStream)2 DBException (com.yahoo.ycsb.DBException)2 FileNotFoundException (java.io.FileNotFoundException)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2