-
1. Re: Questions about creating VDBs procedurally (i.e, outside of the Teiid designer).
rareddy Aug 4, 2014 3:06 PM (in response to lselecky)1 of 1 people found this helpfulLes,
Yes, to all your questions.
As far the VDB is concerned (in the Dynamic VDB case) it is a simple XML file, how you create it is up to you. If you are using Java we provide the necessary classes to make the job little bit easier. Even Groovy shell you can use java libraries if you want to build a vdb. If you need a tool based building then Teiid Designer is the option.
Ramesh..
-
2. Re: Questions about creating VDBs procedurally (i.e, outside of the Teiid designer).
lselecky Aug 5, 2014 10:37 AM (in response to rareddy)Thanks Ramesh, I downloaded the JavaDocs and am looking at the classes. Are there any Java examples for the procedural access?
Thanks again,
Les
-
3. Re: Questions about creating VDBs procedurally (i.e, outside of the Teiid designer).
rareddy Aug 5, 2014 10:48 AM (in response to lselecky)1 of 1 people found this helpfulSee org.teiid.adminapi.impl.TestVDBMetaData for an example
-
4. Re: Questions about creating VDBs procedurally (i.e, outside of the Teiid designer).
lselecky Aug 6, 2014 5:29 PM (in response to rareddy)Thanks Ramesh, I downloaded the source code and have been going through the source code and have looked at the TestVDBMetaData class.
Related to this... I'd like to be able to create an admin connection to JBDV from a Java class and then exercise the capability to build + deploy a VDB.
I've looked at the source for the AdminShell and AdminFactory, and wrote a simple JUnit test to create an admin connection to my local JBoss DV instance.
Here's the code:
@Test
public void testDeployingVDB() throws Exception {
Admin admin = AdminFactory.getInstance().createAdmin("localhost", 9999, "admin", "admin".toCharArray());
System.out.println(admin);
Collection<? extends VDB> vdBs = admin.getVDBs();
for (VDB vdb : vdBs) {
System.out.println(vdb);
}
admin.close();
}
The connection logic, "AdminFactory.getInstance().createAdmin(..." in the code above looks exactly like the similar connection logic in the JBoss AdminShell class but I'm not able to successfully connect.
Here are the log lines from running my code:
Aug 06, 2014 3:48:39 PM org.xnio.Xnio <clinit>
INFO: XNIO Version 3.0.7.GA-redhat-1
Aug 06, 2014 3:48:39 PM org.teiid.adminapi.AdminFactory createAdmin
INFO: TEIID70051 The controller is not available at 127.0.0.1:9,999
null
You can see the "controller is not available" message and the null instance of the admin connection.
I looked in the AdminFactory class and the TEIID70051 message was logged because the nodeTypes were empty.
Here's the relevant AdminFactory method:
try {
CallbackHandler cbh = new AuthenticationCallbackHandler(userName, password);
ModelControllerClient newClient = ModelControllerClient.Factory.create(host, port, cbh);
List<String> nodeTypes = Util.getNodeTypes(newClient, new DefaultOperationRequestAddress());
if (!nodeTypes.isEmpty()) {
boolean domainMode = nodeTypes.contains("server-group"); //$NON-NLS-1$
LOGGER.info("Connected to " //$NON-NLS-1$
+ (domainMode ? "domain controller at " : "standalone controller at ") //$NON-NLS-1$ //$NON-NLS-2$
+ host + ":" + port); //$NON-NLS-1$
return new AdminImpl(newClient);
}
LOGGER.info(AdminPlugin.Util.gs(AdminPlugin.Event.TEIID70051, host, port)); //$NON-NLS-1$ //$NON-NLS-2$
} catch (UnknownHostException e) {
throw new AdminProcessingException(AdminPlugin.Event.TEIID70000, AdminPlugin.Util.gs(AdminPlugin.Event.TEIID70000, host, e.getLocalizedMessage()));
}
You can see where message TEIID70051 is logged.
So is there anything I need to do (for JAAS?) to connect to JBDV from a POJO class that's running outside of the server (i..e., not deployed in a WAR)?
I do see a security CallbackHandler implemented in the AdminFactory class.
I double checked the connection.properties values that the Groovy console uses when executing the "connectAsAdmin()" function and the host, port, user and password values are the same ones I'm using above.
And the Groovy console works fine when I connectAsAdmin() and list the VDBs and data sources so I'm thinking this is related to Java security.
Thanks,
Les
-
5. Re: Questions about creating VDBs procedurally (i.e, outside of the Teiid designer).
lselecky Aug 8, 2014 9:57 AM (in response to lselecky)I discovered the issue, the classpath needed to include all the jars from dataVirtualization\teiid-adminshell\lib.
The client logic did not emit any errors or console messages about missing class definitions.
-
6. Re: Questions about creating VDBs procedurally (i.e, outside of the Teiid designer).
rareddy Aug 8, 2014 10:22 AM (in response to lselecky)Lee,
Sorry, the notifications not working properly all the time for me, I missed you previous question.
I suggest you take look at teiid/IntegrationTestDeployment.java at master · teiid/teiid · GitHub
Using the Groovy shell is little wrapper over the Java API, you do not need to use Groovy for making API calls. Not sure why your CNF exceptions were not thrown, but yes you need to jar files from the "lib" directory. Teiid uses JBoss EAP's management port for this, that dependency brings in few jars. Yes Teiid does use JAAS for security domains, but that is on server side. You need to create a "Management User" in JBoss EAP using "<jboss-eap-6.1>/bin/add-user.sh" and those are the credentials you need to use in the above connection. Also note that Management User is different from JDBC user.
Ramesh..
-
7. Re: Questions about creating VDBs procedurally (i.e, outside of the Teiid designer).
lselecky Aug 8, 2014 3:32 PM (in response to rareddy)Thanks Ramesh, that file along with the version for dynamic VDBs (IntegrationTestDynamicViewDefinition) were exactly what I needed. Thanks for pointing me to the class.