You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@drill.apache.org by "david_hudavy (JIRA)" <ji...@apache.org> on 2015/12/08 04:37:11 UTC
[jira] [Created] (DRILL-4170) how many concurrent users can be
supported
david_hudavy created DRILL-4170:
-----------------------------------
Summary: how many concurrent users can be supported
Key: DRILL-4170
URL: https://issues.apache.org/jira/browse/DRILL-4170
Project: Apache Drill
Issue Type: Test
Components: Client - JDBC
Affects Versions: 1.3.0
Environment: drill1.3 JDBC SCRIPTS
Reporter: david_hudavy
Fix For: 1.4.0
import java.sql.Connection;
import java.sql.Statement;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
public class MultiThreadTestDrill {
public static void main(String[] args) throws InterruptedException {
int threadNum = 200;
long tStart = System.currentTimeMillis();
System.out.println(Thread.currentThread().getName() + "START");
for (int ii = 0; ii < threadNum; ii++) {
Thread t = new WorkerThread();
t.start();
}
while (true) {
if (!WorkerThread.hasThreadRunning()) {
break;
}
Thread.sleep(500);
}
System.out.println(Thread.currentThread().getName() + "END");
long tEnd = System.currentTimeMillis();
System.out.println("TOTAL TIME:" + (tEnd - tStart)/1000 + "seconds");
}
public static class WorkerThread extends Thread {
private static List<Thread> runningThreads = new ArrayList<Thread>();
public WorkerThread() {
}
@Override
public void run() {
regist(this);
// PRINT START INFORMATION
System.out.println(Thread.currentThread().getName() + "START...");
connectToDrill();
unRegist(this);
// PRINT END INFORMATION
System.out.println(Thread.currentThread().getName() + "END");
}
public void regist(Thread t) {
synchronized (runningThreads) {
runningThreads.add(t);
}
}
public void unRegist(Thread t) {
synchronized (runningThreads) {
runningThreads.remove(t);
}
}
public static boolean hasThreadRunning() {
return (runningThreads.size() > 0);
}
private void connectToDrill() {
// TODO Auto-generated method stub
String driver = "org.apache.drill.jdbc.Driver";
String url = "jdbc:drill:drillbit=localhost";
String sql = "SELECT count(*) FROM mysql.datamart.StaticInf";
try {
Class.forName(driver);
// connect drill
Connection conn = (Connection) DriverManager.getConnection(url);
if (!conn.isClosed())
System.out.println("Succeeded connecting to the Drill!");
Statement statement = (Statement) conn.createStatement();
ResultSet rs = statement.executeQuery(sql);
while (rs.next()) {
System.out.println(rs.getString(1));
}
rs.close();
conn.close();
} catch (ClassNotFoundException e) {
System.out.println("Sorry,can`t find the Driver!");
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
mysql.datamart.StaticInf has 2144781 rows
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)