OmniSciDB  a987f07e93
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
com.mapd.parser.server.test.TestDBServer Class Reference
+ Collaboration diagram for com.mapd.parser.server.test.TestDBServer:

Classes

class  ConnInfo
 

Public Member Functions

void testThreadedCall ()
 

Private Member Functions

void randomDBCall (ConnInfo conn)
 
ConnInfo createDBConnection ()
 
void executeQuery (ConnInfo conn, String query, int resultCount)
 
void closeDBConnection (ConnInfo conn)
 

Private Attributes

volatile int threadsRun = 0
 
volatile boolean threadHadFailure = false
 
volatile AssertionError ae
 

Static Private Attributes

static final Logger HEAVYDBLOGGER = LoggerFactory.getLogger(TestDBServer.class)
 
static final int TEST_THREAD_COUNT = 2
 
static CalciteServerWrapper csw = null
 

Detailed Description

Definition at line 41 of file TestDBServer.java.

Member Function Documentation

void com.mapd.parser.server.test.TestDBServer.closeDBConnection ( ConnInfo  conn)
inlineprivate

Definition at line 141 of file TestDBServer.java.

Referenced by com.mapd.parser.server.test.TestDBServer.testThreadedCall().

141  {
142  try {
143  conn.client.disconnect(conn.session);
144  conn.transport.close();
145  } catch (TException x) {
146  fail("Exception on close occurred " + x.toString());
147  }
148  }

+ Here is the caller graph for this function:

ConnInfo com.mapd.parser.server.test.TestDBServer.createDBConnection ( )
inlineprivate

Definition at line 111 of file TestDBServer.java.

Referenced by com.mapd.parser.server.test.TestDBServer.testThreadedCall().

111  {
112  String session = null;
113  TTransport transport = null;
114  Heavy.Client client = null;
115  try {
116  transport = new TSocket("localhost", 6274);
117  transport.open();
118  TProtocol protocol = new TBinaryProtocol(transport);
119  client = new Heavy.Client(protocol);
120  session = client.connect("admin", "HyperInteractive", "omnisci");
121  } catch (TException x) {
122  fail("Exception on create occurred " + x.toString());
123  }
124  return new ConnInfo(session, transport, client);
125  }

+ Here is the caller graph for this function:

void com.mapd.parser.server.test.TestDBServer.executeQuery ( ConnInfo  conn,
String  query,
int  resultCount 
)
inlineprivate

Definition at line 127 of file TestDBServer.java.

References run_benchmark_import.res.

Referenced by com.mapd.parser.server.test.TestDBServer.randomDBCall().

127  {
128  try {
129  TQueryResult res = conn.client.sql_execute(conn.session, query, true, null, -1, -1);
130  if (resultCount != res.row_set.columns.get(0).nulls.size()) {
131  fail("result doesn't match " + resultCount
132  + " != " + res.row_set.columns.get(0).nulls.size());
133  }
134  } catch (TDBException x) {
135  fail("Exception on EXECUTE " + x.getError_msg());
136  } catch (TException x) {
137  fail("Exception on EXECUTE " + x.toString());
138  }
139  }

+ Here is the caller graph for this function:

void com.mapd.parser.server.test.TestDBServer.randomDBCall ( ConnInfo  conn)
inlineprivate

Definition at line 98 of file TestDBServer.java.

References com.mapd.parser.server.test.TestDBServer.executeQuery().

Referenced by com.mapd.parser.server.test.TestDBServer.testThreadedCall().

98  {
99  Random r = new Random();
100  int aliasID = r.nextInt(100000) + 1000000;
101  int limit = r.nextInt(20) + 1;
102  // executeQuery(conn, String.format("Select TABALIAS%d.dest_lon AS COLALIAS%d
103  // from
104  // flights TABALIAS%d LIMIT %d",
105  // aliasID, aliasID, aliasID, limit), limit);
106  executeQuery(conn,
107  "SELECT date_trunc(day, arr_timestamp) as key0,CASE when carrier_name IN ('Southwest Airlines','American Airlines','Skywest Airlines','American Eagle Airlines','US Airways') then carrier_name ELSE 'other' END as key1,COUNT(*) AS val FROM flights_2008_7m WHERE (arr_timestamp >= TIMESTAMP(0) '2008-01-01 00:57:00' AND arr_timestamp < TIMESTAMP(0) '2009-01-01 18:27:00') GROUP BY key0, key1 ORDER BY key0,key1",
108  2202);
109  }
void executeQuery(ConnInfo conn, String query, int resultCount)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void com.mapd.parser.server.test.TestDBServer.testThreadedCall ( )
inline

Definition at line 50 of file TestDBServer.java.

References com.mapd.parser.server.test.TestDBServer.ae, com.mapd.parser.server.test.TestDBServer.closeDBConnection(), com.mapd.parser.server.test.TestDBServer.createDBConnection(), com.mapd.parser.server.test.TestDBServer.randomDBCall(), run, com.mapd.parser.server.test.TestDBServer.TEST_THREAD_COUNT, com.mapd.parser.server.test.TestDBServer.threadHadFailure, and com.mapd.parser.server.test.TestDBServer.threadsRun.

50  {
51  final ExecutorService pool = Executors.newFixedThreadPool(TEST_THREAD_COUNT);
52 
53  Runnable r = new Runnable() {
54  @Override
55  public void run() {
56  try {
57  ConnInfo conn = createDBConnection();
58  Random r = new Random();
59  int calCount = r.nextInt(9) + 1;
60  int calls = 0;
61  for (int i = 1; i <= 100; i++) {
62  // if (i%100 == 0){
63  System.out.println("i is " + i);
64  // }
65  if (calls > calCount) {
66  closeDBConnection(conn);
67  conn = createDBConnection();
68  calCount = r.nextInt(9) + 1;
69  calls = 0;
70  }
71  randomDBCall(conn);
72  calls++;
73  }
74  closeDBConnection(conn);
75  } catch (AssertionError x) {
76  HEAVYDBLOGGER.error("error during Runnable");
77  threadHadFailure = true;
78  ae = x;
79  }
80  threadsRun++;
82  pool.shutdown();
83  }
84  }
85  };
86 
87  for (int i = 0; i < TEST_THREAD_COUNT; i++) {
88  pool.submit(r);
89  }
90  while (!pool.isShutdown()) {
91  // stay alive
92  }
93  if (threadHadFailure) {
94  throw ae;
95  }
96  }
static bool run

+ Here is the call graph for this function:

Member Data Documentation

volatile AssertionError com.mapd.parser.server.test.TestDBServer.ae
private
CalciteServerWrapper com.mapd.parser.server.test.TestDBServer.csw = null
staticprivate

Definition at line 47 of file TestDBServer.java.

final Logger com.mapd.parser.server.test.TestDBServer.HEAVYDBLOGGER = LoggerFactory.getLogger(TestDBServer.class)
staticprivate

Definition at line 42 of file TestDBServer.java.

final int com.mapd.parser.server.test.TestDBServer.TEST_THREAD_COUNT = 2
staticprivate
volatile boolean com.mapd.parser.server.test.TestDBServer.threadHadFailure = false
private
volatile int com.mapd.parser.server.test.TestDBServer.threadsRun = 0
private

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