Calling application specific code on clustered sites can be a
bit of a pain.. here's how i do it.
2. Create a folder on your webroot called '_cluster' e.g
'c:\htdocs\_cluster'
1. Change the mappings in your
C:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\jrun-web.xml
so that there is a mapping to '_cluster'.
I did it like this:
<virtual-mapping>
<resource-path>/_cluster</resource-path>
<system-path>C:\htdocs\_cluster</system-path>
</virtual-mapping>
2. In your application.cfc onApplicationStart add a reference
to the object to the application like this:
application.oApplication = this;
3. Create a method in your application.cfc that can clear all
the queries like this:
<cffunction name="clearCache">
<cfobjectcache action="clear">
</cffunction>
4. on your site, create page that can call that method on
your application (/_cluster/clearQueries.cfm) like this:
variables.appScopeTacker = createObject("java",
"coldfusion.runtime.ApplicationScopeTracker");
variables.stApplication =
variables.appScopeTacker.getApplicationScope(url.sAppName);
variables.stApplication.oApplication.clearCache();
sAppName you can hardcode if you like.
5. Create another file on your server that can call this
first file on all the instances (/_cluster/clearClusterQueries.cfm)
//get all the cf instances that are in your cluster
<cfscript>
variables.aServerNames[1] = "192.168.1.1:8300";
variables.aServerNames[2] = "192.168.1.2:8300";
variables.aServerNames[3] = "192.168.1.3:8300";
//etc.
</cfscript>
//loop them and call the clearQueries template on each one
<cfloop from="1" to="arrayLen(variables.aServerNames)"
index="variables.iServerName">
<cfscript>
variables.sServerName =
variables.aServerNames[variables.iServerName];
//this is why you need a mapping to your site in
variables.sURL = "
http://#variables.sServerName#/_cluster/clearQueries.cfm";
</cfscript>
<cfhttp url="#variables.sURL#"/>
<!--- if you like you can put an iframe in here so you
can see what happens
<iframe src="#variables.sURL#"></iframe>
--->
</cfloop>
6. call
http://x.x.x.x:8300/_cluster/clearClusterQueries.cfm
on any server.
Obviously, you can use a set up that allows you to inspect
applications running on all your instances and determine what
functions are available
on them so that you can call any application.cfc function on
any instance, but for brevities sake i've kinda hardcoded this
solution for you.