6 Replies Latest reply on Aug 19, 2016 4:06 PM by jrod2016

    Validate VDB before calling EmbeddedServer.deploy

    jrod2016

      Is there a way to validate a VDB before calling server.deploy on it?

       

      Thanks,

      John

        • 1. Re: Validate VDB before calling EmbeddedServer.deploy
          shawkins

          The full validation potentially requires a metadata load, so there isn't a option beyond just the full deploy.  Do you have a scenario where you don't want it to be available?  You can set connection-type NONE - VDB Definition · Teiid Documentation

          • 2. Re: Validate VDB before calling EmbeddedServer.deploy
            jrod2016

            In that case, how can I recover a failed deploy? Here's my current deploy code

             

            int newVdbVersion = maxVdbVersion + 1;
            ModelMetaData[] backupModels = getModelsFromVDB(vdb);
            try {
              server.deployVDB(String.format("%s.%d", dbName, newVdbVersion), modelUpdates.apply(vdb, modelMetaData)); // modelUpdates.apply returns ModelMetaData[]
            } catch (Exception e) {
              // How can I recover here?
              throw e;
            }
            

             

            So, the issue I face is that if I get an error like this:

            org.teiid.metadata.ParseException: TEIID30386 org.teiid.api.exception.query.QueryParserException: TEIID31100 Parsing error: Encountered "CREATE VIEW [*]Order[*] (Product_line" at line 1, column 13.
            Was expecting: id
            

             

            Then, subsequent deploys fail with the same error. Anyway to clear out the ModelMetaData which caused an issue with the server?

            • 3. Re: Validate VDB before calling EmbeddedServer.deploy
              shawkins

              > Anyway to clear out the ModelMetaData which caused an issue with the server?

               

              What corrective action are you taking?

              • 4. Re: Validate VDB before calling EmbeddedServer.deploy
                jrod2016

                I plan to remove the view causing the error from the model. Is there any operation which is the opposite of ModelMetaData.addSourceMetadata? Or can I just remove it from sourceMetadataText within ModelMetaData?

                 

                So, I have something like this (which works apparently). Is there a better way to do this?

                 

                   private void removeViewFromModel(String viewName, ModelMetaData mmd) {
                      final int sourceMetadataIndex =
                            mmd.getSourceMetadataText()
                                  .stream()
                                  .map(this::getViewName)
                                  .collect(Collectors.toList())
                                  .indexOf(viewName);
                      mmd.getSourceMetadataText().remove(sourceMetadataIndex);
                      mmd.getSourceMetadataType().remove(sourceMetadataIndex);
                   }
                
                • 5. Re: Validate VDB before calling EmbeddedServer.deploy
                  shawkins

                  > Is there a better way to do this?

                   

                  If you know you want to remove the whole metadata source, then yes that should be fine.

                  • 6. Re: Validate VDB before calling EmbeddedServer.deploy
                    jrod2016

                    Sounds good. Thanks.