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());
}
}
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);
}
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);
}
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)" });
}
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");
}
Aggregations