3 Replies Latest reply on Dec 22, 2009 12:09 PM by rareddy

    Admin API TEIID : DelteVDB

      Hello,

       

      In our project we have embedded the TEIID engine in our application. When we create a new vdb we use the admin API ( addVDB method) to deploy the VDB. This step is working fine.

       

      But we have problems when we want to delete this VDB. We also use the Admin API (deleteVDB method) to do so. What is happening is strange.

      The VDB is well undeploy but the file MYVDB_1.vdb is not delete and there is an ohter file MYVDB_1.vdb_delete that is created.

       

      Is there a process to follow in order to delete a VDB or do we only have to call the deleteVDB method.

       

      It seems like the MYVDB_1.vdb is lock and can't be deleted.

       

      Thansk for you answers on this subject.

        • 1. Re: Admin API TEIID : DelteVDB
          rareddy

          If there are any pending connections that are assosiated with that old VDB, then VDB's status will be switched to "deleted" but it it will not be deleted until all the connections assosiated with that VDB are either closed or terminated. Once the connection count goes to zero the file will be deleted. Any new connections to the "deleted" VDB will also be denied in this stage.

          • 2. Re: Admin API TEIID : DelteVDB
            After several tries to check that all connections are correctly closed, we still have the problem of the vdb.deleted file.

            Here is our basic piece of code :

                    public String / void addVdb(byte[] vdbAsAByteArray) / deleteVDB(String vdbName, String vdbVersion) throws Exception
                    {
                        VDB vdb = null;
                        Connection connect = null;
                        try
                        {
                            // Get a handle to the TEIID Admin API
                            connect = getConnection("admin", "teiid");
                            Admin adminTeiid = connect.getAdminAPI();
                           
                            vdb = adminTeiid.addVDB(vdbName, vdbAsAByteArray, new AdminOptions(AdminOptions.OnConflict.OVERWRITE)); / adminTeiid.deleteVDB(vdbName, vdbVersion);
                        }
                        catch(Exception e)
                        {
                            throw e;
                        }
                        finally
                        {
                            if(connect != null)
                            {
                                try
                                {
                                    connect.close();
                                }
                                catch (SQLException e)
                                {
                                    // Do nothing
                                }
                            }
                        }
                        return vdb.getVDBVersion(); / return;
                    }
                   
                    private Connection getConnection(String user, String password) throws Exception
                    {   
                        String url = "jdbc:teiid:admin@mm://localhost:31000";
                        Class.forName("org.teiid.jdbc.TeiidDriver");
                        Connection c = (com.metamatrix.jdbc.api.Connection) DriverManager.getConnection(url, user, password);
                        return c;
                    }
                   
            We tried to delete all ConnectorBindings after deleting the vdb but the collection is already empty :

                Collection<ConnectorBinding> bindings = adminTeiid.getConnectorBindings("*");
                for(ConnectorBinding binding : bindings)
                {
                    adminTeiid.stopConnectorBinding(binding.getIdentifier(), true);
                    adminTeiid.deleteConnectorBinding(binding.getIdentifier());
                }
               
            We also tried to pass connect to null after closing, to add connect.commit() before closing, but unsuccessfully.

            The more disconcerting is that it never appends when debugging...

            Is there another way we could also investigating ?
            • 3. Re: Admin API TEIID : DelteVDB
              rareddy

              The code looks fine. Yes, when a file locked by a process and we can not delete for some reason then we create ".delete" file. I tried your usecase on both Win/Linux boxes and did not see issue with Teiid holding a lock in either environment.  May be my usage of the VDB did not go through the same scenario as yours.

               

              You can see the code creating the ".delete" file at

              http://anonsvn.jboss.org/repos/teiid/trunk/common-core/src/main/java/com/metamatrix/common/protocol/mmfile/MMFileURLConnection.java

               

              Since you are supplying the byte[] to the "addVDB" call, the only process could possibly hold the lock is Teiid. If you are working on Windows, you can use Process Explorer or use command 'lsof' on the linux to see which process is holding the file lock.

               

              Do not like to suggest this, but may be you can try 'restart' call on the admin api, see if that helps. I also did try the "embedded" scenario ( you are working with server as per your connection URL) even there I could not re-produce it.

               

              Also, which version are you using 6.2? If you can give me simple Junit test which reproduces this issue, I can take look.

               

              Sorry that could'nt be more helpful.

               

              Thanks

               

              Ramesh..