Search in sources :

Example 61 with ModelMetaData

use of org.teiid.adminapi.impl.ModelMetaData in project teiid by teiid.

the class VDBDeployer method dataSourceDependencies.

private void dataSourceDependencies(VDBMetaData deployment, ServiceTarget serviceTarget) {
    final VDBKey vdbKey = new VDBKey(deployment.getName(), deployment.getVersion());
    Set<String> dataSources = new HashSet<String>();
    for (ModelMetaData model : deployment.getModelMetaDatas().values()) {
        for (String sourceName : model.getSourceNames()) {
            // Need to make the data source service as dependency; otherwise dynamic vdbs will not work correctly.
            String dsName = model.getSourceConnectionJndiName(sourceName);
            if (dsName == null) {
                continue;
            }
            if (!dataSources.add(VDBStatusChecker.stripContext(dsName))) {
                // already listening
                continue;
            }
            addDataSourceListener(serviceTarget, vdbKey, dsName);
        }
    }
}
Also used : VDBKey(org.teiid.vdb.runtime.VDBKey) HashSet(java.util.HashSet) ModelMetaData(org.teiid.adminapi.impl.ModelMetaData)

Example 62 with ModelMetaData

use of org.teiid.adminapi.impl.ModelMetaData in project teiid by teiid.

the class VDBParserDeployer method mergeMetaData.

protected VDBMetaData mergeMetaData(DeploymentUnit deploymentUnit) throws DeploymentUnitProcessingException {
    VDBMetaData vdb = deploymentUnit.getAttachment(TeiidAttachments.VDB_METADATA);
    UDFMetaData udf = deploymentUnit.getAttachment(TeiidAttachments.UDF_METADATA);
    VirtualFile file = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT).getRoot();
    if (vdb == null) {
        LogManager.logError(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50016, file.getName()));
        return null;
    }
    try {
        if (udf != null) {
            // load the UDF
            for (Model model : vdb.getModels()) {
                if (model.getModelType().equals(Model.Type.FUNCTION)) {
                    String path = ((ModelMetaData) model).getPath();
                    if (path == null) {
                        throw new DeploymentUnitProcessingException(IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50075, model.getName()));
                    }
                    ((FileUDFMetaData) udf).buildFunctionModelFile(model.getName(), path);
                }
            }
        }
    } catch (IOException e) {
        throw new DeploymentUnitProcessingException(IntegrationPlugin.Event.TEIID50017.name(), e);
    } catch (XMLStreamException e) {
        throw new DeploymentUnitProcessingException(IntegrationPlugin.Event.TEIID50017.name(), e);
    }
    // $NON-NLS-1$ //$NON-NLS-2$
    LogManager.logTrace(LogConstants.CTX_RUNTIME, "VDB", file.getName(), "has been parsed.");
    return vdb;
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) XMLStreamException(javax.xml.stream.XMLStreamException) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) UDFMetaData(org.teiid.deployers.UDFMetaData) Model(org.teiid.adminapi.Model) IOException(java.io.IOException) ModelMetaData(org.teiid.adminapi.impl.ModelMetaData)

Example 63 with ModelMetaData

use of org.teiid.adminapi.impl.ModelMetaData in project teiid by teiid.

the class TestExternalMatViews method testNodeFailure.

@Test
public void testNodeFailure() throws Exception {
    FakeServer server1 = createServer("server1", "infinispan-replicated-config.xml", "tcp-shared.xml");
    HardCodedExecutionFactory hcef = setupData(server1);
    ModelMetaData sourceModel = setupSourceModel();
    ModelMetaData matViewModel = setupMatViewModel();
    ModelMetaData viewModel = new ModelMetaData();
    viewModel.setName("view1");
    viewModel.setModelType(Type.VIRTUAL);
    viewModel.addSourceMetadata("DDL", "CREATE VIEW v1 (col integer primary key, col1 string) " + "OPTIONS (MATERIALIZED true, " + "MATERIALIZED_TABLE 'matview.MAT_V2', " + "\"teiid_rel:MATVIEW_TTL\" 30000, " + "\"teiid_rel:ALLOW_MATVIEW_MANAGEMENT\" true, " + "\"teiid_rel:MATVIEW_SHARE_SCOPE\" 'FULL', " + "\"teiid_rel:MATVIEW_STATUS_TABLE\" 'matview.STATUS', " + "\"teiid_rel:MATVIEW_LOADNUMBER_COLUMN\" 'loadnum') " + "AS select col, col1 from source.physicalTbl");
    server1.deployVDB("comp", sourceModel, viewModel, matViewModel);
    Thread.sleep(1000);
    FakeServer server2 = createServer("server2", "infinispan-replicated-config-1.xml", "tcp-shared.xml");
    setupData(server2);
    server2.deployVDB("comp", sourceModel, viewModel, matViewModel);
    Thread.sleep(5000);
    Connection c = h2DataSource.getConnection();
    ResultSet rs = c.createStatement().executeQuery("SELECT LoadState, Nodename FROM Status WHERE VDBName = 'comp'");
    rs.next();
    assertEquals("LOADED", rs.getString(1));
    assertEquals("server1", rs.getString(2));
    int update = c.createStatement().executeUpdate("UPDATE Status SET LoadState = 'LOADING' WHERE VDBName = 'comp' AND Nodename = 'server1'");
    assertEquals(1, update);
    server1.stop();
    Thread.sleep(1000);
    rs = c.createStatement().executeQuery("SELECT LoadState, Nodename FROM Status WHERE VDBName = 'comp'");
    rs.next();
    assertEquals("LOADED", rs.getString(1));
    assertEquals("server2", rs.getString(2));
}
Also used : FakeServer(org.teiid.jdbc.FakeServer) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) HardCodedExecutionFactory(org.teiid.runtime.HardCodedExecutionFactory) ModelMetaData(org.teiid.adminapi.impl.ModelMetaData) Test(org.junit.Test)

