It is not always possible and easy to have a shared filesystem between multiple Talend ESB instances.
Instead of sharing a filesystem, Talend ESB supports the sharing of a database.
The master instance holds the lock by locking a table in the database. If the master loses the lock, a waiting slave gains access to the locking table, acquires the lock on the table and starts.
The database lock uses JDBC (Java DataBase Connectivity). To use database locking, you have to:
-
copy the JDBC driver in the lib/ext folder on each instance. The JDBC driver to use is the one corresponding to the database used for the locking system.
-
update etc/system.properties file on each instance:
karaf.lock=true
karaf.lock.class=org.apache.karaf.main.DefaultJDBCLock
karaf.lock.level=50
karaf.lock.delay=10
karaf.lock.jdbc.url=jdbc:derby://dbserver:1527/sample
karaf.lock.jdbc.driver=org.apache.derby.jdbc.ClientDriver
karaf.lock.jdbc.user=user
karaf.lock.jdbc.password=password
karaf.lock.jdbc.table=KARAF_LOCK
karaf.lock.jdbc.clustername=karaf
karaf.lock.jdbc.timeout=30
-
karaf.lock
property enabled the HA/failover mechanism. -
karaf.lock.class
property contains the class name providing the lock implementation. Theorg.apache.karaf.main.DefaultJDBCLock
is the most generic database lock system implementation. Apache Karaf supports lock system for specific databases. For more information, see the sections: Lock on Oracle, Lock on Derby, Lock on MySQL, Lock on PostgreSQL, and Lock on Microsoft SQLServer. -
karaf.lock.level
property is the container-level locking. For more information, see the sections: Lock on Oracle, Lock on Derby, Lock on MySQL, Lock on PostgreSQL, and Lock on Microsoft SQLServer. -
karaf.lock.delay
property is the interval period (in seconds) to check if the lock has been released or not. -
karaf.lock.jdbc.url
property contains the JDBC URL to the database (derby in this example). -
karaf.lock.jdbc.driver
property contains the class name of the JDBC driver to use (derby in this example). -
karaf.lock.jdbc.user
property contains the username to use to connect to the database. -
karaf.lock.jdbc.password
property contains the password to use to connect to the database. -
karaf.lock.jdbc.table
property contains the database table to use for the lock.
The Talend ESB will not start if the JDBC driver is not present in the lib/ext folder.
The sample database will be created automatically if it does not exist.
If the connection to the database is lost, the master instance tries to gracefully shutdown, allowing a slave instance to become the master when the database is back. The former master instance will required a manual restart.