use of org.teiid.adminapi.impl.VDBMetaData in project teiid by teiid.
the class VDBMetadataFactory method getVDBMetadata.
public static TransformationMetadata getVDBMetadata(String vdbName, URL vdbURL, URL udfFile) throws IOException {
TransformationMetadata vdbmetadata = VDB_CACHE.get(vdbURL);
if (vdbmetadata != null) {
return vdbmetadata;
}
try {
IndexVDB imf = loadMetadata(vdbName, vdbURL);
Resource r = imf.resources.getEntriesPlusVisibilities().get("/META-INF/vdb.xml");
VDBMetaData vdb = null;
if (r != null) {
vdb = VDBMetadataParser.unmarshell(r.openStream());
}
Collection<FunctionMethod> methods = null;
Collection<FunctionTree> trees = null;
if (udfFile != null) {
String schema = FileUtils.getFilenameWithoutExtension(udfFile.getPath());
methods = FunctionMetadataReader.loadFunctionMethods(udfFile.openStream());
trees = Arrays.asList(new FunctionTree(schema, new UDFSource(methods), true));
}
SystemFunctionManager sfm = SystemMetadata.getInstance().getSystemFunctionManager();
vdbmetadata = new TransformationMetadata(vdb, new CompositeMetadataStore(Arrays.asList(SystemMetadata.getInstance().getSystemStore(), imf.store)), imf.resources.getEntriesPlusVisibilities(), sfm.getSystemFunctions(), trees);
VDB_CACHE.put(vdbURL, vdbmetadata);
return vdbmetadata;
} catch (XMLStreamException e) {
throw new IOException(e);
}
}
use of org.teiid.adminapi.impl.VDBMetaData in project teiid by teiid.
the class EngineStatistics method checkVDB.
static VDBMetaData checkVDB(OperationContext context, String vdbName, String vdbVersion) throws OperationFailedException {
ServiceController<?> sc = context.getServiceRegistry(false).getRequiredService(TeiidServiceNames.VDB_REPO);
VDBRepository repo = VDBRepository.class.cast(sc.getValue());
VDBMetaData vdb = repo.getLiveVDB(vdbName, vdbVersion);
if (vdb == null) {
throw new OperationFailedException(IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50102, vdbName, vdbVersion));
}
Status status = vdb.getStatus();
if (status != VDB.Status.ACTIVE) {
throw new OperationFailedException(IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50096, vdbName, vdbVersion));
}
return vdb;
}
use of org.teiid.adminapi.impl.VDBMetaData in project teiid by teiid.
the class OlingoBridge method getHandler.
public ODataHttpHandler getHandler(String baseUri, Client client, String schemaName) throws ServletException {
if (this.handlers.get(schemaName) == null) {
org.teiid.metadata.Schema teiidSchema = client.getMetadataStore().getSchema(schemaName);
if (teiidSchema == null || !isVisible(client.getVDB(), teiidSchema)) {
throw new ServletException(ODataPlugin.Util.gs(ODataPlugin.Event.TEIID16022));
}
try {
OData odata = OData4Impl.newInstance();
VDBMetaData vdb = client.getVDB();
CsdlSchema schema = ODataSchemaBuilder.buildMetadata(vdb.getFullName(), teiidSchema);
TeiidEdmProvider edmProvider = new TeiidEdmProvider(baseUri, schema, client.getProperty(Client.INVALID_CHARACTER_REPLACEMENT));
ServiceMetadata metadata = odata.createServiceMetadata(edmProvider, edmProvider.getReferences());
ODataHttpHandler handler = odata.createHandler(metadata);
handler.register(new TeiidServiceHandler(schemaName));
this.handlers.put(schemaName, handler);
} catch (XMLStreamException e) {
throw new ServletException(ODataPlugin.Util.gs(ODataPlugin.Event.TEIID16054));
} catch (ODataException e) {
throw new ServletException(ODataPlugin.Util.gs(ODataPlugin.Event.TEIID16054));
}
}
return this.handlers.get(schemaName);
}
use of org.teiid.adminapi.impl.VDBMetaData in project teiid by teiid.
the class VDBRepository method finishDeployment.
public void finishDeployment(String name, String version) {
VDBKey key = new VDBKey(name, version);
CompositeVDB v = this.vdbRepo.get(key);
if (v == null) {
return;
}
VDBMetaData metadataAwareVDB = v.getVDB();
if (v.getOriginalVDB().getStatus() == Status.FAILED) {
if (v.getOriginalVDB() != metadataAwareVDB && metadataAwareVDB.getStatus() == Status.LOADING) {
metadataAwareVDB.setStatus(Status.FAILED);
}
return;
}
synchronized (metadataAwareVDB) {
try {
try {
v.metadataLoadFinished(allowEnv);
} catch (MetadataException e) {
// $NON-NLS-1$
LogManager.logWarning(LogConstants.CTX_RUNTIME, e, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40073, name, version, e.getMessage()));
if (!metadataAwareVDB.isPreview()) {
ValidatorReport report = new ValidatorReport();
report.addItem(new ValidatorFailure(e.getMessage()));
if (!processMetadataValidatorReport(key, report)) {
metadataAwareVDB.setStatus(Status.FAILED);
notifyFinished(name, version, v);
return;
}
}
}
MetadataStore store = metadataAwareVDB.removeAttachment(MetadataStore.class);
ValidatorReport report = new MetadataValidator(store.getDatatypes(), QueryParser.getQueryParser()).validate(metadataAwareVDB, store);
if (report.hasItems()) {
LogManager.logWarning(LogConstants.CTX_RUNTIME, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40073, name, version, report.getItems().iterator().next()));
if (!metadataAwareVDB.isPreview() && !processMetadataValidatorReport(key, report)) {
metadataAwareVDB.setStatus(Status.FAILED);
notifyFinished(name, version, v);
return;
}
}
validateDataSources(metadataAwareVDB);
metadataAwareVDB.setStatus(Status.ACTIVE);
// for replication of events, temp tables and mat views
GlobalTableStore gts = CompositeGlobalTableStore.createInstance(v, this.bufferManager, this.objectReplictor);
metadataAwareVDB.addAttchment(GlobalTableStore.class, gts);
if (this.databaseStore != null) {
metadataAwareVDB.addAttchment(DatabaseStore.class, this.databaseStore);
}
notifyFinished(name, version, v);
} finally {
if (metadataAwareVDB.getStatus() != Status.ACTIVE && metadataAwareVDB.getStatus() != Status.FAILED) {
// guard against an unexpected exception - probably bad validation logic
metadataAwareVDB.setStatus(Status.FAILED);
notifyFinished(name, version, v);
}
}
}
}
use of org.teiid.adminapi.impl.VDBMetaData in project teiid by teiid.
the class VDBStatusChecker method updateSource.
/**
* @return true if the datasource is new to the vdb
* @throws AdminProcessingException
*/
public boolean updateSource(String vdbName, String vdbVersion, SourceMappingMetadata mapping, boolean replace) throws AdminProcessingException {
String dsName = stripContext(mapping.getConnectionJndiName());
VDBMetaData vdb = getVDBRepository().getLiveVDB(vdbName, vdbVersion);
if (vdb == null || vdb.getStatus() == Status.FAILED) {
return false;
}
synchronized (vdb) {
ConnectorManagerRepository cmr = vdb.getAttachment(ConnectorManagerRepository.class);
ConnectorManager existing = cmr.getConnectorManager(mapping.getName());
try {
cmr.createConnectorManager(vdb, cmr.getProvider(), mapping, replace);
} catch (TeiidException e) {
throw new AdminProcessingException(RuntimePlugin.Event.TEIID40033, e);
}
if (mapping.getConnectionJndiName() != null && (existing == null || !dsName.equals(existing.getConnectionName()))) {
List<Runnable> runnables = new ArrayList<Runnable>();
resourceAdded(dsName, runnables, vdb);
return true;
}
return false;
}
}
Aggregations