Search in sources :

Example 31 with VDBMetaData

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

the class EngineStatistics method executeOperation.

@Override
protected void executeOperation(OperationContext context, VDBRepository repo, ModelNode operation) throws OperationFailedException {
    ModelNode result = context.getResult();
    List<VDBMetaData> vdbs = repo.getVDBs();
    for (VDBMetaData vdb : vdbs) {
        VDBMetadataMapper.INSTANCE.wrap(vdb, result.add());
    }
}
Also used : VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) ModelNode(org.jboss.dmr.ModelNode)

Example 32 with VDBMetaData

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

the class TestMatViews method testMatViewWithImportedVDB.

@Test
public void testMatViewWithImportedVDB() throws Exception {
    ModelMetaData mmd = new ModelMetaData();
    mmd.setName("phy");
    mmd.setSchemaSourceType("DDL");
    mmd.setSchemaText("CREATE FOREIGN TABLE t1 ( col1 string, col2 integer )");
    mmd.addSourceMapping("phy", "loopback", null);
    ModelMetaData mmd1 = new ModelMetaData();
    mmd1.setName("phy_mv");
    mmd1.setSchemaSourceType("DDL");
    mmd1.setSchemaText("CREATE FOREIGN TABLE t1_mv ( col1 string, col2 integer )" + " create foreign table status (VDBNAME STRING, VDBVERSION STRING, " + " SCHEMANAME STRING, NAME STRING, TARGETSCHEMANAME STRING, TARGETNAME STRING, " + " VALID BOOLEAN, LOADSTATE STRING, CARDINALITY LONG, UPDATED TIMESTAMP, LOADNUMBER LONG, NODENAME STRING, STALECOUNT LONG)");
    mmd1.addSourceMapping("phy_mv", "loopback", null);
    ModelMetaData mmd2 = new ModelMetaData();
    mmd2.setName("view1");
    mmd2.setModelType(Type.VIRTUAL);
    mmd2.setSchemaSourceType("DDL");
    mmd2.setSchemaText("CREATE VIEW v1 ( col1 string, col2 integer ) OPTIONS (MATERIALIZED true, " + "MATERIALIZED_TABLE 'phy_mv.t1_mv', \"teiid_rel:MATVIEW_STATUS_TABLE\" 'phy_mv.status', \"teiid_rel:MATVIEW_LOAD_SCRIPT\" 'select 1') AS select t1.col1, t1.col2 FROM t1");
    server.addTranslator(LoopbackExecutionFactory.class);
    server.deployVDB("base", mmd, mmd1, mmd2);
    VDBMetaData vdbMetaData = new VDBMetaData();
    vdbMetaData.setXmlDeployment(true);
    VDBImportMetadata importVDB = new VDBImportMetadata();
    importVDB.setName("base");
    importVDB.setVersion("1");
    vdbMetaData.getVDBImports().add(importVDB);
    vdbMetaData.setName("importing");
    server.deployVDB(vdbMetaData);
}
Also used : VDBImportMetadata(org.teiid.adminapi.impl.VDBImportMetadata) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) ModelMetaData(org.teiid.adminapi.impl.ModelMetaData) Test(org.junit.Test)

Example 33 with VDBMetaData

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

the class TestMatViews method testInternalWithManagement.

