OmniSciDB  95562058bd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
com.mapd.tests.DistributedConcurrencyTest Class Reference
+ Collaboration diagram for com.mapd.tests.DistributedConcurrencyTest:

Public Member Functions

void testConcurrency () throws Exception
 

Static Public Member Functions

static void main (String[] args) throws Exception
 

Static Package Attributes

static final Logger logger = LoggerFactory.getLogger(DistributedConcurrencyTest.class)
 
static final String[] text_values
 

Private Member Functions

void runTest (String db, String dbaUser, String dbaPassword, String dbUser, String dbPassword) throws Exception
 

Detailed Description

Definition at line 24 of file DistributedConcurrencyTest.java.

Member Function Documentation

static void com.mapd.tests.DistributedConcurrencyTest.main ( String[]  args) throws Exception
inlinestatic

Definition at line 48 of file DistributedConcurrencyTest.java.

48  {
49  DistributedConcurrencyTest test = new DistributedConcurrencyTest();
50  test.testConcurrency();
51  }
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 num_rows, run, and com.mapd.tests.DistributedConcurrencyTest.text_values.

Referenced by com.mapd.tests.DistributedConcurrencyTest.testConcurrency().

55  {
56  int num_threads = 5;
57  final int runs = 5;
58  final int num_rows = 400;
59  final int fragment_size = 25;
60  Exception exceptions[] = new Exception[num_threads];
61 
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;
66 
67  Thread t = new Thread(new Runnable() {
68  @Override
69  public void run() {
70  long tid = Thread.currentThread().getId();
71  String logPrefix = "[" + tid + "]";
72  String sql = "";
73 
74  for (int runId = 0; runId < runs; runId++) {
75  final String tableName = dbaUser + "_" + threadId + "_" + runId;
76 
77  try {
78  MapdTestClient user =
79  MapdTestClient.getClient("localhost", 6274, db, dbUser, dbPassword);
80 
81  user.runSql("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 
85  for (int i = 0; i < num_rows; i++) {
86  final String integer_val = Integer.toString(i);
87  final String small_val = Integer.toString(i % 128);
88  final String fp_val = Double.toString(i * 1.1);
89  final String deci_val = Double.toString(i + 0.01);
90  final String str_val = "'" + text_values[i % text_values.length] + "'";
91  final String values_string = String.join(" , ",
92  integer_val,
93  integer_val,
94  small_val,
95  small_val,
96  fp_val,
97  fp_val,
98  deci_val,
99  str_val);
100  user.runSql("INSERT INTO " + tableName + " VALUES "
101  + "(" + values_string + ")");
102  }
103 
104  Random rand = new Random(tid);
105 
106  sql = "ALTER TABLE " + tableName + " ADD COLUMN zz TEXT ENCODING DICT(8);";
107  logger.info(logPrefix + " " + sql);
108  user.runSql(sql);
109 
110  // TODO(adb): add get_table_details once thread safe
111 
112  sql = "SELECT * FROM " + tableName + " LIMIT 2;";
113  logger.info(logPrefix + " " + sql);
114  user.runSql(sql);
115 
116  sql = "VALIDATE CLUSTER;";
117  logger.info(logPrefix + " " + sql);
118  user.runSql(sql);
119 
120  user.get_status();
121  user.get_hardware_info();
122  user.get_memory("cpu");
123 
124  sql = "DELETE FROM " + tableName + " WHERE y = " + rand.nextInt(num_rows)
125  + ";";
126  logger.info(logPrefix + " " + sql);
127  user.runSql(sql);
128 
129  sql = "ALTER TABLE " + tableName + " DROP COLUMN x;";
130  logger.info(logPrefix + " " + sql);
131  user.runSql(sql);
132 
133  sql = "SELECT * FROM " + tableName + " WHERE str = '"
134  + text_values[rand.nextInt(text_values.length)] + "';";
135  logger.info(logPrefix + " " + sql);
136  user.runSql(sql);
137 
138  sql = "SELECT COUNT(*) FROM " + tableName + ";";
139  logger.info(logPrefix + " VALIDATE " + sql);
140  user.sqlValidate(sql);
141 
142  sql = "TRUNCATE TABLE " + tableName + ";";
143  logger.info(logPrefix + " " + sql);
144  user.runSql(sql);
145 
146  sql = "DROP TABLE " + tableName + ";";
147  logger.info(logPrefix + " " + sql);
148  user.runSql(sql);
149 
150  } catch (Exception e) {
151  logger.error(logPrefix + " Caught Exception: " + e.getMessage(), e);
152  exceptions[threadId] = e;
153  }
154  }
155  }
156  });
157  t.start();
158  threads.add(t);
159  }
160 
161  for (Thread t : threads) {
162  t.join();
163  }
164 
165  for (Exception e : exceptions) {
166  if (null != e) {
167  logger.error("Exception: " + e.getMessage(), e);
168  throw e;
169  }
170  }
171  }
const int8_t const int64_t * num_rows
static bool run

+ Here is the caller graph for this function:

void com.mapd.tests.DistributedConcurrencyTest.testConcurrency ( ) throws Exception
inline

Definition at line 173 of file DistributedConcurrencyTest.java.

References com.mapd.tests.DistributedConcurrencyTest.runTest().

173  {
174  logger.info("DistributedConcurrencyTest()");
175 
176  MapdTestClient su = MapdTestClient.getClient(
177  "localhost", 6274, "omnisci", "admin", "HyperInteractive");
178  su.runSql("CREATE USER dba (password = 'password', is_super = 'true');");
179  su.runSql("CREATE USER bob (password = 'password', is_super = 'false');");
180 
181  su.runSql("GRANT CREATE on DATABASE omnisci TO bob;");
182 
183  su.runSql("CREATE DATABASE db1;");
184  su.runSql("GRANT CREATE on DATABASE db1 TO bob;");
185  su.runSql("GRANT CREATE VIEW on DATABASE db1 TO bob;");
186  su.runSql("GRANT DROP on DATABASE db1 TO bob;");
187  su.runSql("GRANT DROP VIEW on DATABASE db1 TO bob;");
188 
189  runTest("db1", "admin", "HyperInteractive", "admin", "HyperInteractive");
190  // TODO: run some tests as bob
191 
192  su.runSql("DROP DATABASE db1;");
193  su.runSql("DROP USER bob;");
194  su.runSql("DROP USER dba;");
195 
196  logger.info("DistributedConcurrencyTest() done");
197  }
void runTest(String db, String dbaUser, String dbaPassword, String dbUser, String dbPassword)

+ Here is the call graph for this function:

Member Data Documentation

final Logger com.mapd.tests.DistributedConcurrencyTest.logger = LoggerFactory.getLogger(DistributedConcurrencyTest.class)
staticpackage

Definition at line 25 of file DistributedConcurrencyTest.java.

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: