3 Replies Latest reply on Jan 15, 2013 12:01 PM by Ramesh Reddy Branched to a new discussion.

    Teiid "Local Connection".

    Amit Jahagirdar Newbie

      Hi,

       

      1) My project has teiid and the our application which uses teiid on the same Jboss EAP.

      The current implementation has socket based connection, which is created very often to connect to different data models and fetch data as per the http request.

      I would like to know if "Local Connections" would be a benefit in this scenario ? If Yes what would be the benefits...performance,scalability etc?

       

      2) Further looking into Local connection revelas that we can use "useCallingThread=true" to have the calling thread being maintained and avoid use of worker threads.

      But didnot find a sample code for this.it would be great if a sample is provided for the same.

       

      3) Tricky part: We have about 20 Vdbs which are used as multi-source=true  and connecting to 3/4  physical databases.

           Since user can fetch data from any of these databases I m  unable to create a Teiid-Datasource for them.

       

      Confusion is :: Should there be one teiid data source catering to all the other datasources or should there be one Teiid DS per Vdb in the ds.xml?

      In both the cases how should I provide the database name, jndi-name while creating the Local connection.

      I m referring to the following part described in the teiid documentation:

      ----------------------------------------------------------------------------------------------------------------------------------------------------------------

      <datasources>

        <xa-datasource>

          <jndi-name>TEIID-DS</jndi-name>

          <xa-datasource-class>org.teiid.jdbc.TeiidDataSource</xa-datasource-class>

          <xa-datasource-property name="DatabaseName">myVDB</xa-datasource-property>

          <xa-datasource-property name="user">admin</xa-datasource-property>

          <xa-datasource-property name="password">password</xa-datasource-property>

          <!-- pool and other JBoss datasource properties -->

          <max-pool-size>10</max-pool-size>               

        </xa-datasource>       

      </datasources>

      ----------------------------------------------------------------------------------------------------------------------------------------------------------------


       

      Thanks

      Amit

        • 1. Re: Teiid "Local Connection".
          Ramesh Reddy Master

          Amit,

          1) My project has teiid and the our application which uses teiid on the same Jboss EAP.

          The current implementation has socket based connection, which is created very often to connect to different data models and fetch data as per the http request.

          I would like to know if "Local Connections" would be a benefit in this scenario ? If Yes what would be the benefits...performance,scalability etc?

          Yes. Performance will be better as when using as Local there is no transport, all objects local so there is no marshalling and unmarshelling of messages that relate to the requests and responses.

           

          2) Further looking into Local connection revelas that we can use "useCallingThread=true" to have the calling thread being maintained and avoid use of worker threads.

          But didnot find a sample code for this.it would be great if a sample is provided for the same.

          I am not sure what you are looking for by means of code. The "useCallingThread=true" is set on the URL to make the Local Connection. That is all there is to it, no more code involved from client side.

           

          3) Tricky part: We have about 20 Vdbs which are used as multi-source=true  and connecting to 3/4  physical databases.

               Since user can fetch data from any of these databases I m  unable to create a Teiid-Datasource for them.

           

          Confusion is :: Should there be one teiid data source catering to all the other datasources or should there be one Teiid DS per Vdb in the ds.xml?

          In both the cases how should I provide the database name, jndi-name while creating the Local connection.

          Yes, there is confusion, not in terms of configuration but how your intended usecase is.  May be little more explanation would help. I do not understand your multi-source requirement, and how you client application is accessing them. Individually or there is another vdb?

           

          If you have 20 VDBs that are being used as multi-source=true, then all these 20 vdbs are identical in terms of metadata and there should be another VDB that is defining all these 20 VDBs as sources and defining them as multi-source. For the sake of this last VDB that defined all the others as sources, it needs a data source defined for each one of the VDB.

          1 of 1 people found this helpful
          • 2. Re: Teiid "Local Connection".
            Amit Jahagirdar Newbie

            Hi Ramesh,

             

            Thanks for the reply.

             

            I started using the useCallingThread=true in the url as follows:

             

            String url = "jdbc:teiid:vdbName@mm://"+"localhost"+":"+ 31000+";showplan=on;useCallingThread=true";

             

            With this as base i created two test samples

            1) one which connects the deployed vdb using the teiid datasource (ie specifying the teiid data source in the standalone.xml)

             

             

            <datasource jta="true" jndi-name="java:/TeiidDataSource" pool-name="TeiidData" enabled="true" use-java-context="true" use-ccm="true">
                                <connection-url>jdbc:teiid:PartsExample</connection-url>
                                <driver>teiid</driver>
                                <pool>
                                    <min-pool-size>0</min-pool-size>
                                    <max-pool-size>100</max-pool-size>
                                    <prefill>false</prefill>
                                    <use-strict-min>false</use-strict-min>
                                    <flush-strategy>FailingConnectionOnly</flush-strategy>
                                </pool>
                                <security>
                                    <user-name>user</user-name>
                                    <password>user</password>
                                </security>
                            </datasource>
            

            2) The other which uses url to connect to the same vdb.(Socket based connection).

            String url = "jdbc:teiid:PartsExample@mm://"+"localhost"+":"+ 31000+";showplan=on;useCallingThread=true";

            Normal jdbc code follows...

            ------------------------------------------------------------------------------------------------------------------------------------------------------------------

            I found that though the usecallingThread = true was set the jboss console showed a new I/O server thread created on top of the http request thread(parent thread).

             

            20:49:03,302 DEBUG [org.teiid.TRANSPORT] (New I/O server worker #1-1) processing message:MessageHolder: key=0 contents=javax.crypto.SealedObject@40f8c9bf
            20:49:03,304 DEBUG [org.teiid.SECURITY] (New I/O server worker #1-1) authenticateUser user JDBC
            20:49:03,305 DEBUG [org.teiid.SECURITY] (New I/O server worker #1-1) Logon successful for " user "
            20:49:03,306 DEBUG [org.teiid.SECURITY] (New I/O server worker #1-1) Logon successful, created session: sessionid=J3VG07QBtTpm; userName=user@teiid-security; vd
            bName=PartsExample; vdbVersion=1; createdTime=Tue Jan 15 20:49:03 IST 2013; applicationName=JDBC; clientHostName=SZ024.rdx.lgc.com; clientHardwareAddress=9CB70D
            D40422; IPAddress=172.25.10.33; securityDomain=teiid-security; lastPingTime=Tue Jan 15 20:49:03 IST 2013
            20:49:03,307 DEBUG [org.teiid.TRANSPORT] (New I/O server worker #1-1) send message: MessageHolder: key=0 contents=javax.crypto.SealedObject@321236f4
            20:49:16,695 DEBUG [org.teiid.TRANSPORT] (New I/O server worker #1-1) processing message:MessageHolder: key=1 contents=Invoke interface org.teiid.client.DQP.exe
            cuteRequest
            20:49:16,697 DEBUG [org.teiid.PROCESSOR] (Worker4_QueryProcessorQueue30) Request Thread J3VG07QBtTpm.0 with state NEW
            20:49:16,698 DEBUG [org.teiid.PROCESSOR] (Worker4_QueryProcessorQueue30) J3VG07QBtTpm.0 Non-cachable command.
            20:49:16,699 DEBUG [org.teiid.PROCESSOR] (Worker4_QueryProcessorQueue30) J3VG07QBtTpm.0 executing  Select * from teiidsample.supplier
            

            ---------------------------------------

            While in case of Teiid datasource sample the console always showed up that the http thread is used and no separate I/O thread is created.

             

             

            [org.odata4j.producer.resources.EntityRequestResource] (http--127.0.0.1-8080-1) getEntity(Supplier,('S101'),null,null)
            [org.hibernate.internal.SessionImpl] (http--127.0.0.1-8080-1) Opened session at timestamp: 13582632015
            [org.hibernate.loader.Loader] (http--127.0.0.1-8080-1) Loading entity: [com.synerzip.teiidjpa.model.Supplier#S101]
            [org.hibernate.engine.jdbc.internal.LogicalConnectionImpl] (http--127.0.0.1-8080-1) Obtaining JDBC connection
            [org.jboss.jca.core.connectionmanager.pool.strategy.OnePool] (http--127.0.0.1-8080-1) TeiidData: getConnection(null, null) [1/100]
            [org.hibernate.engine.jdbc.internal.LogicalConnectionImpl] (http--127.0.0.1-8080-1) Obtained JDBC connection
            

            -------------------------------------------------------------------------------------------------------

            So is it true that inspite of the "useCallingThread=true" flag setting the teiid runtime always creates a new I/O server thread when we make a socket based connection?

            • 3. Re: Teiid "Local Connection".
              Ramesh Reddy Master

              Amit,

               

              It "useCallingThread=true" only applies to "LocalConnections", that means in VM connections. If you are making a connection using a socket, even it is from same VM it will be considered as remote connection and this property will not be honored. That is why you are seeing difference.

               

              Now, to much, much more important question (for me at least), I see you are using the odata4j in your call stack.  What are you using this library for? can you elaborate your use case. I do not know if you have read any messages on the Teiid JIRA, but I have been working on https://issues.jboss.org/browse/TEIID-1854 and https://issues.jboss.org/browse/TEIID-1757 and I have been using OData4J. If you are involved in similar efforts may be we can collaborate at some level, such that we can make sure a single and correct solution exists for Teiid. Let me know if you are interested.

               

              Thanks.

               

              Ramesh..