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
e80ffcf2
Commit
e80ffcf2
authored
9 years ago
by
Sean Busbey
Browse files
Options
Downloads
Plain Diff
Merge pull request #329 from busbey/issue-315
[scripts] clean up runtime classpath. closes #315
parents
458e6268
b770679f
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
bin/ycsb
+65
-8
65 additions, 8 deletions
bin/ycsb
with
65 additions
and
8 deletions
bin/ycsb
+
65
−
8
View file @
e80ffcf2
#!/usr/bin/env python
#!/usr/bin/env python
import
argparse
import
argparse
import
fnmatch
import
io
import
io
import
os
import
os
import
shlex
import
shlex
...
@@ -87,13 +88,20 @@ def usage():
...
@@ -87,13 +88,20 @@ def usage():
return
output
.
getvalue
()
return
output
.
getvalue
()
def
debug
(
message
):
print
>>
sys
.
stderr
,
"
[DEBUG]
"
,
message
def
find_jars
(
dir
,
database
):
def
warn
(
message
):
print
>>
sys
.
stderr
,
"
[WARN]
"
,
message
def
error
(
message
):
print
>>
sys
.
stderr
,
"
[ERROR]
"
,
message
def
find_jars
(
dir
,
glob
=
'
*.jar
'
):
jars
=
[]
jars
=
[]
for
(
dirpath
,
dirnames
,
filenames
)
in
os
.
walk
(
dir
):
for
(
dirpath
,
dirnames
,
filenames
)
in
os
.
walk
(
dir
):
for
filename
in
filenames
:
for
filename
in
fnmatch
.
filter
(
filenames
,
glob
):
if
filename
.
endswith
(
"
.jar
"
):
jars
.
append
(
os
.
path
.
join
(
dirpath
,
filename
))
jars
.
append
(
os
.
path
.
join
(
dirpath
,
filename
))
return
jars
return
jars
...
@@ -103,6 +111,35 @@ def get_ycsb_home():
...
@@ -103,6 +111,35 @@ def get_ycsb_home():
dir
=
os
.
path
.
join
(
dir
,
os
.
path
.
pardir
)
dir
=
os
.
path
.
join
(
dir
,
os
.
path
.
pardir
)
return
os
.
path
.
abspath
(
dir
)
return
os
.
path
.
abspath
(
dir
)
def
is_distribution
():
# If there's a top level pom, we're a source checkout. otherwise a dist artifact
return
"
pom.xml
"
not
in
os
.
listdir
(
get_ycsb_home
())
# Run the maven dependency plugin to get the local jar paths.
# presumes maven can run, so should only be run on source checkouts
# will invoke the 'package' goal for the given binding in order to resolve intra-project deps
# presumes maven properly handles system-specific path separators
def
get_classpath_from_maven
(
database
):
try
:
debug
(
"
Running
'
mvn -pl com.yahoo.ycsb:
"
+
database
+
"
-binding -am package -DskipTests
"
"
dependency:build-classpath -DincludeScope=compile -Dmdep.outputFilterFile=true
'"
)
mvn_output
=
subprocess
.
check_output
([
"
mvn
"
,
"
-pl
"
,
"
com.yahoo.ycsb:
"
+
database
+
"
-binding
"
,
"
-am
"
,
"
package
"
,
"
-DskipTests
"
,
"
dependency:build-classpath
"
,
"
-DincludeScope=compile
"
,
"
-Dmdep.outputFilterFile=true
"
])
# the above outputs a "classpath=/path/tojar:/path/to/other/jar" for each module
# the last module will be the datastore binding
line
=
[
x
for
x
in
mvn_output
.
splitlines
()
if
x
.
startswith
(
"
classpath=
"
)][
-
1
:]
return
line
[
0
][
len
(
"
classpath=
"
):]
except
subprocess
.
CalledProcessError
,
err
:
error
(
"
Attempting to generate a classpath from Maven failed
"
"
with return code
'"
+
str
(
err
.
returncode
)
+
"'
. The output from
"
"
Maven follows, try running
"
"'
mvn -DskipTests package dependency:build=classpath
'
on your
"
"
own and correct errors.
"
+
os
.
linesep
+
os
.
linesep
+
"
mvn output:
"
+
os
.
linesep
+
err
.
output
)
sys
.
exit
(
err
.
returncode
)
def
main
():
def
main
():
p
=
argparse
.
ArgumentParser
(
p
=
argparse
.
ArgumentParser
(
...
@@ -129,10 +166,30 @@ def main():
...
@@ -129,10 +166,30 @@ def main():
db_classname
=
DATABASES
[
args
.
database
]
db_classname
=
DATABASES
[
args
.
database
]
command
=
COMMANDS
[
args
.
command
][
"
command
"
]
command
=
COMMANDS
[
args
.
command
][
"
command
"
]
main_classname
=
COMMANDS
[
args
.
command
][
"
main
"
]
main_classname
=
COMMANDS
[
args
.
command
][
"
main
"
]
db_dir
=
os
.
path
.
join
(
ycsb_home
,
args
.
database
+
"
-binding
"
)
cp
=
[
os
.
path
.
join
(
db_dir
,
"
conf
"
)
]
# Classpath set up
cp
.
extend
(
find_jars
(
os
.
path
.
join
(
ycsb_home
,
"
lib
"
),
args
.
database
))
binding
=
args
.
database
.
split
(
"
-
"
)[
0
]
cp
.
extend
(
find_jars
(
os
.
path
.
join
(
db_dir
,
"
lib
"
),
args
.
database
))
if
is_distribution
():
db_dir
=
os
.
path
.
join
(
ycsb_home
,
binding
+
"
-binding
"
)
# include top-level conf for when we're a binding-specific artifact.
# If we add top-level conf to the general artifact, starting here
# will allow binding-specific conf to override (because it's prepended)
cp
=
[
os
.
path
.
join
(
ycsb_home
,
"
conf
"
)]
cp
.
extend
(
find_jars
(
os
.
path
.
join
(
ycsb_home
,
"
lib
"
)))
cp
.
extend
(
find_jars
(
os
.
path
.
join
(
db_dir
,
"
lib
"
)))
else
:
warn
(
"
Running against a source checkout. In order to get our runtime
"
"
dependencies we
'
ll have to invoke Maven. Depending on the state
"
"
of your system, this may take ~30-45 seconds
"
)
db_dir
=
os
.
path
.
join
(
ycsb_home
,
binding
)
# goes first so we can rely on side-effect of package
maven_says
=
get_classpath_from_maven
(
binding
)
# TODO when we have a version property, skip the glob
cp
=
find_jars
(
os
.
path
.
join
(
db_dir
,
"
target
"
),
binding
+
"
-binding*.jar
"
)
# alredy in jar:jar:jar form
cp
.
append
(
maven_says
)
cp
.
insert
(
0
,
os
.
path
.
join
(
db_dir
,
"
conf
"
))
classpath
=
os
.
pathsep
.
join
(
cp
)
classpath
=
os
.
pathsep
.
join
(
cp
)
if
args
.
classpath
:
if
args
.
classpath
:
classpath
=
os
.
pathsep
.
join
([
args
.
classpath
,
classpath
])
classpath
=
os
.
pathsep
.
join
([
args
.
classpath
,
classpath
])
...
...
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