Uploaded image for project: 'Apache Drill'
  1. Apache Drill
  2. DRILL-4170

how many concurrent users can be supported

    XMLWordPrintableJSON

Details

    • Test
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.3.0
    • 1.7.0
    • Client - JDBC
    • None
    • drill1.3 JDBC SCRIPTS

    • Important

    Description

      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

      Attachments

        Activity

          People

            Unassigned Unassigned
            david_hudavy david_hudavy
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: