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

Public Member Functions

void testCatalogConcurrency () throws Exception
 

Static Public Member Functions

static void main (String[] args) throws Exception
 

Static Package Attributes

static final Logger logger = LoggerFactory.getLogger(EagainConcurrencyTest.class)
 

Private Member Functions

void run_test (HeavyDBTestClient dba, String db, String dbUser, String dbPassword, String prefix, int max) throws Exception
 
void runTest (String db, String dbaUser, String dbaPassword, String dbUser, String dbPassword) throws Exception
 

Detailed Description

Definition at line 23 of file EagainConcurrencyTest.java.

Member Function Documentation

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

Definition at line 26 of file EagainConcurrencyTest.java.

26  {
27  EagainConcurrencyTest test = new EagainConcurrencyTest();
28  test.testCatalogConcurrency();
29  }
void com.mapd.tests.EagainConcurrencyTest.run_test ( HeavyDBTestClient  dba,
String  db,
String  dbUser,
String  dbPassword,
String  prefix,
int  max 
) throws Exception
inlineprivate

Definition at line 31 of file EagainConcurrencyTest.java.

Referenced by com.mapd.tests.EagainConcurrencyTest.runTest().

36  {
37  String tableName = "table_" + prefix + "_";
38  String viewName = "view_" + prefix + "_";
39  long tid = Thread.currentThread().getId();
40 
41  logger.info("[" + tid + "]"
42  + "FIRST USER CONNECT");
43  HeavyDBTestClient first_user =
44  HeavyDBTestClient.getClient("localhost", 6274, db, dbUser, dbPassword);
45 
46  logger.info("[" + tid + "]"
47  + "CREATE " + tableName);
48  first_user.runSql("CREATE TABLE " + tableName + " (id integer);");
49 
50  logger.info("[" + tid + "]"
51  + "CREATE VIEW " + viewName);
52  first_user.runSql(
53  "CREATE VIEW " + viewName + " AS (SELECT id * 2 FROM " + tableName + ");");
54 
55  logger.info("[" + tid + "]"
56  + "FIRST USER DISCONNECT");
57  first_user.disconnect();
58 
59  for (int i = 0; i < max; i++) {
60  logger.info("[" + tid + "]"
61  + "USER CONNECT");
62  HeavyDBTestClient user =
63  HeavyDBTestClient.getClient("localhost", 6274, db, dbUser, dbPassword);
64 
65  logger.info("[" + tid + "]"
66  + "INSERT INTO " + tableName);
67  user.runSql("INSERT INTO " + tableName + " VALUES (" + i + ");");
68 
69  user.get_status();
70  user.get_server_status();
71  user.get_hardware_info();
72 
73  logger.info("[" + tid + "]"
74  + "SELECT FROM " + tableName);
75  user.runSql("SELECT * FROM " + tableName + ";");
76 
77  user.get_memory("cpu");
78  user.get_dashboards();
79  // user.get_tables_meta(); // TODO(adb): re-enable after fixing up catalog/db
80  // locking
81 
82  logger.info("[" + tid + "]"
83  + "USER DISCONNECT");
84  user.disconnect();
85  }
86 
87  logger.info("[" + tid + "]"
88  + "DROP " + viewName);
89  dba.runSql("DROP VIEW " + viewName + ";");
90 
91  logger.info("[" + tid + "]"
92  + "DROP " + tableName);
93  dba.runSql("DROP TABLE " + tableName + ";");
94  }

+ Here is the caller graph for this function:

void com.mapd.tests.EagainConcurrencyTest.runTest ( String  db,
String  dbaUser,
String  dbaPassword,
String  dbUser,
String  dbPassword 
) throws Exception
inlineprivate

Definition at line 96 of file EagainConcurrencyTest.java.

References run, and com.mapd.tests.EagainConcurrencyTest.run_test().

Referenced by com.mapd.tests.EagainConcurrencyTest.testCatalogConcurrency().

