14 Replies Latest reply on Apr 23, 2014 2:52 PM by shawkins

    Attaching VDBLifeCycleListener to application

    anilallewar

      We have an application that gets the deployed VDBs at runtime and uses that information to service data that is available through deployed VBDs. For performance considerations we are trying to use in memory cache; however we would like to refresh the cache when say a new VDB gets deployed.

       

      I see that we have VDBLifeCycleListener interface that when implemented should be able to listen to VDB lifecycle events and act accordingly. However I have not been able to find as to how we can hookup the VDBLifeCycleListener implementation to the Teiid runtime.

       

      Can someone please guide me as to how can I attach VDBLifeCycleListener impl to the Teiid runtime?

        • 1. Re: Attaching VDBLifeCycleListener to application
          rareddy

          Anil,

           

          With out extending the Teiid code you can not add "VDBLifeCycleListener". Also, this is internal api and may change version to version. For this you need to write a listener in the Teiid subsystem and register it with the VDBRespository. Look for examples in the code.

           

          Every VDB when deployed in AS7 it wil be deployed as a service with the name "service.jboss.teiid.vdb.{vdb-name}.{version}", so if you know the name of the vdb, then you can write ServiceListener that listens to the VDB started event, once you receive this event then you can check if it is deployed in "active" state or not.

           

          What are caching based VDB loads? there may be alternative solutions available.

           

          Ramesh..

          • 2. Re: Attaching VDBLifeCycleListener to application
            anilallewar

            Ramesh,

             

            Thanks for the quick feedback!!

             

            We have a data platform that server data across different models and each VDB holds data for 1 model. I don't want to read the list of deployed VDBs every time I want to show what VDBs are available for data and hence would want to cache the list of deployed VDBs(not actually data in the VDB).

             

            We don't know the name of the VDBs in advance as the application intends to make data from any VDB that is hot deployed also available. The VDB will however have a custom property that lets us identify that it needs to be serviced by the application.

             

            If it is possible, can you point me to place in the source code where I can look for the service listener and how I register it with VDBRepository?

            • 3. Re: Attaching VDBLifeCycleListener to application
              rareddy

              since you are not doing any action other than storing the name of the VDB in the cache, why not just call the "getVDBs" call on the Admin API? It may not any more expensive than you caching and getting a list from there and keeping them in sync.

               

              If you want to see the VDBLifeCycleListener code take look at the VDBService class.

               

              Ramesh..

              • 4. Re: Attaching VDBLifeCycleListener to application
                anilallewar

                We also require information about the model, source, custom properties that we cache. If we have multiple concurrent users, then reading this data for every user thread will add to performance overhead.

                • 5. Re: Attaching VDBLifeCycleListener to application
                  rareddy

                  The VDB object returned from the "getVDB" does have all that information you are looking for.

                   

                  Unless your application is making a remote call to Teiid Server for this information, I do not think this will add/reduce  any more performance impact. From kind of caching you want to do, I think your application is in same VM as the Teiid, so you just providing another cache entry on top of the Teiid's.  If your app is remote the above scenario does not work anyway.

                   

                  Ramesh..

                  • 6. Re: Attaching VDBLifeCycleListener to application
                    anilallewar

                    We need to make remote calls even though we are in the same VM. This is because our application uses EclipseLink Dynamic JPA for persistence and in case of local connections, the transaction gets propogated to the Teiid layer but not to the backend system which is accessed through a custom JDBC driver.

                     

                    I believe this might be a problem with EclipseLink support for JBoss 7.1.1; I had tested Teiid with Hibernate and it seemed to work fine with local connections then. Unfortunately we are stuck with EclipseLink as that is the only ORM framework that provides support for dynamic JPA.

                     

                    As of now I am going to remove caching and read the VDB info for each call.

                    • 7. Re: Attaching VDBLifeCycleListener to application
                      shawkins

                      Anil/Ramesh,

                       

                      It seems like it would be generally useful to allow the installation of custom listeners since we don't have a global vdb table that could have customizable triggers.  This could cover for example custom strategies for external materialization initialization.  Ramesh were you thinking that the service name mechanism was enough?  Is there a way to generalize that to not know the vdb names/versions ahead of time?

                       

                      Steve

                      • 8. Re: Attaching VDBLifeCycleListener to application
                        rareddy

                        Yes, it should be possible as all the vdb based services have same base name, so they can filtered out to generate an event.

                         

                        Ramesh..

                        • 9. Re: Attaching VDBLifeCycleListener to application
                          anilallewar

                          So in this scenario are we looking at a JMX based listener or trying to create a mechanism to hook up listner into the Teiid runtime?

                          • 10. Re: Attaching VDBLifeCycleListener to application
                            rareddy

                            Remote eventing is something we need to discuss about. JMX is something we have not explicitly supported out of Teiid. This is generally handled by RHQ based monitoring tool under JBoss AS.

                             

                            Teiid does provide a EventDistributor interface which a user can find it by doing a JNDI lookup under JBoss AS, may be that is the appropriate place to have this.

                             

                            Anil, can you log a feature request for this here https://issues.jboss.org/browse/TEIID

                             

                            Ramesh..

                            1 of 1 people found this helpful
                            • 11. Re: Attaching VDBLifeCycleListener to application
                              anilallewar
                              • 12. Re: Attaching VDBLifeCycleListener to application
                                anilallewar

                                Feature implemented in Teiid 8.3.

                                • 13. Re: Attaching VDBLifeCycleListener to application
                                  kchen007

                                  Ramesh:

                                   

                                  Can you provide an example? from your test program, it create a FakeServer and call server.getEventDistributor().register(); My problem is that I do not know how to get the server object.

                                   

                                  thanks

                                  Kevin

                                  • 14. Re: Attaching VDBLifeCycleListener to application
                                    shawkins

                                    Hi Kevin,

                                    When using embedded (which the fakeserver extends) you can just directly call getEventDistributor.  In a server environment, you would use a JNDI lookup as shown on Programmatic Control - Teiid 8.8 (draft) - Project Documentation Editor

                                    Steve