Red Hat Training

A Red Hat training course is available for Red Hat JBoss Data Virtualization

Quick Starts Guide

Red Hat JBoss Data Virtualization 6.3

David Le Sage

Abstract

These quick starts give an overview of product functionality and can be adapted for your own needs.

1. Introduction and Goals of This Guide

Congratulations! You now have quite a bit of experience with Red Hat JBoss Data Virtualization: you can perform a basic installation, run the software and use the Dashboard Builder to connect to data sources.

It is now time to showcase some more of the product’s features that you can utilise to build your own solutions going forward. These features are demonstrated in the various "quick starts" that come with the product.

2. What Are the Quick Starts?

The quick starts are sample projects. The purpose of these quick start samples is to illustrate various JBoss Data Virtualization features. You can find quick starts in EAP_HOME/quickstarts directory.

2.1. Prerequisites

Name

Description

Java Developer Kit

You must have a Java 6 JDK installed on your system.

Java Virtual Machine

Use the JVM installed with your JDK or use OpenJDK or the non-open source Azul Zing.

Maven

You must have Maven installed on your machine. For information about installing this, please refer to the Red Hat JBoss EAP documentation.

Red Hat JBoss Data Virtualization

You must have Data Virtualization installed and running. Refer to "Red Hat JBoss Data Virtualization Getting Started Guide" for details on how to do this.

2.2. General Tips on Running Quick Starts

When you want to run a quick start remember the following points:

  1. Each quick start has different requirements. These are documented in their individual README.md files.
  2. If the server is running in a mode other than standalone mode, you can run only some of the quick starts.

2.2.1. Simple Client Quick Start

The Simple Client quick start teaches you how to connect to JBoss Data Virtualization using either the JDBC driver or a data source. You can use the simple client quick start to test your SQL queries against any JBoss Data Virtualization instance with an active virtual database. Other quick start examples in this guide use this example as a means to test suggested queries. Refer to the individual README.md file for those quick starts in order to setup the environment correctly before executing a test query.

To run the quick start, go to the EAP_HOME/quickstarts/simpleclient directory and open the README.md file in a text editor and read the instructions it contains.

2.2.2. Data Federation Quick Start

The Data Federation quick start teaches you how Red Hat JBoss Data Virtualization can federate data from different sources into one virtual database.

The quick start uses three sample data sources to illustrate this concept, namely

  1. Account Information (stored in an H2 database)
  2. Market Data (stored in a CSV text file)
  3. Other Personal Holdings, (stored in a Microsoft Excel file).

The virtual database to be deployed is called Portfolio. It defines a model for each data source; these will be named Accounts, MarketData and PersonalValuations, respectively. The VDB will be deployed to the Teiid Runtime, thereby making it accessible to the user application via JDBC.

To run the quick start, go to the EAP_HOME/quickstarts/dynamicvdb-datafederation directory and open the README.md file in a text editor and read the instructions it contains.

When you run the quick start’s test query, it joins data from the Accounts and MarketData models. Red Hat JBoss Data Virtualization then accesses both the relational and non-relational sources, calculates the portfolio values, and returns the results.

The dynamicvdb-datafederation/src/vdb/portfolio-vdb.xml file defines the resources that can be accessed by the client application.

In this model, the "vdb" element defines the virtual database that has a name of "Portfolio" with version "1" A "model" element represents a schema that is being integrated. This sample defines three sources. The "source" element inside the "model" element defines the "name" of the source (can be any name), the name of the translator (defines the type of the source like oracle, db2, mysql, h2, file or WS) and the "connection-jndi-name" defines the source’s JNDI name in the Red Hat JBoss EAP container.

Also note that inside the "model" elements, some "property" elements can be used to define how metadata is to be imported from the source. When you configure the quick start, the portfolio-vdb.xml is deployed to the JBoss EAP server. The portfolio-vdb.xml.dodeploy file (also referred to as a marker file, which is empty) is also deployed so that the Teiid Runtime is triggered to load the virtual database. The VDB’s data sources will then be validated for availability, and if successful, the VDB status will be set to "Active".

If the data sources are created and the VDB is deployed correctly, then you will see an information message in the JBoss EAP console that states that the VDB has been deployed and is in an "active" state. If there are any errors then you will see that the VDB was not deployed or is currently in an "inactive" state. Find the issues via the console and fix them before you proceed any further.

There are two virtual models defined in the dynamic vdb; Stocks and OtherHoldings. The Stocks virtual model contains 2 basic views. One, Stocks, to access the stock prices in the text data source and the second, StockPrices, that will join the Stocks with Products to federate the data from both data sources. The OtherHoldings contains a view that joins Acccounts with OtherHoldings to show who the holdings belongs to.

This example uses three data sources, a relational database, a CSV text file and an Excel file. You can substitute any other relational database for H2, as long as you have a suitable JDBC driver. The schema file provided at dynamicvdb-datafederation/src/teiidfiles/customer-schema.sql, is specific to H2 but you can convert it for use with other databases

In order to use a text file as the source, we need a data file which defines the data in a CSV format (comma separated values). Each data file contains column information for the table. The column information is typically defined on line 1, as header line in the file, and all the following lines contain the actual rows of data. Each line corresponds to single row. A portion of the sample file is shown below. The complete sample file is dynamicvdb-datafederation/src/teiidfiles/data/marketdata-price.txt.

