OmniSciDB  c07336695a
com.mapd.parser.server.test.TestMapDServer Class Reference
+ Collaboration diagram for com.mapd.parser.server.test.TestMapDServer:

Classes

class  ConnInfo
 

Public Member Functions

void testThreadedCall ()
 

Private Member Functions

void randomMapDCall (ConnInfo conn)
 
ConnInfo createMapDConnection ()
 
void executeQuery (ConnInfo conn, String query, int resultCount)
 
void closeMapDConnection (ConnInfo conn)
 

Private Attributes

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

Static Private Attributes

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

Detailed Description

Definition at line 40 of file TestMapDServer.java.

Member Function Documentation

◆ closeMapDConnection()

void com.mapd.parser.server.test.TestMapDServer.closeMapDConnection ( ConnInfo  conn)
inlineprivate

Definition at line 140 of file TestMapDServer.java.

References com.mapd.parser.server.test.TestMapDServer.ConnInfo.client, Testing.fail, com.mapd.parser.server.test.TestMapDServer.ConnInfo.session, and com.mapd.parser.server.test.TestMapDServer.ConnInfo.transport.

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

140  {
141  try {
142  conn.client.disconnect(conn.session);
143  conn.transport.close();
144  } catch (TException x) {
145  fail("Exception on close occurred " + x.toString());
146  }
147  }
static unsigned fail
Definition: testing.h:30
+ Here is the caller graph for this function:

◆ createMapDConnection()

ConnInfo com.mapd.parser.server.test.TestMapDServer.createMapDConnection ( )
inlineprivate

Definition at line 110 of file TestMapDServer.java.

References client, Testing.fail, session, and Experimental.String.

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

110  {
111  String session = null;
112  TTransport transport = null;
113  MapD.Client client = null;
114  try {
115  transport = new TSocket("localhost", 6274);
116  transport.open();
117  TProtocol protocol = new TBinaryProtocol(transport);
118  client = new MapD.Client(protocol);
119  session = client.connect("admin", "HyperInteractive", "omnisci");
120  } catch (TException x) {
121  fail("Exception on create occurred " + x.toString());
122  }
123  return new ConnInfo(session, transport, client);
124  }
mapd::shared_ptr< MapDClient > client
static unsigned fail
Definition: testing.h:30
TSessionId session
+ Here is the caller graph for this function:

◆ executeQuery()

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

Definition at line 126 of file TestMapDServer.java.

References com.mapd.parser.server.test.TestMapDServer.ConnInfo.client, Testing.fail, run-benchmark-import.res, and com.mapd.parser.server.test.TestMapDServer.ConnInfo.session.

Referenced by com.mapd.parser.server.test.TestMapDServer.randomMapDCall().

126  {
127  try {
128  TQueryResult res = conn.client.sql_execute(conn.session, query, true, null, -1, -1);
129  if (resultCount != res.row_set.columns.get(0).nulls.size()) {
130  fail("result doesn't match " + resultCount
131  + " != " + res.row_set.columns.get(0).nulls.size());
132  }
133  } catch (TMapDException x) {
134  fail("Exception on EXECUTE " + x.toString());
135  } catch (TException x) {
136  fail("Exception on EXECUTE " + x.toString());
137  }
138  }
static unsigned fail
Definition: testing.h:30
+ Here is the caller graph for this function:

◆ randomMapDCall()

void com.mapd.parser.server.test.TestMapDServer.randomMapDCall ( ConnInfo  conn)
inlineprivate

Definition at line 97 of file TestMapDServer.java.

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

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

97  {
98  Random r = new Random();
99  int aliasID = r.nextInt(100000) + 1000000;
100  int limit = r.nextInt(20) + 1;
101  // executeQuery(conn, String.format("Select TABALIAS%d.dest_lon AS COLALIAS%d
102  // from
103  // flights TABALIAS%d LIMIT %d",
104  // aliasID, aliasID, aliasID, limit), limit);
105  executeQuery(conn,
106  "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",
107  2202);
108  }
void executeQuery(ConnInfo conn, String query, int resultCount)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testThreadedCall()

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

Definition at line 49 of file TestMapDServer.java.

References com.mapd.parser.server.test.TestMapDServer.ae, com.mapd.parser.server.test.TestMapDServer.closeMapDConnection(), com.mapd.parser.server.test.TestMapDServer.createMapDConnection(), com.mapd.parser.server.test.TestMapDServer.randomMapDCall(), run, and com.mapd.parser.server.test.TestMapDServer.TEST_THREAD_COUNT.

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

Member Data Documentation

◆ ae

volatile AssertionError com.mapd.parser.server.test.TestMapDServer.ae
private

◆ csw

CalciteServerWrapper com.mapd.parser.server.test.TestMapDServer.csw = null
staticprivate

Definition at line 46 of file TestMapDServer.java.

◆ MAPDLOGGER

final Logger com.mapd.parser.server.test.TestMapDServer.MAPDLOGGER = LoggerFactory.getLogger(TestMapDServer.class)
staticprivate

Definition at line 41 of file TestMapDServer.java.

◆ TEST_THREAD_COUNT

final int com.mapd.parser.server.test.TestMapDServer.TEST_THREAD_COUNT = 2
staticprivate

◆ threadHadFailure

volatile boolean com.mapd.parser.server.test.TestMapDServer.threadHadFailure = false
private

Definition at line 44 of file TestMapDServer.java.

◆ threadsRun

volatile int com.mapd.parser.server.test.TestMapDServer.threadsRun = 0
private

Definition at line 43 of file TestMapDServer.java.


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