Monday 6 April 2015

Refresh Pentaho's cache system

Hey Guys,

In this post i would like to explain to refresh  Pentaho's cache system (mondrian, CDE, etc.) using a shell script.

Scenario :

Each night, after my ETL process has gone ok (thks Kettle), all data marts populated + aggregations and data validated, I want an automatic refresh of Mondrian cache .

Script:

#!/bin/bash

USER=admin
PASS=password

LOG=/var/pentaho/clearCache.log      /*Location of generating the log file for you Audit purpose*/

logCacheClear() {
    if [ "$1" = "START" ]; then
        echo "[`date +"%Y/%m/%d %H:%M:%S"`] ========== Cleaning $2 cache ==========" >> $LOG
    else
        echo >> $LOG
        echo "[`date +"%Y/%m/%d %H:%M:%S"`] ========== Finished cleaning $2 cache ==========" >> $LOG
    fi
}

execCacheClear() {
    echo -n "Cleaning $1 cache..."
    logCacheClear START $1
    wget --quiet --auth-no-challenge --http-user=$USER --http-password=$PASS -O - "$2" >> $LOG
    logCacheClear STOP $1
    echo " ok"
}


execCacheClear "Mondrian" "http://localhost:8080/pentaho/api/system/refresh/mondrianSchemaCache"

execCacheClear "Dashboards" "http://localhost:8080/pentaho/content/cda/clearCache"


Typically you'd run this script after you run your dashboard ETL.

  • If you're running UNIX put this script in a cron job.

  • If Windows, as a Scheduled Task. 

Cheers !!!!!
 
If you have any question you can ask me or else you can drop me email :



Sumit Bansal
BI Developer
sumitbansal450@gmail.com

No comments :

Post a Comment