use of org.teiid.query.tempdata.GlobalTableStore in project teiid by teiid.
the class CommandContext method setNewVDBState.
public void setNewVDBState(DQPWorkContext newWorkContext) {
this.vdbState = new VDBState();
VDBMetaData vdb = newWorkContext.getVDB();
GlobalTableStore actualGlobalStore = vdb.getAttachment(GlobalTableStore.class);
this.vdbState.globalTables = actualGlobalStore;
this.vdbState.session = newWorkContext.getSession();
this.vdbState.classLoader = vdb.getAttachment(ClassLoader.class);
this.vdbState.vdbName = vdb.getName();
this.vdbState.vdbVersion = vdb.getVersion();
this.vdbState.dqpWorkContext = newWorkContext;
TempMetadataAdapter metadata = new TempMetadataAdapter(vdb.getAttachment(QueryMetadataInterface.class), globalState.sessionTempTableStore.getMetadataStore());
metadata.setSession(true);
this.vdbState.metadata = metadata;
}
use of org.teiid.query.tempdata.GlobalTableStore in project teiid by teiid.
the class EmbeddedServer method startVDBRepository.
private void startVDBRepository() {
this.repo.addListener(new VDBLifeCycleListener() {
@Override
public void added(String name, CompositeVDB vdb) {
}
@Override
public void removed(String name, CompositeVDB vdb) {
if (replicator != null) {
replicator.stop(vdb.getVDB().getAttachment(GlobalTableStore.class));
}
rs.clearForVDB(vdb.getVDBKey());
ppc.clearForVDB(vdb.getVDBKey());
for (SessionMetadata session : sessionService.getSessionsLoggedInToVDB(vdb.getVDBKey())) {
try {
sessionService.closeSession(session.getSessionId());
} catch (InvalidSessionException e) {
}
}
}
@Override
public void finishedDeployment(String name, CompositeVDB vdb) {
if (!vdb.getVDB().getStatus().equals(Status.ACTIVE)) {
return;
}
GlobalTableStore gts = CompositeGlobalTableStore.createInstance(vdb, dqp.getBufferManager(), replicator);
vdb.getVDB().addAttchment(GlobalTableStore.class, gts);
}
@Override
public void beforeRemove(String name, CompositeVDB vdb) {
}
});
this.repo.setSystemFunctionManager(SystemMetadata.getInstance().getSystemFunctionManager());
this.repo.start();
}
use of org.teiid.query.tempdata.GlobalTableStore in project teiid by teiid.
the class TestCompositeGlobalTableStore method testCompositeGlobalTableStore.
@Test
public void testCompositeGlobalTableStore() throws VirtualDatabaseException {
CompositeVDB vdb = TestCompositeVDB.createCompositeVDB(new MetadataStore(), "foo");
GlobalTableStore gts = CompositeGlobalTableStore.createInstance(vdb, BufferManagerFactory.getStandaloneBufferManager(), null);
assertTrue(gts instanceof GlobalTableStoreImpl);
vdb.children = new LinkedHashMap<VDBKey, CompositeVDB>();
MetadataStore ms = new MetadataStore();
Schema s = new Schema();
s.setName("x");
ms.addSchema(s);
CompositeVDB imported = TestCompositeVDB.createCompositeVDB(ms, "foo");
GlobalTableStore gts1 = Mockito.mock(GlobalTableStore.class);
imported.getVDB().addAttchment(GlobalTableStore.class, gts1);
vdb.getChildren().put(new VDBKey("foo1", 1), imported);
CompositeGlobalTableStore cgts = (CompositeGlobalTableStore) CompositeGlobalTableStore.createInstance(vdb, BufferManagerFactory.getStandaloneBufferManager(), null);
assertEquals(gts1, cgts.getStoreForTable(RelationalPlanner.MAT_PREFIX + "X.Y"));
assertEquals(cgts.getPrimary(), cgts.getStore("Z"));
}
use of org.teiid.query.tempdata.GlobalTableStore in project teiid by teiid.
the class AccessInfo method restore.
/**
* Restore reconnects to the live metadata objects
* @throws TeiidComponentException
* @throws TeiidProcessingException
*/
void restore() throws TeiidComponentException, TeiidProcessingException {
if (this.objectsAccessed != null) {
return;
}
VDBMetaData vdb = DQPWorkContext.getWorkContext().getVDB();
TransformationMetadata tm = vdb.getAttachment(TransformationMetadata.class);
GlobalTableStore globalStore = vdb.getAttachment(GlobalTableStore.class);
if (!externalNames.isEmpty()) {
this.objectsAccessed = new HashSet<Object>(externalNames.size());
for (List<String> key : this.externalNames) {
if (key.size() == 1) {
String matTableName = key.get(0);
TempMetadataID id = globalStore.getGlobalTempTableMetadataId(matTableName);
if (id == null) {
// if the id is null, then create a local instance
String viewFullName = matTableName.substring(RelationalPlanner.MAT_PREFIX.length());
id = globalStore.getGlobalTempTableMetadataId(tm.getGroupID(viewFullName));
}
this.objectsAccessed.add(id);
} else {
Schema s = tm.getMetadataStore().getSchema(key.get(0));
Modifiable m = s.getTables().get(key.get(1));
if (m == null) {
m = s.getProcedures().get(key.get(1));
}
if (m != null) {
this.objectsAccessed.add(m);
}
}
}
} else {
this.objectsAccessed = Collections.emptySet();
}
this.externalNames = null;
}
use of org.teiid.query.tempdata.GlobalTableStore 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);
}
}
}
}
Aggregations