SYMBOL,PRICE
IBM,83.46
RHT,11.84
BA, 44.58
ORCL,17.37

The Excel file contains sheet1, that defines a header row and subsequent data rows, similar to a text file. This example will demonstrate that excel files can be used on different operating systems, not just windows. You can use the provided data files or create your own data files. When performing the set up step, data sources will be configured.

2.2.3. Data Roles Quick Start

The dynamicvdb-dataroles quick start demonstrates how you can use data roles to control access to data. (This includes read-only and read-write access.)

In this quick start, the virtual database (portfolio-vdb.xml) has these two data access roles:

  1. read-only - this role provides only read-only access (in other words, selects). This role is given to everybody who has a login credential. (Use the user called "user" with password "user".)
  2. read-write - this role give reads access, in addtion write access (insert/update/delete). This access is given only to users with the "superuser" JAAS role. (Use the user called "portfolio" with password "portfolio".)

To run the quick start, go to the EAP_HOME/quickstarts/dynamicvdb-dataroles directory and open the README.md file in a text editor and read the instructions it contains. Look at the application-roles.properties and application-users.properties, because you have to use the ./add-user.sh (bat) scripts (as indicated in the README).

The quick start shows use of the read-write data-role in the portfolio-vdb.xml file:

  <data-role name="ReadWrite">
     <description>Allow Reads and Writes to tables and procedures</description>

     <permission>
         <resource-name>Accounts</resource-name>
         <allow-create>false</allow-create>
         <allow-read>true</allow-read>
         <allow-update>true</allow-update>
     </permission>

     <permission>
         <resource-name>MarketData</resource-name>
         <allow-create>false</allow-create>
         <allow-read>true</allow-read>
         <allow-update>true</allow-update>
     </permission>

       <mapped-role-name>supervisor</mapped-role-name>
 </data-role>

To see how the users and roles were defined for JAAS, see the application-roles.properties and application-users.properties in the EAP_HOME/MODE/configuration/ directory. JAAS uses application-users.properties to determine user credentials and the application-roles.properties file maps the username to the mapped-role-name element.

2.2.4. Web Service Data Source Quick Start

The Web-Services-as-a-Data-Source quick start demonstrates how to use the Web Service Translator to call a web service that returns an XML document. The quick start also demonstrates how to define a transformation using XMLTABLE and XMLPARSE to translate the XML document into a relational database.

To run the quick start, go to the EAP_HOME/quickstarts/webservices-as-a-datasource directory and open the README.md file in a text editor and read the instructions it contains.

When the quick start is configured, the CustomerRESTWebSvc.war is deployed. This represents the web service data source that JBoss Data Virtualization will access. (It was designed this way so that no external resource is required in order to execute the quick start.) The dynamic VDB, namely webservice-vdb.xml, defines the VIEW using DDL, in order to read and transform the XML document returned from the web service.

2.2.5. JBoss Data Grid Remote Cache as a Data Source Quick Start

The JBoss-Data-Grid-Running-as-a-Data-Source example demonstrates how to access JBoss Data Grid cache using the infinispan-cache translator.

To run the quick start, go to the EAP_HOME/quickstarts/jdg-remote-cache directory and open the README.md file in a text editor and read the instructions it contains.

The source model metadata will be created dynamically based on the configured resource adapter. Notice there is no DDL is being used, as in the local cache quick start. This quick start is defaulting to the dynamically created metadata. However, you can define your own metadata, as in the local cache quick start and provide any necessary overrides.

This example shows you how to do the following:

  1. Define the source model to the object cache by specifying the translator type of "infinispan-cache-dsl".
  2. Set up the Infinispan-dsl resource-adapter in order to communicate to the remote cache
  3. Configure the JDG Cache as a data source, for which the translator is mapped to via the connection-jndi-name. It also demonstrates the ability to do reads and writes (Insert, Update and Delete) to the cache. Example queries are provided, but the actual content in the DML may not match the content you loaded in the cache.

2.2.6. Use Hibernate with Red Hat JBoss Data Virtualization Quick Start

When you utilize Hibernate, it is normally a one-object-to-one-data-source mapping. By using JBoss Data Virtualization as the data source, you approach the integration at the data layer rather than application layer. This makes it easier to join related information and expose it through hibernate, rather than merge the related data at the application layer.

The Hibernate-on-top-of-teiid quick start demonstrates how hibernate can take advantage of multiple data sources through a single Java object by using the data federation capabilities of JBoss Data Virtualization. This quick start extends the Portfolio VDB and creates a view that is mapped to a single relationally mapped object in hibernate.

To run the quick start, go to the EAP_HOME/quickstarts/hibernate-on-top-of-teiid directory and open the README.md file in a text editor and read the instructions it contains.

3. Conclusion

During this hour, you have been taken on a tour of Red Hat JBoss Data Virtualization’s various features. You have run various quick starts that demonstrate the product’s functionality and teach you a little about how it works.

You can now go forward and modify these quick starts to build your own solutions to suit your business needs. Use the pre-packaged quick starts as templates to guide you and refer to the full documentation suite to learn more about the product’s capabilities.