use of org.teiid.deployers.CompositeVDB in project teiid by teiid.
the class VDBService method start.
@Override
public void start(final StartContext context) throws StartException {
ConnectorManagerRepository cmr = new ConnectorManagerRepository();
TranslatorRepository repo = new TranslatorRepository();
this.vdb.addAttchment(TranslatorRepository.class, repo);
// check if this is a VDB with index files, if there are then build the TransformationMetadata
UDFMetaData udf = this.vdb.getAttachment(UDFMetaData.class);
// add required connector managers; if they are not already there
for (Translator t : this.vdb.getOverrideTranslators()) {
VDBTranslatorMetaData data = (VDBTranslatorMetaData) t;
String type = data.getType();
VDBTranslatorMetaData parent = getTranslatorRepository().getTranslatorMetaData(type);
data.setModuleName(parent.getModuleName());
data.addAttchment(ClassLoader.class, parent.getAttachment(ClassLoader.class));
data.setParent(parent);
repo.addTranslatorMetadata(data.getName(), data);
}
createConnectorManagers(cmr, repo, this.vdb);
final ServiceBuilder<Void> vdbService = addVDBFinishedService(context);
this.vdbListener = new VDBLifeCycleListener() {
@Override
public void added(String name, CompositeVDB cvdb) {
}
@Override
public void beforeRemove(String name, CompositeVDB cvdb) {
}
@Override
public void removed(String name, CompositeVDB cvdb) {
}
@Override
public void finishedDeployment(String name, CompositeVDB cvdb) {
if (!VDBService.this.vdbKey.equals(cvdb.getVDBKey())) {
return;
}
// clear out the indexmetadatarepository as it holds state that is no longer necessary
// $NON-NLS-1$
repositories.put("index", new IndexMetadataRepository());
VDBMetaData vdbInstance = cvdb.getVDB();
if (vdbInstance.getStatus().equals(Status.ACTIVE)) {
vdbService.install();
}
}
};
getVDBRepository().addListener(this.vdbListener);
MetadataStore store = new MetadataStore();
try {
// check to see if there is an index file. if there is then we assume
// that index is the default metadata repo
MetadataRepository<?, ?> defaultRepo = null;
for (String s : this.vdbResources.getEntriesPlusVisibilities().keySet()) {
if (s.endsWith(VDBResources.INDEX_EXT)) {
// $NON-NLS-1$
defaultRepo = super.getMetadataRepository("index");
break;
}
}
this.assignMetadataRepositories(vdb, defaultRepo);
// add transformation metadata to the repository.
getVDBRepository().addVDB(this.vdb, store, vdbResources.getEntriesPlusVisibilities(), udf, cmr);
} catch (VirtualDatabaseException e) {
cleanup(context);
throw new StartException(e);
}
this.vdb.removeAttachment(UDFMetaData.class);
try {
loadMetadata(this.vdb, cmr, store, this.vdbResources);
} catch (TranslatorException e) {
cleanup(context);
throw new StartException(e);
}
this.runtimeVDB = buildRuntimeVDB(this.vdb, context.getController().getServiceContainer());
}
use of org.teiid.deployers.CompositeVDB in project teiid by teiid.
the class DQPCoreService method start.
@Override
public void start(final StartContext context) {
this.transactionServerImpl.setWorkManager(getWorkManagerInjector().getValue());
this.transactionServerImpl.setXaTerminator(getXaTerminatorInjector().getValue());
this.transactionServerImpl.setTransactionManager(getTxnManagerInjector().getValue());
this.transactionServerImpl.setDetectTransactions(true);
setPreParser(preParserInjector.getValue());
setAuthorizationValidator(authorizationValidatorInjector.getValue());
this.dqpCore.setBufferManager(bufferManagerInjector.getValue());
this.dqpCore.setTransactionService((TransactionService) LogManager.createLoggingProxy(LogConstants.CTX_TXN_LOG, transactionServerImpl, new Class[] { TransactionService.class }, MessageLevel.DETAIL, Thread.currentThread().getContextClassLoader()));
this.dqpCore.setEventDistributor(getEventDistributorFactoryInjector().getValue().getReplicatedEventDistributor());
this.dqpCore.setResultsetCache(getResultSetCacheInjector().getValue());
this.dqpCore.setPreparedPlanCache(getPreparedPlanCacheInjector().getValue());
this.dqpCore.start(this);
// add vdb life cycle listeners
getVdbRepository().addListener(new VDBLifeCycleListener() {
@Override
public void removed(String name, CompositeVDB vdb) {
// terminate all the previous sessions
SessionService sessionService = (SessionService) context.getController().getServiceContainer().getService(TeiidServiceNames.SESSION).getValue();
Collection<SessionMetadata> sessions = sessionService.getSessionsLoggedInToVDB(vdb.getVDBKey());
for (SessionMetadata session : sessions) {
sessionService.terminateSession(session.getSessionId(), null);
}
// dump the caches.
try {
SessionAwareCache<?> value = getResultSetCacheInjector().getValue();
if (value != null) {
value.clearForVDB(vdb.getVDBKey());
}
value = getPreparedPlanCacheInjector().getValue();
if (value != null) {
value.clearForVDB(vdb.getVDBKey());
}
} catch (IllegalStateException e) {
// already shutdown
}
}
@Override
public void added(String name, CompositeVDB vdb) {
}
@Override
public void finishedDeployment(String name, CompositeVDB cvdb) {
}
@Override
public void beforeRemove(String name, CompositeVDB cvdb) {
}
});
LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50001, this.dqpCore.getRuntimeVersion(), new Date(System.currentTimeMillis()).toString()));
}
use of org.teiid.deployers.CompositeVDB 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.deployers.CompositeVDB in project teiid by teiid.
the class MaterializationManager method nodeDropped.
@Override
public void nodeDropped(String nodeName) {
for (VDBMetaData vdb : getVDBRepository().getVDBs()) {
TransformationMetadata metadata = vdb.getAttachment(TransformationMetadata.class);
if (metadata == null) {
continue;
}
for (ModelMetaData model : vdb.getModelMetaDatas().values()) {
if (vdb.getImportedModels().contains(model.getName())) {
continue;
}
MetadataStore store = metadata.getMetadataStore();
Schema schema = store.getSchema(model.getName());
for (Table t : schema.getTables().values()) {
if (t.isVirtual() && t.isMaterialized() && t.getMaterializedTable() != null) {
String allow = t.getProperty(MaterializationMetadataRepository.ALLOW_MATVIEW_MANAGEMENT, false);
if (allow == null || !Boolean.valueOf(allow)) {
continue;
}
// reset the pending job if there is one.
int update = resetPendingJob(vdb, t, nodeName);
if (update > 0) {
String ttlStr = t.getProperty(MaterializationMetadataRepository.MATVIEW_TTL, false);
if (ttlStr == null) {
ttlStr = String.valueOf(Long.MAX_VALUE);
}
if (ttlStr != null) {
long ttl = Long.parseLong(ttlStr);
if (ttl > 0) {
// run the job
CompositeVDB cvdb = getVDBRepository().getCompositeVDB(new VDBKey(vdb.getName(), vdb.getVersion()));
scheduleSnapshotJob(cvdb, t, ttl, 0L, true);
}
}
}
}
}
}
}
}
use of org.teiid.deployers.CompositeVDB in project teiid by teiid.
the class TestRestWebArchiveBuilder method testOtherModels.
@Test
public void testOtherModels() throws Exception {
MetadataStore ms = new MetadataStore();
CompositeVDB vdb = TestCompositeVDB.createCompositeVDB(ms, "x");
vdb.getVDB().addProperty("{http://teiid.org/rest}auto-generate", "true");
ModelMetaData model = new ModelMetaData();
model.setName("other");
model.setModelType(Type.OTHER);
vdb.getVDB().addModel(model);
RestASMBasedWebArchiveBuilder builder = new RestASMBasedWebArchiveBuilder();
builder.getContent(vdb.getVDB());
}
Aggregations