Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Y
YCSB
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Adnan Ahmad
YCSB
Commits
98564925
Commit
98564925
authored
9 years ago
by
ivan
Browse files
Options
Downloads
Patches
Plain Diff
[s3] added support for SSE
parent
07c06cfb
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
s3/src/main/conf/s3.properties
+3
-0
3 additions, 0 deletions
s3/src/main/conf/s3.properties
s3/src/main/java/com/yahoo/ycsb/db/S3Client.java
+17
-4
17 additions, 4 deletions
s3/src/main/java/com/yahoo/ycsb/db/S3Client.java
with
20 additions
and
4 deletions
s3/src/main/conf/s3.properties
+
3
−
0
View file @
98564925
...
...
@@ -13,3 +13,6 @@ s3.secretKey=YourSecret
# the AWS endpoint
s3.endpoint
=
s3.amazonaws.com
# activating the SSE server side encryption if true
s3.sse
=
false
This diff is collapsed.
Click to expand it.
s3/src/main/java/com/yahoo/ycsb/db/S3Client.java
+
17
−
4
View file @
98564925
...
...
@@ -70,6 +70,7 @@ import com.amazonaws.services.s3.model.S3ObjectSummary;
public
class
S3Client
extends
DB
{
private
static
AmazonS3Client
s3Client
;
private
static
String
sse
;
private
static
final
AtomicInteger
INIT_COUNT
=
new
AtomicInteger
(
0
);
//private static int initCount = 0;
...
...
@@ -178,7 +179,10 @@ public class S3Client extends DB {
if
(
maxErrorRetry
==
null
){
maxErrorRetry
=
propsCL
.
getProperty
(
"s3.maxErrorRetry"
,
"15"
);
}
System
.
out
.
println
(
maxErrorRetry
);
sse
=
props
.
getProperty
(
"s3.sse"
);
if
(
sse
==
null
){
sse
=
propsCL
.
getProperty
(
"s3.sse"
,
"false"
);
}
}
catch
(
Exception
e
){
System
.
err
.
println
(
"The file properties doesn't exist "
+
e
.
toString
());
e
.
printStackTrace
();
...
...
@@ -226,7 +230,7 @@ public class S3Client extends DB {
@Override
public
int
insert
(
String
bucket
,
String
key
,
HashMap
<
String
,
ByteIterator
>
values
)
{
return
writeToStorage
(
bucket
,
key
,
values
,
true
);
return
writeToStorage
(
bucket
,
key
,
values
,
true
,
sse
);
}
/**
* Read a file from the Bucket. Each field/value pair from the result
...
...
@@ -265,7 +269,7 @@ public class S3Client extends DB {
@Override
public
int
update
(
String
bucket
,
String
key
,
HashMap
<
String
,
ByteIterator
>
values
)
{
return
writeToStorage
(
bucket
,
key
,
values
,
false
);
return
writeToStorage
(
bucket
,
key
,
values
,
false
,
sse
);
}
/**
* Perform a range scan for a set of files in the bucket. Each
...
...
@@ -305,7 +309,8 @@ public class S3Client extends DB {
*
*/
protected
int
writeToStorage
(
String
bucket
,
String
key
,
HashMap
<
String
,
ByteIterator
>
values
,
Boolean
updateMarker
)
{
HashMap
<
String
,
ByteIterator
>
values
,
Boolean
updateMarker
,
String
sseLocal
)
{
int
totalSize
=
0
;
int
fieldCount
=
values
.
size
();
//number of fields to concatenate
// getting the first field in the values
...
...
@@ -338,12 +343,20 @@ public class S3Client extends DB {
}
try
(
InputStream
input
=
new
ByteArrayInputStream
(
destinationArray
))
{
ObjectMetadata
metadata
=
new
ObjectMetadata
();
if
(
sseLocal
.
equals
(
"true"
))
{
metadata
.
setSSEAlgorithm
(
ObjectMetadata
.
AES_256_SERVER_SIDE_ENCRYPTION
);
}
metadata
.
setContentLength
(
totalSize
);
try
{
PutObjectResult
res
=
s3Client
.
putObject
(
bucket
,
key
,
input
,
metadata
);
if
(
res
.
getETag
()
==
null
)
{
return
1
;
}
else
{
if
(
sseLocal
.
equals
(
"true"
))
{
System
.
out
.
println
(
"Uploaded object encryption status is "
+
res
.
getSSEAlgorithm
());
}
}
}
catch
(
Exception
e
)
{
System
.
err
.
println
(
"Not possible to write object :"
+
key
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment