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