|
static void | main (String[] args) throws Exception |
|
|
static final Logger | logger = LoggerFactory.getLogger(DistributedConcurrencyTest.class) |
|
static final String[] | text_values |
|
|
void | runTest (String db, String dbaUser, String dbaPassword, String dbUser, String dbPassword) throws Exception |
|
static void com.mapd.tests.DistributedConcurrencyTest.main |
( |
String[] |
args | ) |
throws Exception |
|
inlinestatic |
void com.mapd.tests.DistributedConcurrencyTest.runTest |
( |
String |
db, |
|
|
String |
dbaUser, |
|
|
String |
dbaPassword, |
|
|
String |
dbUser, |
|
|
String |
dbPassword |
|
) |
| throws Exception |
|
inlineprivate |
Definition at line 53 of file DistributedConcurrencyTest.java.
References run, and com.mapd.tests.DistributedConcurrencyTest.text_values.
Referenced by com.mapd.tests.DistributedConcurrencyTest.testConcurrency().
58 final int max_num_rows = 400;
59 final int fragment_size = 25;
60 Exception exceptions[] =
new Exception[num_threads];
62 ArrayList<Thread> threads =
new ArrayList<>();
63 for (
int i = 0; i < num_threads; i++) {
64 logger.info(
"Starting " + i);
65 final int threadId = i;
67 Thread t =
new Thread(
new Runnable() {
70 long tid = Thread.currentThread().getId();
71 String logPrefix =
"[" + tid +
"]";
74 for (
int runId = 0; runId < runs; runId++) {
75 final String tableName = dbaUser +
"_" + threadId +
"_" + runId;
78 HeavyDBTestClient user = HeavyDBTestClient.getClient(
79 "localhost", 6274, db, dbUser, dbPassword);
81 sql =
"CREATE TABLE " + tableName
82 +
"(x BIGINT, y INTEGER, z SMALLINT, a TINYINT, f FLOAT, d DOUBLE, deci DECIMAL(18,6), str TEXT ENCODING NONE) WITH (FRAGMENT_SIZE = "
83 + fragment_size +
")";
84 logger.info(logPrefix +
" " + sql);
87 Random rand =
new Random(tid);
88 int num_rows = rand.nextInt(max_num_rows);
90 for (
int i = 0; i < num_rows; i++) {
91 final String integer_val = Integer.toString(i);
92 final String small_val = Integer.toString(i % 128);
93 final String fp_val = Double.toString(i * 1.1);
94 final String deci_val = Double.toString(i + 0.01);
95 final String str_val =
"'" +
text_values[i % text_values.length] +
"'";
96 final String values_string = String.join(
" , ",
105 sql =
"INSERT INTO " + tableName +
" VALUES "
106 +
"(" + values_string +
")";
109 logger.info(logPrefix +
" " + sql);
113 sql =
"ALTER TABLE " + tableName +
" ADD COLUMN zz TEXT ENCODING DICT(8);";
114 logger.info(logPrefix +
" " + sql);
119 sql =
"SELECT * FROM " + tableName +
" LIMIT 2;";
120 logger.info(logPrefix +
" " + sql);
123 sql =
"VALIDATE CLUSTER;";
124 logger.info(logPrefix +
" " + sql);
130 user.get_hardware_info();
132 user.get_memory(
"cpu");
134 sql =
"DELETE FROM " + tableName +
" WHERE y = " + rand.nextInt(num_rows)
136 logger.info(logPrefix +
" " + sql);
139 sql =
"ALTER TABLE " + tableName +
" DROP COLUMN x;";
140 logger.info(logPrefix +
" " + sql);
143 sql =
"SELECT * FROM " + tableName +
" WHERE str = '"
144 +
text_values[rand.nextInt(text_values.length)] +
"';";
145 logger.info(logPrefix +
" " + sql);
148 sql =
"SELECT COUNT(*) FROM " + tableName +
";";
149 logger.info(logPrefix +
" VALIDATE " + sql);
150 user.sqlValidate(sql);
152 sql =
"TRUNCATE TABLE " + tableName +
";";
153 logger.info(logPrefix +
" " + sql);
156 sql =
"DROP TABLE " + tableName +
";";
157 logger.info(logPrefix +
" " + sql);
160 }
catch (Exception e) {
161 logger.error(logPrefix +
" While running query '" + sql
162 +
"' it threw this: " + e.getMessage());
163 exceptions[threadId] =
new Exception(
164 " While running query '" + sql +
"' it threw this: " + e);
173 for (Thread t : threads) {
177 for (Exception e : exceptions) {
179 logger.error(
"Exception during threaded runs: " + e.getMessage());
static final String[] text_values
void com.mapd.tests.DistributedConcurrencyTest.testConcurrency |
( |
| ) |
throws Exception |
|
inline |
Definition at line 185 of file DistributedConcurrencyTest.java.
References com.mapd.tests.DistributedConcurrencyTest.runTest().
186 logger.info(
"DistributedConcurrencyTest()");
188 HeavyDBTestClient su = HeavyDBTestClient.getClient(
189 "localhost", 6274,
"heavyai",
"admin",
"HyperInteractive");
190 su.runSql(
"CREATE USER dba (password = 'password', is_super = 'true');");
191 su.runSql(
"CREATE USER bob (password = 'password', is_super = 'false');");
193 su.runSql(
"GRANT CREATE on DATABASE heavyai TO bob;");
195 su.runSql(
"CREATE DATABASE db1;");
196 su.runSql(
"GRANT CREATE on DATABASE db1 TO bob;");
197 su.runSql(
"GRANT CREATE VIEW on DATABASE db1 TO bob;");
198 su.runSql(
"GRANT DROP on DATABASE db1 TO bob;");
199 su.runSql(
"GRANT DROP VIEW on DATABASE db1 TO bob;");
201 runTest(
"db1",
"admin",
"HyperInteractive",
"admin",
"HyperInteractive");
204 su.runSql(
"DROP DATABASE db1;");
205 su.runSql(
"DROP USER bob;");
206 su.runSql(
"DROP USER dba;");
208 logger.info(
"DistributedConcurrencyTest() done");
void runTest(String db, String dbaUser, String dbaPassword, String dbUser, String dbPassword)
final Logger com.mapd.tests.DistributedConcurrencyTest.logger = LoggerFactory.getLogger(DistributedConcurrencyTest.class) |
|
staticpackage |
final String [] com.mapd.tests.DistributedConcurrencyTest.text_values |
|
staticpackage |
Initial value:= {"foo",
"bar",
"hello",
"world",
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
"n",
"o",
"p"}
Definition at line 27 of file DistributedConcurrencyTest.java.
Referenced by com.mapd.tests.DistributedConcurrencyTest.runTest().
The documentation for this class was generated from the following file: