4 Replies Latest reply on Apr 1, 2013 2:06 PM by Steven Hawkins

    JDBC/ODBC socket transport in embedded mode

    Himanshu Kapoor Newbie

      Hi ,

       

      I would like to make connection to the vdb's in teiid embedded mode by using the teiid jdbc driver from the external java application (outside the application server i am hosting the teiid embedded).

      Is there any way i can configure this stuff. I looked into the teiid code and found there are two separate connection profiles i.e.embeeded and socket profile and driver.getconnection() method takes

      different path dpeneding on the url passed , i understand if i pass the url which socket profile is expecting it will take that path. However there might be other things which might not work in this

      case and may be i have to open the port (socket communication ) for that connection .

       

      Is there any way you can suggest i can enable this stuff , may be i need to add some functionality on my own , any suggestions will help.

       

      Is there anything in the roadmap to enable thiss stuff in embedded mode.

       

       

      Regards

      Himanshu Kapoor

        • 1. Re: JDBC/ODBC socket transport in embedded mode
          Steven Hawkins Master

          Adding transport support for embedded has been discussed, but no JIRA has been created yet.  Can you log something?  It is fairly straight-forward for us to wrap a transport layer around an embedded instances, such as with tests like https://github.com/teiid/teiid/tree/master/test-integration/common/src/test/java/org/teiid/transport

           

          However to do that on your own would be leveraging a lot of internal apis and may be more configuration/wiring than you'd want to tackle.

           

          Steve

          • 2. Re: JDBC/ODBC socket transport in embedded mode
            Himanshu Kapoor Newbie

            Hi Steve,

             

            Thanks for the reply .I have created a jira feature request for the same , hope community will pick this up soon and provide this stuff in near future.

            https://issues.jboss.org/browse/TEIID-2439

             

            In the mean time I will also start looking into the code you have mentioned as well as start looking into internal api's how to hook them up to make this functionality.

             

            Regards

            Himanshu Kapoor

            • 3. Re: JDBC/ODBC socket transport in embedded mode
              Himanshu Kapoor Newbie

              Hi Steve ,

               

              Thanks for your suggestions. I looked into the teiid tests you mentioned as well as into the internal apis of teiid and able to hook up the jdbc socket functionality and able to access the vdbs using teiid jdbc driver from third party java app.

               

              This is my understanding , please let me know if am going wrong somewhere:

               

              Going through test cases as well debugging teiid stuff , I realized that teiid used jboss netty library for socket communications. Socket Listener class in teiid creates the channel factory , creates the channel pipe line factory (ssl aware handler in this case ) and adds encoder , decoder and handlers to handle the upstream and downstream messages and also binds the InetSocketAddress and creates the server channel (using server bootstrap class) . This means this parent channel i.e. server chanel keep running in boss thread of channel factory to listen on the binded port for the new coming requests and children channels (established connections) keep running in worker threads of channel factory . So i believe it was just the matter of invoking this functionality.

               

              To test this stuff quickly , i derived a class from teiid embedded server and exposed the storage manager and client service registry impl from it ,  like

               

              public class MyTeiid extends  EmbeddedServer{

                  @Override

                  public VDBRepository getVDBRepository() {

                      //compiled code

                     return super.getVDBRepository();

                  }

                 

                  public ClientServiceRegistryImpl getClientServiceRegistry() {

                    return services;

                  }

                 

                  public StorageManager getStorageManager()

                  {

                    return bufferService.getBufferManager();

                  }

              }

               

              Created a socket configuration stuff , and hooked these all things with socket listner in a function say

              static  SocketListener jdbcTransport = null;

               

              void StartTeiidSocketJdbc()

              {

               

                    config = new SocketConfiguration();

                    config.setSSLConfiguration(new SSLConfiguration());

                    addr = new InetSocketAddress("mynetwrkaddr", myportnumber);

                    config.setBindAddress(addr.getHostName());

                    config.setPortNumber(addr.getPort());

                    jdbcTransport = new SocketListener(addr, config, teiidServer.getClientServiceRegistry(),teiidServer.getStorageManager());

              }

               

              as soon as i host the teiid in my application i called the StartTeiidSocketJdbc function.

               

              Now i created the sample java apps to connect to various vdbs using teiid jdbc driver anad able to do so.

              Please let me know if i am missing something.

               

              Regards

              Himanshu Kapoor

              • 4. Re: JDBC/ODBC socket transport in embedded mode
                Steven Hawkins Master

                > Please let me know if i am missing something.

                 

                No, that will work for simple remote jdbc access.  Setting up SSL or changing SocketListener parameters may be something that you need to do later, but you should be able to figure that out quite easily as well.

                 

                When this gets turned into a feature we'll simply move the transport(s) into the EmbeddedServer and expose an appropriate amount of configuration through the EmbeddedConfiguration.  You can take a stab at that if you want or just stick with what you have for now.

                 

                Thanks,

                Steve