Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Y
YCSB
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
f50848b0
Commit
f50848b0
authored
10 years ago
by
nitsanw
Committed by
Sean Busbey
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[test] Improve delay code
Add option to randomize delay(default=true, as before)
parent
0b024834
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/src/main/java/com/yahoo/ycsb/BasicDB.java
+26
-13
26 additions, 13 deletions
core/src/main/java/com/yahoo/ycsb/BasicDB.java
with
26 additions
and
13 deletions
core/src/main/java/com/yahoo/ycsb/BasicDB.java
+
26
−
13
View file @
f50848b0
...
...
@@ -22,6 +22,8 @@ import java.util.Properties;
import
java.util.Set
;
import
java.util.Enumeration
;
import
java.util.Vector
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.locks.LockSupport
;
/**
...
...
@@ -32,11 +34,15 @@ public class BasicDB extends DB
public
static
final
String
VERBOSE
=
"basicdb.verbose"
;
public
static
final
String
VERBOSE_DEFAULT
=
"true"
;
public
static
final
String
SIMULATE_DELAY
=
"basicdb.simulatedelay"
;
public
static
final
String
SIMULATE_DELAY_DEFAULT
=
"0"
;
public
static
final
String
SIMULATE_DELAY
=
"basicdb.simulatedelay"
;
public
static
final
String
SIMULATE_DELAY_DEFAULT
=
"0"
;
public
static
final
String
RANDOMIZE_DELAY
=
"basicdb.ranomizedelay"
;
public
static
final
String
RANDOMIZE_DELAY_DEFAULT
=
"true"
;
boolean
verbose
;
boolean
verbose
;
boolean
randomizedelay
;
int
todelay
;
public
BasicDB
()
...
...
@@ -49,14 +55,21 @@ public class BasicDB extends DB
{
if
(
todelay
>
0
)
{
try
{
Thread
.
sleep
((
long
)
Utils
.
random
().
nextInt
(
todelay
));
}
catch
(
InterruptedException
e
)
{
//do nothing
}
long
delayNs
;
if
(
randomizedelay
)
{
delayNs
=
TimeUnit
.
MILLISECONDS
.
toNanos
(
Utils
.
random
().
nextInt
(
todelay
));
if
(
delayNs
==
0
)
{
return
;
}
}
else
{
delayNs
=
TimeUnit
.
MILLISECONDS
.
toNanos
(
todelay
);
}
long
deadline
=
System
.
nanoTime
()
+
delayNs
;
do
{
LockSupport
.
parkNanos
(
delayNs
);
}
while
(
System
.
nanoTime
()
<
deadline
&&
!
Thread
.
interrupted
());
}
}
...
...
@@ -69,7 +82,7 @@ public class BasicDB extends DB
{
verbose
=
Boolean
.
parseBoolean
(
getProperties
().
getProperty
(
VERBOSE
,
VERBOSE_DEFAULT
));
todelay
=
Integer
.
parseInt
(
getProperties
().
getProperty
(
SIMULATE_DELAY
,
SIMULATE_DELAY_DEFAULT
));
randomizedelay
=
Boolean
.
parseBoolean
(
getProperties
().
getProperty
(
RANDOMIZE_DELAY
,
RANDOMIZE_DELAY_DEFAULT
));
if
(
verbose
)
{
System
.
out
.
println
(
"***************** properties *****************"
);
...
...
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