8 Replies Latest reply on Aug 12, 2013 11:44 AM by jesper.pedersen

    Trying to create datasource, delete and then create again with same name requires sever restart

    van.halbert

      Referencing https://issues.jboss.org/browse/AS7-4776

       

      Teiid is having an issue with the usecase:    create, delete and create again with same name

       

      The use case is driven from the Teiid Designer, which will create a datasource in order that the user can preview the data.    And there are cases when the datasource will need to be removed.  However, a subsequent call to recreate the datasource with the same name will be unsuccessfull unless the server is restarted.    It appears the server isn't cleaning up the connection factory after the delete, hence the issue with trying to readd with the same name.

       

      Any possibility of a fix?

        • 1. Re: Trying to create datasource, delete and then create again with same name requires sever restart
          blafond

          I think the primary issues is the inability to update a data source. Whether that's done at the Designer level via a new  Admin.updateDataSource() method or under the hood via the createDataSource() (check for existing, reconcile properties and update the configuration) doesn't matter.

           

          So currently Designer has to remove/add to insure any new properties are attached to the updated data source.

           

          Barry

          • 2. Re: Trying to create datasource, delete and then create again with same name requires sever restart
            maeste

            The issue is about something else, and fixed a different problem generating an exception during :remove operation on RA, you are asking to remove and re-add subresources of resource-adapter w/o server reload.

            It's not currently supported. You can't change the structure af an RA resource w/o a server reload.

             

            What you can do (because supported) is to edit attributes marked as read-write. Of course you can't edit read-only attributes. In particular you can't add a connection-definition/config-property's value (if I well remember is one of few, if not the only one, attribute marked read only)

             

            What we support is a full remove of ra and resource and readd it. IOW these scripts are not supported (w/o server reload):

             

            #Add resource-adapter

            /subsystem=resource-adapters/resource-adapter=ws:add(module=org.jboss.teiid.resource-adapter.webservice, transaction-support=NoTransaction)

             

            #Add a connection factory

            /subsystem=resource-adapters/resource-adapter=ws/connection-definitions=wsDS:add(jndi-name=java:/wsDS, class-name=org.teiid.resource.adapter.ws.WSManagedConnectionFactory, enabled=true, use-java-context=true)

             

            #remove the added connection factory

            /subsystem=resource-adapters/resource-adapter=ws/connection-definitions=wsDS:remove

             

            #Add the same *named* connection factory again to RA

            /subsystem=resource-adapters/resource-adapter=ws/connection-definitions=wsDS:add(jndi-name=java:/wsDS, class-name=org.teiid.resource.adapter.ws.WSManagedConnectionFactory, enabled=true, use-java-context=true)

            because it is changing structure of resource-adapter main resource removing and readding connection-definition.

             

            Next script is not working too (w/o server reload) for the same reason:

             

            /subsystem=resource-adapters/resource-adapter=ws/connection-definitions=wsDS:add(jndi-name=java:/wsDS, class-name=org.teiid.resource.adapter.ws.WSManagedConnectionFactory, enabled=true, use-java-context=true)

            /subsystem=resource-adapters/resource-adapter=ws/connection-definitions=wsDS/config-properties=EndPoint:add(value=http://foo.com)

            /subsystem=resource-adapters/resource-adapter=ws:activate

             

            /subsystem=resource-adapters/resource-adapter=ws/connection-definitions=wsDS/config-properties=EndPoint:remove

            /subsystem=resource-adapters/resource-adapter=ws/connection-definitions=wsDS/config-properties=EndPoint:add(value=http://foo1.com)

             

             

            What should work is

             

            #Add resource-adapter

            /subsystem=resource-adapters/resource-adapter=ws:add(module=org.jboss.teiid.resource-adapter.webservice, transaction-support=NoTransaction)

             

            #Add a connection factory

            /subsystem=resource-adapters/resource-adapter=ws/connection-definitions=wsDS:add(jndi-name=java:/wsDS, class-name=org.teiid.resource.adapter.ws.WSManagedConnectionFactory, enabled=true, use-java-context=true)

            #Add a config-property if need

            /subsystem=resource-adapters/resource-adapter=ws/connection-definitions=wsDS/config-properties=EndPoint:add(value=http://foo1.com)

             

            #Activate the resource-adapter to apply config

            /subsystem=resource-adapters/resource-adapter=ws:activate

             

            #remove complegtely  added Resource

            /subsystem=resource-adapters/resource-adapter=ws:remove

             

            #Add the same *named* resource-adapter again

            /subsystem=resource-adapters/resource-adapter=ws:add(module=org.jboss.teiid.resource-adapter.webservice, transaction-support=NoTransaction)

             

            #Add the same *named* connection factory again to RA

            /subsystem=resource-adapters/resource-adapter=ws/connection-definitions=wsDS:add(jndi-name=java:/wsDS, class-name=org.teiid.resource.adapter.ws.WSManagedConnectionFactory, enabled=true, use-java-context=true)

             

            #Add again aconfig-property if need

            /subsystem=resource-adapters/resource-adapter=ws/connection-definitions=wsDS/config-properties=EndPoint:add(value=http://MyNewfoo.com)

             

            #Activate the resource-adapter to apply NEW config

            /subsystem=resource-adapters/resource-adapter=ws:activate

             

            And the issue fixed in jira linked is about a script like the last one, generating an error during resource-adapter:remove operation.

             

            I hope it helps.

             

            regards

            S.

            • 3. Re: Trying to create datasource, delete and then create again with same name requires sever restart
              rareddy

              The first script was little mis-leading my mistake, it should have read

               

              /subsystem=resource-adapters/resource-adapter=ws/connection-definitions=wsDS:remove
              

               

              Note that under every resource-adapter there can be more than one "connection-factory", it is connection factory that we are trying to replace. Your suggested method will remove all the connection factories underneath this "resource-adapter"

              • 4. Re: Trying to create datasource, delete and then create again with same name requires sever restart
                maeste

                I understand your point, but if you want to act runtime, it's the only supported method until ironjacamar 2.0.

                 

                Anyway consider that resource-adapters resources are just configuration (to use more correct jca slang "activation"), so it's up to you how many cf you are configuring per activation.

                 

                regards

                S.

                • 5. Re: Trying to create datasource, delete and then create again with same name requires sever restart
                  jesper.pedersen

                  Yes, it is more likely that a single <connection-definition> per <resource-adapter> will suite your case better.

                   

                  Some background on why IronJacamar 2.0 - connection definitions can have a ResourceAdapter instance associated, so in order to support adding or removing connection-definition from a specific deployment we need to do a lot more tracking of the resource adapter object that IronJacamar creates during deployment. That isn't possible in IronJacamar 1.x.

                   

                  Hence 1 <connection-definition> (or 1 <admin-object>) per deployment is better atm.

                  • 6. Re: Trying to create datasource, delete and then create again with same name requires sever restart
                    blafond

                    Some of this explains some behavior we are seeing in Designer.  When previewing data for a model, we deploy both a preview VDB and a preview data source (connection-definiition). If user also Executes a VDB for that source a Data Source (connection-definition) is being created with that same resource-adapter.  We've seen behavior that indicates that a "remove" may have deleted both and we were not expecting that.

                     

                    Barry

                    • 7. Re: Trying to create datasource, delete and then create again with same name requires sever restart
                      rareddy

                      Ok. The issue is Teiid has predefined "resource-adapters" that are loaded from "modules" so there is one "known" definition of it to be used by the tooling. By duplicating "resource-adapter" definition for each connection factory it obsuficates this "known" definitions, thus our usage the way it is currently.

                       

                      In that case, I need to re-evaluate how we can redo logic on our side for supporting before IronJacmar 2.0

                       

                      Thanks

                       

                      Ramesh..

                      • 8. Re: Trying to create datasource, delete and then create again with same name requires sever restart
                        jesper.pedersen

                        If you know which connection definitions that belong together in your model then you could just have 1 <resource-adapter>. However, once 1 connection definition is removed, then all the bound connection-definitions are removed.

                         

                        So it depends if that is acceptable or not.