In a cluster environment, JReport Server provides a load balancing mechanism which enables the server to work more effectively. However, you can also write your own load balancing algorithm based on the API included in JReport Server. Note that if you create a load balancing algorithm with the API, it will take effect in place of other built-in load balance algorithms you have set.
A demo DemoLoadBalancer.java has been provided to illustrate how to customize load balancing using APIs. You can find it in <install_root>\help\samples\APICluster
.
Assuming that you have several clustered servers, take the following steps:
javac -classpath <install_root>\lib\JRESServlets.jar DemoLoadBalancer.java
-Dloadbalance.custom_class=DemoLoadBalancer
to the server's startup file JRServer.bat which locates in <install_root>\bin
. For example:
"%JAVAHOME%\bin\java.exe" -Dloadbalance.custom_class=DemoLoadBalancer "-Dinstall.root=%REPORTHOME%" ...
Reference: For more details, see the jet.server.api.cluster.LoadBalancer interface in JReport Javadoc located in <install_root>\help\api
.
Note: You can choose the load balancing type by setting the API method setLoadBalanceType() at jet.server.api.admin.ClusterAdminService. For example, setting the API method as setLoadBalanceType(0), setLoadBalanceType(1), setLoadBalanceType(2), and setLoadBalanceType(3) means respectively the algorithm Least Current Reports (Min-load), Round Robin, Least Weighted Current Reports (Weighted Min-load) and Random will be chosen.