use of org.teiid.dqp.internal.datamgr.ConnectorManagerRepository in project teiid by teiid.
the class RuntimeVDB method removeSource.
public ReplaceResult removeSource(String modelName, String sourceName) throws AdminProcessingException {
synchronized (this.vdb) {
ModelMetaData model = this.vdb.getModel(modelName);
if (model == null) {
throw new AdminProcessingException(RuntimePlugin.Event.TEIID40090, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40090, modelName, this.vdb.getName(), this.vdb.getVersion()));
}
if (!model.isSupportsMultiSourceBindings()) {
throw new AdminProcessingException(RuntimePlugin.Event.TEIID40108, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40108, modelName, this.vdb.getName(), this.vdb.getVersion()));
}
if (model.getSources().size() == 1) {
throw new AdminProcessingException(RuntimePlugin.Event.TEIID40109, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40109, modelName, this.vdb.getName(), this.vdb.getVersion()));
}
SourceMappingMetadata source = model.getSources().remove(sourceName);
if (source == null) {
throw new AdminProcessingException(RuntimePlugin.Event.TEIID40091, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40091, sourceName, modelName, this.vdb.getName(), this.vdb.getVersion()));
}
if (model.getSources().size() == 1) {
// we default to multi-source with multiple sources, so now we need to explicitly set to true
model.setSupportsMultiSourceBindings(true);
}
String previousDsName = source.getConnectionJndiName();
boolean success = false;
try {
this.listener.dataSourceChanged(modelName, sourceName, null, null);
ConnectorManagerRepository cmr = vdb.getAttachment(ConnectorManagerRepository.class);
// detect if the ConnectorManager is still used
boolean exists = false;
for (ModelMetaData m : this.vdb.getModelMetaDatas().values()) {
if (m == model) {
continue;
}
if (m.getSourceMapping(sourceName) != null) {
exists = true;
break;
}
}
if (!exists) {
cmr.removeConnectorManager(sourceName);
}
ReplaceResult rr = new ReplaceResult();
if (!dsExists(previousDsName, cmr)) {
rr.removedDs = previousDsName;
}
success = true;
return rr;
} finally {
if (!success) {
// TODO: this means that the order has changed
model.addSourceMapping(source);
}
}
}
}
use of org.teiid.dqp.internal.datamgr.ConnectorManagerRepository in project teiid by teiid.
the class VDBRepository method validateDataSources.
void validateDataSources(VDBMetaData vdb) {
ConnectorManagerRepository cmr = vdb.getAttachment(ConnectorManagerRepository.class);
for (ModelMetaData model : vdb.getModelMetaDatas().values()) {
if (model.isSource()) {
Collection<SourceMappingMetadata> mappings = model.getSourceMappings();
for (SourceMappingMetadata mapping : mappings) {
ConnectorManager cm = cmr.getConnectorManager(mapping.getName());
if (cm != null) {
String msg = cm.getStausMessage();
if (msg != null && msg.length() > 0) {
model.addRuntimeError(msg);
model.setMetadataStatus(Model.MetadataStatus.FAILED);
LogManager.logInfo(LogConstants.CTX_RUNTIME, msg);
}
}
}
}
}
}
use of org.teiid.dqp.internal.datamgr.ConnectorManagerRepository in project teiid by teiid.
the class VDBStatusChecker method dataSourceRemoved.
/**
* @param dataSourceName
* @param vdbKey which cannot be null
*/
public void dataSourceRemoved(String dataSourceName, VDBKey vdbKey) {
dataSourceName = stripContext(dataSourceName);
CompositeVDB cvdb = getVDBRepository().getCompositeVDB(vdbKey);
if (cvdb == null) {
return;
}
VDBMetaData vdb = cvdb.getVDB();
if (vdb.getStatus() == Status.FAILED) {
return;
}
synchronized (vdb) {
ConnectorManagerRepository cmr = vdb.getAttachment(ConnectorManagerRepository.class);
for (ModelMetaData model : vdb.getModelMetaDatas().values()) {
String sourceName = getSourceName(dataSourceName, model);
if (sourceName == null) {
continue;
}
Severity severity = Severity.WARNING;
ConnectorManager cm = cmr.getConnectorManager(sourceName);
if (cm.getExecutionFactory().isSourceRequired() && vdb.getStatus() == Status.ACTIVE) {
severity = Severity.ERROR;
}
String msg = RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40012, vdb.getName(), vdb.getVersion(), dataSourceName);
model.addRuntimeMessage(severity, msg);
LogManager.logInfo(LogConstants.CTX_RUNTIME, msg);
}
}
}
use of org.teiid.dqp.internal.datamgr.ConnectorManagerRepository in project teiid by teiid.
the class TestCompositeVDB method testRoleInherit.
@Test
public void testRoleInherit() throws Exception {
VDBRepository repo = new VDBRepository();
repo.setSystemStore(RealMetadataFactory.example1Cached().getMetadataStore());
repo.setSystemFunctionManager(RealMetadataFactory.SFM);
MetadataStore metadataStore = new MetadataStore();
RealMetadataFactory.createPhysicalModel("x", metadataStore);
VDBMetaData vdb = createVDBMetadata(metadataStore, "bqt");
DataPolicyMetadata dpm = new DataPolicyMetadata();
dpm.setName("x");
dpm.setGrantAll(true);
vdb.addDataPolicy(dpm);
ConnectorManagerRepository cmr = new ConnectorManagerRepository();
cmr.addConnectorManager("x", new ConnectorManager("y", "z"));
repo.addVDB(vdb, metadataStore, null, null, cmr);
metadataStore = new MetadataStore();
RealMetadataFactory.createPhysicalModel("y", metadataStore);
vdb = createVDBMetadata(metadataStore, "ex");
VDBImportMetadata vdbImport = new VDBImportMetadata();
vdbImport.setName("bqt");
vdbImport.setVersion("1");
vdbImport.setImportDataPolicies(true);
vdb.getVDBImports().add(vdbImport);
repo.addVDB(vdb, metadataStore, null, null, new ConnectorManagerRepository());
vdb = repo.getLiveVDB("ex");
assertEquals(1, vdb.getDataPolicyMap().get("x").getSchemas().size());
}
use of org.teiid.dqp.internal.datamgr.ConnectorManagerRepository in project teiid by teiid.
the class TestCompositeVDB method testDeepNesting.
@Test
public void testDeepNesting() throws Exception {
VDBRepository repo = new VDBRepository();
repo.setSystemStore(RealMetadataFactory.example1Cached().getMetadataStore());
repo.setSystemFunctionManager(RealMetadataFactory.SFM);
MetadataStore metadataStore = new MetadataStore();
RealMetadataFactory.createPhysicalModel("x", metadataStore);
VDBMetaData vdb = createVDBMetadata(metadataStore, "bqt");
ConnectorManagerRepository cmr = new ConnectorManagerRepository();
cmr.addConnectorManager("x", new ConnectorManager("y", "z"));
repo.addVDB(vdb, metadataStore, null, null, cmr);
metadataStore = new MetadataStore();
RealMetadataFactory.createPhysicalModel("y", metadataStore);
vdb = createVDBMetadata(metadataStore, "ex");
VDBImportMetadata vdbImport = new VDBImportMetadata();
vdbImport.setName("bqt");
vdbImport.setVersion("1");
vdb.getVDBImports().add(vdbImport);
repo.addVDB(vdb, metadataStore, null, null, new ConnectorManagerRepository());
VDBMetaData vdbInstance = repo.getVDB("ex", "1");
assertTrue(!vdbInstance.getAttachment(ConnectorManagerRepository.class).getConnectorManagers().isEmpty());
metadataStore = new MetadataStore();
RealMetadataFactory.createPhysicalModel("z", metadataStore);
vdb = createVDBMetadata(metadataStore, "ex1");
vdbImport = new VDBImportMetadata();
vdbImport.setName("ex");
vdbImport.setVersion("1");
vdb.getVDBImports().add(vdbImport);
repo.addVDB(vdb, metadataStore, null, null, new ConnectorManagerRepository());
vdbInstance = repo.getVDB("ex1", "1");
assertTrue(!vdbInstance.getAttachment(ConnectorManagerRepository.class).getConnectorManagers().isEmpty());
}
Aggregations