// Copyright (c) 1999-2000 David Muse
// See the COPYING file for more information
#ifndef LOADBAL_H
#define LOADBAL_H
#include <strstream.h>
// The loadbal class provides functions for metric based load balancing.
class loadbal {
public:
loadbal();
virtual ~loadbal();
void initLoadbal(char *site, char *package,
char *interface, char *app);
// Reads
// /usr/local/web/"site"/"package"/interfaces/"interface"/"app".ldb
// and processes it. The file should contain 1 line
// per host of hostname and metric. The metric is
// a representation of the power of the machine relative
// to the other machines in the list. A metric should
// be as small a number as possible. The file should
// look something like this:
//
// host1 5
// host2 2
// host3 1
// host4 3
//
// In this scenario, host1 is 5 times as powerful as
// host3, host2 is twice as powerful as host3 and
// host4 is 3 times as powerful as host3. The order
// of the hostnames in the file is irrelevant.
char *nextHost(long seed, long *returnseed);
// Returns the name of a weighted random selection of
// the hosts in the above loaded file, weighted by the
// metric in the file.
//
// The function uses "seed" to seed the random number
// generator and places the next seed value in
// "returnseed".
private:
#include <private/loadbal.h>
};
#endif