ActiveSpaces as Backing Store - learn-tibco-cep/tutorials GitHub Wiki
TIBCO ActiveSpaces is a distributed, scalable, and persistent data grid that can be used as the backing store for Apache Ignite cluster.
As shown in BooksAS4.cdd, you can select ActiveSpaces
as the Persistence Option
for the data store, and specify the data-grid connection properties in the CDD.
Object Management
In the CDD, you may check the Preload Entities
flag in the Domain Object default settings, and so the Ignite cluster will automatically load data from the backing store when a server node starts.
For each concept of Cache Only
mode in the CDD, you may also check the Has Backing Store
flag, and so all data in the cache cluster will be persisted in the ActiveSpaces data grid.
Generate Database Schema
You may generate database schema for ActiveSpaces from the CDD and EAR file of the application. For example, the following script will generate the AS schema for this tutorial, and write generated files in the specified scriptFolder
with file name prefix of perf
.
$BE_HOME/bin/be-storedeploy --propFile $BE_HOME/bin/be-storedeploy.tra -o /path/to/scriptsFolder/perf -c BooksAS4.cdd -s ACTIVESPACES Books.ear
The AS table and index definitions will be written to a file as /path/to/scriptFolder/perf.tibdg
. To support direct queries on ActiveSpaces, we edited the schema file to add the following indexes.
index create d_author author_revision_idx revision
index create d_author author_last_modified_idx last_modified
index create d_book book_revision_idx revision
index create d_book book_last_modified_idx last_modified
The updated schema definition can be viewed at perf.tibdg.
Install and Configure ActiveSpaces
ActiveSpaces depends on TIBCO FTL, so install FTL first as described in Prerequisite. We then download the ActiveSpaces installation package from edelivery.tibco.com, and follow the the instructions to install ActiveSpaces on a RHEL 8 Linux server.
unzip TIB_as_4.8.1_linux_x86_64.zip
cd TIB_as_4.8.1/rpm
sudo yum install -y *.rpm
The ActiveSpaces will be installed under TIBDG_ROOT = /opt/tibco/as/4.8
. For this tutorial, you can use the sample scripts in $TIBDG_ROOT/samples/scripts
to manage ActiveSpaces nodes. By default, the sample scripts write FTL realm data to the same folder as the data of ActiveSpaces. Since FTL cannot use a mounted shared drive to store realm data, we would create a local folder /ftl-server
, and edit the sample script $TIBDB_ROOT/samples/scripts/as-start-ftl6
to store realm data in this folder, i.e.,
RSDIR="/ftl-server/realm_data"
We can then start an ActiveSpaces data grid as follows.
cd $TIBDG_ROOT/samples/scripts
./as-start -r ashostname:8181 -d $WS/as4-data -g perf-grid
It is important to specify the hostname of the AS node, and so it is reachable from remote clients. The command also specifies a folder for storing AS data, and the data grid name, i.e., perf-grid
.
You may check the data grid status by
$TIBDG_ROOT/bin/tibdg -r http://ashostname:8181 -g perf-grid status
You can shutdown the data grid and its associated FTL realm server as follows.
d $TIBDG_ROOT/samples/scripts
./as-stop -r ashostname:8181 -g perf-grid
./as-stop -r ashostname:8181
Create schema for tutorial application
We can then create AS data schema for the tutorial by using the scripts generated in the previous step.
$TIBDG_ROOT/bin/tibdg -r http://ashostname:8181 -g perf-grid -s $BE_HOME/bin/create_tables_as.tibdg
$TIBDG_ROOT/bin/tibdg --http-timeout 60 -r http://ashostname:8181 -g perf-grid -s /path/to/scriptsFolder/perf.tibdg
You may verify that tables are created correctly in ActiveSpaces.
$TIBDG_ROOT/bin/tibdg -r http://ashostname:8181 -g perf-grid table list
Configure ActiveSpaces Connection
The ActiveSpaces connection properties in this tutorial can be configured in BooksAS4.cdd
. You can edit the CDD file to set the following variables.
Property Name | Value |
---|---|
tibco.clientVar.ASDG/realmurl | http://ashostname:8181 |
tibco.clientVar.ASDG/grid | perf-grid |
tibco.clientVar.ASDG/tibdg_timeout | 30 |
Start Cache and Inference Nodes
You can then start cache and inference nodes that will store data in ActiveSpaces on a specified ActiveSpaces host.
# start a cache node
$BE_HOME/bin/be-engine --propFile $BE_HOME/bin/be-engine.tra -n cache-0 -u cache -c BooksAS4.cdd Books.ear
# start an inference node
$BE_HOME/bin/be-engine --propFile $BE_HOME/bin/be-engine.tra -n default-0 -u default -c BooksAS4.cdd Books.ear