Example 64 with ModelMetaData

use of org.teiid.adminapi.impl.ModelMetaData in project teiid by teiid.

the class TestExternalMatViews method internalWithSameExternalProcedures.

private void internalWithSameExternalProcedures(boolean useUpdateScript) throws Exception {
    HardCodedExecutionFactory hcef = setupData(server);
    ModelMetaData sourceModel = setupSourceModel();
    ModelMetaData matViewModel = setupMatViewModel();
    ModelMetaData viewModel = new ModelMetaData();
    viewModel.setName("view1");
    viewModel.setModelType(Type.VIRTUAL);
    viewModel.addSourceMetadata("DDL", "CREATE VIEW v1 (col integer primary key, col1 string) " + "OPTIONS (MATERIALIZED true, " + "\"teiid_rel:MATVIEW_TTL\" 3000, " + "\"teiid_rel:MATVIEW_UPDATABLE\" true, " + "\"teiid_rel:MATVIEW_STATUS_TABLE\" 'matview.STATUS', " + "\"teiid_rel:ALLOW_MATVIEW_MANAGEMENT\" true) " + "AS select col, col1 from source.physicalTbl");
    server.deployVDB("comp", sourceModel, viewModel, matViewModel);
    Thread.sleep(1000);
    assertTest(useUpdateScript, hcef);
}
Also used : HardCodedExecutionFactory(org.teiid.runtime.HardCodedExecutionFactory) ModelMetaData(org.teiid.adminapi.impl.ModelMetaData)

Example 65 with ModelMetaData

use of org.teiid.adminapi.impl.ModelMetaData in project teiid by teiid.

the class TestExternalMatViews method withSwapScripts.

private void withSwapScripts(boolean useUpdateScript) throws Exception {
    HardCodedExecutionFactory hcef = setupData(server);
    ModelMetaData sourceModel = setupSourceModel();
    ModelMetaData matViewModel = setupMatViewModel();
    ModelMetaData viewModel = new ModelMetaData();
    viewModel.setName("view1");
    viewModel.setModelType(Type.VIRTUAL);
    viewModel.addSourceMetadata("DDL", "CREATE VIEW v1 (col integer primary key, col1 string) " + "OPTIONS (MATERIALIZED true, " + "MATERIALIZED_TABLE 'matview.MAT_V1', " + "\"teiid_rel:MATVIEW_TTL\" 3000, " + "\"teiid_rel:ALLOW_MATVIEW_MANAGEMENT\" true, " + "\"teiid_rel:MATVIEW_STATUS_TABLE\" 'matview.STATUS', " + "\"teiid_rel:MATERIALIZED_STAGE_TABLE\" 'matview.MAT_V1_STAGE', " + "\"teiid_rel:MATVIEW_BEFORE_LOAD_SCRIPT\" 'execute matview.native(''truncate table MAT_V1_STAGE'')', " + "\"teiid_rel:MATVIEW_AFTER_LOAD_SCRIPT\"  " + "'begin " + "execute matview.native(''ALTER TABLE MAT_V1 RENAME TO MAT_V1_TEMP'');" + "execute matview.native(''ALTER TABLE MAT_V1_STAGE RENAME TO MAT_V1'');" + "execute matview.native(''ALTER TABLE MAT_V1_TEMP RENAME TO MAT_V1_STAGE''); " + "end', " + "\"teiid_rel:MATVIEW_ONERROR_ACTION\" 'THROW_EXCEPTION') " + "AS select col, col1 from source.physicalTbl");
    server.deployVDB("comp", sourceModel, viewModel, matViewModel);
    Thread.sleep(1000);
    assertTest(useUpdateScript, hcef);
}
Also used : HardCodedExecutionFactory(org.teiid.runtime.HardCodedExecutionFactory) ModelMetaData(org.teiid.adminapi.impl.ModelMetaData)

Aggregations

ModelMetaData (org.teiid.adminapi.impl.ModelMetaData)191 Test (org.junit.Test)131 Properties (java.util.Properties)50 ContentResponse (org.eclipse.jetty.client.api.ContentResponse)45 HardCodedExecutionFactory (org.teiid.runtime.HardCodedExecutionFactory)43 VDBMetaData (org.teiid.adminapi.impl.VDBMetaData)36 Connection (java.sql.Connection)23 MetadataFactory (org.teiid.metadata.MetadataFactory)21 Statement (java.sql.Statement)19 ResultSet (java.sql.ResultSet)18 CallableStatement (java.sql.CallableStatement)16 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)15 ArrayList (java.util.ArrayList)13 StringContentProvider (org.eclipse.jetty.client.util.StringContentProvider)11 SourceMappingMetadata (org.teiid.adminapi.impl.SourceMappingMetadata)11 Table (org.teiid.metadata.Table)11 RealMetadataFactory (org.teiid.query.unittest.RealMetadataFactory)11 List (java.util.List)9 ConnectorManager (org.teiid.dqp.internal.datamgr.ConnectorManager)9 ConnectorManagerRepository (org.teiid.dqp.internal.datamgr.ConnectorManagerRepository)9