Search in sources :

Example 11 with VDBKey

use of org.teiid.vdb.runtime.VDBKey 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);
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : MetadataStore(org.teiid.metadata.MetadataStore) TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) Table(org.teiid.metadata.Table) VDBKey(org.teiid.vdb.runtime.VDBKey) CompositeVDB(org.teiid.deployers.CompositeVDB) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) Schema(org.teiid.metadata.Schema) ModelMetaData(org.teiid.adminapi.impl.ModelMetaData)

Example 12 with VDBKey

use of org.teiid.vdb.runtime.VDBKey in project teiid by teiid.

the class RestASMBasedWebArchiveBuilder method getContent.

@Override
public byte[] getContent(VDBMetaData vdb) throws IOException {
    MetadataStore metadataStore = vdb.getAttachment(TransformationMetadata.class).getMetadataStore();
    Properties props = new Properties();
    String fullName = vdb.getName() + "_" + vdb.getVersion();
    props.setProperty("${context-name}", fullName);
    props.setProperty("${vdb-name}", vdb.getName());
    props.setProperty("${vdb-version}", String.valueOf(vdb.getVersion()));
    props.setProperty("${api-page-title}", fullName + " API");
    String securityType = vdb.getPropertyValue(REST_NAMESPACE + "security-type");
    String securityDomain = vdb.getPropertyValue(REST_NAMESPACE + "security-domain");
    String securityRole = vdb.getPropertyValue(REST_NAMESPACE + "security-role");
    props.setProperty("${security-role}", ((securityRole == null) ? "rest" : securityRole));
    props.setProperty("${security-domain}", ((securityDomain == null) ? "teiid-security" : securityDomain));
    if (securityType == null) {
        securityType = "httpbasic";
    }
    if (securityType.equalsIgnoreCase("none")) {
        props.setProperty("${security-content}", "");
    } else if (securityType.equalsIgnoreCase("httpbasic")) {
        props.setProperty("${security-content}", replaceTemplates(getFileContents("rest-war/httpbasic.xml"), props));
    }
    ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
    ZipOutputStream out = new ZipOutputStream(byteStream);
    writeEntry("WEB-INF/web.xml", out, replaceTemplates(getFileContents("rest-war/web.xml"), props).getBytes());
    writeEntry("WEB-INF/jboss-web.xml", out, replaceTemplates(getFileContents("rest-war/jboss-web.xml"), props).getBytes());
    writeEntry("api.html", out, replaceTemplates(getFileContents("rest-war/api.html"), props).getBytes());
    writeDirectoryEntry(out, "swagger-ui-2.1.1.zip");
    String version = vdb.getVersion();
    VDBKey vdbKey = new VDBKey(vdb.getName(), vdb.getVersion());
    ArrayList<String> applicationViews = new ArrayList<String>();
    for (ModelMetaData model : vdb.getModelMetaDatas().values()) {
        Schema schema = metadataStore.getSchema(model.getName());
        if (schema == null) {
            // OTHER type, which does not have a corresponding Teiid schema
            continue;
        }
        byte[] viewContents = getViewClass(vdb.getName(), version, model.getName(), schema, true);
        if (viewContents != null) {
            writeEntry("WEB-INF/classes/org/teiid/jboss/rest/" + model.getName() + ".class", out, viewContents);
            applicationViews.add(schema.getName());
        }
    }
    writeEntry("WEB-INF/classes/org/teiid/jboss/rest/TeiidRestApplication.class", out, getApplicationClass(applicationViews));
    writeEntry("META-INF/MANIFEST.MF", out, getFileContents("rest-war/MANIFEST.MF").getBytes());
    byte[] bytes = getBootstrapServletClass(vdb.getName(), vdb.getDescription() == null ? vdb.getName() : vdb.getDescription(), vdbKey.getSemanticVersion(), new String[] { "http" }, File.separator + props.getProperty("${context-name}"), "org.teiid.jboss.rest", true);
    writeEntry("WEB-INF/classes/org/teiid/jboss/rest/Bootstrap.class", out, bytes);
    writeEntry("images/teiid_logo_450px.png", out, getBinaryFileContents("rest-war/teiid_logo_450px.png"));
    out.close();
    return byteStream.toByteArray();
}
Also used : MetadataStore(org.teiid.metadata.MetadataStore) TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) VDBKey(org.teiid.vdb.runtime.VDBKey) ZipOutputStream(java.util.zip.ZipOutputStream) Schema(org.teiid.metadata.Schema) ArrayList(java.util.ArrayList) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Properties(java.util.Properties) ModelMetaData(org.teiid.adminapi.impl.ModelMetaData)

Example 13 with VDBKey

use of org.teiid.vdb.runtime.VDBKey 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"));
}
Also used : MetadataStore(org.teiid.metadata.MetadataStore) VDBKey(org.teiid.vdb.runtime.VDBKey) GlobalTableStore(org.teiid.query.tempdata.GlobalTableStore) Schema(org.teiid.metadata.Schema) GlobalTableStoreImpl(org.teiid.query.tempdata.GlobalTableStoreImpl) Test(org.junit.Test)

Example 14 with VDBKey

use of org.teiid.vdb.runtime.VDBKey in project teiid by teiid.

the class SessionAwareCache method clearForVDB.

public void clearForVDB(String vdbName, String version) {
    VDBKey vdbKey = new VDBKey(vdbName, version);
    clearForVDB(vdbKey);
}
Also used : VDBKey(org.teiid.vdb.runtime.VDBKey)

Example 15 with VDBKey

use of org.teiid.vdb.runtime.VDBKey in project teiid by teiid.

the class EngineStatistics method updateServices.

static void updateServices(OperationContext context, RuntimeVDB vdb, String dsName, ReplaceResult rr) {
    if (rr.isNew) {
        VDBDeployer.addDataSourceListener(context.getServiceTarget(), new VDBKey(vdb.getVdb().getName(), vdb.getVdb().getVersion()), dsName);
    }
    if (rr.removedDs != null) {
        final ServiceRegistry registry = context.getServiceRegistry(true);
        ServiceName serviceName;
        try {
            serviceName = TeiidServiceNames.dsListenerServiceName(vdb.getVdb().getName(), vdb.getVdb().getVersion(), rr.removedDs);
        } catch (InvalidServiceNameException e) {
            // the old isn't valid
            return;
        }
        final ServiceController<?> controller = registry.getService(serviceName);
        if (controller != null) {
            context.removeService(serviceName);
        }
    }
}
Also used : VDBKey(org.teiid.vdb.runtime.VDBKey) ServiceName(org.jboss.msc.service.ServiceName) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) InvalidServiceNameException(org.teiid.jboss.TeiidServiceNames.InvalidServiceNameException)

Aggregations

VDBKey (org.teiid.vdb.runtime.VDBKey)18 VDBMetaData (org.teiid.adminapi.impl.VDBMetaData)7 ModelMetaData (org.teiid.adminapi.impl.ModelMetaData)5 MetadataStore (org.teiid.metadata.MetadataStore)5 Schema (org.teiid.metadata.Schema)3 ArrayList (java.util.ArrayList)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 Properties (java.util.Properties)2 Test (org.junit.Test)2 VDBImport (org.teiid.adminapi.VDBImport)2 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 Connection (java.sql.Connection)1 SQLException (java.sql.SQLException)1 HashSet (java.util.HashSet)1 NavigableMap (java.util.NavigableMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentSkipListMap (java.util.concurrent.ConcurrentSkipListMap)1