98  {
99  int num_threads = 5;
100  final int runs = 25;
101  Exception exceptions[] = new Exception[num_threads];
102 
103  ArrayList<Thread> threads = new ArrayList<>();
104  for (int i = 0; i < num_threads; i++) {
105  logger.info("Starting " + i);
106  final String prefix = "for_bob_" + i + "_";
107  final int threadId = i;
108  Thread t = new Thread(new Runnable() {
109  @Override
110  public void run() {
111  try {
112  HeavyDBTestClient dba = HeavyDBTestClient.getClient(
113  "localhost", 6274, db, dbaUser, dbaPassword);
114  run_test(dba, db, dbUser, dbPassword, prefix, runs);
115  } catch (Exception e) {
116  logger.error("[" + Thread.currentThread().getId() + "]"
117  + "Caught Exception: " + e.getMessage(),
118  e);
119  exceptions[threadId] = e;
120  }
121  }
122  });
123  t.start();
124  threads.add(t);
125  }
126 
127  for (Thread t : threads) {
128  t.join();
129  }
130 
131  for (Exception e : exceptions) {
132  if (null != e) {
133  logger.error("Exception: " + e.getMessage(), e);
134  throw new Exception(e.getMessage(), e);
135  }
136  }
137  }
void run_test(HeavyDBTestClient dba, String db, String dbUser, String dbPassword, String prefix, int max)
static bool run

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void com.mapd.tests.EagainConcurrencyTest.testCatalogConcurrency ( ) throws Exception
inline

Definition at line 139 of file EagainConcurrencyTest.java.

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

139  {
140  logger.info("testCatalogConcurrency()");
141 
142  HeavyDBTestClient su = HeavyDBTestClient.getClient(
143  "localhost", 6274, "heavyai", "admin", "HyperInteractive");
144  su.runSql("CREATE USER dba (password = 'password', is_super = 'true');");
145  su.runSql("CREATE USER bob (password = 'password', is_super = 'false');");
146 
147  su.runSql("GRANT CREATE on DATABASE heavyai TO bob;");
148  su.runSql("GRANT CREATE VIEW on DATABASE heavyai TO bob;");
149  su.runSql("GRANT CREATE DASHBOARD on DATABASE heavyai TO bob;");
150 
151  su.runSql("GRANT DROP on DATABASE heavyai TO bob;");
152  su.runSql("GRANT DROP VIEW on DATABASE heavyai TO bob;");
153  su.runSql("GRANT DELETE DASHBOARD on DATABASE heavyai TO bob;");
154 
155  su.runSql("CREATE DATABASE db1;");
156 
157  su.runSql("GRANT CREATE on DATABASE db1 TO bob;");
158  su.runSql("GRANT CREATE VIEW on DATABASE db1 TO bob;");
159  su.runSql("GRANT CREATE DASHBOARD on DATABASE db1 TO bob;");
160 
161  su.runSql("GRANT DROP on DATABASE db1 TO bob;");
162  su.runSql("GRANT DROP VIEW on DATABASE db1 TO bob;");
163  su.runSql("GRANT DELETE DASHBOARD on DATABASE db1 TO bob;");
164 
165  su.runSql("GRANT ACCESS on database heavyai TO dba;");
166  su.runSql("GRANT ACCESS on database heavyai TO bob;");
167  su.runSql("GRANT ACCESS on database db1 TO dba;");
168  su.runSql("GRANT ACCESS on database db1 TO bob;");
169 
170  runTest("db1", "admin", "HyperInteractive", "admin", "HyperInteractive");
171  runTest("db1", "admin", "HyperInteractive", "dba", "password");
172  runTest("db1", "admin", "HyperInteractive", "bob", "password");
173  runTest("db1", "dba", "password", "admin", "HyperInteractive");
174  runTest("db1", "dba", "password", "bob", "password");
175 
176  runTest("heavyai", "admin", "HyperInteractive", "admin", "HyperInteractive");
177  runTest("heavyai", "admin", "HyperInteractive", "dba", "password");
178  runTest("heavyai", "admin", "HyperInteractive", "bob", "password");
179  runTest("heavyai", "dba", "password", "admin", "HyperInteractive");
180  runTest("heavyai", "dba", "password", "bob", "password");
181 
182  su.runSql("DROP DATABASE db1;");
183  su.runSql("DROP USER bob;");
184  su.runSql("DROP USER dba;");
185 
186  logger.info("testCatalogConcurrency() done");
187  }
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.EagainConcurrencyTest.logger = LoggerFactory.getLogger(EagainConcurrencyTest.class)
staticpackage

Definition at line 24 of file EagainConcurrencyTest.java.


The documentation for this class was generated from the following file: