[ 
https://issues.apache.org/jira/browse/SOLR-7986?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14903665#comment-14903665
 ] 

Susheel Kumar commented on SOLR-7986:
-------------------------------------

Hi Joel,

I added locally 3 bad connection string tests. Please let me know your opinion 
before I provide a patch
a) The first below test "testConnectionStringWithMissingZKHost" throws 
SolrException than SQLException. Is that right behaviour. Just wanted to 
confirm.
b) Is it okay to add more public multiple tests method OR have one test method 
and calling various private test methods inside it. Any preference since I see 
the later is more common .
c) The test  "testConnectionStringWithWrongCollection" goes thru various 
retries before it fails. Below the console messages. Is that right behavior. 

Thanks,
Susheel



  @Test
  public void testConnectionStringWithMissingZKHost() throws Exception  {
   //should throw Solr exception as per current design
    exception.expect(SolrException.class);
    String zkHost = zkServer.getZkAddress();
    Properties props = new Properties();
    //bad connection string: missing zkHost
   Connection con = DriverManager.getConnection("jdbc:solr://"  + 
"?collection=collection1", props);
  }
  
  @Test
  public void testConnectionStringJumbled() throws Exception  {
    //should throw SQL exception
     exception.expect(SQLException.class);
     Properties props = new Properties();
     String zkHost = zkServer.getZkAddress();
     //Bad connection string: string jumbled   
     Connection con = DriverManager.getConnection("solr:jdbc://" + zkHost + 
"?collection=collection1", props);
   }
  
  @Test
  public void testConnectionStringWithWrongCollection() throws Exception  {
     //should throw SQL exception
     exception.expect(SQLException.class);
     Properties props = new Properties();
     String zkHost = zkServer.getZkAddress();
     //Bad connection string: wrong collection name   
     Connection con = DriverManager.getConnection("jdbc:solr://" + zkHost + 
"?collection=mycollection", props);
     Statement stmt = con.createStatement();
     ResultSet rs = stmt.executeQuery("select id, a_i, a_s, a_f from 
mycollection order by a_i desc limit 2");
    
   } 

testConnectionStringWithWrongCollection console messages.
-----
Sep 22, 2015 5:26:28 PM com.carrotsearch.randomizedtesting.ThreadLeakControl 
checkThreadLeaks
WARNING: Will linger awaiting termination of 6 leaked thread(s).
95116 WARN  
(TEST-JdbcTest.testConnectionStringWithWrongCollection-seed#[8ED3B3162E3AB02D]-SendThread(127.0.0.1:55137))
 [n:127.0.0.1:55092_cb_i%2Fof c:collection1 s:shard1 r:core_node4 
x:collection1] o.a.z.ClientCnxn Session 0x14ff6f24fcf0012 for server null, 
unexpected error, closing socket connection and attempting reconnect
java.net.ConnectException: Connection refused
        at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
        at 
sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
        at 
org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361)
        at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1081)
96786 WARN  
(TEST-JdbcTest.testConnectionStringWithWrongCollection-seed#[8ED3B3162E3AB02D]-SendThread(127.0.0.1:55137))
 [n:127.0.0.1:55092_cb_i%2Fof c:collection1 s:shard1 r:core_node4 
x:collection1] o.a.z.ClientCnxn Session 0x14ff6f24fcf0012 for server null, 
unexpected error, closing socket connection and attempting reconnect
java.net.ConnectException: Connection refused
        at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
        at 
sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
        at 
org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361)
        at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1081)
98838 WARN  
(TEST-JdbcTest.testConnectionStringWithWrongCollection-seed#[8ED3B3162E3AB02D]-SendThread(127.0.0.1:55137))
 [n:127.0.0.1:55092_cb_i%2Fof c:collection1 s:shard1 r:core_node4 
x:collection1] o.a.z.ClientCnxn Session 0x14ff6f24fcf0012 for server null, 
unexpected error, closing socket connection and attempting reconnect
java.net.ConnectException: Connection refused
        at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
        at 
sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
        at 
org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361)
        at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1081)
100696 WARN  
(TEST-JdbcTest.testConnectionStringWithWrongCollection-seed#[8ED3B3162E3AB02D]-SendThread(127.0.0.1:55137))
 [n:127.0.0.1:55092_cb_i%2Fof c:collection1 s:shard1 r:core_node4 
x:collection1] o.a.z.ClientCnxn Session 0x14ff6f24fcf0012 for server null, 
unexpected error, closing socket connection and attempting reconnect
java.net.ConnectException: Connection refused
        at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
        at 
sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
        at 
org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361)
        at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1081)
102136 WARN  
(TEST-JdbcTest.testConnectionStringWithWrongCollection-seed#[8ED3B3162E3AB02D]-SendThread(127.0.0.1:55137))
 [n:127.0.0.1:55092_cb_i%2Fof c:collection1 s:shard1 r:core_node4 
x:collection1] o.a.z.ClientCnxn Session 0x14ff6f24fcf0012 for server null, 
unexpected error, closing socket connection and attempting reconnect
java.net.ConnectException: Connection refused
.......
......
.......

> JDBC Driver for SQL Interface
> -----------------------------
>
>                 Key: SOLR-7986
>                 URL: https://issues.apache.org/jira/browse/SOLR-7986
>             Project: Solr
>          Issue Type: New Feature
>          Components: clients - java
>    Affects Versions: Trunk
>            Reporter: Joel Bernstein
>             Fix For: Trunk
>
>         Attachments: SOLR-7986-SPI.patch, SOLR-7986.patch, SOLR-7986.patch, 
> SOLR-7986.patch, SOLR-7986.patch, SOLR-7986.patch, SOLR-7986.patch, 
> SOLR-7986.patch, SOLR-7986.patch, SOLR-7986.patch
>
>
> This ticket is to create a JDBC Driver (thin client) for the new SQL 
> interface (SOLR-7560). As part of this ticket a driver will be added to the 
> Solrj libary under the package: *org.apache.solr.client.solrj.io.sql*
> Initial implementation will include basic *Driver*, *Connection*, *Statement* 
> and *ResultSet* implementations.
> Future releases can build on this implementation to support a wide range of 
> JDBC clients and tools.
> *Syntax using parallel Map/Reduce for aggregations*:
> {code}
> Properties props = new Properties();
> props.put("aggregationMode", "map_reduce");
> props.put("numWorkers", "10");
> Connection con = 
> DriverManager.getConnection("jdbc:solr://<zkhost:port>?collection=<collection>",
>  props);
> Statement stmt = con.createStatement();
> ResultSet rs = stmt.executeQuery("select a, sum(b) from tablex group by a 
> having sum(b) > 100");
> while(rs.next()) {
>     String a = rs.getString("a");
>     double sumB = rs.getDouble("sum(b)");
> }
> {code} 
> *Syntax using JSON facet API for aggregations*:
> {code}
> Properties props = new Properties();
> props.put("aggregationMode", "facet");
> Connection con = 
> DriverManager.getConnection("jdbc:solr://<zkhost:port>?collection=<collection>",
>  props);
> Statement stmt = con.createStatement();
> ResultSet rs = stmt.executeQuery("select a, sum(b) from tablex group by a 
> having sum(b) > 100");
> while(rs.next()) {
>     String a = rs.getString("a");
>     double sumB = rs.getDouble("sum(b)");
> }
> {code}
>  



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to