-
Notifications
You must be signed in to change notification settings - Fork 174
/
hstore
executable file
·116 lines (107 loc) · 4.21 KB
/
hstore
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -----------------------------------------------------------------------
# Copyright (C) 2012 by H-Store Project
# Brown University
# Massachusetts Institute of Technology
# Yale University
#
# http://hstore.cs.brown.edu/
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
# -----------------------------------------------------------------------
from __future__ import with_statement
import os
import sys
import subprocess
import logging
from glob import glob
## H-Store Third-Party Libraries
realpath = os.path.realpath(__file__)
basedir = os.path.dirname(realpath)
if not os.path.exists(realpath):
cwd = os.getcwd()
basename = os.path.basename(realpath)
if os.path.exists(os.path.join(cwd, basename)):
basedir = cwd
sys.path.append(os.path.realpath(os.path.join(basedir, "third_party/python")))
sys.path.append(os.path.realpath(os.path.join(basedir, "tools")))
import hstore
import argparse
logging.basicConfig(level = logging.INFO,
format="%(asctime)s %(levelname)-5s: %(message)s",
datefmt="%m-%d-%Y %H:%M:%S",
stream = sys.stdout)
THIRD_PARTY_DIR = "third_party/java/jars"
BUILD_DIR = "obj/release/prod"
JVM_ARGS = [
"-client",
"-Xmx128m",
"-Dlog4j.configuration=log4j.properties",
"-ea",
]
JVM_CLASSPATH = [ BUILD_DIR ] + glob("%s/*.jar" % THIRD_PARTY_DIR)
JVM_TARGET = "edu.brown.terminal.HStoreTerminal"
## ==============================================
## main
## ==============================================
if __name__ == '__main__':
aparser = argparse.ArgumentParser(description='H-Store Terminal Client')
aparser.add_argument('project', help='Benchmark name or Project Jar')
aparser.add_argument('--host', type=str,
help='Hostname of an HStoreSite to connect to.')
aparser.add_argument('--port', type=int,
help='Port number of an HStoreSite to connect to.')
aparser.add_argument('--csv', action='store_true',
help='Output all tables as CSV results')
args = vars(aparser.parse_args())
# Check whether we have a jar file
# Otherwise make sure it's a valid benchmarks
if not os.path.exists(args['project']):
benchmarks = hstore.getBenchmarks()
if not args['project'] in benchmarks:
logging.error("Invalid benchmark name '%s'" % args['project'])
logging.error("Valid benchmarks: %s" % ", ".join(benchmarks))
sys.exit(1)
args['project'] = "%s.jar" % args['project']
if not os.path.exists(args['project']):
logging.error("Project jar '%s' does not exist" % (args['project']))
sys.exit(1)
# Options
options = [ ]
for key in ('host', 'port', 'csv'):
if key in args and args[key]:
options.append("terminal.%s=%s" % (key, args[key]))
## FOR
# Invoke java directly
cmd = "java %s -classpath %s %s catalog.jar=%s %s" % (\
" ".join(JVM_ARGS), \
":".join(JVM_CLASSPATH), \
JVM_TARGET, \
args['project'],
" ".join(options))
logging.debug(cmd)
try:
p = subprocess.Popen(cmd, shell=True)
p.wait()
except:
pass
sys.exit(p.returncode)
## MAIN