@Test
public void testInternalWithManagement() throws Exception {
    ModelMetaData mmd2 = new ModelMetaData();
    mmd2.setName("view1");
    mmd2.setModelType(Type.VIRTUAL);
    mmd2.addSourceMetadata("DDL", "CREATE VIEW v1 ( col integer, col1 string, primary key (col, col1) ) " + "OPTIONS (MATERIALIZED true, \"teiid_rel:ALLOW_MATVIEW_MANAGEMENT\" true, \"teiid_rel:MATVIEW_TTL\" 200) AS select 1, current_database(); " + "CREATE VIEW v2 ( col integer, col1 string, primary key (col, col1) ) " + "OPTIONS (MATERIALIZED true, \"teiid_rel:ALLOW_MATVIEW_MANAGEMENT\" true) AS select 1, current_database()");
    VDBMetaData vdb = new VDBMetaData();
    vdb.setXmlDeployment(true);
    vdb.setName("comp");
    vdb.setModels(Arrays.asList(mmd2));
    vdb.addProperty("lazy-invalidate", "true");
    server.deployVDB(vdb);
    Connection c = server.getDriver().connect("jdbc:teiid:comp", null);
    Statement s = c.createStatement();
    Thread.sleep(5000);
    // ensure that we are preloaded
    ResultSet rs = s.executeQuery("select * from MatViews where name = 'v1'");
    assertTrue(rs.next());
    assertTrue("LOADED".equals(rs.getString("loadstate")));
    assertEquals(true, rs.getBoolean("valid"));
    Timestamp ts = rs.getTimestamp("updated");
    rs = s.executeQuery("select * from MatViews where name = 'v2'");
    assertTrue(rs.next());
    assertEquals("LOADED", rs.getString("loadstate"));
    assertEquals(true, rs.getBoolean("valid"));
    Timestamp v2ts = rs.getTimestamp("updated");
    // and queryable
    rs = s.executeQuery("select * from v1");
    rs.next();
    assertEquals("1", rs.getString(1));
    rs = s.executeQuery("select * from v2");
    rs.next();
    assertEquals("1", rs.getString(1));
    // wait for ttl to expire
    Thread.sleep(1000);
    rs = s.executeQuery("select * from MatViews where name = 'v1'");
    assertTrue(rs.next());
    assertTrue("LOADED".equals(rs.getString("loadstate")) || "NEEDS_LOADING".equals(rs.getString("loadstate")));
    assertEquals(true, rs.getBoolean("valid"));
    Timestamp ts1 = rs.getTimestamp("updated");
    assertTrue(ts1.compareTo(ts) > 0);
    rs = s.executeQuery("select * from MatViews where name = 'v2'");
    assertTrue(rs.next());
    assertEquals("LOADED", rs.getString("loadstate"));
    assertEquals(true, rs.getBoolean("valid"));
    Timestamp v2ts1 = rs.getTimestamp("updated");
    assertEquals(v2ts, v2ts1);
}
Also used : Statement(java.sql.Statement) CallableStatement(java.sql.CallableStatement) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) Timestamp(java.sql.Timestamp) ModelMetaData(org.teiid.adminapi.impl.ModelMetaData) Test(org.junit.Test)

Example 34 with VDBMetaData

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

the class TestPGMetadata method testTypes.

@Test
public void testTypes() throws Exception {
    VDBMetaData vdb = buildVDB("t");
    server.deployVDB(vdb);
    // $NON-NLS-1$ //$NON-NLS-2$
    this.internalConnection = server.createConnection("jdbc:teiid:t");
    // $NON-NLS-1$
    execute("select format_type((select oid from pg_type where typname = '_int2'), 0)");
    assertResults(new String[] { "expr1[string]", "smallint[]" });
    // $NON-NLS-1$
    execute("select format_type((select oid from pg_type where typname = 'float4'), 0)");
    assertResults(new String[] { "expr1[string]", "real" });
    // $NON-NLS-1$
    execute("select format_type((select oid from pg_type where typname = 'numeric'), 100)");
    assertResults(new String[] { "expr1[string]", "numeric(0,96)" });
}
Also used : VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) Test(org.junit.Test)

Example 35 with VDBMetaData

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

the class TestPGMetadata method test_PG_Metadata_DEFAULT.

@Test
public void test_PG_Metadata_DEFAULT() throws Exception {
    VDBMetaData vdb = buildVDB("z");
    server.deployVDB(vdb);
    // $NON-NLS-1$ //$NON-NLS-2$
    this.internalConnection = server.createConnection("jdbc:teiid:z");
    // $NON-NLS-1$
    execute("select * FROM pg_am");
}
Also used : VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) Test(org.junit.Test)

Aggregations

VDBMetaData (org.teiid.adminapi.impl.VDBMetaData)121 Test (org.junit.Test)48 ModelMetaData (org.teiid.adminapi.impl.ModelMetaData)36 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)16 MetadataStore (org.teiid.metadata.MetadataStore)15 ConnectorManagerRepository (org.teiid.dqp.internal.datamgr.ConnectorManagerRepository)14 VDBRepository (org.teiid.deployers.VDBRepository)12 ArrayList (java.util.ArrayList)10 IOException (java.io.IOException)9 ConnectorManager (org.teiid.dqp.internal.datamgr.ConnectorManager)9 Properties (java.util.Properties)8 XMLStreamException (javax.xml.stream.XMLStreamException)8 VDBImportMetadata (org.teiid.adminapi.impl.VDBImportMetadata)8 DataPolicyMetadata (org.teiid.adminapi.impl.DataPolicyMetadata)7 TeiidComponentException (org.teiid.core.TeiidComponentException)7 VDBKey (org.teiid.vdb.runtime.VDBKey)7 ByteArrayInputStream (java.io.ByteArrayInputStream)6 VDBTranslatorMetaData (org.teiid.adminapi.impl.VDBTranslatorMetaData)6 Schema (org.teiid.metadata.Schema)6 SessionMetadata (org.teiid.adminapi.impl.SessionMetadata)5