setServers method
Specify a cluster of one or more MigratoryData servers to which the client will connect to.
For example, to connect to a cluster formed of two MigratoryData servers installed at the addresses \c p1.example.com and \c p2.example.com, and configured to accept clients on the standard HTTP port \c 80, the following code can be used:
client.setServers(new String[] {"p1.example.com:80", "p2.example.com:80"});
To achieve load-balancing, the library connects the client to a MigratoryData server chosen randomly from the \c servers list. In this way, the load is balanced among all the members of the cluster.
Moreover, the library supports weighted load-balancing. This feature is especially useful if the MigratoryData servers in the cluster are installed on machines with different capacities. You can assign to each member of the cluster a \em weight ranging from \c 0 to \c 100. This weight assignment is a hint provided to the library to select with a higher probability a MigratoryData server with a higher weight either initially when the client connects to the cluster or later during a fail-over reconnection.Supposing the address \c p1.example.com corresponds to a machine that is twice more powerful than the machine having the address \c p2.example.com, then you can assign to \c p1.example.com a weight \c 100 and to \c p2.example.com a weight \c 50 by prefixing each address with the assigned weight as follows:
client.setServers(new String[] {"100 p1.example.com:80", "50 p2.example.com:80"});The library assigns a default weight \c 100 to the addresses not prefixed with a specific weight.
To achieve failover, if the connection between the client and a MigratoryData server is broken, then the library will automatically detect the failure and will select another MigratoryData server from the \c servers list. If the client fails to connect to the newly selected server, a status notification MigratoryDataClient.NOTIFY_SERVER_DOWN will be triggered (unless you modify the number of failed connection attempts with \link MigratoryDataClient.notifyAfterFailedConnectionAttempts() \endlink), and a new MigratoryData server of the cluster will be selected again and again until the client will be able to connect to one of the MigratoryData servers of the cluster. When successfully connected the library will trigger a status notification MigratoryDataClient.NOTIFY_SERVER_UP.
\param servers an array of strings where each string represents the network address (IP address or DNS domain name and its corresponding port) of a MigratoryData server, optionally prefixed by a weight ranging from \c 0 to \c 100; if the weight prefix is not provided to an address, then the \c 100 weight will be automatically assigned to that address
Implementation
setServers(List<String> servers) {
clientImpl.setServers(servers);
}