SERVER_LOAD_ATTRIBUTE field, as the following code shows:... long bef = System.currentTimeMillis(); chain.doFilter(request,response); long aft = System.currentTimeMillis(); long in_request = aft - bef; request.setAttribute(JRunProxyService.SERVER_LOAD_ATTRIBUTE, new Long(in_request)); ...
For a complete example of a filter that uses this sample code, see "Reviewing a simple custom load-balancing filter".
%> javac -classpath /opt/jrun4/lib/jrun.jar SimpleLBFilter.java -d /opt/jrun4/servers/default/default-ear/default-war/WEB-INF/classes
Note: Install the filter on every JRun server in the cluster.
... <filter> ��<filter-name>MILF</filter-name> ��<filter-class>MetricsLoadMonitorFilter</filter-class> </filter> ... <filter-mapping> ��<filter-name>MILF</filter-name> ��<url-pattern>/*</url-pattern> </filter-mapping> ...
LoadBalancingAlgorithm attribute of the JRunProxyService attribute to MIN or MAX.<service class="jrun.servlet.jrpp.JRunProxyService" name="ProxyService"> ��<attribute name="bindToJNDI">true</attribute> ��<attribute name="port">51010</attribute> ��<attribute name="deactivated">false</attribute> ��<attribute name="LoadBalancingAlgorithm">MIN</attribute> ��<attribute name="ServerWeight">3</attribute> ��<attribute name="StickySessions">true</attribute> </service>
You are required to restart the JRun server when you add a servlet filter.
RSS feed | Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/jrun/4/JRun_Service_Pack_1_Guide/customloadbalancing3.htm
Comments
No screen name said on Mar 10, 2005 at 5:07 AM :