Search in sources :

Example 6 with UDFMetaData

use of org.teiid.deployers.UDFMetaData in project teiid by teiid.

the class EmbeddedAdminImpl method restartVDB.

@Override
public void restartVDB(String vdbName, String vdbVersion, String... models) throws AdminException {
    VDBMetaData vdb = checkVDB(vdbName, vdbVersion);
    synchronized (vdb) {
        try {
            // need remove model cache first
            VDBMetaData currentVdb = this.embeddedServer.repo.removeVDB(vdbName, vdbVersion);
            ConnectorManagerRepository cmr = this.embeddedServer.cmr;
            UDFMetaData udf = currentVdb.getAttachment(UDFMetaData.class);
            // need get the visibilityMap from runtime
            LinkedHashMap<String, VDBResources.Resource> visibilityMap = new LinkedHashMap<String, VDBResources.Resource>();
            MetadataStore store = new MetadataStore();
            this.embeddedServer.repo.addVDB(currentVdb, store, visibilityMap, udf, cmr);
        } catch (Exception e) {
            throw new AdminProcessingException(RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40135, vdbName, vdbVersion, models), e);
        }
    }
}
Also used : MetadataStore(org.teiid.metadata.MetadataStore) ConnectorManagerRepository(org.teiid.dqp.internal.datamgr.ConnectorManagerRepository) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) UDFMetaData(org.teiid.deployers.UDFMetaData) VDBResources(org.teiid.query.metadata.VDBResources) TransformerException(javax.xml.transform.TransformerException) TeiidComponentException(org.teiid.core.TeiidComponentException) SessionServiceException(org.teiid.dqp.service.SessionServiceException)

Example 7 with UDFMetaData

use of org.teiid.deployers.UDFMetaData in project teiid by teiid.

the class FakeServer method deployVDB.

public void deployVDB(String vdbName, MetadataStore metadata, DeployVDBParameter parameterObject) {
    VDBMetaData vdbMetaData = null;
    try {
        if (parameterObject.vdbResources != null && parameterObject.useVdbXml) {
            VDBResource resource = parameterObject.vdbResources.get("/META-INF/vdb.xml");
            if (resource != null) {
                vdbMetaData = VDBMetadataParser.unmarshell(resource.openStream());
            }
        }
        if (vdbMetaData == null) {
            vdbMetaData = new VDBMetaData();
            vdbMetaData.setName(vdbName);
            for (Schema schema : metadata.getSchemas().values()) {
                ModelMetaData model = addModel(vdbMetaData, schema);
                if (parameterObject.metadataRepo != null) {
                    model.addAttchment(MetadataRepository.class, parameterObject.metadataRepo);
                    // fakeserver does not load through the repository framework, so call load after the fact here.
                    MetadataFactory mf = createMetadataFactory(vdbMetaData, metadata, model, parameterObject.vdbResources);
                    mf.setSchema(schema);
                    try {
                        parameterObject.metadataRepo.loadMetadata(mf, null, null);
                    } catch (TranslatorException e) {
                        throw new TeiidRuntimeException(e);
                    }
                }
            }
        } else {
            if (!parameterObject.useDataRoles) {
                vdbMetaData.setDataPolicies(Collections.EMPTY_LIST);
            }
            cmr.createConnectorManagers(vdbMetaData, this);
        }
        UDFMetaData udfMetaData = null;
        if (parameterObject.udfs != null) {
            udfMetaData = new UDFMetaData();
            for (Map.Entry<String, Collection<FunctionMethod>> entry : parameterObject.udfs.entrySet()) {
                udfMetaData.addFunctions(entry.getKey(), entry.getValue());
            }
        }
        if (parameterObject.vdbImports != null) {
            for (VDBImportMetadata vdbImport : parameterObject.vdbImports) {
                vdbMetaData.getVDBImports().add(vdbImport);
            }
        }
        vdbMetaData.setStatus(VDB.Status.ACTIVE);
        this.repo.addVDB(vdbMetaData, metadata, parameterObject.vdbResources, udfMetaData, cmr);
        this.repo.finishDeployment(vdbMetaData.getName(), vdbMetaData.getVersion());
        this.repo.getLiveVDB(vdbMetaData.getName(), vdbMetaData.getVersion()).setStatus(VDB.Status.ACTIVE);
    } catch (VirtualDatabaseException e) {
        throw new RuntimeException(e);
    } catch (ConnectorManagerException e) {
        throw new RuntimeException(e);
    } catch (XMLStreamException e) {
        throw new RuntimeException(e);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : VDBImportMetadata(org.teiid.adminapi.impl.VDBImportMetadata) VDBResource(org.teiid.metadata.VDBResource) Schema(org.teiid.metadata.Schema) UDFMetaData(org.teiid.deployers.UDFMetaData) TeiidRuntimeException(org.teiid.core.TeiidRuntimeException) IOException(java.io.IOException) ModelMetaData(org.teiid.adminapi.impl.ModelMetaData) ConnectorManagerException(org.teiid.dqp.internal.datamgr.ConnectorManagerRepository.ConnectorManagerException) TeiidRuntimeException(org.teiid.core.TeiidRuntimeException) MetadataFactory(org.teiid.metadata.MetadataFactory) VDBMetadataFactory(org.teiid.metadata.index.VDBMetadataFactory) XMLStreamException(javax.xml.stream.XMLStreamException) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) Collection(java.util.Collection) TranslatorException(org.teiid.translator.TranslatorException) VirtualDatabaseException(org.teiid.deployers.VirtualDatabaseException) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Aggregations

UDFMetaData (org.teiid.deployers.UDFMetaData)7 VDBMetaData (org.teiid.adminapi.impl.VDBMetaData)5 IOException (java.io.IOException)4 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)3 VirtualFile (org.jboss.vfs.VirtualFile)3 ModelMetaData (org.teiid.adminapi.impl.ModelMetaData)3 VirtualDatabaseException (org.teiid.deployers.VirtualDatabaseException)3 MetadataStore (org.teiid.metadata.MetadataStore)3 IndexMetadataRepository (org.teiid.metadata.index.IndexMetadataRepository)3 XMLStreamException (javax.xml.stream.XMLStreamException)2 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)2 Model (org.teiid.adminapi.Model)2 Translator (org.teiid.adminapi.Translator)2 VDBTranslatorMetaData (org.teiid.adminapi.impl.VDBTranslatorMetaData)2 TeiidException (org.teiid.core.TeiidException)2 ConnectorManagerRepository (org.teiid.dqp.internal.datamgr.ConnectorManagerRepository)2 VDBResources (org.teiid.query.metadata.VDBResources)2 TranslatorException (org.teiid.translator.TranslatorException)2 Collection (java.util.Collection)1 LinkedHashMap (java.util.LinkedHashMap)1