Warmup dynacache with a script

Sometimes you need to quickly fill dynacache entries using a script after invalidating the whole cache contents or after a staging propagation.

There are two main issues to solve in a Commerce cluster (horizontal and vertical): fill the entries in every JVM in every node using the store hostname and do it concurrently.

To do this we used an Ant script recycling WCBD configuration.

The script called project-warmup-dynacache.test.xml is very simple.

First it loads the WCBD properties configuration (project-test.properties and project-test.private.properties) with a new custom property

cluster.members=node1.store.com:9080,node1.store.com:9085,node2.store.com:9080,node2.store.com:9085

The Ant script cycle into these cluster clone hosts

<target name=”createCategoryURLs”>
<foreach list=”${cluster.members}”
target=”warmupCategorias”
param=”clone.host”
trim=”true”
inheritall=”true”
inheritrefs=”true”>
</foreach>
</target>

generating a file with category’s URLs using a SQL Ant task

<target name=”warmupCategorias”>
<sql driver=”${jdbc.driver}”
url=”${jdbc.url}”
userid=”${db.user.name}”
password=”${db.user.password}”
classpath=”${jdbc.driver.path}”
output=”categoryURLList.${clone.host}.txt”
print=”true”>select DISTINCT ‘url = “http://${clone.host}/webapp/wcs/stores/servlet/Category3_10151_’ || cata.catalog_id || ‘_’||CATESPADRE.CATGROUP_ID||’_-5_Y_image_0_____”‘ from catgroup catespadre, catgrprel rela, catgroup cateshija, catalog cata, store st, cattogrp catrel where CATESPADRE.CATGROUP_ID = RELA.CATGROUP_ID_PARENT and CATESHIJA.CATGROUP_ID = RELA.CATGROUP_ID_CHILD and CATA.CATALOG_ID = CATREL.CATALOG_ID and CATA.identifier = ‘Extended Sites Catalog Asset Store’ and ST.DIRECTORY = ‘MadisonsESite’ and CATESPADRE.MARKFORDELETE &lt;&gt; 1 and CATESPADRE.LASTUPDATE &gt; to_timestamp (’09/12/2011′,’DD/MM/YYYY’) UNION select DISTINCT ‘url = “http://${clone.host}/webapp/wcs/stores/servlet/Category3_10151_’ || cata.catalog_id || ‘_’||CATESPADRE.CATGROUP_ID||’_-5_Y_image_0___’||CATESHIJA.CATGROUP_ID||’__”‘ from catgroup catespadre, catgrprel rela, catgroup cateshija, catalog cata where RELA.CATALOG_ID = CATA.CATALOG_ID and CATA.identifier = ‘Extended Sites Catalog Asset Store’ and CATESPADRE.CATGROUP_ID = RELA.CATGROUP_ID_PARENT and CATESHIJA.CATGROUP_ID = RELA.CATGROUP_ID_CHILD and CATESPADRE.MARKFORDELETE &lt;&gt; 1 and CATESPADRE.LASTUPDATE &gt; to_timestamp (’09/12/2011′,’DD/MM/YYYY’);</sql>

Then with an exec task, the Ant script executes a single line sh script (for categories and products)

curl –header “Host: test.store.com” –header “\$WSSP: 80” -K /opt/IBM/WC/wcbd/deploy/server/$1 -o “/opt/IBM/WC/wcbd/deploy/server/$2” >/dev/null 2>&1

This curl command takes the category URLs like

http://node1.store.com:9080/webapp/wcs/stores/servlet/Category3_10151_11551_17510_-1_Y_image_0_____

changes the Host header to “test.store.com” and adds the websphere port header $WSSP (just like the plugin do).

Changing these http headers we solved the problem to fill cache entries for a specific JVM in a specific node using the store hostname “test.store.com”.

Finally we execute the curl script asynchronously using a specific sh script

<exec executable=”antRunAsync.sh” failonerror=”yes”>
<env key=”ANTRUN_NOHUP” value=”true” /> <!– optional –>
<env key=”ANTRUN_OUTPUT” value=”/opt/IBM/WC/wcbd/deploy/server/categoryURLListOutput.${clone.host}.txt” /> <!– required –>
<arg value=”/opt/IBM/WC/wcbd/deploy/server/getCategoriesCurl-test.sh categoryURLList.${clone.host}.txt categoryURLListOutput.${clone.host}.txt” />
</exec>

This way we can fill cache contents in every JVM at the same time.

To execute the script we use the WCBD directory

/opt/IBM/WC/wcbd/deploy/server/wcbd-ant -buildfile /opt/IBM/WC/wcbd/deploy/server/project-warmup-dynacache.test.xml

Advertisements

Websphere Commerce and Portal Architect ✔ Motivated IT professional with more than ten years of experience, combining Java and JEE developer skills with systems and IBM products installation knowledge. ✔ Strong experience and skills on planning, architecting and implementing complex commerce and portal solutions based on IBM middleware products. ✔ Reliable with a strong network attitude, experience on leading developer's teams and manage international relationships. Specialties ✔ Pleasant manner, reliable. ✔ Ability to consider issues from different point of views. ✔ End-oriented work capacity and problem-solving attitude. ✔ Ability to work with deadlines and under pressure. ✔ Ability to prioritise tasks and manage people. ✔ Ability to increase the whole team skills. ✔ Ability to generate commercial leads

Tagged with: , ,
Posted in cache, websphere commerce

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: