Discussion:
Reset the Delta Store from CLI
Add Reply
b***@gmail.com
2017-09-07 08:42:23 UTC
Reply
Permalink
Raw Message
Hi all,
I just want to share some snippets here with you.

Challenge:
I developed a couple of AL's (all similar) where I have to use the delta store functionality. (I was impressed how quick it was implemented.)
While considering the operational task I was asked to provide a solution to reset the delta store in case something went wrong with the sync between source and target.


Asking Eddie he provided this script to me:

// storeName is the name used as the Delta Store param of the Delta tab
// Store values like this in Properties so you can use system.getTDIProperty() to retrieve them.
// This is easier that trying to read configuration settings of AL components.
var storeName = system.getTDIProperty("sync.delta.store.name");
var tableName = "IDI_DS_" + storeName.toUpperCase();
try {
com.ibm.di.store.StoreFactory.dropTable(tableName)
} catch (ex) {
task.logmsg("WARN", "Error deleting " + tableName + " - " + ex);
}


The idea was to put the script in an parameterized AL. The parameter controls which delta store should be reset.
The operation guys should just run a command like this
<path_to_tdi>/tdi/V7.1/ibmdisrv -c <path_to_project>/tdw2icd.xml -r "AL-ResetDeltaStore" -al "AL-1.2.1.08"
to reset the delta store. (Where "AL-1.2.1.08" is the AL for which the delta store should be resetted.

Solution:
In an "Prolog - Before init" script the parameter is parsed

// reading the parameter
var al = main.commandLineParam("al");
if (al == null) {
// testing with "AL-1.2.1.08"
al = "AL-1.2.1.08"
}
al = al.replace('-','').replace('.','').replace(' ','');
system.setPersistentObject("deltaDB", al);

A second script contains the real reset procedure of the delta store as provided from Eddie but now using the input parameter for the delta store here.

// storeName is the name used as the Delta Store param of the Delta tab
// Store values like this in Properties so you can use system.getTDIProperty() to retrieve them.
// This is easier that trying to read configuration settings of AL components.
// var storeName = system.getTDIProperty("sync.delta.store.name");
deltaDB = system.getPersistentObject("deltaDB");
var tableName = "IDI_DS_" + deltaDB.toUpperCase();
task.logmsg("DEBUG", "intending to clear the delta store " + tableName);
try {
com.ibm.di.store.StoreFactory.dropTable(tableName)
task.logmsg("DEBUG", "clearing the delta store " + tableName);
} catch (ex) {
task.logmsg("WARN ", "Error deleting " + tableName + " - " + ex);
}

Runs fine for me.
The only thing I'm missing is when the delta store doesn't exist, I don't get an error message.

Thanks, Eddie, for the quick response,
Holger.
Eddie Hartman
2017-09-07 19:29:19 UTC
Reply
Permalink
Raw Message
Post by b***@gmail.com
Hi all,
I just want to share some snippets here with you.
I developed a couple of AL's (all similar) where I have to use the delta store functionality. (I was impressed how quick it was implemented.)
While considering the operational task I was asked to provide a solution to reset the delta store in case something went wrong with the sync between source and target.
// storeName is the name used as the Delta Store param of the Delta tab
// Store values like this in Properties so you can use system.getTDIProperty() to retrieve them.
// This is easier that trying to read configuration settings of AL components.
var storeName = system.getTDIProperty("sync.delta.store.name");
var tableName = "IDI_DS_" + storeName.toUpperCase();
try {
com.ibm.di.store.StoreFactory.dropTable(tableName)
} catch (ex) {
task.logmsg("WARN", "Error deleting " + tableName + " - " + ex);
}
The idea was to put the script in an parameterized AL. The parameter controls which delta store should be reset.
The operation guys should just run a command like this
<path_to_tdi>/tdi/V7.1/ibmdisrv -c <path_to_project>/tdw2icd.xml -r "AL-ResetDeltaStore" -al "AL-1.2.1.08"
to reset the delta store. (Where "AL-1.2.1.08" is the AL for which the delta store should be resetted.
In an "Prolog - Before init" script the parameter is parsed
// reading the parameter
var al = main.commandLineParam("al");
if (al == null) {
// testing with "AL-1.2.1.08"
al = "AL-1.2.1.08"
}
al = al.replace('-','').replace('.','').replace(' ','');
system.setPersistentObject("deltaDB", al);
A second script contains the real reset procedure of the delta store as provided from Eddie but now using the input parameter for the delta store here.
// storeName is the name used as the Delta Store param of the Delta tab
// Store values like this in Properties so you can use system.getTDIProperty() to retrieve them.
// This is easier that trying to read configuration settings of AL components.
// var storeName = system.getTDIProperty("sync.delta.store.name");
deltaDB = system.getPersistentObject("deltaDB");
var tableName = "IDI_DS_" + deltaDB.toUpperCase();
task.logmsg("DEBUG", "intending to clear the delta store " + tableName);
try {
com.ibm.di.store.StoreFactory.dropTable(tableName)
task.logmsg("DEBUG", "clearing the delta store " + tableName);
} catch (ex) {
task.logmsg("WARN ", "Error deleting " + tableName + " - " + ex);
}
Runs fine for me.
The only thing I'm missing is when the delta store doesn't exist, I don't get an error message.
Thanks, Eddie, for the quick response,
Holger.
Thanks for sharing, Holger! :D

Loading...