~ubuntu-branches/ubuntu/precise/crossroads/precise

« back to all changes in this revision

Viewing changes to xr/backend/backend

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Ritter
  • Date: 2010-07-05 16:27:00 UTC
  • Revision ID: james.westby@ubuntu.com-20100705162700-0g08tfav8ee9y51u
Tags: upstream-2.65
ImportĀ upstreamĀ versionĀ 2.65

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef _BACKEND_
 
2
#define _BACKEND_
 
3
 
 
4
#include "sys/sys"
 
5
#include "backenddef/backenddef"
 
6
#include "fdset/fdset"
 
7
#include "error/error"
 
8
#include "ThreadsAndMutexes/mutex/mutex"
 
9
#include "profiler/profiler"
 
10
#include "backendcheck/backendcheck"
 
11
#include "httpbuffer/httpbuffer"
 
12
#include "dnsentry/dnsentry"
 
13
 
 
14
using namespace std;
 
15
 
 
16
class Backend {
 
17
public:
 
18
    Backend ();
 
19
    Backend (BackendDef const &b);
 
20
    virtual ~Backend();
 
21
    bool connect();
 
22
    void markconnecterror();
 
23
    
 
24
    int sock() const                    { return clsocket; }
 
25
    
 
26
    void check();
 
27
    string description() const;
 
28
    
 
29
    bool available() const;
 
30
    string availablestr() const;
 
31
    
 
32
    bool live() const                   { return islive; };
 
33
    void live (bool state);    
 
34
    string livestr() const;
 
35
    
 
36
    void up (bool state);
 
37
    bool up() const                     { return isup; }
 
38
    string upstr() const;
 
39
    
 
40
    string const &server() const        { return bdef.server(); }
 
41
    void server(string s)               { bdef.server(s); }
 
42
 
 
43
    int port() const                    { return bdef.port(); }
 
44
    void port(int p)                    { bdef.port(p); }
 
45
 
 
46
    unsigned maxconn() const            { return bdef.maxconn(); }
 
47
    void maxconn (unsigned m)           { bdef.maxconn(m); }
 
48
 
 
49
    string const &hostmatch() const     { return bdef.hostmatch(); }
 
50
    void hostmatch(string const &s)     { bdef.hostmatch(s); }
 
51
    regex_t const &hostregex() const    { return bdef.hostregex(); }
 
52
 
 
53
    string const &urlmatch() const      { return bdef.urlmatch(); }
 
54
    void urlmatch(string const &u)      { bdef.urlmatch(u); }
 
55
    regex_t const &urlregex() const     { return bdef.urlregex(); }
 
56
 
 
57
    unsigned weight() const             { return bdef.weight(); }
 
58
    void weight (unsigned w)            { bdef.weight(w); }
 
59
    unsigned adjustedweight() const     { return bdef.adjustedweight(); }
 
60
 
 
61
    unsigned connections() const        { return nconn; }
 
62
    unsigned connecterrors() const      { return nconnerr; }
 
63
    
 
64
    double bytesserved() const          { return bytes_served; }
 
65
    unsigned clientsserved() const      { return totconn; }
 
66
 
 
67
    double loadavg() const              { return loadaverage; }
 
68
    void loadavg(double l)              { loadaverage = l; }
 
69
 
 
70
    void addbytes (unsigned n);
 
71
    void startconnection();
 
72
    void endconnection();    
 
73
 
 
74
    BackendDef const &backenddef() const {
 
75
        return bdef;
 
76
    }
 
77
 
 
78
    BackendCheck const &backendcheck() {
 
79
        return bdef.backendcheck();
 
80
    }
 
81
    void backendcheck(BackendCheck const &b) {
 
82
        bdef.backendcheck(b);
 
83
    }
 
84
 
 
85
    void balancerindex(int i)           { index = i; }
 
86
    int balancerindex() const           { return index; }
 
87
    
 
88
 
 
89
private:
 
90
    BackendDef bdef;
 
91
    bool islive;
 
92
    bool isup;
 
93
    int clsocket;
 
94
    unsigned nconn, totconn, nconnerr;
 
95
    double bytes_served;
 
96
    double loadaverage;
 
97
    DNSEntry dnsentry;
 
98
    int index;
 
99
};
 
100
 
 
101
#endif