Skip to content
Snippets Groups Projects
Commit f84956ae authored by Sean Busbey's avatar Sean Busbey
Browse files

[s3] updates to compile.

- version number fix
- DB methods return Status objects.
parent ff25df0f
No related branches found
No related tags found
No related merge requests found
...@@ -19,7 +19,7 @@ LICENSE file. ...@@ -19,7 +19,7 @@ LICENSE file.
<parent> <parent>
<groupId>com.yahoo.ycsb</groupId> <groupId>com.yahoo.ycsb</groupId>
<artifactId>binding-parent</artifactId> <artifactId>binding-parent</artifactId>
<version>0.5.0-SNAPSHOT</version> <version>0.6.0-SNAPSHOT</version>
<relativePath>../binding-parent</relativePath> <relativePath>../binding-parent</relativePath>
</parent> </parent>
......
...@@ -32,6 +32,7 @@ import com.yahoo.ycsb.ByteArrayByteIterator; ...@@ -32,6 +32,7 @@ import com.yahoo.ycsb.ByteArrayByteIterator;
import com.yahoo.ycsb.ByteIterator; import com.yahoo.ycsb.ByteIterator;
import com.yahoo.ycsb.DB; import com.yahoo.ycsb.DB;
import com.yahoo.ycsb.DBException; import com.yahoo.ycsb.DBException;
import com.yahoo.ycsb.Status;
import com.amazonaws.services.s3.AmazonS3Client; import com.amazonaws.services.s3.AmazonS3Client;
import com.amazonaws.services.s3.*; import com.amazonaws.services.s3.*;
...@@ -105,19 +106,19 @@ public class S3Client extends DB { ...@@ -105,19 +106,19 @@ public class S3Client extends DB {
* The name of the bucket * The name of the bucket
* @param key * @param key
* The record key of the file to delete. * The record key of the file to delete.
* @return Zero on success, a non-zero error code on error. See the * @return OK on success, otherwise ERROR. See the
* {@link DB} class's description for a discussion of error codes. * {@link DB} class's description for a discussion of error codes.
*/ */
@Override @Override
public int delete(String bucket, String key) { public Status delete(String bucket, String key) {
try { try {
s3Client.deleteObject(new DeleteObjectRequest(bucket, key)); s3Client.deleteObject(new DeleteObjectRequest(bucket, key));
} catch (Exception e){ } catch (Exception e){
System.err.println("Not possible to delete the key "+key); System.err.println("Not possible to delete the key "+key);
e.printStackTrace(); e.printStackTrace();
return 1; return Status.ERROR;
} }
return 0; return Status.OK;
} }
/** /**
* Initialize any state for the storage. * Initialize any state for the storage.
...@@ -252,11 +253,11 @@ public class S3Client extends DB { ...@@ -252,11 +253,11 @@ public class S3Client extends DB {
* multiplied by the number of field. In this way the size * multiplied by the number of field. In this way the size
* of the file to upload is determined by the fieldlength * of the file to upload is determined by the fieldlength
* and fieldcount parameters. * and fieldcount parameters.
* @return Zero on success, a non-zero error code on error. See the * @return OK on success, ERROR otherwise. See the
* {@link DB} class's description for a discussion of error codes. * {@link DB} class's description for a discussion of error codes.
*/ */
@Override @Override
public int insert(String bucket, String key, public Status insert(String bucket, String key,
HashMap<String, ByteIterator> values) { HashMap<String, ByteIterator> values) {
return writeToStorage(bucket, key, values, true, sse, ssecKey); return writeToStorage(bucket, key, values, true, sse, ssecKey);
} }
...@@ -273,10 +274,10 @@ public class S3Client extends DB { ...@@ -273,10 +274,10 @@ public class S3Client extends DB {
* it is null by default * it is null by default
* @param result * @param result
* A HashMap of field/value pairs for the result * A HashMap of field/value pairs for the result
* @return Zero on success, a non-zero error code on error or "not found". * @return OK on success, ERROR otherwise.
*/ */
@Override @Override
public int read(String bucket, String key, Set<String> fields, public Status read(String bucket, String key, Set<String> fields,
HashMap<String, ByteIterator> result) { HashMap<String, ByteIterator> result) {
return readFromStorage(bucket, key, result, ssecKey); return readFromStorage(bucket, key, result, ssecKey);
} }
...@@ -291,11 +292,10 @@ public class S3Client extends DB { ...@@ -291,11 +292,10 @@ public class S3Client extends DB {
* The file key of the file to write. * The file key of the file to write.
* @param values * @param values
* A HashMap of field/value pairs to update in the record * A HashMap of field/value pairs to update in the record
* @return Zero on success, a non-zero error code on error. See this class's * @return OK on success, ERORR otherwise.
* description for a discussion of error codes.
*/ */
@Override @Override
public int update(String bucket, String key, public Status update(String bucket, String key,
HashMap<String, ByteIterator> values) { HashMap<String, ByteIterator> values) {
return writeToStorage(bucket, key, values, false, sse, ssecKey); return writeToStorage(bucket, key, values, false, sse, ssecKey);
} }
...@@ -314,11 +314,10 @@ public class S3Client extends DB { ...@@ -314,11 +314,10 @@ public class S3Client extends DB {
* @param result * @param result
* A Vector of HashMaps, where each HashMap is a set field/value * A Vector of HashMaps, where each HashMap is a set field/value
* pairs for one file * pairs for one file
* @return Zero on success, a non-zero error code on error. See the * @return OK on success, ERROR otherwise.
* {@link DB} class's description for a discussion of error codes.
*/ */
@Override @Override
public int scan(String bucket, String startkey, int recordcount, public Status scan(String bucket, String startkey, int recordcount,
Set<String> fields, Vector<HashMap<String, ByteIterator>> result) { Set<String> fields, Vector<HashMap<String, ByteIterator>> result) {
return scanFromStorage(bucket, startkey, recordcount, result, ssecKey); return scanFromStorage(bucket, startkey, recordcount, result, ssecKey);
} }
...@@ -336,7 +335,7 @@ public class S3Client extends DB { ...@@ -336,7 +335,7 @@ public class S3Client extends DB {
* to S3. If false an existing object will be re-uploaded * to S3. If false an existing object will be re-uploaded
* *
*/ */
protected int writeToStorage(String bucket, String key, protected Status writeToStorage(String bucket, String key,
HashMap<String, ByteIterator> values, Boolean updateMarker, HashMap<String, ByteIterator> values, Boolean updateMarker,
String sseLocal, SSECustomerKey ssecLocal) { String sseLocal, SSECustomerKey ssecLocal) {
int totalSize = 0; int totalSize = 0;
...@@ -372,7 +371,7 @@ public class S3Client extends DB { ...@@ -372,7 +371,7 @@ public class S3Client extends DB {
} catch (Exception e){ } catch (Exception e){
System.err.println("Not possible to get the object :"+key); System.err.println("Not possible to get the object :"+key);
e.printStackTrace(); e.printStackTrace();
return 1; return Status.ERROR;
} }
} }
byte[] destinationArray = new byte[totalSize]; byte[] destinationArray = new byte[totalSize];
...@@ -401,7 +400,7 @@ public class S3Client extends DB { ...@@ -401,7 +400,7 @@ public class S3Client extends DB {
PutObjectResult res = PutObjectResult res =
s3Client.putObject(putObjectRequest); s3Client.putObject(putObjectRequest);
if(res.getETag() == null) { if(res.getETag() == null) {
return 1; return Status.ERROR;
} else { } else {
if (sseLocal.equals("true")) { if (sseLocal.equals("true")) {
System.out.println("Uploaded object encryption status is " + System.out.println("Uploaded object encryption status is " +
...@@ -414,14 +413,14 @@ public class S3Client extends DB { ...@@ -414,14 +413,14 @@ public class S3Client extends DB {
} catch (Exception e) { } catch (Exception e) {
System.err.println("Not possible to write object :"+key); System.err.println("Not possible to write object :"+key);
e.printStackTrace(); e.printStackTrace();
return 1; return Status.ERROR;
} finally { } finally {
return 0; return Status.OK;
} }
} catch (Exception e) { } catch (Exception e) {
System.err.println("Error in the creation of the stream :"+e.toString()); System.err.println("Error in the creation of the stream :"+e.toString());
e.printStackTrace(); e.printStackTrace();
return 1; return Status.ERROR;
} }
} }
...@@ -436,7 +435,7 @@ public class S3Client extends DB { ...@@ -436,7 +435,7 @@ public class S3Client extends DB {
* The Hash map where data from the object are written * The Hash map where data from the object are written
* *
*/ */
protected int readFromStorage(String bucket, String key, protected Status readFromStorage(String bucket, String key,
HashMap<String, ByteIterator> result, SSECustomerKey ssecLocal) { HashMap<String, ByteIterator> result, SSECustomerKey ssecLocal) {
try { try {
GetObjectRequest getObjectRequest = null; GetObjectRequest getObjectRequest = null;
...@@ -465,9 +464,9 @@ public class S3Client extends DB { ...@@ -465,9 +464,9 @@ public class S3Client extends DB {
} catch (Exception e){ } catch (Exception e){
System.err.println("Not possible to get the object "+key); System.err.println("Not possible to get the object "+key);
e.printStackTrace(); e.printStackTrace();
return 1; return Status.ERROR;
} finally { } finally {
return 0; return Status.OK;
} }
} }
...@@ -487,7 +486,7 @@ public class S3Client extends DB { ...@@ -487,7 +486,7 @@ public class S3Client extends DB {
* pairs for one file * pairs for one file
* *
*/ */
protected int scanFromStorage(String bucket, String startkey, protected Status scanFromStorage(String bucket, String startkey,
int recordcount, Vector<HashMap<String, ByteIterator>> result, int recordcount, Vector<HashMap<String, ByteIterator>> result,
SSECustomerKey ssecLocal) { SSECustomerKey ssecLocal) {
...@@ -532,6 +531,6 @@ public class S3Client extends DB { ...@@ -532,6 +531,6 @@ public class S3Client extends DB {
ssecLocal); ssecLocal);
result.add(resultTemp); result.add(resultTemp);
} }
return 0; return Status.OK;
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment