From f79d422aec7e0ce9b0d8e6a4f7170ad7d2daea6a Mon Sep 17 00:00:00 2001 From: QiYu Date: Thu, 6 Apr 2017 14:40:47 +0800 Subject: [PATCH 1/2] add ignore --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 93a3523d..afa61d1c 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,7 @@ /0.3.0.9 /META-INF /OSGI-INF +/release/archive/ +/release/log/ +/release/start +/release/stop From b64f7d6ad8c759ea64effd98e84a11a3e0e3636d Mon Sep 17 00:00:00 2001 From: QiYu Date: Thu, 6 Apr 2017 14:42:31 +0800 Subject: [PATCH 2/2] range request support --- .../intel/cosbench/api/S3Stor/S3Storage.java | 32 +++++++++++++++++-- .../src/com/abc/api/abcAuth/AbcAuth.java | 2 +- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/dev/cosbench-s3/src/com/intel/cosbench/api/S3Stor/S3Storage.java b/dev/cosbench-s3/src/com/intel/cosbench/api/S3Stor/S3Storage.java index 509c56be..23e76cd8 100644 --- a/dev/cosbench-s3/src/com/intel/cosbench/api/S3Stor/S3Storage.java +++ b/dev/cosbench-s3/src/com/intel/cosbench/api/S3Stor/S3Storage.java @@ -3,6 +3,7 @@ import static com.intel.cosbench.client.S3Stor.S3Constants.*; import java.io.*; +import java.util.Random; import org.apache.http.HttpStatus; @@ -24,6 +25,10 @@ public class S3Storage extends NoneStorage { private String endpoint; private AmazonS3 client; + + private boolean isRangeRequest ; + private int rangeStart ; + private int rangeEnd ; @Override public void init(Config config, Logger logger) { @@ -41,6 +46,11 @@ public void init(Config config, Logger logger) { String proxyHost = config.get(PROXY_HOST_KEY, ""); String proxyPort = config.get(PROXY_PORT_KEY, ""); + + isRangeRequest = config.getBoolean("is_range_request", false); + rangeStart = config.getInt("range_start", 0); + rangeEnd = config.getInt("range_end", 4048); + parms.put(ENDPOINT_KEY, endpoint); parms.put(AUTH_USERNAME_KEY, accessKey); @@ -92,9 +102,25 @@ public InputStream getObject(String container, String object, Config config) { super.getObject(container, object, config); InputStream stream; try { - - S3Object s3Obj = client.getObject(container, object); - stream = s3Obj.getObjectContent(); + if(isRangeRequest) + { + GetObjectRequest rangeObjectRequest = new GetObjectRequest(container, object); + Random rand = new Random(); + + int randNumber1 = rand.nextInt(rangeEnd - rangeStart + 1) + rangeStart; + int randNumber2 = rand.nextInt(rangeEnd - rangeStart + 1) + rangeStart; + int start = Math.min(randNumber1, randNumber2) ; + int end = Math.max(randNumber1, randNumber2) ; + + rangeObjectRequest.setRange(start, end); + S3Object objectPortion = client.getObject(rangeObjectRequest); + stream = objectPortion.getObjectContent(); + } + else + { + S3Object s3Obj = client.getObject(container, object); + stream = s3Obj.getObjectContent(); + } } catch (Exception e) { throw new StorageException(e); diff --git a/ext/adaptor/abc-auth/src/com/abc/api/abcAuth/AbcAuth.java b/ext/adaptor/abc-auth/src/com/abc/api/abcAuth/AbcAuth.java index 92951717..bfdd9dfa 100644 --- a/ext/adaptor/abc-auth/src/com/abc/api/abcAuth/AbcAuth.java +++ b/ext/adaptor/abc-auth/src/com/abc/api/abcAuth/AbcAuth.java @@ -87,7 +87,7 @@ public AuthContext login() { } private AuthContext createContext() { - AuthContext context = new AuthContext(); + AuthContext context = new DefaultAuthContext(); context.put(AUTH_TOKEN_KEY, client.getAuthToken()); return context; }