Introduction
The Data Access Component (DAC) plays a new role in the FEWS system. It allows webservices that are deployed in the same servlet container as the DAC to communicate directly with the FEWS central database.The DAC makes use of the FEWS OpenAPI to communicate with the attached webservices.
The main functionality of the DAC is given below.
- Allow webservice deployed in a Servlet container such as Tomcat to access the FEWS central database directly or through an instance of the DataStore component. Through the DataStore component it will be possible to access the following information:
- read / write timeseries
- read / log messages
- read FEWS configuration
- run workflows
Design
The Design of the FEWS data access component is directly linked to the FEWS database model. For more information on the design of the FEWS database model we refer to documentation of the Master Controller database.
The Data Access Components will make use of existing components such as the DataStore component currently used by the FEWS client instances (OC, FSS) and the ExtendedDataSource components used to connect to de Master Controller database.
Data Access Component
Is a java class that is configured as a Global Resource in a Servlet container and will be initialized as a Singleton for each database connection. The Data Access Component will implement an interface that will allow webservices to access the FEWS DataStore. In the future this interface can be expanded to provide more convenience methods and to reduce code duplication. All resources used by the Data Access Component will be added to the Tomcat class path. This way it is possible for other webservices deployed in the same Servlet container to access and use the DataStore without having to include all FEWS data access resources.
Each instance of the Data Access Component represents one database connection for one FEWS region.
DataStore
This component will be initialized once the Data Access Component is initialized. A DataStore requires an instance of a ExternalDataSource (connection to MC database) and a reference to a cache directory for storing the datastore cache files. This information is configured in the Global Resource of the Data Access Component.
ExternalDataSource
This is a component required by the DataStore. This component will be configured as a separate Global Resource within the Servlet container. Only one ExternalDataSource instance is allowed per Master Controller database.
FEWS Webservice
A FEWS webservice component that uses the Data Access Component can do so by performing a lookup from the InitialContext. Each webservice can use the FEWS configuration present in the central database. It is up to the webservice itself to decide how it wishes to publish the available information to the outside world. This can either be done by publishing Capabilities in the same way OGC standards do this (WMS, WFS, WaterML) or by configuration such as the FewsPiService does this.
Security
To secure access to the Data Access Component or to individual webservices there are standards provided by the Servlet container. We will make use of these standards wherever and whenever required.
Installation
Here follows a list of applications that need to be installed in order to use the DAC:
Java
Download the latest stable release for the JRE (version 1.6.23 or higher).
Tomcat
Download the latest stable release for Tomcat (version 6.0.35 or higher).
Fews bin + region home
Install a Fews bin directory and Region Home directory as you would for an Operator Client. Make sure these directories are accessible from the Tomcat installation. In the Region Home directory copy the files 'clientConfig.xml' and 'log4j.properties' shown below. Change the values in example to match the values of your system.
clientConfig.xml:
N.B.: The DAC is no longer available since FEWS 2017.02
The FEWS Data Access Component (DAC) is a web application that allows Webservices to directly access the FEWS system. The DAC communicates directly with the FEWS data store component. The database is created and updated by a FEWS Operator Client system.
Webservices hosted in a Tomcat container can access the DAC and exchange data with the underlying FEWS system.
Code Block | ||||
---|---|---|---|---|
| ||||
Code Block | ||||
<?xml version="1.0" encoding="UTF-8"?> <clientConfiguration xmlns="http://www.wldelft.nl/fews" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.wldelft.nl/fews http://fews.wldelft.nl/schemas/version1.0/clientConfig.xsd"> <databaseServer> <!—Keuze uit: postgresql, oracle of sqlserver --> <dbServerType>postgresql</dbServerType> <dbServerName>db_serverhostname</dbServerName> <dbServerPort>db_port </dbServerPort> <dbInstanceName>database name</dbInstanceName> <dbInstanceUser>user</dbInstanceUser> <!-- <dbInstancePassword>clear text password</dbInstancePassword> --> <dbInstanceEncryptedPassword>encrypted password</dbInstanceEncryptedPassword> </databaseServer> </clientConfiguration> |
log4j.properties
Code Block |
---|
# This configuration file should be placed in the FEWS region home directory in order for DAC to load it.
# Change the <region_name> to match name of actual region.
log4j.debug=true
log4j.rootLogger=INFO, DAC
# Define all the appenders
log4j.appender.DAC=org.apache.log4j.DailyRollingFileAppender
log4j.appender.DAC.File=${catalina.base}/logs/DAC_<fews_home_dir>.log
log4j.appender.DAC.Append=true
log4j.appender.DAC.Encoding=UTF-8
# Roll-over the log once per day
log4j.appender.DAC.DatePattern='.'yyyy-MM-dd'.log'
|
Data Access Component
Copy the following two files to the <Tomcat_installation>/lib directory:
- Dac.jar (provided by Deltares)
- log4j-<version>.jar (retrieve from Fews-bin directory)
Now update the Tomcat server configuration file; <Tomcat_installation>/conf/server.xml as described below:
Add DacLifecycleListener
Between the element tags <Host> ... </Host> add the following lines:
Code Block |
---|
<Host name="localhost" appBase="webapps" <databaseServer> <!--jdbc url. jdbc:postgresql://host:port/database OR jdbc:oracle:thin:@//host:port/service_name OR jdbc:oracle:thin:@host:port:SID OR jdbc:oracle:thin:@TNSName OR jdbc:jtds:sqlserver://host:port/database, use DBVisualizer to test the url--> <url>jdbc:oracle:thin:@dummy_hostname:1521:dummy_databasename</url> <user>dummy_username</user> unpackWARs="true" autoDeploy="true"> ... <!-- Class that listens to Tomcat lifecycle eventsuse F12 in orderexplorer to shutdownencrypt DataAccessComponent password---> <Listener className="nl.wldelft.fews.system.data.dac.DacLifecycleListener" /> ... </Host> |
Add DAC as 'global resource'
Between the element tags <GlobalNamingResources> ... </GlobalNamingResources> add the following lines (update where necessary):
Code Block |
---|
<!— Definieer DAC global resource in het bestand server.xml. Paden moeten absolute zijn: windows: d:/fews/bin of d:/fews/hhnk_da; linux: /fews/bin of /fews/hhnk_da --> <GlobalNamingResources> ... <Resource name="global_resource_naam" auth="Container" type="nl.wldelft.fews.system.data.dac.DataAccessComponent" factory="nl.wldelft.fews.system.data.dac.DacBeanFactory" regionHome="absoluut pad naar fews_home_dir" binPath="absoluut pad naar fews_bin_dir" /> </GlobalNamingResources> <encryptedPassword>dummy_password_encrypted</encryptedPassword> </databaseServer> <!-- The JMSServer section is only required for the writing of timeseries For a read only instance this section must be omitted. --> <jmsServer> <appServerType>jboss</appServerType> <appServerName>dummy_hostname_2</appServerName> <appServerPort>1099</appServerPort> <rootJNDI>/wd/nz/mc00/</rootJNDI> </jmsServer> <localCacheSizeMB>500</localCacheSizeMB> </clientConfiguration> |