Download Parallel Crystal Developers Manual
Transcript
The following example shows you how to use the Load balancer in automatic mode:
PCREApplicationClient client = null;
try {
client = new PCREApplicationClient(“LB.host.com”);
client.Connect(true);
/* make method calls ... */
} catch ( PCREError e ) { e.Report(); }
// 1.
// 2.
// 3.
The connection process is completed in the following steps:
1. A PCREApplicationClient is specifying a host name for the Load Balancing.
2. Connect is called with the value true which activates the Load Balancer in automatic
mode. The Load Balancer returns the Report Server host determined by its current
selection algorithm and the client is connected to that host.
3. If there are no Report Servers available to the Load Balancer, the Connect call will
throw a PCREServerError exception and at Step 3 the message
Server error: Load Balancer failure: no available Report Servers
will be printed.
In order to use the Load Balancer in manual mode, you call the
RequestReportServerList method that returns a vector of candidate hosts. You apply
your own selection procedure to the vector and then call the client's
ResetReportServerHost method passing the selected vector element. Finally you call
Connect to connect to the client to the Report Server. The following example shows a
typical code fragment:
PCREApplicationClient client = null;
try {
client = new PCREApplicationClient(“LB.host.com”)
PCREReportServerInfo[] servers =
client.RequestReportServerList();
PCREReportServerInfo host = MySelection(servers);
client.ResetReportServerHost(host);
client.Connect();
/* method calls ... */
} catch ( PCREError e.Report(); }
Each element of the vector returned by RequestReportServerList contains
information about the Report Server encapsulated as an instance of the helper class
PCREReportServerInfo:
public class PCREReportServerInfo {
public double loadFactor;
//
public int numberOfServers;
//
public int numberOfProcessors;
//
public String gatewayName;
//
public String reportServerAddress;//
}
Parallel Crystal Developer's Manual
Version 2.4 - Revised 5/27/00
Gateway load factor.
Number of running servers.
Number of host processors.
Gateway Server name.
Report server address.
104